var httpObj10 = false;
		try {
			  httpObj10 = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj10 = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj10 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj10 = false;
			}
	  }
	}

var httpObj11 = false;
		try {
			  httpObj11 = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj11 = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj11 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj11 = false;
			}
	  }
	}

var httpObj12 = false;
		try {
			  httpObj12 = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj12 = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj12 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj12 = false;
			}
	  }
	}

var httpObj13 = false;
		try {
			  httpObj13 = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj13 = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj13 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj13 = false;
			}
	  }
	}

var httpObj14 = false;
		try {
			  httpObj14 = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj14 = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj14 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj14 = false;
			}
	  }
	}

var httpObj15 = false;
		try {
			  httpObj15 = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj15 = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj15 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj15 = false;
			}
	  }
	}

var httpObj16 = false;
		try {
			  httpObj16 = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj16 = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj16 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj16 = false;
			}
	  }
	}

function ChangingClassName(selflink){
	HideIndexLoginError('','IndexLoginError');
	document.getElementById('ym_link').className='';
	//document.getElementById('fb_link').className='';
	document.getElementById('gm_link').className='';
	document.getElementById('yh_link').className='';
	document.getElementById('aol_link').className='';
	document.getElementById('rm_link').className='';
	document.getElementById('it_link').className='';
	document.getElementById('hm_link').className='';
	selflink.className='selected';
	document.getElementById('gm_div').style.display='none';
}


function OpenLoginDiv(linkdiv,gmdiv,maildiv,msgdiv,typediv){

	var linkdiv;
	var gmdiv;
	var maildiv;
	var msgdiv;
	var typediv;

	document.getElementById('ReportBug1').style.display = 'block';
	document.getElementById('mask_div').style.visibility = 'visible';

	
	document.getElementById('ym_link').className='';
	//document.getElementById('fb_link').className='';
	document.getElementById('gm_link').className='';
	document.getElementById('yh_link').className='';
	document.getElementById('aol_link').className='';
	document.getElementById('rm_link').className='';
	document.getElementById('it_link').className='';
	document.getElementById('hm_link').className='';
	document.getElementById(linkdiv).className='selected';

	if(typediv=='YM'){		
		document.getElementById('gm_div').style.display='none';
		document.getElementById('ym_div').style.display='block';
		document.getElementById('gm_div').style.display='none';
		//document.getElementById('fb_div').style.display='none';
		document.getElementById('ym_message').style.display='block';	
		document.getElementById('tab').style.display='block';
	}else{
		document.getElementById(gmdiv).style.display='block';
		document.getElementById('ym_div').style.display='none';
		//document.getElementById('fb_div').style.display='none';
		document.getElementById('fqdn_new').value=maildiv;
		//document.getElementById('email_fqdn').value='@'+maildiv;
		document.getElementById('gmail_message').style.display='none';
		document.getElementById('yahoo_message').style.display='none';
		document.getElementById('aol_message').style.display='none';
		document.getElementById('rediff_message').style.display='none';
		document.getElementById('indiatime_message').style.display='none';
		document.getElementById('hotmail_message').style.display='none';
		document.getElementById(msgdiv).style.display='block';	
		document.getElementById('tab').style.display='block';

	}

	HideIndexLoginError('','IndexLoginError');

}

function CloseLoginDiv(divname){
	document.getElementById(divname).style.display = 'none';
	document.getElementById('mask_div').style.visibility = 'hidden';
	document.getElementById('email_pre').value = '';
	document.getElementById('email_pass').value = '';
}

function CheckIndexLoginError(ErrorDivName){
	
	if(document.getElementById(ErrorDivName).style.display == 'block')
		return true;
	else
		return false;
	
}

function DisplayIndexLoginError(Message,ErrorDivName){
	document.getElementById(ErrorDivName).style.display = 'block';
	document.getElementById(ErrorDivName).innerHTML = Message;
}

function HideIndexLoginError(Message,ErrorDivName){
	document.getElementById(ErrorDivName).value = '';
	document.getElementById(ErrorDivName).style.display = 'none';
}

function DisplayIndexLoginLoadingDiv(LoadingDivName,MainDivName){
	document.getElementById(MainDivName).style.display = 'none';
	HideIndexLoginError('','IndexLoginError');
	document.getElementById(LoadingDivName).style.display = 'block';
}

function HideIndexLoginLoadingDiv(LoadingDivName,MainDivName){
	document.getElementById(LoadingDivName).style.display = 'none';
	document.getElementById(MainDivName).style.display = 'block';	
}



function opentab(selflink,div_name){
	ChangingClassName(selflink);
	document.getElementById(div_name).style.display='block';
}

function opentab_fqdn(selflink,div_name,fqdn,mess_div){
	ChangingClassName(selflink);
	document.getElementById('gm_loading_div').style.display='none';
	document.getElementById(div_name).style.display='block';
	document.getElementById('ym_div').style.display='none';
	//document.getElementById('fb_div').style.display='none';
	document.getElementById('fqdn_new').value=fqdn;
	//document.getElementById('email_fqdn').value='@'+fqdn;
	document.getElementById('gmail_message').style.display='none';
	document.getElementById('yahoo_message').style.display='none';
	document.getElementById('aol_message').style.display='none';
	document.getElementById('rediff_message').style.display='none';
	document.getElementById('indiatime_message').style.display='none';
	document.getElementById('hotmail_message').style.display='none';
	document.getElementById(mess_div).style.display='block';	
	document.getElementById('tab').style.display='block';
	document.getElementById('email_pre').value = '';
	document.getElementById('email_pass').value = '';
}

function opentab_ym(selflink,div_name,fqdn,mess_div){
	ChangingClassName(selflink);
	document.getElementById('ym_div').style.display='block';
	document.getElementById('gm_div').style.display='none';
	//document.getElementById('fb_div').style.display='none';
	document.getElementById('ym_message').style.display='block';	
	document.getElementById('tab').style.display='block';
	document.getElementById('user_pass2').value = '';
}

function opentab_fb(selflink,div_name,fqdn,mess_div){
	ChangingClassName(selflink);
	document.getElementById('ym_div').style.display='none';
	document.getElementById('gm_div').style.display='none';
	//document.getElementById('fb_div').style.display='block';
	//document.getElementById('fb_message').style.display='block';	
	document.getElementById('tab').style.display='block';
}

function FetchAddressBook(tab){
	if(!tab) tab = 'invite_home';
	var EmailUserName = document.getElementById("email_pre").value;
	var EmailDomain = document.getElementById("fqdn_new").value;
	

	if(document.getElementById("email_pre").value=='' || document.getElementById("email_pass").value==''){
		DisplayIndexLoginError('Please enter your Email / Password.','IndexLoginError');
		return false;
	}else{
		var SplitResult = EmailUserName.split("@");
		var EmailUserName = SplitResult[0];
		var Email = EmailUserName+'@'+EmailDomain;

		var url = urlpath+"LoadLoginForm.php?action=fetch_addressbook&email_pre="+EmailUserName+"&email_pass="+document.getElementById("email_pass").value+"&fqdn="+EmailDomain+"&tab="+tab;
		httpObj10.open("POST",url,true);
		httpObj10.onreadystatechange = function(){
			if(httpObj10.readyState==1||httpObj10.readyState==2||httpObj10.readyState==3){
				DisplayIndexLoginLoadingDiv('gm_loading_div','gm_div');
			}
			if(httpObj10.readyState==4){
				if(httpObj10.responseText=='--BadUserNamePassword--'){
					HideIndexLoginLoadingDiv('gm_loading_div','gm_div');
					DisplayIndexLoginError('Incorrect UserName / Password.','IndexLoginError');
				}else if(httpObj10.responseText=='--ServerError--'){
					HideIndexLoginLoadingDiv('gm_loading_div','gm_div');
					DisplayIndexLoginError('Server Error.','IndexLoginError');
				}else if(httpObj10.responseText=='--UnsupportedWebmail--'){
					HideIndexLoginLoadingDiv('gm_loading_div','gm_div');
					DisplayIndexLoginError('Unsupported Webmail.','IndexLoginError');
				}else if(httpObj10.responseText=='--True--'){
					if(CheckIndexLoginError('IndexLoginError'))
						HideIndexLoginError('','IndexLoginError');
					CheckEmailLogin(Email);
				}
			}
		}
		httpObj10.send(null);
	}
}

function CheckEmailLogin(YouMintEmail){
	var url = urlpath+"CheckUserAuthentication.php?YouMintEmail="+YouMintEmail;
	httpObj11.open("POST",url,true);
	httpObj11.onreadystatechange = function(){
		if(httpObj11.readyState==4){
			
			strcontent = httpObj11.responseText;
			var SplitResult = strcontent.split("--");
			var Position = SplitResult[2].indexOf("@");
			if(Position != -1){
				HideIndexLoginLoadingDiv('ReportBug1','ReportBug2');
				DisplayIndexLoginLoadingDiv('ym_div','gm_loading_div');
				ChangingClassName('ym_link');
				DisplayIndexLoginLoadingDiv('singlesignon_form','confirmationemail');
				document.getElementById('singlesignon_email').value = SplitResult[2];
				document.getElementById('singlesignon_username').value = SplitResult[3];
			}else{
				
				if(httpObj11.responseText=='--notverified--'){
					HideIndexLoginLoadingDiv('gm_loading_div','gm_div');
					DisplayIndexLoginError('Please verify yourself.','IndexLoginError');
				}else if(httpObj11.responseText=='--notauthenticated--'){
					HideIndexLoginLoadingDiv('gm_loading_div','gm_div');
					DisplayIndexLoginError('You are not authenticated.','IndexLoginError');
				}else if(httpObj11.responseText=='--directloginuser--'){
					//window.location.href=urlpath+"FreeSms.html";
					window.location.href=urlpath+"Profile.html";
					//window.location.href=urlpath+"Invite.html";
				}else if(httpObj11.responseText=='--freesmsredirect--'){
					window.location.href="http://www.youmint.com/freesms/";  
				}else if(httpObj11.responseText=='--eventsmsredirect--'){
					window.location.href=urlpath+"eventsmstemplates.php"; 
				}else if(httpObj11.responseText=='--confirmemail--'){
					if(CheckIndexLoginError('IndexLoginError'))
						HideIndexLoginError('','IndexLoginError');
					OpenEmailVerification(YouMintEmail);
				}else if(httpObj11.responseText=='--unsubscribeuser--'){
					window.location.href=urlpath+"ProfileSettings.php?unsub=yes"; 
			   	}	
			}
		}
	}
	httpObj11.send(null);
}

function OpenEmailVerification(YouMintEmail){
	var url = urlpath+"GetUserName.php?YouMintEmail="+YouMintEmail;
	httpObj12.open("POST",url,true);
	httpObj12.onreadystatechange = function(){
		if(httpObj12.readyState==4){
			if(httpObj12.responseText=='--notverified--'){
				DisplayIndexLoginError('Please verify yourself.','IndexLoginError');
			}else if(httpObj12.responseText=='--notauthenticated--'){
				DisplayIndexLoginError('You are not authenticated.','IndexLoginError');
			}else{
				if(CheckIndexLoginError('IndexLoginError'))
					HideIndexLoginError('','IndexLoginError');
				document.getElementById('confirmationemail').innerHTML = httpObj12.responseText;
				HideIndexLoginLoadingDiv('ReportBug1','ReportBug3');
				DisplayIndexLoginLoadingDiv('confirmationemail','userinformation');
				document.getElementById('gm_loading_div').style.display = 'none';
			}
		}
	}
	httpObj12.send(null);
}

function LoginOnClick(UserName){ 
	var url = urlpath+"LoginUsingUserName.php?YouMintUserName="+UserName;
	httpObj13.open("POST",url,true);
	httpObj13.onreadystatechange = function(){
		if(httpObj13.readyState==4){
			if(httpObj13.responseText=='--notverified--'){
				DisplayIndexLoginError('Please verify yourself.','IndexLoginError3');
			}else if(httpObj13.responseText=='--notauthenticated--'){
				DisplayIndexLoginError('You are not authenticated.','IndexLoginError3');
			}else if(httpObj13.responseText=='--directloginuser--'){
				//window.location.href=urlpath+"FreeSms.html";
				window.location.href=urlpath+"Profile.html";
				//window.location.href=urlpath+"Invite.html";
			}else if(httpObj13.responseText=='--freesmsredirect--'){
				window.location.href="http://www.youmint.com/freesms/";
			}else if(httpObj11.responseText=='--eventsmsredirect--'){
				window.location.href=urlpath+"eventsmstemplates.php"; 
			}else if(httpObj11.responseText=='--unsubscribeuser--'){
				window.location.href=urlpath+"ProfileSettings.php?unsub=yes"; 
			}
		}
	}
	httpObj13.send(null);
}

function OpenRegistrationPage(YouMintEmail){
	var url = urlpath+"UserInformation.php?YouMintEmail="+YouMintEmail;
	httpObj14.open("POST",url,true);
	httpObj14.onreadystatechange = function(){
		if(httpObj14.readyState==4){
			if(httpObj14.responseText=='--notverified--'){
				DisplayIndexLoginError('Please verify yourself.','IndexLoginError3');
			}else if(httpObj14.responseText=='--notauthenticated--'){
				DisplayIndexLoginError('You are not authenticated.','IndexLoginError3');
			}else{
				document.getElementById('userinformation').innerHTML = httpObj14.responseText;
				HideIndexLoginLoadingDiv('ReportBug1','ReportBug3');
				DisplayIndexLoginLoadingDiv('userinformation','confirmationemail');
				if(CheckIndexLoginError('IndexLoginError3'))
					HideIndexLoginError('','IndexLoginError3');
			}
		}
	}
	httpObj14.send(null);
}

function GetForgotPassword(YouMintEmail){
	var url = urlpath+"SingleSignOnForgotPassword.php?YouMintEmail="+YouMintEmail;
	httpObj15.open("POST",url,true);
	httpObj15.onreadystatechange = function(){
		if(httpObj15.readyState==4){
			if(httpObj15.responseText=='--notverified--'){
				DisplayIndexLoginError('Please verify yourself.','IndexLoginError3');
			}else if(httpObj15.responseText=='--notauthenticated--'){
				DisplayIndexLoginError('You are not authenticated.','IndexLoginError3');
			}else{
				document.getElementById('userinformation').innerHTML = httpObj15.responseText;
				HideIndexLoginLoadingDiv('ReportBug1','ReportBug3');
				DisplayIndexLoginLoadingDiv('userinformation','confirmationemail');
				if(CheckIndexLoginError('IndexLoginError3'))
					HideIndexLoginError('','IndexLoginError3');
			}
		}
	}
	httpObj15.send(null);
}

function SendForgotPassword(){
	var YouMintEmail = document.getElementById('forgotemail').value;
	var url = urlpath+"SendSingleSignOnForgotPassword.php?YouMintEmail="+YouMintEmail;
	httpObj16.open("POST",url,true);
	httpObj16.onreadystatechange = function(){
		if(httpObj16.readyState==4){
			if(httpObj16.responseText=='--notverified--'){
				DisplayIndexLoginError('Please verify yourself.','IndexLoginError3');
			}else if(httpObj16.responseText=='--notauthenticated--'){
				DisplayIndexLoginError('You are not authenticated.','IndexLoginError3');
			}else{
				document.getElementById('userinformation').innerHTML = '<p style="align:center;margin:20px 10px 20px 0px;font-family: Arial,Helvetica,sans-serif; font-size:12px;">Your password has been sent to your email account.<br><a href="javascript:void(0);" onclick="javascript:OpenYoumintLoginDiv();">Click</a> here to login. </p>';
				HideIndexLoginLoadingDiv('ReportBug1','ReportBug3');
				DisplayIndexLoginLoadingDiv('userinformation','confirmationemail');	
				if(CheckIndexLoginError('IndexLoginError3'))
					HideIndexLoginError('','IndexLoginError3');
			}
		}
	}
	httpObj16.send(null);
}

function OpenYoumintLoginDiv(){
	HideIndexLoginLoadingDiv('ReportBug3','ReportBug1');
	document.getElementById('ym_link').className='selected';
	document.getElementById('gm_link').className='';
	document.getElementById('yh_link').className='';
	document.getElementById('aol_link').className='';
	document.getElementById('rm_link').className='';
	document.getElementById('it_link').className='';
	document.getElementById('hm_link').className='';
	document.getElementById('ym_div').style.display='block';
	document.getElementById('gm_div').style.display='none';
	document.getElementById('gm_loading_div').style.display='none';
	//document.getElementById('fb_div').style.display='none';
	document.getElementById('ym_message').style.display='block';	
	document.getElementById('tab').style.display='block';
}

function YouMintLogin(){
	if(!getInputLogin('user_name2')) return false;
	else if(!getInputLogin('user_pass2')) return false;
	else if(LoginUserNameValidity(trim(document.getElementById('user_name2').value))){
		window.location.href=urlpath+"LoginError.html";
		return false;
	}

	var name = document.getElementById("user_name2").value;
	var pass = document.getElementById("user_pass2").value;
	var rememberme = document.getElementById("rememberme").checked;
	
	//var url =  urlpath+"LoginVerification.php?name="+name+"&pass="+pass+"&agreement=true";
	var url =  urlpath+"LoginVerification.php?name="+name+"&pass="+pass+"&agreement=true&checkvalue="+rememberme;
	httpObj10.open("POST",url,true);
	httpObj10.onreadystatechange = function(){
		if(httpObj10.readyState==1||httpObj10.readyState==2||httpObj10.readyState==3){
			DisplayIndexLoginLoadingDiv('gm_loading_div','ym_div');
		}
		if(httpObj10.readyState==4){
			var strContent = httpObj10.responseText;
			if(strContent==1){
				HideIndexLoginLoadingDiv('gm_loading_div','ym_div');
				DisplayIndexLoginError('Incorrect UserName / Password.','IndexLoginError');
				//location.href=urlpath+"LoginError.html";
			}else if(strContent=='--2--'){
				location.href=urlpath+"Occasion_Invite.php";
			}else if(strContent=='--3--'){
				window.location.href=urlpath+"FreeSms.html";
			}else if(strContent=='--6--'){
				window.location.href="http://www.youmint.com/freesms/";	
			}else if(strContent=='--7--'){
				window.location.href=urlpath+"eventsmstemplates.php";	
			}else if(strContent=='--8--'){
				window.location.href=urlpath+"ProfileSettings.php?unsub=yes";	
			}else{
				//window.location.href=urlpath+"FreeSms.html";
				window.location.href=urlpath+"Profile.html";
				//window.location.href=urlpath+"Invite.html";
			}
		}
	};
	httpObj10.send(null);
	return false;
}

/*function OpenSingleSignOnRegistration(){
	HideIndexLoginLoadingDiv('ReportBug1','ReportBug2');
	//DisplayIndexLoginLoadingDiv('ym_div','gm_loading_div');
	//ChangingClassName('ym_link');
	DisplayIndexLoginLoadingDiv('singlesignon_form','confirmationemail');
	
	
	document.getElementById('regist').innerHTML ="<b>REGISTER</b>";
	document.getElementById('registmsg').innerHTML = "<br><b>IT'S FREE AND ANYONE CAN JOIN</b><br>";
	
}*/
