var xmlHttp
function _doPopulateCity(conname){
	var url="citypopulate.php?conname=" + conname;
	xmlHttp = GetXmlHttpObject(ReturnCity)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
/*-----------------------------------------Search subcategory----------------------------------*/

function clearDropDowntemplate1() {   

var theDropDown = document.getElementById("state")   
var numberOfOptions = theDropDown.options.length   
for (i=0; i<numberOfOptions; i++) {   
 //Note: Always remove(0) and NOT remove(i)   
 theDropDown.remove(0)   
}
}  
function clearDropDowntemplatealbum() {   

var theDropDown = document.getElementById("album")   
var numberOfOptions = theDropDown.options.length   
for (i=0; i<numberOfOptions; i++) {   
 //Note: Always remove(0) and NOT remove(i)   
 theDropDown.remove(0)   
}
}  

function getstate(id){
clearDropDowntemplate1();

	var url="getstate.php?country=" + id ;
	xmlHttp = GetXmlHttpObject(Returnstate);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}
function Returnstate() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		var restxt=xmlHttp.responseText;
		
	
		
		var newtxt=restxt.split(',');
		
		//   var state=document.getElementById("state");
		   
		    document.getElementById("state").options[0]=new Option('--Please Select--','0');
		   for (i = 0; i < newtxt.length-1; i++) {
			 newarr=newtxt[i].split('|');
			 document.getElementById("state").options[i+1]=new Option(newarr[1],newarr[0]);
			 //state option=new option(newarr[0],newarr[1]);
			// state.append("<option value='" +newarr[0]+ "'>"+newarr[1]+ "</option>");
			 
		//document.getElementById("category").innerHTML = xmlHttp.responseText;
	                                  } 
	}
}




function getalbum(id)
{
clearDropDowntemplatealbum();

	var url="getalbum.php?album=" + id ;
	xmlHttp = GetXmlHttpObject(Returnalbum);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}
function Returnalbum() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		var restxt=xmlHttp.responseText;
		
	
		
		var newtxt=restxt.split(',');
		
		//   var state=document.getElementById("state");
		   
		   
		  // alert(newtxt);
		  if(newtxt!=0)
		  {
		  
		    document.getElementById("album").options[0]=new Option('--Please Select--','0');
			//alert(newtxt.length);
		   for (i = 0; i < newtxt.length; i++) {
			 newarr=newtxt[i].split('|');
			// alert(newarr[1]);
			 document.getElementById("album").options[i+1]=new Option(newarr[1],newarr[0]);
			 //state option=new option(newarr[0],newarr[1]);
			// state.append("<option value='" +newarr[0]+ "'>"+newarr[1]+ "</option>");
			 
		//document.getElementById("category").innerHTML = xmlHttp.responseText;
	                                  } 
		  }
		  else
		  {
			    document.getElementById("album").options[0]=new Option('--Please Select--','0');
		  }
	}
}

/*function Returnsubcategory()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		//document.getElementById("errorMessageAd").innerHTML = '';
		//alert(xmlHttp.responseText);
		var str=xmlHttp.responseText;
		var arr=str.split("|");
		//alert(arr.length);
		for(i=0;i<arr.length-1;i++)
		{
			var arr1=arr[i].split(",");
		//	for(j=0;j<arr1.length-1;j++)
			//{
			document.getElementById("cat_name").options[i]=new Option(arr1[0],arr1[1]);
			//}
		}
		//document.getElementById("test").innerHTML = xmlHttp.responseText;
	}	
}*/
/*-----------------------------------------Search subcategory----------------------------------*/
/*-----------------------------------------Search subcategory----------------------------------*/
function callcategorytype(id){
	
		var url="categoryType_process.php?mode=add&categorytype_id=" + id ;
	//alert(url);
	xmlHttp = GetXmlHttpObject(Returncategory)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function Returncategory() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		
		document.getElementById("category").innerHTML = xmlHttp.responseText;
	} 
}
function callcategorytype_edit(id){
	

		var url="categoryType_process.php?mode=edit&categorytype_id="+id;
	//alert(url);
	xmlHttp = GetXmlHttpObject(Returncategory_edit)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function Returncategory_edit() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		
		document.getElementById("category").innerHTML = xmlHttp.responseText;
	} 
}
/*-----------------------------------------Search subcategory----------------------------------*/

function featured_project(id){
	document.getElementById("featured").display ='';;
		var url="featured_process.php?id="+id+"&mode=add" ;
	//alert(url);
	xmlHttp = GetXmlHttpObject(Returnfeatured_project)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function Returnfeatured_project() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		alert(xmlHttp.responseText);
		document.getElementById("featured").innerHTML = xmlHttp.responseText;
	} 
}
function featured_project_edit(id){
	var typeid=document.frm.cattype_name.value;
//	alert(typeid);
	var featured=document.frm.featured_hidden.value;
	//alert(featured);
	var project_id=document.frm.project_id.value;
	//alert(project_id);
		var url="featured_process.php?mode=edit&id="+id+"&typeid="+typeid+"&featured="+featured+"&projectID="+project_id;
	//alert(url);
	xmlHttp = GetXmlHttpObject(Returnfeatured_project_edit)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function Returnfeatured_project_edit() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		//alert(xmlHttp.responseText);
		document.getElementById("featured").innerHTML = xmlHttp.responseText;
	} 
}
function changeme(x){
	alert(x);
	var url="citypopulate_new.php?x="+x;
	xmlHttp = GetXmlHttpObject(ReturnMytest)
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function doState(){
	var city = document.getElementById('city').value ;
	var url="state.php?city="+city;
	xmlHttp = GetXmlHttpObject(ReturnMystate)
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function _doCheckUser(strUser) {
	var url="ajax.user.php?user=" + strUser;
	xmlHttp = GetXmlHttpObject(UserChange)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)	
}
function _doAdvCost(date,addType,picture) {
	var url="ajax.cost.php?date=" + date + "&type=" + addType + "&picture=" + picture;
	xmlHttp = GetXmlHttpObject(ReturnCost)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function ReturnCity() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById("popcity").innerHTML = xmlHttp.responseText;
	}	
}
function clearDropDown() {   
if (!document.getElementById("cat_name").checked) {   
//nothing to do, since checkbox is not "checked" .so return   
return  
}   
var theDropDown = document.getElementById("cat_name")   
var numberOfOptions = theDropDown.options.length   
for (i=0; i<numberOfOptions; i++) {   
 //Note: Always remove(0) and NOT remove(i)   
 theDropDown.remove(0)   
}   
}   

function clearDropDowntemplate() {   
if (!document.getElementById("cat_name").checked) {   
//nothing to do, since checkbox is not "checked" .so return   
return  
}   
var theDropDown = document.getElementById("cat_name")   
var numberOfOptions = theDropDown.options.length   
for (i=0; i<numberOfOptions; i++) {   
 //Note: Always remove(0) and NOT remove(i)   
 theDropDown.remove(0)   
}   
}  

function getcategory(id) {

	/*var count=document.getElementById("cat_name").options.length;
	for(i=0;i<=count-1;i++)
	{
		document.getElementById("cat_name").options[i].value=
	}
	*/
	//alert(id);
	clearDropDown();
	var url="getcategoryprocess.php?categorytype_id="+id+"&mode=add";
	xmlHttp = GetXmlHttpObject(Returnget_category)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function Returnget_category()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		//document.getElementById("errorMessageAd").innerHTML = '';
		//alert(xmlHttp.responseText);
		var str=xmlHttp.responseText;
		//alert(str);
		var arr=str.split("|");
	
		for(i=0;i<=arr.length-1;i++)
		{
			var newarr=arr[i].split(",");
			
			
			document.getElementById("cat_name").options[i]=new Option(newarr[1],newarr[0]);
			//document.getElementById("cat_name").options[i].value=new Option(newarr[0]);
		}
		//document.getElementById("test").innerHTML = xmlHttp.responseText;	
	}	
}

function getcategory_template(id) {

	clearDropDowntemplate();
	clearDropDowntemplate();
	var url="getcategoryprocess.php?categorytype_id="+id+"&mode=add";
	xmlHttp = GetXmlHttpObject(Returnget_categorytemplate)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function Returnget_categorytemplate()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		//document.getElementById("errorMessageAd").innerHTML = '';
		//alert(xmlHttp.responseText);
		var str=xmlHttp.responseText;
		//alert(str);
		var arr=str.split("|");
	
		for(i=0;i<=arr.length-1;i++)
		{
			var newarr=arr[i].split(",");
			
			
			document.getElementById("cat_name").options[i]=new Option(newarr[1],newarr[0]);
			//document.getElementById("cat_name").options[i].value=new Option(newarr[0]);
		}
		//document.getElementById("test").innerHTML = xmlHttp.responseText;	
	}	
}


function getcategory_edit(id) {
	clearDropDown();
	var url="getcategoryprocess.php?categorytype_id="+id+"&mode=edit";
	xmlHttp = GetXmlHttpObject(Returnget_category_edit)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function Returnget_category_edit()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		//document.getElementById("errorMessageAd").innerHTML = '';
		//alert(xmlHttp.responseText);
		var str=xmlHttp.responseText;
		//alert(str);
		var arr=str.split("|");
		//alert(arr.length);
		
		for(i=0;i<=arr.length-1;i++)
		{
			var newarr=arr[i].split(",");
			
			
			document.getElementById("cat_name").options[i]=new Option(newarr[1],newarr[0]);
			//document.getElementById("cat_name").options[i].value=new Option(newarr[0]);
		}
		//document.getElementById("test").innerHTML = xmlHttp.responseText;	
	}	
}

function ReturnMytest()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		//document.getElementById("errorMessageAd").innerHTML = '';
		//alert(xmlHttp.responseText);
		var str=xmlHttp.responseText;
		var arr=str.split(",");
		//alert(arr.length);
		for(i=0;i<arr.length-1;i++)
		{
			document.getElementById("city").options[i]=new Option(arr[i],arr[i]);
		}
		//document.getElementById("test").innerHTML = xmlHttp.responseText;
	}	
}
function ReturnMystate(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById("state").value = xmlHttp.responseText;
	}	
}
function ReturnCost() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById("idCost").innerText = "INR " + xmlHttp.responseText;
	}	
}
function UserChange() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById("idUser").innerHTML = xmlHttp.responseText;
	} 
}
function GetXmlHttpObject(handler) { 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0) {
		alert("This example doesn't work in Opera") 
		return; 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
			strName="Microsoft.XMLHTTP"
		} 
		try	{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} catch(e) { 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0) {
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}
function getimg1(id){
document.getElementById("gallery").innerHTML ='';
alert(id);
	var url="getimg.php?id=" + id ;
	xmlHttp = GetXmlHttpObject(Returnimg);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}
function Returnimg() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		var restxt=xmlHttp.responseText;
		
	
		
		//var newtxt=restxt.split(',');
		
		//   var state=document.getElementById("state");
		   
		   
			 //state option=new option(newarr[0],newarr[1]);
			// state.append("<option value='" +newarr[0]+ "'>"+newarr[1]+ "</option>");
			 
		document.getElementById("gallery").innerHTML = xmlHttp.responseText;
	                                  } 
	
}





/************************************************
function _doCheckUser(strUser) {
	var url="ajax.user.php?user=" + strUser;
	ajaxRequest = GetXmlHttpObject(UserChange)
	ajaxRequest.open("GET", url , true)
	ajaxRequest.send(null)
}

function ReturnCost() {
	if (ajaxRequest.readyState==4 || ajaxRequest.readyState=="complete") {
		document.getElementById("idCost").innerText = "INR " + ajaxRequest.responseText;
	}	
}
************************************************/
