// JavaScript Document
<!--

//Disable right mouse click Script
var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->

function clr()
	{
		document.search.srch.value="";
	}
	
function clr1()
	{
		document.login.email.value="";
	}	
	
function check()
	{
		if(document.login.email.value=="")
	{
		alert("Please put your email.");
		document.login.email.focus();
		return false;
	}
	    else if(document.login.password.value=="")
	{
		alert("Please put your password.");
		document.login.password.focus();
		return false;
	} 
		return true;
	}

function popup()
{
	window.open('http://www.mycity.co.in/forgotpassword.php','ForgotPassword','height=200,width=600,top=100,left=300');
}

function subs()
{
	//alert("teste");
	window.open('http://www.mycity.co.in/subscribe.php','SubscribeNewsletter','height=250,width=280,top=100,left=300');
}

function add_info(uid,id,info)
{
	//alert("teste");
	//alert(id);
	window.open("add_more_info.php?user_id="+uid+"&info_id="+id+"&info_name="+info,'AddMoreInfo','height=330,width=280,top=100,left=300');
}

function add_desc(uid,id,info)
{
	//alert("teste");
	//alert(id);
	window.open("add_more_desc.php?user_id="+uid+"&city_id="+id+"&city_des="+info,'AddMoreDescription','height=330,width=280,top=100,left=300');
}


function openwindow()
{
	name=document.newsletter.name.value;
	email=document.newsletter.email.value;
	if (document.newsletter.name.value.length == 0) {
          alert("Please enter your name\n");
	 		newsletter.name.focus();
	  return false;
     }
	 else if (document.newsletter.email.value.length == 0) {
          alert("Please enter your email id.\n");
	 		newsletter.email.focus();
	  return false;
     }
	/*url="news.php?name="+name+"&email="+email;
	window.open(url,'window1','height=200,width=200,left=350');
	document.newsletter.email.value="";*/
	return true;
}

function openwindow1()
{
	name=document.add_more_info.name.value;
	email=document.add_more_info.email.value;
	info=document.add_more_info.info.value;
	if (document.add_more_info.name.value.length == 0) {
          alert("Please enter your name\n");
	 		document.add_more_info.name.focus();
	  return false;
     }
	 else if (document.add_more_info.email.value.length == 0) {
          alert("Please enter your email id.\n");
	 		document.add_more_info.email.focus();
	  return false;
     }
	 else if (document.add_more_info.info.value.length == 0) {
          alert("Please enter text\n");
	 		document.add_more_info.info.focus();
	  return false;
     }
	return true;
}

function openwindow2()
{
	name=document.add_more_desc.name.value;
	email=document.add_more_desc.email.value;
	info=document.add_more_desc.info.value;
	if (document.add_more_desc.name.value.length == 0) {
          alert("Please enter your name\n");
	 		document.add_more_desc.name.focus();
	  return false;
     }
	 else if (document.add_more_desc.email.value.length == 0) {
          alert("Please enter your email id.\n");
	 		document.add_more_desc.email.focus();
	  return false;
     }
	 else if (document.add_more_desc.desc.value.length == 0) {
          alert("Please enter text\n");
	 		document.add_more_desc.desc.focus();
	  return false;
     }
	return true;
}


function window1()
{
	//alert("test");
	if(document.add_info.city.value == '')
	{
		alert("Please select your city.");
		document.add_info.city.focus();
		return false;
	}
	    else if(document.add_info.cat.value == '')
	{
		alert("Please select category.");
		document.add_info.cat.focus();
		return false;
	} 
		else if(document.add_info.subcat.value == '')
	{
		alert("Please select Sub-category.");
		document.add_info.subcat.focus();
		return false;
	}
		else if(document.add_info.name.value == '')
	{
		alert("Please enter Name.");
		document.add_info.name.focus();
		return false;
	}
		else if(document.add_info.address.value == '')
	{
		alert("Please enter Address.");
		document.add_info.address.focus();
		return false;
	}
		/*else if(document.add_info.pin.value == '')
	{
		alert("Please enter Pin.");
		document.add_info.pin.focus();
		return false;
	}*/
		
    else if(document.add_info.pin.value != '')
	{
			if(isNaN(document.add_info.pin.value))
		{		
			 alert('Please Specify PIN in number!');	
			 document.add_info.pin.value="";
			 document.add_info.pin.focus();
			 return false;
		}
			else if((document.add_info.pin.value.length < 6) || (document.add_info.pin.value.length > 6))
		{
			alert('Please Specify PIN in 6 digit number');
			document.add_info.pin.focus(); 
			return false;
		}
		return true;
	}
		else if(document.add_info.description.value == '')
	{
		alert("Please enter Description.");
		document.add_info.description.focus();
		return false;
	}
		return true;
}

function privacy()
{
	var url;
	url="privacy.php";
	window.open(url,'details','scrollbars=yes,height=270,width=400,top=300,left=480');
}
function term()
{
	var url;
	url="siterules.php";
	window.open(url,'details','scrollbars=yes,height=270,width=400,top=300,left=480');
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
function checkForm()
{
	var cemail,cpassword,cc_pass,cf_name,cl_name,ccity,cstate,cpin,cchk;
	with(window.document.reg)
	{
		cemail  = uid;
		cpassword = password;
		cc_pass = c_pass;
		cf_name = f_name;
		cl_name = l_name;
		ccity = city;
		cstate = state;
		ccountry = country;
		cpin = pin;
		cchk = chk;
	}
    if(!isEmail(trim(cemail.value)))
	{
		alert('Your email address is not valid.');
		cemail.value="";
		cemail.focus();
		return false;
	}
	else if(trim(cpassword.value) == '')
	{
		alert('Please enter your Password');
		cpassword.focus();
		return false;
	}
	else if(trim(cc_pass.value) == '')
	{
		alert('Please enter your Confrim Password');
		cc_pass.focus();
		return false;
	}
	else if(cpassword.value != cc_pass.value)
	{
		alert('Please enter same password in confirm password.');
		cc_pass.value="";
		cc_pass.focus();
		return false;
	}
	else if(trim(cf_name.value) == '')
	{
		alert('Please enter your First Name');
		cf_name.focus();
		return false;
	}
	else if(trim(cl_name.value) == '')
	{
		alert('Please enter your Last Name');
		cl_name.focus();
		return false;
	}
	else if(trim(cstate.value) == '')
	{
		alert('Please select your State');
		cstate.focus();
		return false;
	}
	else if(trim(ccountry.value) == '')
	{
		alert('Please select your Country');
		ccountry.focus();
		return false;
	}
	else if(isNaN(cpin.value))
    {		
         alert('Please Specify PIN Code in number!');	
         cpin.value="";
		 cpin.focus();
         return false;
    }
	else if(cchk.checked == false)
	{
	    alert("Please agree terms and condition");
		cchk.focus();
		return false;
    }
	else
	{
		cemail.value  = trim(cemail.value);
		cpassword.value = trim(cpassword.value);
		cc_pass.value = trim(cc_pass.value);
		cf_name.value = trim(cf_name.value);
		cl_name.value = trim(cl_name.value);
		ccity.value = trim(ccity.value);
		cstate.value = trim(cstate.value);
		ccountry.value = trim(ccountry.value);
		cpin.value = trim(cpin.value);
		cchk.value = trim(cchk.value);
		return true;
	}
}

/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Check if a string is in valid email format. 
Returns true if valid, false otherwise.
*/
function isEmail(str)
{
	var regex = /^[-_.a-z0-9]+@(([-a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
	return regex.test(str);
}



//forgot password validation
function check1()
	{
		if(document.fpass.email.value=="")
	{
		alert("Please enter your email.");
		document.fpass.email.focus();
		return false;
	}
		return true;
	}

//check city form
function check_city()
{
	if(document.city.State_Code.value == "")
	{
		alert("Please select state in which your city belongs.");
		document.city.State_Code.focus();
		return false;
	}
	else if(document.city.City_Name.value=="")
	{
		alert("Please put your city name to be added to our list.");
		document.city.City_Name.focus();
		return false;
	}
	else if(document.city.City_Brief.value=="")
	{
		alert("Please add some brief description about your city.");
		document.city.City_Brief.focus();
		return false;
	}
		return true;
}

//check city form
function check_contact()
{
	if(document.myform.title.value=="")
	{
		alert("Please select title.");
		document.myform.title.focus();
		return false;
	}
	else if(document.myform.name.value=="")
	{
		alert("Please enter your name.");
		document.myform.name.focus();
		return false;
	}
	else if(document.myform.email.value=="")
	{
		alert("Please enter your email.");
		document.myform.email.focus();
		return false;
	}
	else if(document.myform.comment.value=="")
	{
		alert("Please enter your comment.");
		document.myform.comment.focus();
		return false;
	}
		return true;
}

//check password
function check_password()
	{
		if(document.change_password.c_pass.value == "")
		{
			alert("Current password can't left blank.");
			document.change_password.c_pass.focus();
			return false;
		}
	    else if(document.change_password.n_pass.value == "")
		{
			alert("New password can't left blank.");
			document.change_password.n_pass.focus();
			return false;
		} 
		else if(document.change_password.n_pass1.value == "")
		{
			alert("Confirm password can't left blank.");
			document.change_password.n_pass1.focus();
			return false;
		}
		else if((document.change_password.n_pass.value) != (document.change_password.n_pass1.value))
		{
			alert("Confirm password doesn't match.");
			document.change_password.n_pass1.focus();
			return false;
		}		
		return true;
	}

