//var backButtonImage="../inc/img/tab/backButton.jpg";
//var nextButtonImage="../inc/img/tab/nextButton.jpg";
//var sendEPostCard="../inc/img/tab/sendPostCard.jpg";
var imageUrlTabber=new Array();
var imageTitleTabber=new Array();
var imageDescriptionTabber=new Array();
var tabStateTabber=[];
var tabNamesTabber=[];
var tabDisplayNamesTabber=[];
var totalTabsTabber;
var totalImagesTabber;
var currentTabTabber;
var oXmlDomTabber;
var xmlObjTabber;
var mainTab;
function init(xmlString, tabImage, width, argMainTab)
{
 mainTab=argMainTab;
 //Add code By Akhilesh for Detection of Browser Date:12*Feb*09
    if(navigator.appName.indexOf("Netscape")!=-1)
    {
        //For Mozilla
        if(window.location.href.indexOf("photoGallery")!= -1)
        {
            if(isIE(navigator.userAgent))
            {
                oXmlDomTabber=createIEXMLDOM();
	            oXmlDomTabber.async=false;
                oXmlDomTabber.loadXML(xmlString);    
               
            }
            else 
            {
                var parser=new DOMParser();
                oXmlDomTabber=parser.parseFromString(xmlString,"text/xml");
            }
        }
        else
        {
                var parser=new DOMParser();
                oXmlDomTabber=parser.parseFromString(xmlString,"text/xml");
       
        }
    }
    else
    { 
        //For IE
        if(navigator.userAgent)
        {
	        oXmlDomTabber=createIEXMLDOM();
	        oXmlDomTabber.async=false;
            oXmlDomTabber.loadXML(xmlString);    
        }
        else
        {
            var parser=new DOMParser();
            oXmlDomTabber=parser.parseFromString(xmlString,"text/xml");
        }
    }   
    //End code By Akhilesh for Detection of Browser Date:12*Feb*09    
    xmlObjTabber=oXmlDomTabber.documentElement;
    totalTabsTabber=xmlObjTabber.childNodes.length;
    for(var count=0;count<totalTabsTabber;count++)
	    tabStateTabber[count]=0;
    currentTabTabber=0;
    for(var count=0;count<totalTabsTabber;count++)
    {
	    tabNamesTabber[count]=xmlObjTabber.childNodes[count].nodeName;
	    if(xmlObjTabber.childNodes[count].childNodes[0].firstChild==undefined)
	        tabDisplayNamesTabber[count]="";
	    else
	        tabDisplayNamesTabber[count]=xmlObjTabber.childNodes[count].childNodes[0].firstChild.nodeValue;
    }
    multiTabObj=new MultiTab();
    multiTabObj.init(OnTabClick, argMainTab, tabImage, width);
    for(var count=0;count<totalTabsTabber;count++)
    {
	    multiTabObj.addTab(tabDisplayNamesTabber[count], argMainTab+"_TabContent"+(count+1));
    }
    if(activeTabName!="")
    {
	    for(var activeIndex=0;activeIndex<totalTabsTabber;activeIndex++)
	    {
		    if(tabDisplayNamesTabber[activeIndex]==activeTabName)
			    break;
	    }
	    if(activeIndex!=totalTabsTabber)
	    {
	        currentTabTabber=activeIndex;
	        multiTabObj.ActivateTab(activeTabName);
	    }
    }
    else
    {
        for(var tabIndex=0;tabIndex<totalTabsTabber;tabIndex++)
        {
            var index=0;
            imageTitleTabber[tabIndex]=new Array();
            imageUrlTabber[tabIndex]=new Array();
            imageDescriptionTabber[tabIndex]=new Array();
            for(var childIndex=0;childIndex<xmlObjTabber.childNodes[tabIndex].childNodes.length-1;childIndex++,index++)
            {
	            if(xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[0].firstChild==undefined &&
		            xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[1].firstChild==undefined &&
		            xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[2].firstChild==undefined)
		            continue;
		        if(xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[0].firstChild!=undefined)
	                imageTitleTabber[tabIndex][index]=xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[0].firstChild.nodeValue;
		        if(xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[1].firstChild!=undefined)
		        {
		            imageUrlTabber[tabIndex][index]=new Image();
	                imageUrlTabber[tabIndex][index].src=xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[1].firstChild.nodeValue;
	                
	            }
		        if(xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[2].firstChild!=undefined)
    	            imageDescriptionTabber[tabIndex][index]=xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[2].firstChild.nodeValue;
            }
        }
    }
    totalImagesTabber=imageUrlTabber[currentTabTabber].length;
    if(totalImagesTabber==0)
    {
        var contentsTab=document.getElementById("Contents");
        if(contentsTab!=undefined)
        {
            contentsTab.style.display="none";
        }
    }
    else
        refreshImage();
}
/* In Function OnTabClick replace a Index variable with index_Current and add code In Function OnTabClick for photogallery[SlideShow] If you come from
 Main Navigation.i.e.From Main Navigation: Guest Services> Facilitate & Services>> View Photo Gallery.
 */
function OnTabClick(rowIndex, colIndex, tabName) 
{
	var index_Current;
	for(index_Current=0;index_Current<totalTabsTabber;index_Current++)
	{
		if(tabDisplayNamesTabber[index_Current]==tabName)
			break;
	}
	/*imageTitleTabber.splice(0, imageTitleTabber.length);
	imageUrlTabber.splice(0, imageUrlTabber.length);
	imageDescriptionTabber.splice(0, imageDescriptionTabber.length);
    for(var childIndex=0;childIndex<xmlObjTabber.childNodes[index].childNodes.length-1;childIndex++)
    {
	    if(xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[0].firstChild==undefined &&
		    xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[1].firstChild==undefined &&
		    xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[2].firstChild==undefined)
		    continue;
		if(xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[0].firstChild!=undefined)
	        imageTitleTabber[childIndex]=xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[0].firstChild.nodeValue;
		if(xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[1].firstChild!=undefined)
		{
		    imageUrlTabber[childIndex]=new Image();
	        imageUrlTabber[childIndex].src=xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[1].firstChild.nodeValue;
	    }
		if(xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[2].firstChild!=undefined)
    	    imageDescriptionTabber[childIndex]=xmlObjTabber.childNodes[index].childNodes[childIndex+1].childNodes[2].firstChild.nodeValue;
    }*/
    
    // Add Code By Akhilesh Vishwakarma for enable View PhotoGallery[Slide Show] If you Come from Main Navigation
    if(activeTabName!="")
    {
    for(var tabIndex=0;tabIndex<totalTabsTabber;tabIndex++)
        {
            var index=0;
            imageTitleTabber[tabIndex]=new Array();
            imageUrlTabber[tabIndex]=new Array();
            imageDescriptionTabber[tabIndex]=new Array();
            for(var childIndex=0;childIndex<xmlObjTabber.childNodes[tabIndex].childNodes.length-1;childIndex++,index++)
            {
	            if(xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[0].firstChild==undefined &&
		            xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[1].firstChild==undefined &&
		            xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[2].firstChild==undefined)
		            continue;
		        if(xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[0].firstChild!=undefined)
	                imageTitleTabber[tabIndex][index]=xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[0].firstChild.nodeValue;
		        if(xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[1].firstChild!=undefined)
		        {
		            imageUrlTabber[tabIndex][index]=new Image();
	                imageUrlTabber[tabIndex][index].src=xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[1].firstChild.nodeValue;
	                
	            }
		        if(xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[2].firstChild!=undefined)
    	            imageDescriptionTabber[tabIndex][index]=xmlObjTabber.childNodes[tabIndex].childNodes[childIndex+1].childNodes[2].firstChild.nodeValue;
            }
        }
    
    }
     // End Code By Akhilesh Vishwakarma for enable View PhotoGallery[Slide Show] If you Come from Main Navigation
    currentTabTabber=index_Current;
	totalImagesTabber=imageUrlTabber[currentTabTabber].length;
	refreshImage();
}

function PreviousImage()
{
	if(tabStateTabber[currentTabTabber]>0)
	{
		tabStateTabber[currentTabTabber]--;
		refreshImage();
	}
}

function NextImage()
{
	if(tabStateTabber[currentTabTabber]<totalImagesTabber-1)
	{
		tabStateTabber[currentTabTabber]++;
		refreshImage();
	}
}
function EnlargePhotoSlideShowImage(imageHeight,imageWidth)
{
   window.open(imageUrlTabber[currentTabTabber][tabStateTabber[currentTabTabber]].src,null,'left=200, top=100, height='+imageHeight+', width='+imageWidth+', scrollbars=0,menubar=0,status=0,toolbar=0');
}
function SendEPostCard(IsBrand)
{
    
    if(IsBrand=='True')
    {
        var strHotelCode;
        strHotelCode=GetURL_BrandPhotoGallery(imageTitleTabber[currentTabTabber][tabStateTabber[currentTabTabber]]);
        window.open(postCardUrl+"?hotel="+strHotelCode+"&image="+EncodeimageUrlTabber(imageUrlTabber[currentTabTabber][tabStateTabber[currentTabTabber]].src),null,'left=200, top=100, height=480, width= 640, status=yes, resizable= yes, scrollbars= yes, toolbar= yes,location= yes, menubar= yes');
    }
    else if(IsBrand=='False')
    {
        window.open(postCardUrl+"?hotel="+ hotel+"&image="+EncodeimageUrlTabber(imageUrlTabber[currentTabTabber][tabStateTabber[currentTabTabber]].src),null,'left=200, top=100, height=480, width= 640, status=yes, resizable= yes, scrollbars= yes, toolbar= yes,location= yes, menubar= yes');
    }  
    
}
/* Function Created by Bikram to encode Image URL */
function EncodeimageUrlTabber(imageUrlTabber)
{
    var ImagePath=imageUrlTabber;
    EncodedImagePath=new String(ImagePath);
    //alert(EncodedImagePath);
    EncodedImagePath=replaceAll(EncodedImagePath,"/","*sl*");
    //alert(EncodedImagePath);
    return EncodedImagePath;
}
/* Function Created by Bikram */
function replaceAll( ImagePath, from, to )
 {
    var idx = ImagePath.indexOf( from );
    while ( idx > -1 ) {
        ImagePath = ImagePath.replace( from, to ); 
        idx = ImagePath.indexOf( from );
    }

    return ImagePath;
}

/*function OnChange(dropDown)
{
	var currentTabTabberElement=document.getElementById("TabContent"+(currentTabTabber+1));
	currentTabTabberElement.style.display="none";
	var mainDiv=document.getElementById("Contents");
	xmlObj=oXmlDom.documentElement;
	var hotelIndex=0;
	for(var count=0;count<xmlObj.childNodes.length;count++)
	{
		if(xmlObj.childNodes[count].childNodes[0].firstChild.nodeValue==dropDown.options[dropDown.selectedIndex].value)
			break;
		hotelIndex++;
	}	
	totalTabsTabber=xmlObj.childNodes[hotelIndex].childNodes.length-1;
	for(var count=0;count<totalTabsTabber;count++)
		tabStateTabber[count]=0;
	for(var count=0;count<totalTabsTabber;count++)
	{
		tabNamesTabber[count]=xmlObj.childNodes[hotelIndex].childNodes[count+1].nodeName;
		tabDisplayNamesTabber[count]=xmlObj.childNodes[hotelIndex].childNodes[count+1].childNodes[0].firstChild.nodeValue;
	}
	
	strHtml="";
	for(var count=0;count<xmlObj.childNodes[hotelIndex].childNodes.length-1;count++)
	{	
		strHtml=strHtml+"<div id=\"TabContent"+(count+1)+"\">";
		var tabId=xmlObj.childNodes[hotelIndex].childNodes[count+1].nodeName;		
		strHtml=strHtml+"<img height=\"350\" width=\"500\" class=\"SSSlideShowImage\" id=\"Image"+tabId+"\">";
		strHtml=strHtml+"<br />";
		strHtml=strHtml+"<table class=\"SSSlideShowPanel\" width=\"100%\"><tr><td colspan=\"1\" class=\"SSSlideShowPanelButtonSpace\"></td><td colspan=\"1\"><a href=\"javascript:void(null)\" onclick=\"PreviousImage();\" style=\"float:left\"><img border=\"0\" src=\""+backButtonImage+"\"></a><div class=\"SSSlideShowStatus\" id=\"slideShowStatusControl"+tabId+"\" style=\"float:left\">&nbsp;&nbsp;1/22&nbsp;&nbsp;</div><a href=\"javascript:void(null)\" onclick=\"NextImage();\" style=\"float:left\"><img border=\"0\" src=\""+nextButtonImage+"\"></a></td><td colspan=\"1\"><a href=\"javascript:void(null)\" onclick=\"PreviousImage();\"  class=\"SSSlideShowECard\"><img border=\"0\" src=\""+sendEPostCard+"\"></a></td></tr></table><br />";
		strHtml=strHtml+"<strong><div class=\"SSSlideShowTitle\" id=\"Title"+tabId+"\"></div></strong>";
		strHtml=strHtml+"<div class=\"SSSlideShowDescription\" id=\"Description"+tabId+"\"></div>";
		strHtml=strHtml+"</div>";
	}
	mainDiv.innerHTML=strHtml;
	multiTabObj.clearTabs();
	for(var count=0;count<totalTabsTabber;count++)
	{
		multiTabObj.addTab(tabDisplayNamesTabber[count], "TabContent"+(count+1));
	}
	currentTabTabber=0;
	currentHotel=hotelIndex;
	imageTitleTabber.splice(0, imageTitleTabber.length);
	imageUrlTabber.splice(0, imageUrlTabber.length);
	imageDescriptionTabber.splice(0, imageDescriptionTabber.length);
	for(var childIndex=0;childIndex<xmlObj.childNodes[currentHotel].childNodes[1].childNodes.length-1;childIndex++,index++)
	{
		if(xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[0].firstChild==undefined &&
			xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[1].firstChild==undefined &&
			xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[2].firstChild==undefined)
			continue;
		if(xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[0].firstChild!=undefined)
			imageTitleTabber[childIndex]=xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[0].firstChild.nodeValue;
		if(xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[1].firstChild!=undefined)
			imageUrlTabber[childIndex]=xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[1].firstChild.nodeValue;
		if(xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[2].firstChild!=undefined)
			imageDescriptionTabber[childIndex]=xmlObj.childNodes[currentHotel].childNodes[1].childNodes[childIndex+1].childNodes[2].firstChild.nodeValue;
	}
	totalImagesTabber=imageUrlTabber.length;
	refreshImage();
}*/

function refreshImage()
{
	var imageTag=document.getElementById(mainTab+"_Image"+tabNamesTabber[currentTabTabber]);
	if(imageUrlTabber[currentTabTabber][tabStateTabber[currentTabTabber]]!=undefined)
		imageTag.src=imageUrlTabber[currentTabTabber][tabStateTabber[currentTabTabber]].src;
	else
		imageTag.src="";
	var titleTag=document.getElementById(mainTab+"_Title"+tabNamesTabber[currentTabTabber]);
	if(imageTitleTabber[currentTabTabber][tabStateTabber[currentTabTabber]]!=undefined)
	{
		titleTag.innerHTML=imageTitleTabber[currentTabTabber][tabStateTabber[currentTabTabber]];
		titleTag.style.display="";
    }
	else
	    titleTag.style.display="none";
	var textTag=document.getElementById(mainTab+"_Description"+tabNamesTabber[currentTabTabber]);
	if(imageDescriptionTabber[currentTabTabber][tabStateTabber[currentTabTabber]]!=undefined)
	{
        var brCount=parseInt(2-(imageDescriptionTabber[currentTabTabber][tabStateTabber[currentTabTabber]].length/85));
		textTag.innerHTML=imageDescriptionTabber[currentTabTabber][tabStateTabber[currentTabTabber]];
		for(var count=0;count<=brCount;count++)
		    textTag.innerHTML=textTag.innerHTML+"<br />";
    }
	else
		textTag.innerHTML="<br /><br />";
	var status=document.getElementById("slideShowStatusControl"+tabNamesTabber[currentTabTabber]);
	if(status!=null)
	{
       status.innerHTML="&nbsp;&nbsp;"+(tabStateTabber[currentTabTabber]+1)+"/"+totalImagesTabber+"&nbsp;&nbsp;";
   }
}

function createIEXMLDOM()
{
	var arrSignatures=["MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", 			
			"MSXML2.DOMDocument", "Microsoft.XmlDom"];
	for(var i=0;i<arrSignatures.length; i++)
	{
		try
		{
			var oXmlDomTabber=new ActiveXObject(arrSignatures[i]);
			return oXmlDomTabber;
		}
		catch(oError)
		{	}	
	}
}

function isOpera(sUserAgent)
{
	return sUserAgent.indexOf("Opera") > -1;
}

function isSafari(sUserAgent)
{
	if(isKHTML(sUserAgent))
		return sUserAgent.indexOf("AppleWebKit") > -1;
}

function isKHTML(sUserAgent)
{
	return sUserAgent.indexOf("KHTML") > -1 || sUserAgent.indexOf("Konqueror") > -1 || sUserAgent.indexOf("AppleWebKit") > -1;
}

function isIE(sUserAgent)
{
	return sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1 && !isOpera(sUserAgent);
}

function isFirefox(sUserAgent)
{
	return sUserAgent.indexOf("Firefox") > -1;
}

/*var selectBox=document.getElementById("hotelList");
xmlObj=oXmlDom.documentElement;
for(var count=0;count<xmlObj.childNodes.length;count++)
{
	var option1=document.createElement('option');
	option1.value=xmlObj.childNodes[count].childNodes[0].firstChild.nodeValue;
	option1.text=xmlObj.childNodes[count].childNodes[0].firstChild.nodeValue;
	selectBox.options.add(option1);		
}*/


// Add Code By Akhilesh to get Brand Photo gallery Url,Fetch the HotelCode from Hotelnames.xml and send it to method:SendEPostCard(IsBrand)
function GetURL_BrandPhotoGallery(strHotelFullName)
{
       var oXmlDomHotel;
       var xmlObjHotel;
        if(isIE(navigator.userAgent))
        {
	        oXmlDomHotel=createIEXMLDOM();
	        oXmlDomHotel.async=false;
            oXmlDomHotel.load('../inc/xml/hotelnames.xml');    
        }
        else
        {
            var oXmlDomHotel=document.implementation.createDocument("", "", null);
            oXmlDomHotel.async=false;
            oXmlDomHotel.load('../inc/xml/hotelnames.xml');
        }
        xmlObjHotel=oXmlDomHotel.documentElement;
        
        for(var i=0;i<xmlObjHotel.childNodes.length;i++)
            {
                if(xmlObjHotel.childNodes[i].nodeName=='h')
                {
                    if((xmlObjHotel.childNodes[i].attributes[2].nodeValue == strHotelFullName) )
	                {    var getHotelCode;
	                    getHotelCode= xmlObjReserv.childNodes[i].attributes[3].nodeValue;
	                    return getHotelCode;

	                }
                }
            }
}
// End Code By Akhilesh 