// JavaScript Document

function valid_java_index_story()

{

//name email story

	if(document.form_story.name.value=="")

	{

		alert("Please Enter Name");

		document.form_story.name.focus();

		return false;

	}

	if(document.form_story.email.value=="")

	{

		alert("Please Enter Email");

		document.form_story.email.focus();

		return false;

	}

	var email=document.form_story.email.value;

	var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

	if(email!= "")

	{	

		var eres=email.search(emailFormat);

		if(eres == -1)

		{

			alert("Please Enter Valid Email..");

			document.form_story.email.focus();

			return false;

		}

	}

	if(document.form_story.story.value=="")

	{

		alert("Please Enter Story");

		document.form_story.story.focus();

		return false;

	}

}



function valid_java_index_search()

{

//state  city  zip 

	if((document.form_search.state.value!="")&&(document.form_search.city.value!="")&&(document.form_search.zip.value!=""))

	{

		alert("Sorry \n\r Either Select State & city \n\r or either Zip-Code \n\r But not Both");

		document.form_search.zip.focus();

		return false;

	}

	

	if((document.form_search.state.value=="")&&(document.form_search.city.value=="")&&(document.form_search.zip.value==""))

	{

		alert("First  Select State & city \n\r or either Zip-Code");

		document.form_search.zip.focus();

		return false;

	}

	

	if((document.form_search.state.value!="")&&(document.form_search.city.value=="")&&(document.form_search.zip.value==""))

	{

		alert("Select  city ");

		document.form_search.city.focus();

		return false;

	}

	if((document.form_search.state.value!="")&&(document.form_search.city.value=="")&&(document.form_search.zip.value!=""))

	{

		alert("Enter Only Zip value \n\r Not select state & city ");

		document.form_search.zip.focus();

		return false;

	}



	document.form_search.submit();

}







function validate_for_integers(inputfield, inputevent) 

{

	var key;

	var keychar;



	if (window.event) {

		key = window.event.keyCode;

	} else if (inputevent) {

		key = inputevent.which;

	} else {

		return true;

	}

	

	keychar = String.fromCharCode(key);

	if ((key==null) || (key==0) || (key==8) ||

    		(key==9) || (key==13) || (key==27)) {

		return true;



	} else if (("0123456789").indexOf(keychar) > -1) {

		return true;

		

	} else {

		return false;

	}

}



function java_select_state(id)

{



	var sPath = window.location.pathname;

	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);



	var statecode = document.form_search.state.options[document.form_search.state.selectedIndex].value;

	if (statecode != 0)

	{

		window.location.href=sPage+"?x="+id;

	}



}



function java_select_city(city)

{

	var sPath = window.location.pathname;

	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);





	var statecode = document.form_search.state.options[document.form_search.state.selectedIndex].value;

	var city = document.form_search.city.options[document.form_search.city.selectedIndex].value;

	

	if (city != 0)

	{

		window.location.href=sPage+"?x="+id&"city="+city;	

	}



}

