// JavaScript Document

var xmlHttp;

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

////////////// Captcha validation for Quick Contact Form ///////////////

function checkcode(thecode)
{ 	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="register_ajax_captcha.php"
	url=url+"?code="+thecode
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=check_captcha_code
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	//alert(url);
}
function check_captcha_code() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		captchaOK=xmlHttp.responseText;
		document.getElementById("valid_captcha_code").innerHTML=xmlHttp.responseText
	}
}

///////////////////////// the  end /////////////////////

////////////// Captcha validation for Contact Us Form ///////////////

function verifyCode(thecode)
{ 	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="register_ajax_captcha.php"
	url=url+"?code="+thecode
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=check_captcha_cont
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	//alert(url);
}
function check_captcha_cont() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		captchaOK=xmlHttp.responseText;
		document.getElementById("valid_captcha").innerHTML=xmlHttp.responseText
	}
}

///////////////////////// the  end /////////////////////

//////// Functions begin for whether Username is duplicated or not! //////////
function unameRepeat(val)
{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url="select_username.php"
		url=url+"?q="+val		
		//url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=validUsername
		xmlHttp.open("GET",url,true)		
		xmlHttp.send(null)		
}
function validUsername() 
{
	var flag=0;
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 		
		document.getElementById("userName_chk").innerHTML=xmlHttp.responseText
		flag=1		
	}
	if(document.getElementById("userName_chk").innerHTML!="" && flag==1)
	{
		document.sign_frm.uname.focus();
		return false;
	}
}
/////////////////////////////////////  Album Add start //////////////////////

function addAlbum(uid,albnm)
{	
	if(trimstr("add_albnm_frm","albnm")==false)	
	return false;
	
	if(checkrequire("add_albnm_frm","albnm","Please Enter Album Name")==false)
	return false;
	
	if(document.add_albnm_frm.albnm.value=="")
	{
		alert("Please Enter Album Name");	
		return false;
	}
	albnm=document.add_albnm_frm.albnm.value;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="album_save.php"
	url=url+"?uid="+uid
	url=url+"&albnm="+albnm
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=create_albnm
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	overlayclose('albm_div');
	document.add_albnm_frm.albnm.value="";
	alb_updt(uid);
}

function create_albnm() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("alb_create").innerHTML=xmlHttp.responseText		
	} 
}
/////////////////////////////////////  Album Add End //////////////////////

///////////////////////////////////////////////// Ajax For Check Album Name Combobox//////////////////////////////////////////

function check_album(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if (str=="")
	{	
		return false;
	}

	var url="checkalbum.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=usercheck_change;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}
function usercheck_change() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 		
		document.getElementById("checkalbum").innerHTML=xmlHttp.responseText
		if (xmlHttp.responseText!=""){
			document.add_albnm_frm.albnm.value=""
			document.add_albnm_frm.albnm.focus()
		} 
	} 
}

///////////////////////////////////////  Album add automatically in combo box start //////////////////////////////////////////
var xmlHttp1="";
function alb_updt(id)
{	
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if (id=="")
	{	
		return false;
	}

	var url="alb_updt.php";
	url=url+"?q="+id;
	url=url+"&sid="+Math.random();
	xmlHttp1.onreadystatechange=album_change;
	xmlHttp1.open("GET",url,true);
	xmlHttp1.send(null);	
}
function album_change() 
{ 
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
	{ 		
		document.getElementById("alb_updt").innerHTML=xmlHttp1.responseText	
	} 
}
///////////////////////////////////////  Album add automatically in combo box end //////////////////////////////////////////


///////////////////////////////////////  for changing combo box dynamic  //////////////////////////////////////////

function select_sub_cat(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if (str==""){	
		return false;
	}

	var url="select_sub_cat.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=select_sub_cat_done
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function select_sub_cat_done() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 	
		document.getElementById("selectcity").innerHTML=xmlHttp.responseText 				
	} 
}
/////////////////////////////////////// Add as Friend//////////////////////////////////////////

function add_friend(reciver_id,user_id)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if (reciver_id==""){	
		return false;
	}

	var url="addfriend.php"
	url=url+"?hid="+reciver_id
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=add_friend_done
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function add_friend_done() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 	
		document.getElementById("added").innerHTML=xmlHttp.responseText 				
	} 
}