var httpObj = false;
		try {
			  httpObj = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj = false;
			}
	  }
	}

var CityName = new Array('Ahmedabad','Bangalore','Bhopal','Bhubaneswar','Calicut','Chandigarh','Chennai','Cochin','Coimbatore','Delhi','Ernakulam','Faridabad','Ghaziabad','Guntur','Gurgaon','Guwahati','Hyderabad','Indore','Jaipur','Kannur','Kanpur','Kolkata','Kottayam','Lucknow','Ludhiana','Madurai','Malapuram','Mangalore','Mumbai','Mysore','Nagpur','Nashik','Navi Mumbai','Noida','Palghat','Patna','Pune','Rajkot','Salem','Secunderabad','Surat','Thane','Thrissur','Tiruchy','Trivandrum','Vadodara','Vijayawada','Vishakhapatnam','Warangal');

function DisplayError(Message){
	document.getElementById("newerror").style.display = "block";
	document.getElementById("newerror").innerHTML = parseHTML('<p style="margin:0 auto; color:#000000;">' + Message + '</p>');
}

function HideError(){
	document.getElementById("newerror").innerHTML = parseHTML('');
	document.getElementById("newerror").style.display = "none";
}

function DisplayError1(Message,DivName){
	document.getElementById(DivName).style.display = "block";
	document.getElementById(DivName).innerHTML = parseHTML('<p style="margin:0 auto; color:#000000;">' + Message + '</p>');
}

function HideError1(DivName){
	document.getElementById(DivName).innerHTML = parseHTML('');
	document.getElementById(DivName).style.display = "none";
}

function ShowCross(name){
	if(name=='city1'){
		document['city1'].src = "./images/cross.png";
		document.getElementById('othercity').style.border = "1px solid #d12f19";
		document.getElementById('othercity').style.background = "#f7cbc2";
	}else{
		document[name].src = "./images/cross.png";
		document.getElementById(name).style.border = "1px solid #d12f19";
		document.getElementById(name).style.background = "#f7cbc2";
	}
}

function RemoveCross(name){
	if(name=='city1'){
		document['city1'].src = "./images/tick.png";
		document.getElementById('othercity').style.border = "1px solid #a1a1a1";
		document.getElementById('othercity').style.background = "#fff";
	}else{
		document[name].src = "./images/tick.png";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}
}

function SetValue(value){
	document.getElementById("seterror").value = value;
}

function GetInputName(name){
	if(name=="f_name"){
		document['l_name'].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}else if(name=="email"){
		document['email'].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}else if(name=="day" || name=="month" || name=="year"){
		document['year'].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}else if(name=="mobile"){
		document['mobile'].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}else if(name=="address"){
		document['address'].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}else if(name=="inst"){
		document['inst'].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}else if(name=="class"){
		document['class'].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}/* else if(name=="maritalstatus"){
		document['gender'].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	} */else{
		document[name].src="images/a.gif";
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
	}
}

function UserNameDataBaseValidation(){
	var url = urlpath+"registration_step3.php?username="+trim(document.getElementById("username").value);
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==4){
			if(httpObj.responseText=='--1--'){
				ShowCross('username');
				DisplayError('Username is already registered. Log-in.');
				SetValue(httpObj.responseText);
			}else if(httpObj.responseText=='--2--'){
				ShowCross('username');
				DisplayError('Username is blocked. Contact Support.');
				SetValue(httpObj.responseText);
			}else{
				RemoveCross('username');
				HideError();
				SetValue(0);
			}
		}
	}
	httpObj.send(null);
}

function UserNameValidation(){
	var UserNameValue = trim(document.getElementById("username").value);
	var value = UserNameValidity(UserNameValue);
	if(UserNameValue == ''){
		ShowCross('username');
		return false;
	}else if(value) {
		ShowCross('username');
		DisplayError(value);
		return false;	
	}else{
		UserNameDataBaseValidation();
		if(document.getElementById("seterror").value=='--1--')	
			return false;
		else if(document.getElementById("seterror").value=='--2--')	
			return false;
	}
	return true;
}

function CheckUserName(){
	if(!UserNameValidation()) return false;
	else return true;
}

function CheckPassword(){
	var PasswordValue = trim(document.getElementById("user_pass").value);
	var value = inValidPassword(PasswordValue);
	var status = 0;
	if(PasswordValue==''){
		ShowCross('user_pass');
	}else if(value){
		ShowCross('user_pass');
		DisplayError(value);
		status = 1;
	}else{
		if(PasswordValue != ''){
			RemoveCross('user_pass');
			HideError();
		}
	}

	if(PasswordValue=='' || status==1){
		return false;
	}
	else{
		return true;
	}
}

function CapitalizeMe(val) {
	
	var CapitalString = val.toUpperCase();
	var firstchar = CapitalString.substring(0,1);
	var reststring = CapitalString.substring(1);
	var SmallString = reststring.toLowerCase();

	var name = firstchar+SmallString;
	return name;
}

function CheckFirstName(){

	var FirstNameValue = trim(document.getElementById("f_name").value);
	var value = NameValidity(FirstNameValue);
	document.getElementById("f_name").value = trim(CapitalizeMe(FirstNameValue));
	
	
	if(FirstNameValue == ''){	
		document['l_name'].src="./images/cross.png";
		document.getElementById("f_name").style.border = "1px solid #d12f19";
		document.getElementById("f_name").style.background = "#f7cbc2";
		return false;
	}else if(value){
		document['l_name'].src="./images/cross.png";
		document.getElementById("f_name").style.border = "1px solid #d12f19";
		document.getElementById("f_name").style.background = "#f7cbc2";
		DisplayError(value);
		return false;
	}else{
		if(FirstNameValue != ''){
			document['l_name'].src="images/a.gif";
			document.getElementById("f_name").style.border = "1px solid #a1a1a1";
			document.getElementById("f_name").style.background = "#fff";
			HideError();
			return true;
		}
	}
}

function CheckLastName(){
	var LastNameValue = trim(document.getElementById("l_name").value);
	var value = NameValidity(LastNameValue);
	document.getElementById("l_name").value = trim(CapitalizeMe(LastNameValue));
	
	if(LastNameValue == ''){	
		ShowCross('l_name');
		return false;
	}else if(value){
		ShowCross('l_name');
		DisplayError(value);
		return false;
	}else{ 
		if(LastNameValue != ''){
			document.getElementById("l_name").style.border = "1px solid #a1a1a1";
			document.getElementById("l_name").style.background = "#fff";
			if(CheckFirstName()){				
				document['l_name'].src="./images/tick.png";
				HideError();
				return true;
			}
		}
	}
}

function EmailDataBaseValidation(){
	var url = urlpath+"CheckEmailTest.php?email="+trim(document.getElementById("email").value);
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==4){
			if(httpObj.responseText == '--1--'){
				ShowCross('email');
				DisplayError('Email address is already registered. Log-in.');
				SetValue(httpObj.responseText);
			}else if(httpObj.responseText == '--2--'){
				ShowCross('email');
				DisplayError('Email address seems to be incorrect.');
				SetValue(httpObj.responseText);
			}else{
				RemoveCross('email');
				HideError();
				SetValue(0);
			}
		}
	}
	httpObj.send(null);
}

function EmailValidation(){
	var EmailValue = trim(document.getElementById("email").value);
	var value = EmailValidity(EmailValue);
	
	if(EmailValue == ''){
		ShowCross('email');
		return false;
	}else if(value){
		ShowCross('email');
		DisplayError(value);
		return false;
	}else if(EmailValue != ''){
		document.getElementById("l_name").style.border = "1px solid #a1a1a1";
		document.getElementById("l_name").style.background = "#fff";
	
			document['email'].src="./images/tick.png";
			HideError();
			return true;
	}else{
		EmailDataBaseValidation();
		if(document.getElementById("seterror").value=='--1--')	
			return false;
		else if(document.getElementById("seterror").value=='--2--')	
			return false;
	}
	return true;
}

function CheckEmail(){

	if(!EmailValidation()) return false;
	else { return true;	}
}

function CheckCountry(name){
	if(name == "country" || name == "city" || name == "gender" || name == "maritalstatus"){
		if(document.getElementById(name).value == '')
		{
			ShowCross(name);
			return false;
		}
		if(document.getElementById(name).value != '')
		{
			RemoveCross(name);
			HideError();
			return true;
		}
	}
}
function CheckAddress(){
	var AddressValue = trim(document.getElementById("address").value);
	var value = AddressValidity(AddressValue);
	
	if(AddressValue == ''){	
		ShowCross('address');
		return false;
	}else if(value){
		ShowCross('address');
		DisplayError(value);
		return false;
	}else{ 
		if(AddressValue != ''){
			document.getElementById("address").style.border = "1px solid #a1a1a1";
			document.getElementById("address").style.background = "#fff";
			document['address'].src="./images/tick.png";
			HideError();
		}
	}
}
function CheckInst(){
	var Institute = trim(document.getElementById("inst").value);
	var value = InstValidity(Institute);
	
	if(Institute == ''){	
		ShowCross('inst');
		return false;
	}else if(value){
		ShowCross('inst');
		DisplayError(value);
		return false;
	}else{ 
		if(Institute != ''){
			document.getElementById("inst").style.border = "1px solid #a1a1a1";
			document.getElementById("inst").style.background = "#fff";
			document['inst'].src="./images/tick.png";
			HideError();
		}
	}
}
function CheckClass(){
	var Class = trim(document.getElementById("class").value);
	var value = ClassValidity(Class);
	
	if(Class == ''){	
		ShowCross('class');
		return false;
	}else if(value){
		ShowCross('class');
		DisplayError(value);
		return false;
	}else{ 
		if(Class != ''){
			document.getElementById("inst").style.border = "1px solid #a1a1a1";
			document.getElementById("inst").style.background = "#fff";
			document['class'].src="./images/tick.png";
			HideError();
		}
	}
}
function CheckSub(){
	var Subject = trim(document.getElementById("sub").value);
	var value = SubjectValidity(Subject);
	
	if(Subject == ''){	
		ShowCross('sub');
		return false;
	}else if(value){
		ShowCross('sub');
		DisplayError(value);
		return false;
	}else{ 
		if(Subject != ''){
			document.getElementById("sub").style.border = "1px solid #a1a1a1";
			document.getElementById("sub").style.background = "#fff";
			document['sub'].src="./images/tick.png";
			HideError();
		}
	}
}
function CheckDob(name){
	if(name == "month"||name == "day"||name == "year"){
		if(document.getElementById(name).value == '')
		{
			document['year'].src="./images/delete.png";
			document.getElementById(name).border = "1px solid #d12f19";
			document.getElementById(name).style.background = "#f7cbc2";
			return false;
		}
		if(document.getElementById(name).value != '')
		{
			if(document.getElementById('day').value!='' || document.getElementById('month').value!='' || document.getElementById('year').value!=''){
				if(!CheckDate())return false;
				else return true;
			}else{
				if(name=="year" && document.getElementById('month').value!='' && document.getElementById('day').value!=''){
					//document['year'].src = "images/check.gif";
					document['year'].src="./images/tick.png";
				}
				if(name=="month" && document.getElementById('year').value!='' && document.getElementById('day').value!=''){
					//document['year'].src = "images/check.gif";	
					document['year'].src="./images/tick.png";
				}
				if(name=="day" && document.getElementById('month').value!='' && document.getElementById('year').value!=''){
					//document['year'].src = "images/check.gif";
					document['year'].src="./images/tick.png";
				}
					document.getElementById(name).border = "1px solid #a1a1a1";
					document.getElementById(name).style.background = "#ffffff";
					document.getElementById("error").innerHTML = parseHTML('');
					document.getElementById("error").style.display = "none";
					return true;
			}
		}
	}
}

function CheckDate(){
	var Day = document.getElementById("day").value;
	var Month = document.getElementById("month").value;
	var Year = document.getElementById("year").value;
	var Dob = Year+"-"+Month+"-"+Day;

	age = qryHowOld(new Date(), Month + '/' + Day + '/' + Year );

		if(age.indexOf('Year') != -1) {
			age_count = age.substring( 0, age.indexOf('Year') );
			age_count = parseInt(age_count);
			if(age_count < 18) {
				ShowCross('year');
				DisplayError("Your age must be 18+ to join!");
				return false;
			}else{
				RemoveCross('year');
				HideError();
			    return true;
			}
		}
	//return true;
}

function qryHowOld(varAsOfDate, varBirthDate)
{
	var dtAsOfDate;
	var dtBirth;
	var dtAnniversary;
	var intSpan;
	var intYears;
	var intMonths;
	var intWeeks;
	var intDays;
	var intHours;
	var intMinutes;
	var intSeconds;
	var strHowOld;

	// get born date
	dtBirth = new Date(varBirthDate);

	// get as of date
	dtAsOfDate = new Date(varAsOfDate);

	// if as of date is on or after born date
	if ( dtAsOfDate >= dtBirth )
	{

		// get time span between as of time and birth time
		intSpan = ( dtAsOfDate.getUTCHours() * 3600000 +
		dtAsOfDate.getUTCMinutes() * 60000 +
		dtAsOfDate.getUTCSeconds() * 1000    ) -
		( dtBirth.getUTCHours() * 3600000 +
		dtBirth.getUTCMinutes() * 60000 +
		dtBirth.getUTCSeconds() * 1000       )

		// start at as of date and look backwards for anniversary

		// if as of day (date) is after birth day (date) or
		//    as of day (date) is birth day (date) and
		//    as of time is on or after birth time
		if ( dtAsOfDate.getUTCDate() > dtBirth.getUTCDate() ||
		( dtAsOfDate.getUTCDate() == dtBirth.getUTCDate() && intSpan >= 0 ) )
		{

			// most recent day (date) anniversary is in as of month
			dtAnniversary =
			new Date( Date.UTC( dtAsOfDate.getUTCFullYear(),
			dtAsOfDate.getUTCMonth(),
			dtBirth.getUTCDate(),
			dtBirth.getUTCHours(),
			dtBirth.getUTCMinutes(),
			dtBirth.getUTCSeconds() ) );

		}

		// if as of day (date) is before birth day (date) or
		//    as of day (date) is birth day (date) and
		//    as of time is before birth time
		else
		{

			// most recent day (date) anniversary is in month before as of month
			dtAnniversary =
			new Date( Date.UTC( dtAsOfDate.getUTCFullYear(),
			dtAsOfDate.getUTCMonth() - 1,
			dtBirth.getUTCDate(),
			dtBirth.getUTCHours(),
			dtBirth.getUTCMinutes(),
			dtBirth.getUTCSeconds() ) );

			// get previous month
			intMonths = dtAsOfDate.getUTCMonth() - 1;
			if ( intMonths == -1 )
			intMonths = 11;

			// while month is not what it is supposed to be (it will be higher)
			while ( dtAnniversary.getUTCMonth() != intMonths )

			// move back one day
			dtAnniversary.setUTCDate( dtAnniversary.getUTCDate() - 1 );

		}

		// if anniversary month is on or after birth month
		if ( dtAnniversary.getUTCMonth() >= dtBirth.getUTCMonth() )
		{

			// months elapsed is anniversary month - birth month
			intMonths = dtAnniversary.getUTCMonth() - dtBirth.getUTCMonth();

			// years elapsed is anniversary year - birth year
			intYears = dtAnniversary.getUTCFullYear() - dtBirth.getUTCFullYear();

		}

		// if birth month is after anniversary month
		else
		{

			// months elapsed is months left in birth year + anniversary month
			intMonths = (11 - dtBirth.getUTCMonth()) + dtAnniversary.getUTCMonth() + 1;

			// years elapsed is year before anniversary year - birth year
			intYears = (dtAnniversary.getUTCFullYear() - 1) - dtBirth.getUTCFullYear();

		}

		// to calculate weeks, days, hours, minutes and seconds
		// we can take the difference from anniversary date and as of date

		// get time span between two dates in milliseconds
		intSpan = dtAsOfDate - dtAnniversary;

		// get number of weeks
		intWeeks = Math.floor(intSpan / 604800000);

		// subtract weeks from time span
		intSpan = intSpan - (intWeeks * 604800000);

		// get number of days
		intDays = Math.floor(intSpan / 86400000);

		// subtract days from time span
		intSpan = intSpan - (intDays * 86400000);

		// get number of hours
		intHours = Math.floor(intSpan / 3600000);

		// subtract hours from time span
		intSpan = intSpan - (intHours * 3600000);

		// get number of minutes
		intMinutes = Math.floor(intSpan / 60000);

		// subtract minutes from time span
		intSpan = intSpan - (intMinutes * 60000);

		// get number of seconds
		intSeconds = Math.floor(intSpan / 1000);

		// create output string
		if ( intYears > 0 )
		if ( intYears > 1 )
		strHowOld = intYears.toString() + ' Years';
		else
		strHowOld = intYears.toString() + ' Year';
		else
		strHowOld = '';

		if ( intMonths > 0 )
		if ( intMonths > 1 )
		strHowOld = strHowOld + ' ' + intMonths.toString() + ' Months';
		else
		strHowOld = strHowOld + ' ' + intMonths.toString() + ' Month';

		if ( intWeeks > 0 )
		if ( intWeeks > 1 )
		strHowOld = strHowOld + ' ' + intWeeks.toString() + ' Weeks';
		else
		strHowOld = strHowOld + ' ' + intWeeks.toString() + ' Week';

		if ( intDays > 0 )
		if ( intDays > 1 )
		strHowOld = strHowOld + ' ' + intDays.toString() + ' Days';
		else
		strHowOld = strHowOld + ' ' + intDays.toString() + ' Day';

		if ( intHours > 0 )
		if ( intHours > 1 )
		strHowOld = strHowOld + ' ' + intHours.toString() + ' Hours';
		else
		strHowOld = strHowOld + ' ' + intHours.toString() + ' Hour';

		if ( intMinutes > 0 )
		if ( intMinutes > 1 )
		strHowOld = strHowOld + ' ' + intMinutes.toString() + ' Minutes';
		else
		strHowOld = strHowOld + ' ' + intMinutes.toString() + ' Minute';

		if ( intSeconds > 0 )
		if ( intSeconds > 1 )
		strHowOld = strHowOld + ' ' + intSeconds.toString() + ' Seconds';
		else
		strHowOld = strHowOld + ' ' + intSeconds.toString() + ' Second';

	}
	else
	strHowOld = 'Not Born Yet'

	// return string representation
	return strHowOld
}

function CheckSexStatus(name){
	if(name == "gender"||name == "maritalstatus"){
		if(document.getElementById(name).value == '')
		{
			//document['year'].src = "images/false.gif";
			document['gender'].src="./images/cross.png";
			document.getElementById(name).border = "1px solid #d12f19";
			document.getElementById(name).style.background = "#f7cbc2";
			return false;
		}
		if(document.getElementById(name).value != '')
		{
			if(name=="maritalstatus" && document.getElementById('gender').value!='' ){
				//document['year'].src = "images/check.gif";
				document['gender'].src="./images/tick.png";
			}
			if(name=="gender" && document.getElementById('maritalstatus').value!=''){
				//document['year'].src = "images/check.gif";	
				document['gender'].src="./images/tick.png";
			}
			
			document.getElementById(name).border = "1px solid #a1a1a1";
			document.getElementById(name).style.background = "#ffffff";
			document.getElementById("newerror").innerHTML = parseHTML('');
			document.getElementById("newerror").style.display = "none";
			return true;
		}
	}
}

function MobileDataBaseValidation(){
	var url = urlpath+"CheckMobileTest.php?mobile="+trim(document.getElementById('mobile').value);
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==4){
			if(httpObj.responseText == '--1--'){
				ShowCross('mobile');
				DisplayError('Mobile is already registered. Log-in.');
				SetValue(httpObj.responseText);
			}else if(httpObj.responseText == '--2--'){
				ShowCross('mobile');
				DisplayError('Mobile is blocked. Contact Support.');
				SetValue(httpObj.responseText);
			}else{
				RemoveCross('mobile');
				HideError();
				SetValue(0);
			}
		}
	}
	httpObj.send(null);
}

function MobileValidation(){
	var MobileValue = trim(document.getElementById('mobile').value);
	var value = MobileValidity(MobileValue);
	
	if(MobileValue == ''){
		ShowCross('mobile');
		return false;
	}else if(value){
		ShowCross('mobile');
		DisplayError(value);
		return false;
	}else if(MobileValue != ''){
			document.getElementById("mobile").style.border = "1px solid #a1a1a1";
			document.getElementById("mobile").style.background = "#fff";
							
			document['mobile'].src="./images/tick.png";
			HideError();
			return true;
	}
	/* else{
		MobileDataBaseValidation();
		if(document.getElementById("seterror").value=='--1--')	
			return false;
		else if(document.getElementById("seterror").value=='--2--')	
			return false;
	} */
	return true;
}

function CheckMobile(){
	if(!MobileValidation()) return false;
	else return true;
}

function CallCityValue(value){
	if(value=='Other'){
		var rishi = ': <select name="city" id="city" class="selectstyle" onchange="javascript:ChanageCityOnSelection(this.value);" style=" width:110px; font-family:lucida grande, tahoma, verdana, arial, sans-serif; font-size:11px; border:1px solid #a1a1a1;">';
	}else{
		var rishi = ': <select name="city" id="city" class="selectstyle" onBlur="javascript:CheckCountry(this.name);" onchange="javascript:ChanageCityOnSelection(this.value);" style=" width:217px; font-family:lucida grande, tahoma, verdana, arial, sans-serif; font-size:11px; border:1px solid #a1a1a1; ">';
	}
	for(i=0;i<CityName.length;i++){
		if(CityName[i]==value)
			rishi = rishi + '<option value="'+CityName[i]+'" selected>'+CityName[i]+'</option>';
		else
			rishi = rishi + '<option value="'+CityName[i]+'">'+CityName[i]+'</option>';
	}
	if(value=='Other'){
		rishi = rishi + '<option value="Other" selected>Other City</option>';
		rishi = rishi + '</select>&nbsp;<input name="othercity" id="othercity" type="text" style="width:97px;" onfocus="ClearCity();" onBlur="SetOtherCity();" value="--Enter a city--"/><img width="16" height="16" name="city1" src="images/blank.gif" alt="" style="margin:0px 0px 4px 5px; vertical-align:middle;"/>';
	}
	else{
		rishi = rishi + '<option value="Other">Other City</option>';
		rishi = rishi + '</select><img width="16" height="16" name="city" src="images/blank.gif" alt="" style="margin:0px 0px 4px 4px; vertical-align:middle;"/>';
	}
	return rishi;
}	

function ClearCity(){
	if(document.getElementById("othercity").value=='--Enter a city--')
		document.getElementById("othercity").value="";
}

function SetCityValue(divName,setcity){
	document.getElementById(divName).innerHTML = parseHTML(setcity);
}

function ChanageCityOnSelection(value){
	if(value!='Other'){
		setcity = CallCityValue(value);
		document.getElementById("show_other_city").style.display = "none";
		document.getElementById("show_city").style.display = "block";
		SetCityValue('show_city',setcity);
		//document.getElementById('show_city').focus();
		document.getElementById('city').focus();
	}else{
		setcity = CallCityValue(value);
		document.getElementById("show_city").style.display = "none";
		document.getElementById("show_other_city").style.display = "block";
		SetCityValue('show_other_city',setcity);
		document.getElementById('othercity').focus();
	}
}

function SetOtherCity(){
	if(document.getElementById("othercity").value=="")
		document.getElementById("othercity").value="--Enter a city--";
		
		var CityValue = document.getElementById('othercity').value;
		var value = CityValidity(CityValue);
		
		if(CityValue == '' || CityValue=='--Enter a city--'){
			ShowCross('city1');
			return false;
		}else if(value){
			ShowCross('city1');
			DisplayError(value);
			return false;
		}else{
			RemoveCross('city1');
			return true;
		}
	return true;
}

function CheckCity(){
	if(document.getElementById("city").value==''){
		ShowCross('city');
		return false;	
	}else if(document.getElementById("city").value=='Other'){
		if(!SetOtherCity()) return false;
		else return true;
	}else
		return true;
}


function CheckTC(){
	if(document.getElementById("agreement").checked == false){
			ShowCross('agreement');
			return false;
	}else{
			RemoveCross('agreement');
			return true;			
	}
}

function CheckCaptchaCode(){
	if(trim(document.getElementById("user_verify").value)==''){
		ShowCross('user_verify');
		return false;
	}else if(trim(document.getElementById("user_verify").value)!=''){
		document['user_verify'].src = "./images/a.gif";
		document.getElementById('user_verify').style.border = "1px solid #a1a1a1";
		document.getElementById('user_verify').style.background = "#fff";
		return true;
	}
}

var timer = 0;
var timer1 = 0;

function gotoRegStep2(){
	
	/*alert(CheckFirstName());
	alert(CheckLastName());
	alert(EmailValidation());
	alert(MobileValidation());
	alert(CheckCountry("city"));
	alert(CheckDob("day"));
	alert(CheckDob("month"));
	alert(CheckDob("year"));
	alert(CheckGender());
	alert(CheckCountry("maritalstatus"));
	alert(UserNameValidation());
	alert(CheckPassword());
	alert(CheckTC("agreement"));*/


	if(!CheckFirstName()) return false;
	else if(!CheckLastName()) return false;
	else if(!EmailValidation()) return false;
	else if(!MobileValidation()) return false;
	else if(!CheckAddress()) return false;
	else if(!CheckDob("day")) return false;
	else if(!CheckDob("month")) return false;
	else if(!CheckDob("year")) return false;
	else if(!CheckInst()) return false;
	else if(!CheckClass()) return false;
	else if(!CheckSub()) return false;
	else if(!CheckSexStatus("gender")) return false;
	else if(!UserNameValidation()) return false;
	else if(!CheckPassword()) return false;
	else if(!CheckCaptchaCode()) return false;
	else if(!CheckTC("agreement")) return false;
	
	var username = document.getElementById("username").value;
	var f_name = document.getElementById("f_name").value;
	var l_name = document.getElementById("l_name").value;
	var email = document.getElementById("email").value;
	var pass1 = document.getElementById("user_pass").value;
	
	var city = document.getElementById("city").value;
	if(city=='Other'){
		var othercity = document.getElementById("othercity").value;
	}else{
		var othercity = '';
	}

	var month = document.getElementById("month").value;
	var day = document.getElementById("day").value;
	var year = document.getElementById("year").value;
	var dob = year+'-'+month+'-'+day;	
	
	var gender = document.getElementById("gender").value;
	var maritalstatus = document.getElementById("maritalstatus").value;
	var mobile = document.getElementById("mobile").value;
	var user_verify = document.getElementById("user_verify").value;
	
	document.getElementById('ValidationDiv').style.display = 'block';
	document.getElementById('form').style.display = 'none';
	document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Verification in progress</p>');

	var url = urlpath+"registration_step1.php?f_name="+f_name+"&l_name="+l_name+"&email="+email+"&pass="+pass1+"&city="+city+"&othercity="+othercity+"&dob="+dob+"&gender="+gender+"&maritalstatus="+maritalstatus+"&mobile="+mobile+"&username="+username+"&user_verify="+user_verify+"&register=yes";
	//alert(url);
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==1||httpObj.readyState==2||httpObj.readyState==3){
			document.getElementById('ValidationDiv').innerHTML = parseHTML("<p style='text-align:center;padding-top:40px;padding-bottom:40px; font-weight:bold; font-family:lucida grande, tahoma, verdana, arial, sans-serif; font-size:12px;'><img src='./images/loadinfo.net.gif'></p>");
		}
		if(httpObj.readyState==4){
			strContent=httpObj.responseText;
			//alert(strContent);
			if(strContent=='--1--'|| strContent=='--2--'||strContent=='--3--'|| strContent=='--4--'|| strContent=='--5--' || strContent=='--6--' || strContent=='--7--'){
				document.getElementById('ValidationDiv').innerHTML = parseHTML('');
				document.getElementById('ValidationDiv').style.display = 'none';
				document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; color:#000000; margin-bottom:0px; color:#1e56a1; font-weight:bold;"> <img src="./images/itsfree.gif" /></p>');
				document.getElementById('form').style.display = 'block';	
				
					if(strContent=='--1--'){
						ShowCross('username');
						DisplayError('UserName is already registered.');
					}
					if(strContent=='--2--'){
						ShowCross('username');
						DisplayError('UserName is blocked.');
					}
					if(strContent=='--3--'){
						ShowCross('email');
						DisplayError('Email is already registered.');
					}
					if(strContent=='--4--'){
						ShowCross('email');
						DisplayError('YouMint email Id cannot be registered.');
					}
					if(strContent=='--5--'){
						ShowCross('mobile');
						DisplayError('Mobile is already registered with us.');
					}
					if(strContent=='--6--'){
						ShowCross('mobile');
						DisplayError('Mobile is blocked.');
					}
					if(strContent=='--7--'){
						ShowCross('user_verify');
						DisplayError('Verification Code is wrong.');
					}
			}else{
				document.getElementById('ValidationDiv').style.display = 'none';
				document.getElementById('RishiRajNigam').innerHTML = parseHTML(strContent);
				
				/* New Code */
				
				document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Confirm Mobile</p>');
				document.getElementById('form1').style.display = 'block';
				document.getElementById('RishiRajNigam').style.display = 'block';
				//timer = setTimeout(function(){ShowTimerDivNew()},15000);
				
				/* End of New Code */

				/*document.getElementById('form1').style.display = 'block';
				document.getElementById('ShowTimerDiv').style.display = 'block';
				timer = setTimeout(function(){ShowTimerDiv()},5000);*/
			}
		}
	}
	httpObj.send(null);
	//return false;
}

/* New Code */
function ShowTimerDivNew(){
	document.getElementById('FirstTimeVerificationCode').style.display = 'block';
}
/* New Code */

/*function ShowTimerDiv(){
	document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Enter the Code</p>');
	document.getElementById('ShowTimerDiv').style.display = 'none';
	document.getElementById('RishiRajNigam').style.display = 'block';
	document.getElementById('FirstTimeVerificationCode').style.display = 'block';
}

function KillLoadingDiv(){
	clearTimeout(timer);
	document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Enter the Code</p>');
	document.getElementById('ShowTimerDiv').style.display = 'none';
	document.getElementById('RishiRajNigam').style.display = 'block';
	document.getElementById('FirstTimeVerificationCode').style.display = 'block';
}*/

function MobileDataBaseValidationSecondStep(name){
	var url = urlpath+"CheckMobileTest.php?mobile="+trim(document.getElementById(name).value);
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==4){
			if(httpObj.responseText == '--1--'){
				ShowCross(name);
				DisplayError('Mobile is already registered. Log-in.');
				SetValue(httpObj.responseText);
			}else if(httpObj.responseText == '--2--'){
				ShowCross(name);
				DisplayError('Mobile is blocked. Contact Support.');
				SetValue(httpObj.responseText);
			}else{
				RemoveCross(name);
				HideError();
				SetValue(0);
			}
		}
	}
	httpObj.send(null);
}

function MobileValidationSecondStep(name){
	var MobileValue = trim(document.getElementById(name).value);
	var value = MobileValidity(MobileValue);
	
	if(MobileValue == ''){
		ShowCross(name);
		return false;
	}else if(value){
		ShowCross(name);
		DisplayError(value);
		return false;
	}else{
		MobileDataBaseValidationSecondStep(name);
		if(document.getElementById("seterror").value=='--1--')	
			return false;
		else if(document.getElementById("seterror").value=='--2--')	
			return false;
	}
	return true;
}

function MobileNumberSame(){
	var OldMobile = document.getElementById('enteredmobile').value;
	var NewMobile = document.getElementById('confirmmobile').value;

	if(OldMobile!=NewMobile){
		DisplayError('Mobile number mismatch.');
		return false;
	}else{
		HideError();
		return true;
	}
}

function CheckUserMobileNo(){
	if(!MobileValidationSecondStep('enteredmobile')) return false;
	else if(!MobileValidationSecondStep('confirmmobile')) return false;
		
	var OldMobile = document.getElementById('enteredmobile').value;
	var NewMobile = document.getElementById('confirmmobile').value;

	var url = urlpath+"SendVerificationCode.php?oldmobile="+OldMobile+"&newmobile="+NewMobile;

	/*document.getElementById('form1').style.display = 'none';
	document.getElementById('ValidationDiv').style.display = 'block';*/

	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==1||httpObj.readyState==2||httpObj.readyState==3){
			document.getElementById('mobilebutton').value='verifying';
			document.getElementById('mobilebutton').disabled = 'true';
			//document.getElementById('ValidationDiv').innerHTML = parseHTML("<p style='text-align:center;padding-top:40px;padding-bottom:40px; font-weight:bold; font-family:lucida grande, tahoma, verdana, arial, sans-serif; font-size:12px;'><img src='./images/loadinfo.net.gif'><br><br>Sending Code to <br>your mobile...</p>");
		}
		if(httpObj.readyState==4){
			var strContent = httpObj.responseText;
			//document.getElementById('ValidationDiv').style.display = 'none';

			if(strContent=='--1--'||strContent=='--4--'||strContent=='--5--'){
				document.getElementById('form1').style.display = 'block';

				document.getElementById('mobilebutton').value='confirm';
				document.getElementById('mobilebutton').disabled = '';

				if(strContent=='--1--'){
					//ShowCross('username');
					DisplayError('Mobile number mismatch.');
				}				
				if(strContent=='--4--'){
					ShowCross('confirmmobile');
					DisplayError('Mobile is already registered.');
				}
				if(strContent=='--5--'){
					ShowCross('confirmmobile');
					DisplayError('Mobile is blocked.');
				}
			}else{
				//document.getElementById('ValidationDiv').style.display = 'none';

				document.getElementById('RishiRajNigam').innerHTML = parseHTML(strContent);
				document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Enter the Code</p>');
				document.getElementById('form1').style.display = 'block';
				document.getElementById('RishiRajNigam').style.display = 'block';
				timer = setTimeout(function(){ShowTimerDivNew()},30000);
			}
		}
	}
	httpObj.send(null);
}

function captureHitEnter(e, func_with_param) {
	var characterCode;

	if(e && e.which){
		e = e
		characterCode = e.which
	}
	else{
		e = event
		characterCode = e.keyCode
	}
	if(characterCode == 13){
		eval(func_with_param);
		return false;
	}
	else{
			return true;
	}
}

function VerificationCodeDataBaseValidation(){
	var url = urlpath+"registration_step2.php?code="+trim(document.getElementById("code").value);
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==4){
			if(httpObj.responseText == '--1--'){
				ShowCross('code');
				DisplayError('Wrong code entered');
				SetValue(httpObj.responseText);	
			}else{
				RemoveCross('code');
				HideError();
				SetValue(0);
			}
		}
	}
	httpObj.send(null);
}

function CodeValidation(){
		var CodeValue = document.getElementById("code").value;
		var value = CodeValidity(CodeValue);
		if(CodeValue == ''){
			ShowCross('code');
			return false;
		}else if(value){
			ShowCross('code');
			DisplayError('Verification code entered seems to be incorrect.');
			return false;
		}else{
			VerificationCodeDataBaseValidation();
			if(document.getElementById("seterror").value=='--1--')	
				return false;
		}
	return true;
}

function CheckCode(){
	if(!CodeValidation()) return false;
	else return true;
	
}

function gotoRegStep3(){
	if(!CheckCode()) return false;
	
	document.getElementById('ValidationDiv').style.display = 'block';
	
	if(document.getElementById('form1').style.display == 'block'){
		document.getElementById('form1').style.display = 'none';
		var formname = 'form1';
	}

	if(document.getElementById('form2').style.display == 'block'){
		document.getElementById('form2').style.display = 'none';
		var formname = 'form2';
	}
	
	//alert(formname);
	var url = urlpath+"VerifyMobileCode.php?code=" + trim(document.getElementById("code").value);
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==1||httpObj.readyState==2||httpObj.readyState==3){
			document.getElementById('ValidationDiv').innerHTML = parseHTML("<p style='text-align:center;margin-top:40px;margin-bottom:40px;'><img src='./images/loadinfo.net.gif'><br><img src='./images/loading.gif'></p>");
		}
		
		if(httpObj.readyState==4){
			var strContent=httpObj.responseText;
			if(httpObj.responseText=='--1--'){
				document.getElementById('ValidationDiv').innerHTML = parseHTML('');
				document.getElementById('ValidationDiv').style.display = 'none';
				document.getElementById(formname).style.display = 'block';
				ShowCross('code');
				DisplayError('Wrong code entered.');
			}else{
				location.href = "RegistrationInvite.php";
			}
		}
	}
	httpObj.send(null);
	//return false;
}

function ResendVerificationCode(mobile,code){
	
	document.getElementById('newerror').style.display = 'none';
	document.getElementById('ValidationDiv').style.display = 'block';
	document.getElementById('form1').style.display = 'none';
	document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Verification in progress</p>');

	var url = urlpath+"ResendVerificationCode.php?mobile="+mobile+"&code="+code;
	
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==1||httpObj.readyState==2||httpObj.readyState==3){
			document.getElementById('ValidationDiv').innerHTML = parseHTML("<p style='text-align:center;padding-top:40px;padding-bottom:40px;font-weight:bold; font-family:lucida grande, tahoma, verdana, arial, sans-serif; font-size:12px;'><img src='./images/loadinfo.net.gif'><br><br>Re-sending Code to<br> your mobile...</p>");
		}
		if(httpObj.readyState==4){
			var strContent=httpObj.responseText;
			document.getElementById('RishiRajNigam1').innerHTML = parseHTML(strContent);
			document.getElementById('ValidationDiv').style.display = 'none';
			
			/* New Code */
			document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Enter the Code</p>');
			document.getElementById('form2').style.display = 'block';
			document.getElementById('RishiRajNigam1').style.display = 'block';
			document.getElementById('ShowVerificationDiv').style.display = 'block';
			timer1 = setTimeout(function(){ShowTimerDivNew1()},30000);
			/* New Code */


			/*document.getElementById('form2').style.display = 'block';
			document.getElementById('ShowTimerDiv1').style.display = 'block';
			document.getElementById('ResendingImage').style.display = 'block';
			document.getElementById('ResendingImage1').style.display = 'block';
			timer1 = setTimeout(function(){ShowTimerDiv1()},5000);*/
		}	
	}
	httpObj.send(null);
}

function ShowTimerDivNew1(){
	document.getElementById('SecondTimeVerificationCode').style.display = 'block';
}

/*function ShowTimerDiv1(){
	document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Enter the Code</p>');
	document.getElementById('ResendingImage').style.display = 'none';
	document.getElementById('RishiRajNigam1').style.display = 'block';
	document.getElementById('SecondTimeVerificationCode').style.display = 'block';
}

function KillLoadingDiv1(){
	clearTimeout(timer1);
	document.getElementById("signinform").innerHTML = parseHTML('<p style="margin:0 auto; margin-bottom:0px; font-weight:bold;font-family:lucida grande, tahoma, verdana, arial, sans-serif;font-size:20px; color:#1e56a1;">Enter the Code</p>');
	document.getElementById('ResendingImage').style.display = 'none';
	document.getElementById('ResendingImage1').style.display = 'none';
	document.getElementById('ShowTimerDiv1').style.display = 'none';
	document.getElementById('RishiRajNigam1').style.display = 'block';
	document.getElementById('ShowVerificationDiv').style.display = 'block';
	document.getElementById('SecondTimeVerificationCode').style.display = 'block';
}*/

function LoadNextStep(){
	var url = "RegistrationInvite.php";
	window.location = url;
}

function RedirectRegistration(){
	location.href = "registrationstep4.php";
	return false;
}

function RemoveValue(name){
	if(name=='user_name2' && document.getElementById(name).value=='username')
		document.getElementById(name).value = '';
	if(name=='user_pass2' && document.getElementById(name).value=='password')
		document.getElementById(name).value = '';
}

function getInputLogin(name){
	if(trim(document.getElementById(name).value) == ''){
		document.getElementById(name).style.border = "1px solid #d12f19";
		document.getElementById(name).style.background = "#f7cbc2";
		return false;
	}
	if(document.getElementById(name).value != ''){
		document.getElementById(name).style.border = "1px solid #a1a1a1";
		document.getElementById(name).style.background = "#fff";
		return true;
	}
}

function Login(){
	if(!getInputLogin('user_name2')) return false;
	else if(!getInputLogin('user_pass2')) return false;

	var name = document.getElementById("user_name2").value;
	var pass = document.getElementById("user_pass2").value;
	var agreement = document.getElementById("agreement2").checked;
	
	var url =  urlpath+"LoginVerification.php?name="+name+"&pass="+pass+"&agreement="+agreement;
	
	document.getElementById('loginbutton').value='Signing In...';
	document.getElementById('loginbutton').disabled = 'true';

	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==1||httpObj.readyState==2||httpObj.readyState==3){
			document.getElementById('loginbutton').value = 'Signing In...';
			document.getElementById('loginbutton').disabled = 'true';
		}
		if(httpObj.readyState==4){
			var strContent = httpObj.responseText;
			if(strContent==1){
				document.getElementById('loginbutton').value='Login';
				document.getElementById('loginbutton').disabled = '';
				//DisplayError1('Username or Password is not correct!','userloginerror');
				location.href=urlpath+"LoginError.html";
			}else{
				location.href=urlpath+"Profile.html";
				//location.href=urlpath+"Invite.html";
			}
		}
	};
	httpObj.send(null);
	return false;
}

function CheckForgotPasswordUserName(){
	if(!getInputLogin('user_name1')) return false;
	else return true;
}

function CheckForgotPasswordMobile(){
	var MobileValue = trim(document.getElementById('mobile1').value);
	var value = MobileValidity(MobileValue);
	
	if(MobileValue == ''){
		ShowCross('mobile1');
		return false;
	}else if(value){
		ShowCross('mobile1');
		DisplayError1(value,'forgotpassworderror');
		return false;
	}else{
		RemoveCross('mobile1');
		HideError1('forgotpassworderror');
		return true;
	}
}

function ForgotPasswordRegistration(){
	if(!CheckForgotPasswordUserName()) return false;
	else if(!CheckForgotPasswordMobile()) return false;
	
	var username = document.getElementById("user_name1").value;
	var mobile = document.getElementById("mobile1").value;
	var url = urlpath+"ForgotPassword.php?username="+username+"&mobile="+mobile;
	httpObj.open("POST",url,true);
	
	document.getElementById("ForgotPaswordFormDiv").style.display = "none";

	httpObj.onreadystatechange = function(){
		if(httpObj.readyState==1||httpObj.readyState==2||httpObj.readyState==3){
			document.getElementById("ForgotPaswordLoadingDiv").style.display = "block";
		}
		if(httpObj.readyState==4){
			document.getElementById("ForgotPaswordLoadingDiv").style.display = "none";
			if(httpObj.responseText=='--No--'){
				document.getElementById("ForgotPaswordFormDiv").style.display = "block";
				document.getElementById("user_name1").value = username;
				document.getElementById("mobile1").value = mobile;
				DisplayError1('Information provided is not correct!','forgotpassworderror');
				return false;
			}else{
				document.getElementById("ForgotPaswordFormDiv").style.display = "block";
				document.getElementById("ForgotPaswordFormDiv").innerHTML = parseHTML('<p style=" align:center;margin-top:20px;margin-bottom:20px;  font-size:11px;">Your password has been sent to your email account.</p>');
			}
		}
	}
	httpObj.send(null);
}	

function HideOverDiv(type){
	
	document.getElementById('NetworkAlertDiv').style.display = 'none';
	document.getElementById('mask_div').style.visibility = 'hidden';
	document.getElementById('city').disabled = '';
	document.getElementById('day').disabled = '';
	document.getElementById('month').disabled = '';
	document.getElementById('year').disabled = '';
	document.getElementById('gender').disabled = '';
	document.getElementById('maritalstatus').disabled = '';
	if(type =='click'){
		document.getElementById('f_name').focus();
	}
	var url = urlpath+"OverlayClick.php?type=" + type;
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
	
	}
	httpObj.send(null);
}