//Starting of the Ajax function */
/**
function HTTPClient()
{};
HTTPClient.prototype = {
   xmlhttp: null,
   callback: null,
   loadRemoteContent: function(url, callbackFunction)
   {
       this.callback = function(self) {
           eval(callbackFunction + '(self.xmlhttp);');
       }
       var self = this;
       if (window.XMLHttpRequest) {
           this.xmlhttp = new XMLHttpRequest();
           this.xmlhttp.onreadystatechange = function() {
               self.processReqChange(self);
           }
           this.xmlhttp.open("GET", url, true);
           this.xmlhttp.send(null);
       } else if (window.ActiveXObject) {
           this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
           if (this.xmlhttp) {
               this.xmlhttp.onreadystatechange = function() {
                   self.processReqChange(self);
               };
                             
               this.xmlhttp.open("GET", url, true);
               this.xmlhttp.send();
           }
       }
   },
   processReqChange: function(self)
   {
       if (this.xmlhttp.readyState == 4) {
          if (this.xmlhttp.status == 200) {
             self.callback(self);
           } else {
               alert("There was a problem retrieving the data:\n" + this.xmlhttp.statusText);
           }
       }
   }
}

**/
/*
function call_lat( lat, long )
{
	   var r = Math.random();
       var httpClient = new HTTPClient();
         httpClient.loadRemoteContent("../test.php?lat="+lat+"&long="+ long, 'handle');
}

function handle(response)
{
	var message = response.responseText;
	var temp;
    alert(message);
}*/
/*closing of the Ajax function */







/*Main Function of the Another Module */


function validator_new()
{
	//alert('1');	
	var errors = 0;	
	var str ="";
	//alert(errors);					
	if(document.getElementById("fName").value == '') 
	{ 
		str ="<br>*First Name required\n";
		errors++;
		document.getElementById('f_name').innerHTML = str;
		//return true;		
			//alert(errors);					
	}
	else if(document.getElementById("fName").value != '') 
	{ 
		str ="";
		document.getElementById('f_name').innerHTML = str;
		//return true;		
	}
	//alert(errors);					

	if(document.getElementById("loginname").value == '') 
	{
		str1 = "<br>*Login Name required\n";
		errors++;
		document.getElementById('dlname').innerHTML = str1;
		//return true;			
	}
	else if(document.getElementById("loginname").value != '') 
	{
		str1 = "";
		document.getElementById('dlname').innerHTML = str1;
		//return true;	
	}
		

	if(document.getElementById("pass_word").value == '') 
	{
		str6 = "<br>*Password required\n";
		errors++;
		document.getElementById('pass').innerHTML = str6;
	}
	else if(document.getElementById("pass_word").value != '')
	{
		str6 = " "; 
		document.getElementById('pass').innerHTML = str6;
		if(document.getElementById("pass_word").value.length < 4 )
		{ 
			errors++;
			str7 = "<br>*The Password Should Be at Least Four Characters Long\n";
			document.getElementById('pass').innerHTML = str7;
		}
		else if(document.getElementById("pass_word").value.length >= 4 )
		{	
			str7 = "";
			document.getElementById('pass').innerHTML = str7;
			if(document.getElementById("passRetype").value == '')
			{
				errors++;
				str8= "<br>*Retype Password. \n";
				document.getElementById('repass').innerHTML = str8;
			}
			else 
			{	
				
				str8= "";
				document.getElementById('repass').innerHTML = str8;
				if(passcheck())
				{
					errors++;
					str9 = "<br>*Password not Matched\n";
					document.getElementById('repass').innerHTML = str9;
				}
				else
				{
					str9 = "";
					document.getElementById('repass').innerHTML = str9;
				}
			}
		}			
	}

	if(document.getElementById("email").value == '') 
	{
		errors++;
		str2= "<br>*Email address required\n";
		document.getElementById('emailadd').innerHTML = str2;		
	}
		
	else if(document.getElementById("email").value != '')
	{
		
		str2= "";
		document.getElementById('emailadd').innerHTML = str2;		

		if(!(checkemail(document.getElementById("email").value)))
		{
			errors++;
			str3 = "<br>*Enter Valid Email address\n";
			document.getElementById('emailadd').innerHTML = str3;
		}
		else
		{
			
			str3 = "";
			document.getElementById('emailadd').innerHTML = str3;

			if(document.getElementById("emailRetype").value == '')
			{
				 errors++;
				 str4 = "<br>*Retype Email address\n";
				 document.getElementById('remail').innerHTML = str4;
			}
			else 
			{
				
				 str4 = "";
				 document.getElementById('remail').innerHTML = str4;

				if(document.getElementById("email").value != document.getElementById("emailRetype").value)
				 {
					 errors++;
					str5 = "<br>*Email address not Matched\n";
					document.getElementById('remail').innerHTML = str5;
				 }
				 else
				 {
					 
					str5 = "";
					document.getElementById('remail').innerHTML = str5;

				 }
			 }
		}			
	}

	if(document.getElementById("zip").value == '') 
	{
		errors++;
		str10 = "<br>*Zip Code required\n";
		document.getElementById('zip1').innerHTML = str10;
	}
	else if(document.getElementById("zip").value != '') 
	{
		str10 = "";
		document.getElementById('zip1').innerHTML = str10;
	}
	if(document.getElementById("birthyear").value == '0') 
	{
		errors++;
		str11 = "<br>*Birth Year required\n";
		document.getElementById('birthstr').innerHTML = str11;
	}
	else if(document.getElementById("birthyear").value != '0') 
	{
		str11 = "";
		document.getElementById('birthstr').innerHTML = str11;
	}
			
	
	if(errors>0)
	{
			//alert('Errors found');
		return false;
	}
	else if(errors==0)
	{
			//alert('No errors found');
		return true;
	}
}









function newsvalidator() {
	
	
	var errors = 0;
	
	var str ="";
	
		if(document.getElementById("title").value == '') { 
			errors++;
			str +="<br>*Title required. \n";
			}
		
		
		if(document.getElementById("url").value == '') { 
			errors++;
			str += "<br>*URL required.\n";
			}
		
		
		
			
		if(document.getElementById("url").value != '') { 
			if(!(isValidURL(document.getElementById("url").value)))
					{
						errors++;
					str += "<br>*URL must be valid.\n";
					}
			}
			
		if(document.getElementById("2").style.display=="block")
		{
		if(document.getElementById("pic_source").value == '') { 
			errors++;
			str += "<br>*Picture Source required.\n";
			}
		}
		if(document.getElementById("discription").value == '') { 
			errors++;
			str += "<br>*Discription required.\n";
			}
	  if(document.getElementById("sex").value == '') { 
			errors++;
			str += "<br>*Gender required.\n";
			}
			
		if (errors != 0) { 
			//alert(str);
			document.getElementById('error_show').innerHTML = str;
			
			return false;
		}
		

	}


function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
} 


function checkemail(email)
{
if(!email.match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/))
return false;
return true;
}


function check_email(frmail) {
if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(frmail))){
return (true)
}
return (false)
}

	function multiEmail(email_field) 
	{
		var email = email_field.split(',');
		for (var i = 0; i < email.length; i++) {
		if (!check_email(email[i])) {
		alert('one or more email addresses entered is invalid');
		return false;
		}
		}
		return true;
	}


function checkPhone(string)
{
	if (isNaN(string))
	   return false;
	   return true;
}


function loginvalidator() {
	
	var errors = 0;
	
	var str ="These Entries are Blank \n";
	//var firstname = document.getElementById("Username");	
		if(document.getElementById("user_name").value == '') {
			errors++;
			str += "User Name is Blank ?\n";
			}
	
		if(document.getElementById("password").value == '') {
			errors++;
			str += "Password is Blank ? \n";
			}
			
			
		if (errors != 0) {
			alert(str);
			return false;
		}
		
}




function passforget() {
	
	//alert('helllo');
	var errors = 0;
	
	var str ="";
	
		if(document.getElementById("email").value == '') {
			errors++;
			str += "Email Field is Blank";
			}
	
				
		if (errors != 0) {
			alert(str);
			return false;
		}
}





function passforget_validator() {
	
	//alert('helllo');
	var errors = 0;
	
	var str ="These Entries are Blank \n";
	
		if(document.getElementById("user_name").value == '') {
			errors++;
			str += "User Name is Blank ?\n";
			}
	
			if(document.getElementById("password").value == '') {
			errors++;
			str += "Password is Blank ? \n";
			}
				if(document.getElementById("password").value != '') {
					if(document.getElementById("password").value.length < 4 )
						{
						errors++;
						str += "The Password Should Be at Least Four Characters Long  ?\n";
						}
						else{	
								if(document.getElementById("password_confirmation").value == '')
									{
									 errors++;
									 str += "please Retype The Password ?\n";
									 }
									else {	if(passcheck()){
											errors++;
											str += "Password is not Matched  ?\n";}
											}
							}
					
					}
			
				
		if (errors != 0) {
			alert(str);
			return false;
		}
}

function passcheck()
{

		if(document.getElementById("pass_word").value != document.getElementById("passRetype").value)
			return true;
			else return false;
			
			
}

function change(locale) 
{
var url ='http://localhost/?lang='+locale;
location.href=url;

/*var urlpart = window.location.href;
var urlparts = urlpart.split('=');
var url = urlparts[0] + "=" + locale;
location.href=url;*/

}


function geo_validator() {
	
	
	var errors = 0;
	
	var str ="These Entries are Blank \n";
	
		if(document.getElementById("add1").value == '') {
			errors++;
			str += "Address Line One is Blank ?\n";
			}
	
		if(document.getElementById("street").value == '') {
			errors++;
			str += "Street Address is Blank ? \n";
			}
				

		if(document.getElementById("geo_city").value == '') {
			errors++;
			str += "City Field is Blank ? \n";
			}
				
		if(document.getElementById("geo_state").value == '') {
			errors++;
			str += "State Field is Blank ?\n";
			}
	
	
		if (errors != 0) {
			alert(str);
			return false;
		}
		

	}
