/************ for ajax form validation ends here ***********/
//var siteurl = "http://inforg18/socialpulse/";
var siteurl = "http://www.thesocialpulse.com/";

function fnloginvalidate(){

document.getElementById("somediv").innerHTML ='<div><table border="0" cellpadding="0" cellspacing="0" width="100%" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';


xmlHttpIsLogins=RemoteRequestObject();

if (xmlHttpIsLogins==null)
 {
	 alert ("Browser does not support HTTP Request")
	 return
 }
	 var regtype =""
		 if(document.getElementById("regtype")!=null) {
		regtype = document.getElementById("regtype").value

	 }

//alert(regtype);
var url=siteurl+"chklogin.php?username="+document.getElementById("username").value+"&psw="+document.getElementById("psw").value+"&regtype="+regtype+"&rand="+Math.random();
alert(url)
//alert(xmlHttpVenues.onreadystatechange);
xmlHttpIsLogins.onreadystatechange=stateChangedLogins
xmlHttpIsLogins.open("GET",url,true)
xmlHttpIsLogins.send(null);


}
function stateChangedLogins()
{


	if (xmlHttpIsLogins.readyState==4 || xmlHttpIsLogins.readyState=="complete")
		{

			var t= xmlHttpIsLogins.responseText
			var arr = Array();
			arr = t.split("|");
            alert(xmlHttpIsLogins.responseText);
				if(arr[0]=="wrong") {
					document.getElementById("resultform").innerHTML = "";
					document.getElementById("resultform").innerHTML = arr[1];
				} else {
					fnClose();

					if((arr[2] == "inline") && (arr[1] =="aboutsm")) {
						dhtmlaboutsm();
						//alert(arr[1])
					} else if((arr[2] == "inline") && (arr[1] =="leavecomments")) {
						dhtmleventcomment()
						//alert(arr[2])
					} else if((arr[2] == "inline") && (arr[1] =="rsvp") ){
						dhtmleventrsvp();
					} else if((arr[2] == "inline") && (arr[1] =="guestlist") ){
						dhtmleventguestlist();
					} else if((arr[2] == "inline") && (arr[1] =="addcomment") ){
						dhtmlpublicaddcomment();
					} else if((arr[2] == "inline") && (arr[1] =="addfriend") ){
						dhtmlpublicaddtofriend();
					}else if((arr[2] == "inline") && (arr[1] =="addpost") ){
						dhtmlpublicpost();
					}
					else if((arr[2] == "inline") && (arr[1] =="addpostcomment") ){
						
						dhtmlpublicpostcomment();
					}
					else if((arr[2] == "inline") && (arr[1] =="addfriendpopup") ){
						//alert("asdas")
						dhtmladdfriendpopup();
					}
					
					else if((arr[2] == "inline") && (arr[1] =="sendmsg") ){
						dhtmlpublicsendmessage(1);
					} else if((arr[2] == "inline") && (arr[1] =="rating") ){
						dhtmlrating();
					} else if((arr[2] == "inline") && (arr[1] =="reviews") ){
						dhtmlreview();
					} else if((arr[2] == "inline") && (arr[1] =="booktalent") ){
						dhtmlbooktalent();
					} else if((arr[2] == "function") && (arr[1] =="talentprofile") ){
						submitRating();
					} else if(arr[2] == "new") {
						window.location.href=arr[1];
					}
					
					
				}
			//document.getElementById("somediv").innerHTML="<div id='somediv_val' >"+xmlHttpdhtmllogin.responseText+"</div>"			
			//divwin=dhtmlmodal.open('agebox', 'div', 'somediv', 'Login', 'width=350px,height=150px,center=1,resize=0,scrolling=0'); 
			//fnloginvalidate();
	} 
}



/************ for ajax form validation ends here ***********/


function fnIsUserLogin(){
	
	
//alert(parent.document.getElementById("regtype").value)
//document.getElementById("inline_txt").innerHTML ='<div><table border="0" cellpadding="0" cellspacing="0" width="100%" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';

xmlHttpIsLogin=RemoteRequestObject();

if (xmlHttpIsLogin==null)
 {
	 alert ("Browser does not support HTTP Request")
	 return
 } 

	 
	
	 if((document.getElementById("regtype")!=null) && ((document.getElementById("regtype").value=='photogallery') || (document.getElementById("regtype").value=='blog') || (document.getElementById("regtype").value=='video-sharing') || (document.getElementById("regtype").value=='video-upload'))) {
		
		var url=siteurl+ "isuserlogin.php?rand="+Math.random(); 
				
	  } else {
		 
		 var url=siteurl+"isuserlogin.php?rand="+Math.random(); 
	  }


//alert(url)
//alert(xmlHttpVenues.onreadystatechange);
xmlHttpIsLogin.onreadystatechange=stateChangedLogin
xmlHttpIsLogin.open("GET",url,true)
xmlHttpIsLogin.send(null);


}



function stateChangedLogin() 
{ 
	//alert(xmlHttpIsLogin.responseText)
	
	if (xmlHttpIsLogin.readyState==4 || xmlHttpIsLogin.readyState=="complete")
	{	
		//alert(xmlHttpIsLogin.responseText)
				
		if(xmlHttpIsLogin.responseText== "false"){

			
		    
			dhtmlogin();

			
		}
		else {
			var regtype="";
				//alert()
				if(parent.document.getElementById("regtype")!=null){
					regtype = parent.document.getElementById("regtype").value
					if(regtype == "addfriendpopup") {
					//alert("asdas")
					dhtmladdfriendpopup();
				}
				}
				
				if(document.getElementById("regtype")!=null) {
					regtype = document.getElementById("regtype").value
					
				
				if(regtype =="aboutsm") {
					dhtmlaboutsm();
				} else if(regtype =="leavecomments") {
					dhtmleventcomment();
				} else if(regtype =="Venues") {
					 window.location.href="venueregistration.php"
				}else if(regtype =="business") {
					 window.location.href="businessregistration.php"
				} else if(regtype =="Events") {
					 window.location.href="eventregistration.php"
				} else if(regtype =="Model") {
					 //window.location.href="talent_regstep1.html"
					 window.location.href="modelregistration_step2.html"
				} else if(regtype =="Photographer") {
					 //window.location.href="talent_regstep1.html"
					 window.location.href="photographerregistration_step2.html"
				}else if(regtype =="talentregister") {
					 //window.location.href="talent_regstep1.html"
					 window.location.href="talentregistration.html"
				} else if(regtype =="Music") {
					 //window.location.href="talent_regstep1.html"
					 window.location.href="musicregistration_step2.html"
				} else if(regtype =="rsvp") {
					 dhtmleventrsvp();
				} else if(regtype =="guestlist") {
					 dhtmleventguestlist();
				}else if(regtype =="addcomment") {
					 dhtmlpublicaddcomment();
				} else if(regtype =="addfriend") {
					dhtmlpublicaddtofriend();
				}
				else if(regtype =="addpost") {
					dhtmlpublicpost();
				}else if(regtype =="addpostcomment") {
					dhtmlpublicpostcomment();
				}
				
				else if(regtype =="sendmsg") {
					dhtmlpublicsendmessage();
				}else if(regtype =="rating") {
					dhtmlrating();
				}
				else if(regtype =="reviews") {
					dhtmlreview();
				} 
				else if(regtype =="talentprofile") {
					submitRating();
				} else if(regtype =="booktalent") {
					dhtmlbooktalent();
				}
			} 
		}
		
	} 
}

function dhtmlogin()
{ 
	if(parent.document.getElementById("regtype") != null){
		regtype1= parent.document.getElementById("regtype").value
			 if(regtype1=='addfriendpopup'){
				window.location.href="popup_login.php?regtype"+regtype1+"&rand="+Math.random()
			}
	}
	
	 if(document.getElementById("regtype")!=null) {
		var regtype = document.getElementById("regtype").value
		var url=siteurl+"popup_login.php"
		url=url+"?regtype="+regtype+"&rand="+Math.random()
		//alert(url)
	 } else {
		 
			 var url=siteurl+"popup_login.php"
			
		url=url+"?rand="+Math.random()
	 }

		
		if((document.getElementById("regtype")!=null) && ((document.getElementById("regtype").value=="photogallery") || (document.getElementById("regtype").value=="video-upload") || (document.getElementById("regtype").value=="video-sharing") || (document.getElementById("regtype").value=="blog"))) {
			var url= siteurl+"popup_login.php"
		url=url+"?regtype="+regtype+"&rand="+Math.random()
		}



			divwin=dhtmlmodal.open('agebox', 'iframe', url, 'Login', 'width=550px,height=250px,center=1,resize=0,scrolling=1');
}

			//fnloginvalidate();

function fnCloseLogin(){
	dhtmlmodal.close(document.getElementById("agebox"))
	window.location.href="register.html"
}

function fnClose(){
	//alert("something")
	dhtmlmodal.close(document.getElementById("agebox"))

}






/*************** forgot email address starts here **************/

var xmlHttpdhtmlretpassword
function fndhtmretpassword()
{ 
	xmlHttpdhtmlretpassword=RemoteRequestObject()
	if (xmlHttpdhtmlretpassword==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 } 
	
	    var url=siteurl+"forgotpassword.php"
			
		url=url+"?rand="+Math.random()
	 
		xmlHttpdhtmlretpassword.onreadystatechange=stateChangedhtmlretpassword 
		xmlHttpdhtmlretpassword.open("GET",url,true)
		xmlHttpdhtmlretpassword.send(null)
	
}

function stateChangedhtmlretpassword() 
{ 
	if (xmlHttpdhtmlretpassword.readyState==4 || xmlHttpdhtmlretpassword.readyState=="complete")
	{
		document.getElementById("somediv").style.display="";
		document.getElementById("somediv").innerHTML="";
		
			document.getElementById("somediv").innerHTML="<div id='somediv_val' >"+xmlHttpdhtmlretpassword.responseText+"</div>"			
			divwin=dhtmlmodal.open('agebox', 'span', 'somediv', 'Retrieve Password', 'width=450px,height=200px,center=1,resize=0,scrolling=0'); 
	} 
}

/*************** forgot email address ends here **************/


/************ for ajax forgot password validation starts here ***********/

function fnretpassvalidate(){

document.getElementById("somediv").innerHTML ='<div><table border="0" cellpadding="0" cellspacing="0" width="100%" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';

	
xmlHttpretpassvalidate=RemoteRequestObject();

if (xmlHttpretpassvalidate==null)
 {
	 alert ("Browser does not support HTTP Request")
	 return
 } 
	 
		var url=siteurl+"submitforgotpassword.php?femail="+document.getElementById("femail").value+"&rand="+Math.random(); 
	
//alert(url)
//alert(xmlHttpVenues.onreadystatechange);
xmlHttpretpassvalidate.onreadystatechange=stateChangedPasswords
xmlHttpretpassvalidate.open("GET",url,true)
xmlHttpretpassvalidate.send(null);

		
}
function stateChangedPasswords() 
{ 
	if (xmlHttpretpassvalidate.readyState==4 || xmlHttpretpassvalidate.readyState=="complete")
		{	
			
			var t= xmlHttpretpassvalidate.responseText
			var err_msg = "";
				//alert(t)
					
					if(t =='2') {
						err_msg ='Invalid Email address, Please enter correct Email'
					} else if(t =='1') {
						err_msg ='Your username and password has been sent to your email address.'
					} else {
						err_msg ='Enter email address'
					}
					document.getElementById("error_password").innerHTML="";
					document.getElementById("error_password").innerHTML = err_msg;
				
			
	} 
}

/************ for ajax forgot password validation ends here ***********/
