var xmlHttp
var hint

/////////////////////////////////////////////////////////////////
function checkemail(email)
{

	if (email.length==0 )
	{	 document.getElementById("chkemail").innerHTML="Enter Email";	return;	}
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{	alert ("Browser does not support HTTP Request");		return;	} 
	var url

	url="ajax/email.php?email="+email;

	xmlHttp.onreadystatechange=stateEmail	;
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}
/////////////////////////////////////////////////////////////////////////////////////	
function stateEmail() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{	
		document.getElementById("chkemail").innerHTML = xmlHttp.responseText;	
		if(xmlHttp.responseText=='Available')
			document.getElementById("available").value = 'yes';	
		else
			document.getElementById("available").value = 'no';
		return document.getElementById("available").value;	
	} 
} 	

/////////////////////////////////////////////////////////////////////////////////////

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



/////////////////////////////////////////////////////////////////////////////////////	
function stateText() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{	
		//alert("state");
		//document.getElementById("tab_div").innerHTML = '';
		//if(xmlHttp.responseText=='0')
		document.getElementById("change_div").innerHTML = "Record Added Successfully </br>";	
		document.getElementById("tab").style.display = "none";
		document.getElementById("disp_tab").style.display = "";
		return;
	} 
} 	

/////////////////////////////////////Add text////////////////////////////////////////////////
function add_text(article_id,title,detail)
{
	
	//alert("article_id="+article_id+"&title="+title+"&detail="+detail);
	if (article_id.length==0 )
	{	 document.getElementById("change_div").innerHTML="Please Enter Title";	return;	}
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{	alert ("Browser does not support HTTP Request");		return;	} 
	var url

	url="ajax/text.php?article_id="+article_id+"&title="+title+"&detail="+detail;
	
	//alert("dasf");
	xmlHttp.onreadystatechange=stateText;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
/////////////////////////////////////edit text////////////////////////////////////////////////

function edit_text(text_id,title,detail)
{
	
	//alert("article_id="+article_id+"&title="+title+"&detail="+detail);
	if (text_id.length==0 )
	{	 document.getElementById("change_div").innerHTML="Please Enter Title";	return;	}
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{	alert ("Browser does not support HTTP Request");		return;	} 
	var url

	url="ajax/edit_text.php?text_id="+text_id+"&title="+title+"&detail="+detail;
	
	//alert("dasf");
	xmlHttp.onreadystatechange=stateText;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
/////////////////////////////////////edit text////////////////////////////////////////////////

function add_video(article_id,title,url1)
{
	//alert("article_id="+article_id+"&title="+title+"&detail="+detail);
	if (title.length==0 )
	{	 document.getElementById("change_div").innerHTML="Please Enter Title";	return;	}
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{	alert ("Browser does not support HTTP Request");		return;	} 
	var url

	url="ajax/add_video.php?article_id="+article_id+"&title="+title+"&url="+url1;
	
	//alert("dasf");
	xmlHttp.onreadystatechange=stateText;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
/////////////////////////////////////edit text////////////////////////////////////////////////

function edit_video(video_id,title,url1)
{
	//alert("article_id="+article_id+"&title="+title+"&detail="+detail);
	if (title.length==0 )
	{	 document.getElementById("change_div").innerHTML="Please Enter Title";	return;	}
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{	alert ("Browser does not support HTTP Request");		return;	} 
	var url

	url="ajax/add_video.php?video_id="+video_id+"&title="+title+"&url="+url1;
	
	//alert("dasf");
	xmlHttp.onreadystatechange=stateText;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
/////////////////////////////////////edit text////////////////////////////////////////////////

function add_link(article_id,title,url1,desc)
{
	//alert("article_id="+article_id+"&title="+title+"&detail="+detail);
	if (title.length==0 )
	{	 document.getElementById("change_div").innerHTML="Please Enter Title";	return;	}
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{	alert ("Browser does not support HTTP Request");		return;	} 
	var url

	url="ajax/add_link.php?article_id="+article_id+"&title="+title+"&url="+url1+"&desc="+desc;
	
	//alert("dasf");
	xmlHttp.onreadystatechange=stateText;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}