// JavaScript Documentvar xmlHttp


var xmlHttp
var xmlHttp2

function show_county_town(txt_county,txt_town)
{
	
	//alert(txt_county);
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	document.getElementById("div_ct").innerHTML='Loading...';
	var url = "ajaxpro.php"
	url+="?CountyID="+txt_county+"&TownID="+txt_town
	url+="&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedcounty
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function show_county_town_admin(txt_county,txt_town)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	document.getElementById("div_ct").innerHTML='Loading...';
	var url = "admin_ajaxpro.php"
	url+="?CountyID="+txt_county+"&TownID="+txt_town
	url+="&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function show_county_town_news(txt_county,txt_town)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	document.getElementById("div_ct").innerHTML='Loading...';
	var url = "news_ajaxpro.php"
	url+="?CountyID="+txt_county+"&TownID="+txt_town
	url+="&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function show_county_town_news_edit(x)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	document.getElementById("div_ct").innerHTML='Loading...';
	var url = "news_edit_ajaxpro.php"
	url+="?id="+x+"&edit=true"
	url+="&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
/////////////////////////////////////a/<-----------------SMS------------------------> ///////////////////////////////////////////////////////////////////
 function GetAj( )
					{
						var o = null;
						try
						{
							o = new XMLHttpRequest( );
						}
						catch ( e )
						{
							try
							{
								o = new ActiveXObject( "MSXML2.XMLHTTP" );
							}
							catch ( e )
							{
								o = new ActiveXObject( "MICROSOFT.XMLHTTP" );
							}
						}
						return o;
					}
 
 var http =GetAj();


function show_county_town_sms(txt_county,txt_town,str,str1,str2)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	document.getElementById("div_ct").innerHTML='Loading...';
	
	///////////////////////////////
	
	if (str2==1 )
	{
		var url = "article_ajaxpro.php"
	}
	else if (str2==2 )
	{
		var url = "comm_ajaxpro.php"
	}
	else
	{
		var url = "notification_ajaxpro.php"
	}
	
	/////////////////////////////////////
	
	
//	var url = "notification_ajaxpro.php"
	url=url+"?CountyID="+txt_county+"&TownID="+txt_town+"&str="+str+"&str1="+str1
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState =="complete")
	{
		document.getElementById("div_ct").innerHTML=xmlHttp.responseText;
		// alert(xmlHttp.responseText);
		 
		 
	}
}

 



function  cmd_sms_smt(str,str1,str2,str3)
{ 
	
	/*alert(str+"|"+str1+"|"+str2+"|"+str3);
	return ;*/
	var url = "sms_notification_progress.php";
	var params = "TownID="+ str +"&SectiontypeID="+ str1+"&SectionID="+ str2+"&ID="+ str3;
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			
		document.getElementById("msg").innerHTML=http.responseText;
		}
	}
	http.send(params);

	
}
/////////////////////////////////////<--------------INDEX-------->/////////////////////////////////////////////////////////////////\\
function show_sitemap(w,x,y,z)
{
	var  tid = w; 
	xmlHttp=GetXmlHttpObject()
	if (http==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	document.getElementById("div_int_"+tid ).innerHTML='<img src="images/ajax-loader.gif">';
	var url ='sectiondtl.php'
	url+="?townid="+ w+"&tname="+x+"&countyid="+y+"&cname="+z+"&sid="+Math.random()
	
	
    xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
			 		 document.getElementById("div_int_"+tid ).innerHTML=xmlHttp.responseText;
      }
    }

	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}



/////////////////////////////////////<--------------END-------->/////////////////////////////////////////////////////////////////\\
////////////////////////////////////////////////////

function show_form(id,field,form,did,pageindex,pagesize)
{

	xmlHttp=GetXmlHttpObject()
	if (http==null)
	{
			alert ("Browser does not support HTTP Request")
		return
	}
		  document.getElementById("div_"+did ).innerHTML='Loading..';
		  
		  
		  var url =form 
	      url+="?"+field+"="+ id +"&pageindex="+ pageindex +"&pagesize="+pagesize+"&sid="+Math.random()
		 
	 xmlHttp.onreadystatechange=function()
    {
		if(xmlHttp.readyState==4)
		  {
				///alert(xmlHttp.responseText);
				document.getElementById("div_"+did ).innerHTML=xmlHttp.responseText;
		  }
    }

	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
////////////////////////////////////////////////////////////////////////////////////////////////////

function  setpaging(pageindex,pagesize,field,file,id,did)
{ 
		
	xmlHttp=GetXmlHttpObject()
	if (http==null)
	{
			alert ("Browser does not support HTTP Request")
		return
	}
		
		document.getElementById("div_"+did ).innerHTML='Loading';
		var url =file 
	    url+="?pageindex="+pageindex+"&pagesize="+ pagesize + "&"+field+"="+id+"&sid="+Math.random()
	
		
		 
	 xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	 	///	alert(xmlHttp.responseText);
			document.getElementById("div_"+did ).innerHTML=xmlHttp.responseText;
      }
    }

	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

////////////////////////////////////////////////////


 

function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		 document.getElementById("div_ct").innerHTML=xmlHttp.responseText;
	}
}

function stateChangedcounty()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState =="complete")
	{
		 document.getElementById("div_ct").innerHTML=xmlHttp.responseText;
		 
		 
		 
	}
}
 


function loopSelected()
{
	var txtSelectedValuesObj = document.f1.Town;
	var selectedArray = new Array();
	var selObj = document.getElementById('TownID_list');
	var i;
	var count = 0;
	for (i=0; i<selObj.options.length; i++) {
		if (selObj.options[i].selected) {
			selectedArray[count] = selObj.options[i].value;
			count++;
		}
	}
	txtSelectedValuesObj.value = selectedArray;
}


/////////////////


function  cmd_preview(str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11,str12,str13,str14,str15,str16,str17,str18)
{ 
	
	/*alert(str+"|"+str1+"|"+str2+"|"+str3);
	return ;*/
	var url = "process.php";
	var params = "Field2="+ str2 +"&Field3="+ str3+"&Field4="+ str4+"&Field5="+ str5;
			params +=" & Field6="+ str6 +"&Field7="+ str7+"&Field8="+ str8+"&Field9="+ str9;
			params +=" & Field10="+ str10 +"&Field11="+ str11+"&Field12="+ str12+"&Field13="+ str13;
			params +=" & Field14="+ str14 +"&Field15="+ str15+"&Field16="+ str16+"&Field17="+ str17+"&Field18="+ str18;
	
	//alert(params);
	//return false ;
	
	
	http.open("POST", url, true);
	///return false ;
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			
	 
		//alert ( http.responseText);
		 
		}
	}
	http.send(params);

	
}

 
//////////////////////////////////////////////////////////////////////////////////////
var xmlHttp
function show_form2(id,field,form,div_d,pageindex,pagesize,field1,id1,redirect)
{

	xmlHttp=GetXmlHttpObject()
	if (http==null)
	{
			alert ("Browser does not support HTTP Request")
		return
	}
		
		document.getElementById("div_"+div_d ).innerHTML='<img src="images/ajax-loader.gif">';
		  
		  
		 
		///addons="";
		  if (field1 !=null)
		  { addons= "&"+field1+ "="+id1; }
		  
		  var url =form 
	      url+="?"+field+"="+ id +addons+"&pageindex="+ pageindex +"&pagesize="+pagesize+"&redirect="+redirect+"&sid="+Math.random()
			///	alert(url);

 
		 
	 xmlHttp.onreadystatechange=function()
    {
		if(xmlHttp.readyState==4)
		  {
				//alert(xmlHttp.responseText);
				document.getElementById("div_"+div_d ).innerHTML=xmlHttp.responseText;
		  }
    }

	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

////////////////////////////////////////////Paging/////////////////////////////////////////////////////
function  setpaging2(pageindex,pagesize,field,file,id,div_id)
{ 
		
	xmlHttp=GetXmlHttpObject()
	if (http==null)
	{
			alert ("Browser does not support HTTP Request")
		return
	}
		
		document.getElementById("div_"+did ).innerHTML='<img src="images/ajax-loader.gif">';
		var url =file 
	    url+="?pageindex="+pageindex+"&pagesize="+ pagesize + "&"+field+"="+id+"&sid="+Math.random()
	
		
		 
	 xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	 	///	alert(xmlHttp.responseText);
			document.getElementById("span_"+did ).innerHTML=xmlHttp.responseText;
      }
    }

	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 
/////////////////////////////////////31 OCT 2009/////////////////////////////////////////////////
var xmlHttp
function show_form_county(id,field,form,div_d,pageindex,pagesize,field1,id1,redirect)
{
	 
	xmlHttp=GetXmlHttpObject()
	if (http==null)
	{
			alert ("Browser does not support HTTP Request")
		return
	}
		
		document.getElementById("div_"+div_d ).innerHTML='Loading..';
		  
		  
		 
			
		  if (field1 !=null)
		  { addons= "&"+field1+ "="+id1; }
		  
		  var url =form 
	      url+="?"+field+"="+ id +addons+"&pageindex="+ pageindex +"&pagesize="+pagesize+"&redirect="+redirect+"&sid="+Math.random()
		  
		
	
 
		 
	 xmlHttp.onreadystatechange=function()
    {
		if(xmlHttp.readyState==4)
		  {
				document.getElementById("div_"+div_d ).innerHTML=xmlHttp.responseText;
		  }
    }

	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function  cmd_topic(div,cmd,str1,str2,str3,str4)
{ 
	
	//alert(cmd+"|"+str1+"|"+str2+"|"+str3+"|"+str4);
	//return ;
	var url = "command.php";
	var params = "command="+cmd+"&ID="+ str1+"&location="+ str2+"&Topic="+ str3;
		  params +=" & Detail="+ str4;
	
	//alert(params);
	//return false ;
	
	
	http.open("POST", url, true);
	///return false ;
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) 
		{
			document.getElementById("msg_"+div).innerHTML="Topic Create sucessfully! ";
			show_form_county(str1,'ID', 'comments.php','1')
		}
	}
	http.send(params);

}

function  cmd_comment(div,cmd,str1,str2,str3,ID,pgindex,pgsize)
{ 
	
	//alert(cmd+"|"+str1+"|"+str2+"|"+str3);
	//return ;
	var url = "command.php";
	var params = "command="+cmd+"&CommentsID="+ str1+"&Detail="+ str2+"&UserID="+ str3;
		  
	
 
	
	http.open("POST", url, true);
	///return false ;
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) 
		{
			document.getElementById("msg_"+div+"_"+str1).innerHTML="Comment  add sucessfully! ";
		    show_form_county(ID,'ID', 'comments.php','1',pgindex,pgsize,'type','1');	
		  
		}
	}
	http.send(params);

	
}


///////////////////////////////////////////////////////////////////////////////////////////////////////

function GetXmlHttpObject()
{
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
