// JScript File

function popupWin(siteLink)
{
    window.open(siteLink,'voapp','status=1, fullscreen=yes, resizable=yes,scrollbars=yes, titlebar=yes');
}

function openNewWindow(url,winName,winFeatures)
{
    window.open(url,winName,winFeatures);
}

function printpreview()
{
    var OLECMDID = 7;
    /* OLECMDID values:
    * 6 - print
    * 7 - print preview
    * 1 - open window
    * 4 - Save As
    */
    var PROMPT = 1; // 2 DONTPROMPTUSER
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';

    //if (navigator.appName == "Microsoft Internet Explorer")
    try
    {
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        WebBrowser1.ExecWB(OLECMDID, PROMPT);
        WebBrowser1.outerHTML = "";
    }
    catch (e) { window.print(); }

}

// Auto resize left & right column height
function ResizeColumns()
{
     ResizePageBannerHeight();

     //use x.js script to get the div height
     var rHeight = xHeight("RightColumn");
     var lHeight = xHeight("LeftColumn");

     //set fixed height for Price Table in Prices Page
     if ( xHeight("PricePageTable")>0 && xHeight("PricePageTable") < 490 ) 
     { 
        lHeight+=510; 
     }
     else if ( xHeight("PricePageTable") >= 490 ) { lHeight+=150; }

     //set fixed height for location selector panel in location main/city/country and location detail Page
     if ( xHeight("LocSelectorInfoPanel") > 0 && xHeight("LocSelectorInfoPanel") < 100  ) 
     { 
        lHeight+=100; 
     }
     else if ( xHeight("LocSelectorInfoPanel") >= 100 ) { lHeight+=30; }
     
     if ( xHeight("ContactUsForm") > 0 ) { lHeight+=180; }
     if ( xHeight("BookTourForm") > 0 ) { lHeight+=170; }
     if ( xHeight("MyEnquiryForm") > 0 ){ lHeight+=180; }
     
     var maxHeight = Math.max(rHeight, lHeight);
     
     //add rhs bottom padding
     if (rHeight > lHeight) { maxHeight +=10; }
       
     xHeight("RightColumn",maxHeight);
     xHeight("LeftColumn",maxHeight);
}

// Auto resize Header Language Bar Width
function ResizeHeaderLangBarWidth()
{
     var langBarWidth = xWidth("DefaultLangTitle") + xWidth("DomainLangBar");
     var domainLangListWidth = xWidth("LangList");

     var maxWidth = Math.max(langBarWidth, domainLangListWidth);

     xWidth("LangList",maxWidth);
     xWidth("DomainSwithBarModule",maxWidth);
  
}

function showDomainLang(isVisible)
{
    var langPnl = document.getElementById("plLang");

    if (isVisible == false)
    {
        langPnl.style.display="none";
    }
    else
    {
        ResizeHeaderLangBarWidth();
                
        if (langPnl.style.display == "none") { langPnl.style.display=""; }
        else { langPnl.style.display="none"; }
    }

}

// Resize rotation box height
function ResizeRotateBoxHeight(id)
{
    //get all rotate box ads
    var boxList = getelementsbyPrefix(id,document.documentElement);
    var maxH = xHeight(id+"0");

    //get max height
    for(var i=0;i<boxList.length;i++)
    {
      maxH = Math.max(xHeight(id+i), maxH);
    }
    //set each box with the max height
    for(var i=0;i<boxList.length;i++)
    {
      xHeight(id+i, maxH);   
    }
    xHeight("RotateMainBox",maxH); 

}

function ResizePageBannerHeight()
{
    // Page Banner min-height 117px
    // BannerLeft - use in child Tab,location detail page
    // BannerSpan - vo/so index page
    // BannerContent - country/city/location main page
     var maxH = Math.max(xHeight("BannerLeft"), xHeight("BannerSpan"));
     maxH = Math.max(xHeight("BannerContent"), maxH);
     maxH = Math.max(xHeight("PageMainBanner"), maxH);

     xHeight("PageMainBanner",maxH);
  
}

function backToParent(url, close)
{
	self.opener.location = url;
	if(close) self.close();
}

// format the GreyBox caption
function formatGBCaption(caption)
{
    // replace escaped apostrophes with real apostrophes
    return caption.replace("&apos", "'")
}

// customise greybox (without loading image)
GB_myShow = function(caption, url, height, width, callback_fn) {
    caption = formatGBCaption(caption)
    var options = {
        caption: caption,
        height: height || 500,
        width: width || 500,
        fullscreen: false,
        show_loading: false,
        center_win:true,
        callback_fn: callback_fn
    }
    var win = new GB_Window(options);
    return win.show(url);
}
// Virtual Tour greybox
GB_showVT = function(caption, url, height, width, callback_fn) {
    caption = formatGBCaption(caption)
    var options = {
        caption: caption,
        height: height || 495,
        width: width || 470,
        fullscreen: false,
        show_loading: false,
        center_win:false,
        callback_fn: callback_fn
    }
    var win = new GB_Window(options);
    return win.show(url);
}

// Virtual Office Video greybox
GB_showVideo = function(caption, url, height, width, callback_fn) {
    caption = formatGBCaption(caption)
    var options = {
        caption: caption,
        height: height || 500,
        width: width || 583,
        fullscreen: false,
        show_loading: false,
        center_win:false,
        callback_fn: callback_fn
    }
    var win = new GB_Window(options);
    return win.show(url);
}

// Dynamic Heights
function addHiddenBoxHeight(id)
{
    var currHeight = xHeight("LeftColumn") + xHeight(id);
    xHeight("RightColumn",currHeight);
    xHeight("LeftColumn",currHeight);
}
function removeHiddenBoxHeight(id)
{
    var currHeight = xHeight("LeftColumn") - xHeight(id);
    xHeight("RightColumn",currHeight);
    xHeight("LeftColumn",currHeight);
}

// Show/Hide Hidden Box
function showdetails(seo,showTxt,hideTxt,showAltTag,hideAltTag,dlSiteURL){
    var mainDiv = document.getElementById(seo);
    var hideDiv = document.getElementById("h_"+seo);
    var linkLbl = document.getElementById("lbl_"+seo);
    var imgID = document.getElementById("img_"+seo);

    if(hideDiv.style.display == "none") //show box
    {
        hideDiv.style.display="";
        hideDiv.className="PriceTableHiddenBorder";
        mainDiv.className="PriceTableBorder";
        imgID.src=dlSiteURL+"/icon_hide_small.gif";
        imgID.alt=hideAltTag;
        linkLbl.innerHTML=hideTxt;
                
        addHiddenBoxHeight(hideDiv.id);

    }
    else //hide box
    {
        removeHiddenBoxHeight(hideDiv.id);

        hideDiv.style.display = "none";
        hideDiv.className="";
        mainDiv.className="";
        imgID.src=dlSiteURL+"/icon_show_small.gif";
        imgID.alt=showAltTag;
        linkLbl.innerHTML=showTxt;
                
    }
}
