﻿// JScript File
var ext=".htm";
var MenuXml;
var pagenameHotelId=document.getElementById("pageName").value;
var pageNameID=new Array();
pageNameID=pagenameHotelId.split('|');

var pageName=pageNameID[1];
var HotelID=pageNameID[0];
var currentPage=pageNameID[2]



Read();

function LeftMenu()
{
var Design="<table width='220px'  border='0' cellspacing='0' cellpadding='0'>";
Design+="<tr><td style='width:35px;' rowspan='2'>&nbsp;</td><td style='height:41px;width=185px;'>&nbsp;</td></tr>";
Design+="<tr><td><table style='width:100%' border='0' cellspacing='0' cellpadding='0'>";
  

var xmlObj=MenuXml.documentElement;
var strMainMenu=MenuXml.getElementsByTagName(pageName);

strSubMenu=strMainMenu[0].getElementsByTagName("SubMenu");

 Design+="<tr><td style='width:10px'></td><td height='5' bgcolor='#FFFFFF'></td></tr>";
 for(i=0;i<strSubMenu.length;i++)
 {
    var strChildMenu=strSubMenu[i].getElementsByTagName("ChildMenu");
  if(i==0)
    {
               //Design+="<tr><td style='padding-right:5px;'><img style='width:6px;height:9px;' id='"+i+"arrow' src='images/menu_images/Arrow_over.jpg' /></td><td  style='height:28px;'  id='"+i+"td'><img border='0' id='"+i+"img' src="+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("focusimg")+" /></td></tr>";     
              Design+="<tr style='height:28px;'><td colspan='2'  style='height:28px;' id='"+i+"td'><a href='"+strSubMenu[i].getAttribute("link")+"' ><img style='height:28px;' border='0' id='"+i+"img' src="+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("txtimg")+" onmouseover=changeover('"+i+"img','"+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("focusimg")+"','"+i+"arrow'); onmouseout=changeout('"+i+"img','"+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("txtimg")+"','"+i+"arrow'); /></a></td></tr>";     
    }
    else
    {
       if(i==1)
         Design+="<tr><td style='width:10px'></td><td bgcolor='#FFFFFF' style='height:5px;width:180px;' ></td></tr>";
        if(strSubMenu.length-1==i) 
        {  
         Design+="<tr style='height:28px;'><td colspan='2' style='height:28px;'  id='"+i+"td'><a target='_blank' href='"+strSubMenu[i].getAttribute("link")+"' ><img border='0' style='height:28px;' id='"+i+"img' src="+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("img")+" onmouseover=changeover('"+i+"img','"+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("focusimg")+"','"+i+"arrow'); onmouseout=changeout('"+i+"img','"+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("img")+"','"+i+"arrow'); /></a></td></tr>";     
        }
        else
        {
         Design+="<tr style='height:28px;'><td colspan='2'  style='height:28px;'  id='"+i+"td'><a href='"+strSubMenu[i].getAttribute("link")+"' ><img style='height:28px;' border='0' id='"+i+"img' src="+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("img")+" onmouseover=changeover('"+i+"img','"+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("focusimg")+"','"+i+"arrow'); onmouseout=changeout('"+i+"img','"+strMainMenu[0].getElementsByTagName("SubMenu")[i].getAttribute("img")+"','"+i+"arrow'); /></a></td></tr>";     
        }
     
    }
           
       if(i!=0)
       Design+="<tr><td style='width:10px'></td><td height='1' bgcolor='#FFFFFF'></td></tr>";
   
   if(strChildMenu!=null)
    {
        var j=0;
       
        for(j=0;j<strChildMenu.length;j++)
            {
                   
                if(j==0)
                {
                Design+="<tr><td></td><td style='width:185px'>";
                Design+="<table width='165px' border='0' align='right' cellpadding='0' cellspacing='0'>";
                }
     
              if(strChildMenu[j].getAttribute("hide")!="no")
              {
                 if(CheckHotelId(strChildMenu[j].getAttribute("hid")))
                 {
                  if(strChildMenu[j].getAttribute("name")==currentPage)
                     Design+="<tr style='height:25px;'><td colspan='2' style='height:25px;'  id='"+j+"tdo'><img style='height:25px;' id='"+j+"imgo' border='0' src="+strChildMenu[j].getAttribute("focusimg")+" /></td></tr>";
                     else
                    Design+="<tr style='height:25px;'><td colspan='2'  style='height:25px;'  id='"+j+"tdo'><a href=javascript:redirectpage('"+HotelID+"','"+strChildMenu[j].getAttribute("link")+"'); ><img style='height:25px;' border='0' id='"+j+"imgo' src="+strChildMenu[j].getAttribute("img")+" onmouseover=changeover('"+j+"imgo','"+strChildMenu[j].getAttribute("focusimg")+"','"+j+"arrowo'); onmouseout=changeout('"+j+"imgo','"+strChildMenu[j].getAttribute("img")+"','"+j+"arrowo'); /></a></td></tr>";
                 
                    Design+="<tr><td bgcolor='#FFFFFF' style='height:1px;width:180px;'></td></tr>";
                 } 
              }    
                 else
                  {
                 
                   
                  if(strChildMenu[j].getAttribute("name")==currentPage)
                      Design+="<tr style='height:25px;'><td colspan='2' style='height:25px;'  id='"+j+"tdo'><img style='height:25px;' id='"+j+"imgo' border='0' src="+strChildMenu[j].getAttribute("focusimg")+" /></td></tr>";
                     else
                    Design+="<tr style='height:25px;'><td colspan='2'  style='height:25px;'  id='"+j+"tdo'><a href=javascript:redirectpage('"+HotelID+"','"+strChildMenu[j].getAttribute("link")+"'); ><img style='height:25px;' border='0' id='"+j+"imgo' src="+strChildMenu[j].getAttribute("img")+" onmouseover=changeover('"+j+"imgo','"+strChildMenu[j].getAttribute("focusimg")+"','"+j+"arrowo'); onmouseout=changeout('"+j+"imgo','"+strChildMenu[j].getAttribute("img")+"','"+j+"arrowo'); /></a></td></tr>";
                 
                   //Design+=generate(strChildMenu,j);
                   if(strChildMenu.length-1!=j)
                   ///flg=0;
                    Design+="<tr><td bgcolor='#FFFFFF' style='height:1px;width:180px;'></td></tr>";
                   else
                   flg=1;
                   //Design+="<tr><td height='5' bgcolor='#FFFFFF'></td></tr>";
                   }
                 var strChildSubMenu=strChildMenu[j].getElementsByTagName("ChildSubMenu");
                
             if(j==strChildMenu.length-1)
            Design+="</table>";
            }
          
     }
     
    // if(flg==1)
    // Design+="<tr><td></td><td height='5' bgcolor='#FFFFFF'></td></tr>";
     Design+="</td></tr>";
   }

  Design+="</table></td></tr></table>";  


document.write(Design);
MenuXml=null;


}

function Read()
 {
   if(navigator.appName=="Microsoft Internet Explorer")
    {
      ReadXml1();
    }
    else
    {
       ReadXml()
    }
 }
function ReadXml()
 {
     var XmlHTTP = null;
    var Possibles = {0: "XMLHttpRequest()", 1: "ActiveXObject('Microsoft.XMLHttp')", 2:"ActiveXObject('MSXML2.XMLHttp')", 3:"ActiveXObject('MSXML2.XMLHttp.3.0')", 4:"ActiveXObject('MSXML2.XMLHttp.4.0')", 5:"ActiveXObject('MSXML2.XMLHttp.5.0')", 6:"ActiveXObject('MSXML2.XMLHttp.6.0')",7:"ActiveXObject('Msxml.DOMDocument')", 8:""};
    var Option = 0;
    while(XmlHTTP === null){
        XmlHTTP = eval("new " + Possibles[Option]);
       
    }
if(XmlHTTP === null)
    return false;
XmlHTTP.open("get", "Common_Inc/left_link.xml", false);
XmlHTTP.send("");
MenuXml = XmlHTTP.responseXML;
LeftMenu();
}
  
function ReadXml1() 
{ 

	if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
	{ 
		MenuXml = new ActiveXObject("Msxml.DOMDocument"); 
		MenuXml.async = false; 
		MenuXml.onreadystatechange = function () 
		{ 
		    if (MenuXml.readyState == 4) LeftMenu(); 
		} 
		MenuXml.load("Common_Inc/left_link.xml"); 
	} 
	else if( document.implementation && document.implementation.createDocument ) 
	{ 
		MenuXml = document.implementation.createDocument("","",null); 
		MenuXml.async=false; 
		var loaded = MenuXml.load("Common_Inc/left_link.xml"); 
		moz=1;
		if (loaded) 
		{ 
			LeftMenu();
		} 
	} 
	else 
	{ 
		alert("Your browser can\'t handle this script"); 
		return; 
	} 
}
 
function CheckHotelId(Ids)
{
 var cnt=0;
 var HotelId=new Array();
 HotelId=Ids.toString().split('|');
 for(m=0;m<HotelId.length;m++)
  {
    if(HotelId[m]==HotelID)
     {
     cnt++;
     }
  
  }
  if(cnt>0) 
   return false;
  else
   return true; 

} 
 
 function generate(strNode,f)
 {
 var des="@";
 if(strNode[f].getAttribute("name")==currentPage)
 des+="<tr><td height='2' bgcolor='#FFFFFF'></td></tr>";
 else
 {

 if(f<strNode.length-1)
      {
            if(strNode[f+1].getAttribute("name")==currentPage)
            des+="<tr><td height='2' bgcolor='#FFFFFF'></td></tr>";
            else
            des+="<tr><td height='1' bgcolor='#FFFFFF'></td></tr>";
          
      }
 else
      {
             des+="<tr><td height='1' bgcolor='#FFFFFF'></td></tr>";
      }  
 
 }
 des=des.substring(1,des.length);
 return des;
 
 
 }
 
function redirectpage(Id,pname)
{
//document.location.href;
//if(pname=="LocalInfo")
 // document.location.href=Id+"_cityfacts"+ext;
//else
  document.location.href=Id+"_"+pname+ext;  
}


 function changeover(imgid,imgname,arrowname)
 {
 document.getElementById(imgid).src=imgname;
 //document.getElementById(arrowname).src="images/menu_images/Arrow.jpg";
 }
 function changeout(imgid,imgname,arrowname)
 {
 document.getElementById(imgid).src=imgname;
 //document.getElementById(arrowname).src="images/menu_images/Arrow_over.jpg";
 }
 function redirectpages(Id,pname)
{
//document.location.href;
//if(pname=="Overview")
  //document.location.href=Id+"_"+pname+".aspx";
//else
  document.location.href=Id+"_"+pname+ext;  
   // document.location.href="index.html?hotelId="+Id+"&page="+pname; 
}

function redirectpage(Id,pname)
{
//document.location.href;
//if(pname=="Overview")
  //document.location.href=Id+"_"+pname+".aspx";
//else
  //document.location.href=Id+"_"+pname+ext;  
  if(pname!="CityFacts")
    document.location.href="index.htm?hotelId="+Id+"&page="+pname; 
    else
     document.location.href=Id+"_"+pname+ext;
}

function clickforlocation()
 {
 document.location.href="index.htm?page=location";
 
 }