var SHOG_http_map = false;
var SHOG_http_sk = false;
var SHOG_http_sk_list = false;
var SHOG_http_tab = false;
var SHOG_http_layout = false;

function show_loading()
{
  	document.getElementById("div_loading").style.left=""+(50+document.body.scrollLeft)+"px";
	document.getElementById("div_loading").style.top=""+(150+document.body.scrollTop)+"px";
  	document.getElementById("div_loading").style.visibility="visible";
  	
  	window.status="Loading...";
}

function hide_loading()
{
  	window.setTimeout("hide_loading_now()",500);
  
}
function hide_loading_now(){
  document.getElementById("div_loading").style.visibility="hidden";
  window.status="Loaded";
}


function SHOG_init_ajax_map()
{
  		SHOG_http_map = false;
		if (window.XMLHttpRequest) 
				  	{ 
	                SHOG_http_map = new XMLHttpRequest();
	                if (SHOG_http_map.overrideMimeType) 
						{
	                    	SHOG_http_map.overrideMimeType('text/xml');
				        }		   
					}
				else if (window.ActiveXObject) 
					{ //IE	
			            try {
			                SHOG_http_map = new ActiveXObject("Msxml2.XMLHTTP");
			                } catch (e) {
			                	try {
			                        SHOG_http_map = new ActiveXObject("Microsoft.XMLHTTP");
			                        } catch (e) {}
			                	}
			        
			        }
			
			        if (!SHOG_http_map) {
			                    alert('Oppss...unable to init AJAX !');
			                    return false;
			        }			
}

function SHOG_terminate_ajax_map()
{
  SHOG_http_map=null;
}

function SHOG_update_ajax_map() {
  	show_loading();
  	try{
        if (SHOG_http_map.readyState == 4) {
            if (SHOG_http_map.status == 200) {
               
              	var return_value =SHOG_http_map.responseText.split("<map>");
          	 	if((return_value[0]=="START")&&(return_value[2]=="END"))
          	 		{
          	 		  	//SHOG_resetPointer();
				  
				    	var result_map="";
				    	var data_set=return_value[1].split("@");
				    	var total_data=data_set[0];
				    	result_map="";
				    
				    	for(var i=0;i<total_data;i++)
				    		{
				    		 	try{
				    		  	var data=data_set[i+1].split("$");
							  	SHOG_plotPointer(i+1,data[0],data[1]);
							  //	alert(i+","+data[0]);
							  
							  	var img="<img src='../map/pointer.png' border=0 ><font style='position:relative;left:-14;top:-5;align:center;font-size:9px;color:#FFFFFF;' ><b>"+(i+1)+"</b></font>";
							  	
							  	result_map=result_map+"<div style='width:90%;padding:3px 3px 3px 3px;border:1px solid #C0C0C0;background:#eeeeee;'><table width=100% ><tr><td align=left valign=top  ><a href=\"javascript:SHOG_toggleHideShowPointer("+(i+1)+");\">"+img+"</a></td><td align=left >"+data[2]+"</td>";
							  	
							  	result_map=result_map+"<td valign=top align=right  >";
							  	
							  	result_map=result_map+"<a  href=\"javascript:SHOG_toggleHideShowPointer("+(i+1)+");\">Hide/Show on Map</a><br><br>";
							  	result_map=result_map+"<a  href=\"javascript:SHOG_toggleHideShowAllPointer('HIDE');SHOG_toggleHideShowPointer("+(i+1)+");\">Show this on Map</a><br>";
							  	
								result_map=result_map+"</td></tr>";				
							 
							  	result_map=result_map+"<tr><td colspan=3 ><br></td></tr></table></div><br>";
							  	}
								catch(e)
								{
									
								}
							}
							
					//	result_map="<table width=100% >"+result_map+"</table>";
				   		document.getElementById("map_list").innerHTML=result_map+"<br>"+return_value[1];
						document.getElementById("map_list").innerHTML="Total of "+total_data+" Spots found in this area<br><br>"+result_map;
					}
				else
					{
				  	alert("Oppss...unable to get back the valid content"+SHOG_http_map.responseText);
					}	
				SHOG_terminate_ajax_map();
				hide_loading();
            } else {
               alert('Oppss...Unable to perform your action\nThere is problem with the network connection.');
            }
        	hide_loading();
        }
	}
	catch(e)
	{
	  //alert(e);
	  hide_loading();
	}
}


function SHOG_get_ajax_map(url,query_string){
  				
  				SHOG_init_ajax_map();
			  	SHOG_http_map.onreadystatechange = SHOG_update_ajax_map;  
			  	SHOG_http_map.open('GET', url+query_string, true);
				SHOG_http_map.send(null);  
				
}
//=================================================================================================

function SHOG_init_ajax_tab()
{
  		SHOG_http_tab = false;
		if (window.XMLHttpRequest) 
				  	{ 
	                SHOG_http_tab = new XMLHttpRequest();
	                if (SHOG_http_tab.overrideMimeType) 
						{
	                    	SHOG_http_tab.overrideMimeType('text/xml');
				        }		   
					}
				else if (window.ActiveXObject) 
					{ //IE	
			            try {
			                SHOG_http_tab = new ActiveXObject("Msxml2.XMLHTTP");
			                } catch (e) {
			                	try {
			                        SHOG_http_tab = new ActiveXObject("Microsoft.XMLHTTP");
			                        } catch (e) {}
			                	}
			        
			        }
			
			        if (!SHOG_http_tab) {
			                    alert('Oppss...unable to init AJAX !');
			                    return false;
			        }			
}

function SHOG_terminate_ajax_tab()
{
  SHOG_http_tab=null;
}

function SHOG_update_ajax_tab() {
  	show_loading();
  	try{
        if (SHOG_http_tab.readyState == 4) {
            if (SHOG_http_tab.status == 200) {
               
              	var return_value =SHOG_http_tab.responseText.split("<tab>");
          	 	if((return_value[0]=="START")&&(return_value[2]=="END"))
          	 		{	  
						document.getElementById("index_tab_content").innerHTML=return_value[1];
					
					}
				else
					{
				  	alert("Oppss...unable to get back the valid content"+SHOG_http_tab.responseText);
					}	
				SHOG_terminate_ajax_tab();
				hide_loading();
            } else {
               alert('Oppss...Unable to perform your action\nThere is problem with the network connection.');
            }
        	hide_loading();
        }
	}
	catch(e)
	{
	  //alert(e);
	  hide_loading();
	}
}


function SHOG_get_ajax_tab(url,query_string){
  				
  				SHOG_init_ajax_tab();
			  	SHOG_http_tab.onreadystatechange = SHOG_update_ajax_tab;  
			  	SHOG_http_tab.open('GET', url+query_string, true);
				SHOG_http_tab.send(null);  
				
}

//=====================================================================================================
var sk_return_div="";

function SHOG_init_sk_sub()
{
  		SHOG_http_sk = false;
		if (window.XMLHttpRequest) 
				  	{ 
	                SHOG_http_sk = new XMLHttpRequest();
	                if (SHOG_http_sk.overrideMimeType) 
						{
	                    	SHOG_http_sk.overrideMimeType('text/xml');
				        }		   
					}
				else if (window.ActiveXObject) 
					{ //IE	
			            try {
			                SHOG_http_sk = new ActiveXObject("Msxml2.XMLHTTP");
			                } catch (e) {
			                	try {
			                        SHOG_http_sk = new ActiveXObject("Microsoft.XMLHTTP");
			                        } catch (e) {}
			                	}
			        
			        }
			
			        if (!SHOG_http_sk) {
			                    alert('Oppss...unable to init AJAX !');
			                    return false;
			        }			
}

function SHOG_terminate_sk_sub()
{
  SHOG_http_sk=null;
  sk_return_div="";
}

function SHOG_update_sk_sub() {
  	show_loading();
  	try{
        if (SHOG_http_sk.readyState == 4) {
            if (SHOG_http_sk.status == 200) {
               
              	var return_value =SHOG_http_sk.responseText.split("<sk>");
          	 	if((return_value[0]=="START")&&(return_value[2]=="END"))
          	 		{

          	 		  	var data_set=return_value[1].split("@");
          	 		  	
				    	var total_data=data_set[1];
				    	
				    	var sk_items="";
				    	
				    	var data=data_set[2].split("%");
				    	for(var i=0;i<total_data;i++)
				    		{
				    		  sk_items=sk_items+data[i];
				    		}
				    	if(sk_items=="")
				    	{
				    	  	sk_items=data_set[0]+"<ul>No Sub Category</ul>"+""+data_set[3];
						  	SHOG_put_sk_item(sk_items);
						}
						else
						{
						  	sk_items=data_set[0]+sk_items+""+data_set[3];
						  	SHOG_put_sk_item(sk_items);
						}
				    	
						
					}
				else
					{
				  	alert("Oppss...unable to get back the valid content"+SHOG_http_map.responseText);
					}	
				SHOG_terminate_sk_sub();
				hide_loading();
            } else {
               alert('Oppss...Unable to perform your action\nThere is problem with the network connection.');
            }
        	hide_loading();
        }
        hide_loading();
	}
	catch(e)
	{
	  hide_loading();
	  //alert(e);
	}
}




function SHOG_get_sk_sub(url,query_string,return_div){
  
  				sk_return_div=return_div;
  				SHOG_init_sk_sub();
			  	SHOG_http_sk.onreadystatechange = SHOG_update_sk_sub;  
			  	SHOG_http_sk.open('GET', url+query_string, true);
				SHOG_http_sk.send(null);  
				
}


//===============================================================================================================

var sk_list_return_div="";
function SHOG_init_sk_list()
{
  		SHOG_http_sk_list = false;
		if (window.XMLHttpRequest) 
				  	{ 
	                SHOG_http_sk_list = new XMLHttpRequest();
	                if (SHOG_http_sk_list.overrideMimeType) 
						{
	                    	SHOG_http_sk_list.overrideMimeType('text/xml');
				        }		   
					}
				else if (window.ActiveXObject) 
					{ //IE	
			            try {
			                SHOG_http_sk_list = new ActiveXObject("Msxml2.XMLHTTP");
			                } catch (e) {
			                	try {
			                        SHOG_http_sk_list = new ActiveXObject("Microsoft.XMLHTTP");
			                        } catch (e) {}
			                	}
			        
			        }
			
			        if (!SHOG_http_sk_list) {
			                    alert('Oppss...unable to init AJAX !');
			                    return false;
			        }			
}

function SHOG_terminate_sk_list()
{
  SHOG_http_sk_list=null;
  sk_list_return_div="";
}

function SHOG_update_sk_list() {
  	show_loading();
  	try{
        if (SHOG_http_sk_list.readyState == 4) {
            if (SHOG_http_sk_list.status == 200) {
               
              	var return_value =SHOG_http_sk_list.responseText.split("<sk>");
          	 	if((return_value[0]=="START")&&(return_value[2]=="END"))
          	 		{
          	 		  SHOG_put_sk_list(return_value[1]);

					}
				else
					{
				  	alert("Oppss...unable to get back the valid content"+SHOG_http_sk_list.responseText);
					}	
				SHOG_terminate_sk_list();
				hide_loading();
            } else {
               alert('Oppss...Unable to perform your action\nThere is problem with the network connection.');
            }
        	hide_loading();
        }
	}
	catch(e)
	{
	  //alert(e);
	  hide_loading();
	}
}




function SHOG_get_sk_list(url,query_string,return_div){
  				showDiv('div_shops');
  				sk_list_return_div=return_div;
  				SHOG_init_sk_list();
			  	SHOG_http_sk_list.onreadystatechange = SHOG_update_sk_list;  
			  	SHOG_http_sk_list.open('GET', url+query_string, true);
				SHOG_http_sk_list.send(null);  
				
}


//=================================================================================================

function SHOG_init_ajax_layout()
{
  		SHOG_http_layout = false;
		if (window.XMLHttpRequest) 
				  	{ 
	                SHOG_http_layout = new XMLHttpRequest();
	                if (SHOG_http_layout.overrideMimeType) 
						{
	                    	SHOG_http_layout.overrideMimeType('text/xml');
				        }		   
					}
				else if (window.ActiveXObject) 
					{ //IE	
			            try {
			                SHOG_http_layout = new ActiveXObject("Msxml2.XMLHTTP");
			                } catch (e) {
			                	try {
			                        SHOG_http_layout = new ActiveXObject("Microsoft.XMLHTTP");
			                        } catch (e) {}
			                	}
			        
			        }
			
			        if (!SHOG_http_layout) {
			                    alert('Oppss...unable to init AJAX !');
			                    return false;
			        }			
}

function SHOG_terminate_ajax_layout()
{
  SHOG_http_layout=null;
}

function SHOG_update_ajax_layout() {
  	show_loading();
  	try{
        if (SHOG_http_layout.readyState == 4) {
            if (SHOG_http_layout.status == 200) {
               
              	var return_value =SHOG_http_layout.responseText.split("<lay>");
          	 	if((return_value[0]=="START")&&(return_value[2]=="END"))
          	 		{	  
						document.getElementById("div_layout_status").innerHTML=return_value[1];
					
					}
				else
					{
				  	alert("Oppss...unable to get back the valid content ["+SHOG_http_layout.responseText+"]");
					}	
				SHOG_terminate_ajax_layout();
				hide_loading();
            } else {
               alert('Oppss...Unable to perform your action\nThere is problem with the network connection.');
            }
        	hide_loading();
        }
	}
	catch(e)
	{
	  //alert(e);
	  hide_loading();
	}
}


function SHOG_get_ajax_layout(url,query_string){
  				
  				SHOG_init_ajax_layout();
			  	SHOG_http_layout.onreadystatechange = SHOG_update_ajax_layout;  
			  	SHOG_http_layout.open('GET', url+query_string, true);
				SHOG_http_layout.send(null);  
				
}

//=====================================================================================================









