

function trim(s) {
	s = s.replace(/(^\s*)|(\s*$)/gi,"");
	s = s.replace(/[ ]{2,}/gi," ");
	s = s.replace(/\n /,"\n");
	return s;
}

function isEmail ( string ) {
  if ( string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1 )
    return true;
  else
    return false;
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function validateSearchBox()
{
	
	var EmailId	=	 trim(document.getElementById('EmailId').value);
	var City	=	 trim(document.getElementById('City').value);
	
	document.getElementById('EmailId').value	=	EmailId;
	if (EmailId == 'Enter Email ID')
	{
		EmailId = '';
	}

	if(EmailId == '')
	{
		alert("Email ID Cant Be Left Blank. Please Enter EmailId");
		document.getElementById('EmailId').focus();
		return false;
	}
	else if(!isEmail(EmailId))
	{
		alert("Invalid Email ID. Please Enter a Valid Email Id");
		document.getElementById('EmailId').focus();
		return false;
	}
}

function validateHeaderLoginBox()
{
	var EmailId	=	 trim(document.getElementById('header_login_email').value);
	var City	=	 trim(document.getElementById('header_drp_city').value);
	if (EmailId == "Enter Email ID")
	{
		EmailId = '';
	}

	if(EmailId == '')
	{
		alert("Email ID Cant Be Left Blank. Please Enter EmailId");
		document.getElementById('header_login_email').focus();
		return false;
	}
	else if(!isEmail(EmailId))
	{
		alert("Invalid Email ID. Please Enter a Valid Email Id");
		document.getElementById('header_login_email').focus();
		return false;
	}
}

function validateSignIn()
{
	var EmailId	=	 trim(document.getElementById('EmailId_SignIn').value);
	var Password_SignIn	=	 trim(document.getElementById('Password_SignIn').value);
	if (EmailId == "Enter Email ID")
	{
		EmailId = '';
	}

	if(EmailId == '')
	{
		alert("Email ID Cant Be Left Blank. Please Enter EmailId");
		document.getElementById('EmailId_SignIn').focus();
		return false;
	}
	else if(!isEmail(EmailId))
	{
		alert("Invalid Email ID. Please Enter a Valid Email Id");
		document.getElementById('EmailId_SignIn').focus();
		return false;
	}
	
	if(Password_SignIn == '')
	{
		alert("Password cannot be left blank. Please enter Password.");
		document.getElementById('Password_SignIn').focus();
		return false;
	}
}

function validateForgetPassword()
{
	var EmailId	=	 trim(document.getElementById('EmailId_ForgetPassword').value);
	if (EmailId == "Enter Email ID")
	{
		EmailId = '';
	}
	if(EmailId == '')
	{
		alert("Email ID Cant Be Left Blank. Please Enter EmailId");
		document.getElementById('EmailId_ForgetPassword').focus();
		return false;
	}
	else if(!isEmail(EmailId))
	{
		alert("Invalid Email ID. Please Enter a Valid Email Id");
		document.getElementById('EmailId_ForgetPassword').focus();
		return false;
	}
}

function ValidateChangeEmail()
{
	var EmailId	=	 trim(document.getElementById('email_change_new').value);
	if (EmailId == "Enter Email ID")
	{
		EmailId = '';
	}
	if(EmailId == '')
	{
		alert("Email ID Cant Be Left Blank. Please Enter EmailId");
		document.getElementById('email_change_new').focus();
		return false;
	}
	else if(!isEmail(EmailId))
	{
		alert("Invalid Email ID. Please Enter a Valid Email Id");
		document.getElementById('email_change_new').focus();
		return false;
	}
}

function validatePassword()
{
	var passwd1	=	 trim(document.getElementById('upd_passwd').value);
	var passwd2	=	 trim(document.getElementById('upd_passwd_confirm').value);
	if(trim(passwd1) == "" || trim(passwd2) == "")
	{
		alert("Password Not Entered. Please Enter Again");
		document.getElementById('upd_passwd').focus();
		return false;
	}
	if(passwd1 != passwd2)
	{
		alert("Password Mismatch. Please Enter Again");
		document.getElementById('upd_passwd').focus();
		return false;
	}
	else if(passwd1 != passwd2)
	{
		return true;
	}
	//return false;
}

function validateChngPassword()
{
	var passwd1	=	 trim(document.getElementById('chng_passwd').value);
	var passwd2	=	 trim(document.getElementById('chng_passwd_confirm').value);
	if(trim(passwd1) == "" || trim(passwd2) == "")
	{
		alert("Password Not Entered. Please Enter Again");
		document.getElementById('chng_passwd').focus();
		return false;
	}
	if(passwd1 != passwd2)
	{
		alert("Password Mismatch. Please Enter Again");
		document.getElementById('chng_passwd').focus();
		return false;
	}
	else if(passwd1 != passwd2)
	{
		return true;
	}
}

function ValidateEmailSubs() {
// Checking if at least one period button is selected. Or not.
if (!document.getElementById('option_mail_subscription').checked){

alert("Please Select Option");
return false;
}
}

function ValidateSearchBox()
{
	var stext	=	 trim(document.getElementById('stext').value);
	if (stext == "Search Taaza Deals")
	{
		stext = '';
	}
	if(stext == '')
	{
		alert("Search keywords missing. Please enter some keywords to search.");
		document.getElementById('stext').focus();
		return false;
	}
}


<!-- 
//Browser Support Code
function ajaxFunction(a,b,c){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			alert("success");
			//document.myForm.time.value = ajaxRequest.responseText;
		}
	}
	//var age = document.getElementById('age').value;
	//var wpm = document.getElementById('wpm').value;
	//var sex = document.getElementById('sex').value;
	var queryString = "?a=" + a + "&b=" + b + "&c=" + c;
	ajaxRequest.open("GET", "ajax-example.php" + queryString, true);
	ajaxRequest.send(null); 
}

//-->

