var xmlHttp

function chkuser(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	if(!str== '')
	{
		var url="chkuser.php?step=1&username="+str
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function stateChanged() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	response = xmlHttp.responseText			
	if(response == "True")
	{
		document.getElementById("chkuserid").innerHTML="<font color=#FF0000>This username already exists, choose another</font>" 
		document.frm.flg.value = "False";	
		//alert(document.getElementById("chkuserid").innerHTML)			
	}
	else
	{		
		document.getElementById("chkuserid").innerHTML="";
		document.frm.flg.value = "True";	
	}		
 } 
}

function chkEmail(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="chkuser.php?step=2&email="+str
	if(str!='')
	{
		xmlHttp.onreadystatechange=stateEmailChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function stateEmailChanged() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	response = xmlHttp.responseText			
	if(response == "True")
	{
		document.getElementById("chkEmailid").innerHTML="";
		document.frm.flg.value = "True";				
	}
	else
	{		
		document.getElementById("chkEmailid").innerHTML="<font color=#FF0000>Please entert a valid email address</font>" 
		document.frm.flg.value = "False";
	}		
 } 
}


function chkOldPass(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	if(!str== '')
	{
		var url="chkuser.php?step=3&password="+str
		xmlHttp.onreadystatechange=stateChgPass 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function stateChgPass() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	response = xmlHttp.responseText	
	if(response == "True")
	{
		document.getElementById("chkPassid").innerHTML="";
		document.frm.flg.value = "True";				
	}
	else
	{		
		document.getElementById("chkPassid").innerHTML="<font color=#FF0000>Invalid old password</font>" 
		document.frm.flg.value = "False";	
	}		
 } 
}

function chkproject(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	if(!str== '')
	{
		var url="chkuser.php?step=4&pname="+str
		xmlHttp.onreadystatechange=stateProject 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function stateProject() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 	{ 
 		response = xmlHttp.responseText	
		//alert(response);
		if(response == "True")
		{
			document.getElementById("chkprojectid").innerHTML="";
			document.frm.flg.value = "True";				
		}
		else
		{		
			document.getElementById("chkprojectid").innerHTML="<font color=#FF0000>Project name already exist</font>" 
			document.frm.flg.value = "False";	
		}
 	} 
}

///change Msg Status
function getMsgStatus(str) 
{		
	var strURL="chkuser.php?step=6&msgstatus="+str;	
	var req = GetXmlHttpObject();	
	if (req) {
		
		req.onreadystatechange = function() 
		{			
			if (req.readyState == 4) 
			{					
				if (req.status == 200) {					
					document.getElementById('div_msgstatus').innerHTML=req.responseText;					
					//document.geElementById('preloader').innerHTML = "";
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}				
		req.open("GET", strURL, true);
		req.send(null);
	}		
}


///change project Status
function getPageRefresh(str) 
{		
	if(str=="")
		return false
	if(str==0)
		window.location.href= "accountinfo.php";
		
	var strURL="project_detail.php?proid="+str;	
	var req = GetXmlHttpObject();	
	if (req) {
		
		req.onreadystatechange = function() 
		{			
			if (req.readyState == 4) 
			{					
				if (req.status == 200) {					
					document.getElementById('norefresh').innerHTML=req.responseText;
					
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}				
		req.open("GET", strURL, true);
		req.send(null);
	}		
}
