var xmlHttp;
var count=0;

function GetXmlHttpObject()
{ 
	var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  
	return xmlHttp;
	
}

function getPosition(page,menuID){
  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	

	var url=page+menuID;	
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											if(xmlHttp.responseText==""){
												document.getElementById("p1").style.display="none";
												document.getElementById("p2").style.display="none";
											}else{
												document.getElementById("p1").style.display="block";
												document.getElementById("p2").style.display="block";
											}
											fill_combo(xmlHttp.responseText,document.getElementById("position"));
											
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	

	}
	
function fill_combo(passed_values,passed_combo_ref)
{
			//alert(passed_values);
			passed_combo_ref.length=0;
			var mytool_array=passed_values.split("|");
			
			if (passed_values == "") {
				var new_Option = new Option('no page', '0');
				passed_combo_ref.options[0] = new_Option;
				passed_combo_ref.disabled=true;
				
				return false;
			}else if(passed_values == "0"){
				var new_Option = new Option('no page', '');
				passed_combo_ref.options[0] = new_Option;
				passed_combo_ref.disabled=true;
			return false;
			}
		
			for(counter=0;counter<mytool_array.length;counter++)		
			{
			
				if(mytool_array[counter].length>0)
				{
					var mytool_array_param=mytool_array[counter].split(",");
					
					
					var new_Option = new Option(mytool_array_param[0], mytool_array_param[1]);
					passed_combo_ref.options[counter] = new_Option;
					
				}
				else
				{					
					if(counter==0)
					{					
					passed_combo_ref.length=0;
					}
				}
			}
			
		}

function searchKeyword(page,table,keyword,extra){

  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	if(keyword=="ALL"){
		keyword="";
		}

	var url=WEBSITE_URL+"admin/scripts/"+page+".php?search="+keyword+extra+"&table="+table;
	document.getElementById("ajaxsearch").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											document.getElementById("ajaxsearch").innerHTML='';
											document.getElementById("searchAjax").innerHTML=xmlHttp.responseText;
											
										
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	

		
}

function searchKeywordUI(page,keyword,extra){
  xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	if(keyword=="ALL"){
		keyword="";
		}

	var url=WEBSITE_URL+page+".php?search="+keyword+extra;
	
	document.getElementById("ajaxsearch").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp1.onreadystatechange=function(){
										if (xmlHttp1.readyState == 4 || xmlHttp1.readyState=="complete")
										{
											document.getElementById("ajaxsearch").innerHTML='';
											document.getElementById("searchAjax").innerHTML=xmlHttp1.responseText;
											
										
										}
								};
	xmlHttp1.open("GET",url,true);
	xmlHttp1.send(null);
	

		
}


function setSection(page,keyword){

  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	if(keyword=="ALL"){
		keyword="";
		}

	var url=WEBSITE_URL+"admin/scripts/"+page+".php?search="+keyword;
	document.getElementById("searchSection").style.display="block";
	document.getElementById("searchSection").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											
											//alert(xmlHttp.responseText);
											document.getElementById("searchSection").innerHTML='';
											document.getElementById("editTab").innerHTML=xmlHttp.responseText;
											document.getElementById("searchSection").style.display="none";
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	

		

	
	}
	
	
function setHeaderimage(pageID){

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

	var url=WEBSITE_URL+"admin/scripts/headerList.php?pageID="+pageID;
	
	document.getElementById("search").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											
											document.getElementById("editTab").innerHTML=xmlHttp.responseText;
											//document.getElementById("search").innerHTML='';
											
											
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	

		

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

	var url=WEBSITE_URL+"admin/scripts/quickList.php";
	
	document.getElementById("search").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											document.getElementById("editTab").innerHTML=xmlHttp.responseText;
											//document.getElementById("search").innerHTML='';
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}

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

	var url=WEBSITE_URL+"admin/scripts/headerimageList.php?search="+order;
	
	document.getElementById("search").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											document.getElementById("orderlist").innerHTML=xmlHttp.responseText;
											document.getElementById("search").innerHTML='';
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}





function menuLimit(limit){

  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url=WEBSITE_URL+"admin/scripts/menuLimit.php?limit="+limit;
	document.getElementById("search").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											document.getElementById("searchAjax").innerHTML=xmlHttp.responseText;
											document.getElementById("search").innerHTML='';
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}
	
	
	
	
function searchHeaderImage(page){

  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url=WEBSITE_URL+"admin/scripts/searchHeaderImage.php?page="+page;
	//document.getElementById("search").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											document.getElementById("orderlist").innerHTML=xmlHttp.responseText;
											//document.getElementById("search").innerHTML='';
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}
	
	

function menuRecord(menuId){
	
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url=WEBSITE_URL+"admin/scripts/menuRecord.php?menuId="+menuId;
	document.getElementById("search").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											document.getElementById("searchAjax").innerHTML=xmlHttp.responseText;
											document.getElementById("search").innerHTML='';
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}
	
	

function searchHeaderByName(pageId){
	
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url=WEBSITE_URL+"admin/scripts/searchHeaderByName.php?pageId="+pageId;
	document.getElementById("search").innerHTML="<img src='"+WEBSITE_URL+"admin/web/img/icons/wait.gif' border=0 />";
	xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
										{
											document.getElementById("searchAjax").innerHTML=xmlHttp.responseText;
											document.getElementById("search").innerHTML='';
										}
								};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}
	