﻿function f_ButtonSingleClick(button){
    var bRv = true;
    if(button.className.indexOf('half-transparent') >= 0){       
       bRv = false;
    }else{
       PioWeb.setClassName(null, button, null, "half-transparent", true, false);
    }
    return bRv;       
}

function f_ThumbnailWithGallery_1(varName, dir){
   var ar_sImg = window[varName + "__galljsvar"];
   var iIndex = window[varName + "__galljsvar__index"];
   
   iIndex += dir;
   if(iIndex < 0){
      iIndex = ar_sImg.length - 1;
   }else if(iIndex >= ar_sImg.length){
      iIndex = 0; 
   }
   window[varName + "__galljsvar__index"] = iIndex;
   
   document.getElementById(varName + "__gallcont").innerHTML = ar_sImg[iIndex];  
}


function f_VacationMonthView(e, ctl, preffix){
   var ctlCurr = PioWeb.getEventTargetElement(e);
   if(ctlCurr.tagName == "TD"){
       if(ctlCurr.className.indexOf("disabled") < 0){
           var sDayNumber = PioWeb.trim(ctlCurr.innerHTML);
           var sTmp = sDayNumber.replace(/^[\d]+$/,"");
           if(sTmp == ""){
               var sCommand = preffix + "_day_" + sDayNumber;
               sCommand = ctl.getAttribute("evalcommand").replace("{0}", sCommand);
               eval(sCommand);
           }
       }
   }
}


function f_CompareCheckbox(checkbox,hotel){
   var ar_oObjects = new Array();
   var iMax = 4;   
   var sMyType = checkbox.getAttribute("a_CompareCheckbox");
   var colChecks = document.getElementsByTagName("INPUT");
   for(var i = 0; i<colChecks.length; i++){
       var ctlInput = colChecks[i];
       if(ctlInput.type != "checkbox") continue;
       var sType = ctlInput.getAttribute("a_CompareCheckbox");
       if(sType == null) continue;
       if(sType != sMyType) continue;
       if(!ctlInput.checked) continue;
       if(ctlInput != checkbox){             
          ar_oObjects.push(ctlInput);
       }else{
          iMax--;       
       }
   }
   while(ar_oObjects.length > iMax){
       var ctlInput = ar_oObjects.pop();
       ctlInput.checked = false;
   }
   if(checkbox.tagName == "INPUT" && checkbox.checked){
       ar_oObjects.push(checkbox);
   }
   
   var sConf = "";   
   for(var i = 0;i < ar_oObjects.length;i++){
      sConf += ar_oObjects[i].value + ";";
   }
   if(sConf != "")
      sConf = sConf.substr(0, sConf.length - 1);
   else if (hotel != null)
   {
      var i=0;
      var iCtl = 0;
      while( i < colChecks.length && iCtl < 4){
        var ctlInput = colChecks[i++];
        if(ctlInput.type != "checkbox") continue;
        var sType = ctlInput.getAttribute("a_CompareCheckbox");
        if(sType == null) continue;
        if(sType != sMyType) continue;
        sConf += ctlInput.value + ";";
        iCtl++; 
      }
   }
   if(checkbox.tagName == "A"){
       checkbox.href = checkbox.href + "?SVOWSCMPREX=" + sConf;
   }
}//@@@ f_CompareCheckbox()

function f_CompareLink(link,hotel){
   f_CompareCheckbox(link,hotel);
}

var _of_Tooltip = null;
function f_Tooltip_PageLoad(e){
    if(window.opera && document.readyState != "complete") return;
    PioWeb.detachEvent(window, "load", f_Tooltip_PageLoad);
    
    var ctlFly = document.body.appendChild(document.createElement("DIV"));
    ctlFly.style.position = "absolute";
    ctlFly.style.top = "0px";
    ctlFly.style.left = "0px";
    ctlFly.className = "f-tooltip";    
    ctlFly.style.visibility = "hidden";
    ctlFly.style.zIndex = 1000000;
    
    ctlFly.innerHTML = "<table style=\"width:100%;height:100%\"><tr><td>&nbsp;<td></tr></table>";    
           
    _of_Tooltip = new PioWebAbsoluteElementEx("_of_Tooltip",null,ctlFly,"align","align","bottom","top",0,0);
    _of_Tooltip.freeStateObject = ctlFly.childNodes[0].rows[0].cells[0];
    
    PioWeb.attachEvent(document, "mouseover", f_Tooltip_MouseOver);
    PioWeb.attachEvent(document, "mouseout", f_Tooltip_MouseOut);
}
function f_Tooltip_MouseOver(e){
    var ctlSrc = PioWeb.getEventTargetElement(e);
    if(ctlSrc == null) return;
    
    var sToolTip = ctlSrc.getAttribute("f_tooltip");
    
    var bMakeToolTip = false;
    if(sToolTip == null || sToolTip == ""){
         var bToolTip = ctlSrc.getAttribute("f_btooltip");
         if(bToolTip != null && bToolTip != "") bMakeToolTip = true;
    }else{
         bMakeToolTip = true;
    }    
    if(!bMakeToolTip) return;
    
    if(ctlSrc.title && ctlSrc.title != "" && ctlSrc.title != sToolTip){
         sToolTip = ctlSrc.title;
         ctlSrc.setAttribute("f_tooltip", sToolTip);
         ctlSrc.title = "";
    }else if(ctlSrc.alt && ctlSrc.alt != "" && ctlSrc.alt != sToolTip){
         sToolTip = ctlSrc.alt;
         ctlSrc.setAttribute("f_tooltip", sToolTip);
         ctlSrc.alt = "";
    }
    
    if(sToolTip == "") return;
    
    var ctlFly = _of_Tooltip.freeStateObject; //_of_Tooltip.flyObj.childObj;
    ctlFly.innerHTML = sToolTip;
    _of_Tooltip.setPosition(ctlSrc);
    _of_Tooltip.show();              
}
function f_Tooltip_MouseOut(e){
    var ctlSrc = PioWeb.getEventTargetElement(e);
    if(ctlSrc != null){
        var sTitle = ctlSrc.getAttribute("f_tooltip");
        if(sTitle != null && sTitle != ""){
             _of_Tooltip.hide();
        }
    }
}
PioWeb.attachEvent(window, "load", f_Tooltip_PageLoad);


function f_ModalBehaivor_Open(){
   var oHider = PioEffects.getContetsFader();
   oHider.open();
}
function f_ModalBehaivor_Close(){
   var oHider = PioEffects.getContetsFader();
   oHider.close();
}

var f_flyShowServerSiteAlert_PageLoaded_Arr = new Array();
function f_flyShowServerSiteAlert_PageLoaded(sender, args){
    var f_flyShowServerSiteAlert_PageLoaded_HideModal = document.getElementById("f_flyShowServerSiteAlert_PageLoaded_HideModal");
    if(f_flyShowServerSiteAlert_PageLoaded_HideModal != null){
         f_ModalBehaivor_Close(); 
    }

    if(f_flyShowServerSiteAlert_PageLoaded_Arr != null){
        for(var i = 0; i < f_flyShowServerSiteAlert_PageLoaded_Arr.length; i++){        
            f_flyShowServerSiteAlert(f_flyShowServerSiteAlert_PageLoaded_Arr[i]);
        }
    }
}
function f_flyShowServerSiteAlert(id){
   var oFlyWindow = document.getElementById(id);
   if(oFlyWindow == null){
       return false;
   }
   
   f_ModalBehaivor_Open();
   
   oFlyWindow.style.display = "";      
   var iX = (document.body.clientWidth - oFlyWindow.offsetWidth) / 2;
   var iY = (document.body.clientHeight - oFlyWindow.offsetHeight) / 2;   
   if(PioWeb.BrName == "IE"){
      oFlyWindow.style.left = iX + "px";
      oFlyWindow.style.setExpression("top", "document.getElementsByTagName('body')[0].scrollTop+" + iY + "+'px'");            
   }else{
      oFlyWindow.style.left = iX + "px";            
      oFlyWindow.style.top = iY + "px";            
   }
   oFlyWindow.style.visibility = "visible";
}
function f_flyHideServerSiteAlert(id){
   var oFlyWindow = document.getElementById(id);
   if(oFlyWindow == null){
       return false;
   }
   
   oFlyWindow.style.visibility = "hidden";
   oFlyWindow.style.display = "none";       
   
   f_ModalBehaivor_Close();  
}


function f_Changecss(theClass,element,value){
     //Last Updated on May 21, 2008
     //documentation for this script at
     //http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
     var cssRules;
     if (document.all) {
        cssRules = 'rules';
     }
     else if (document.getElementById) {
        cssRules = 'cssRules';
     }
     
     var added = false;
     for (var S = 0; S < document.styleSheets.length; S++){
          for (var R = 0; R < document.styleSheets[S][cssRules].length; R++){
               if (document.styleSheets[S][cssRules][R].selectorText == theClass){
                    if(document.styleSheets[S][cssRules][R].style[element]){
                        document.styleSheets[S][cssRules][R].style[element] = value;
                        added=true;
	                    break;
                    }
               }
          }

         if(!added){
             if(document.styleSheets[S].insertRule){
		          document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
		     }else if (document.styleSheets[S].addRule) {
			        document.styleSheets[S].addRule(theClass,element+': '+value+';');
		     }
         }
     }
}

function gal_Item_Class(previewHtml, thumbnanilHtml, fullsizeHtml, descr){
    this.previewHtml = previewHtml;
    this.thumbnanilHtml = thumbnanilHtml;
    this.fullsizeHtml = fullsizeHtml;
    this.descr = descr;
}

function gal_hdlResizeForFlyWindow(e, forse){
    var pnlFlyWindow = document.getElementById("flyGalWindow");
    if(pnlFlyWindow != null)
        f_hdlResizeForFlyWindow(pnlFlyWindow,forse);
}
function  f_hdlResizeForFlyWindow(pnlFlyWindow,forse)
{
    if(forse || pnlFlyWindow.style.visibility != "hidden"){ 
        var iX = (document.body.clientWidth - pnlFlyWindow.offsetWidth) / 2;
        var iY = (document.body.clientHeight - pnlFlyWindow.offsetHeight) / 2;   
        pnlFlyWindow.style.left = iX + "px";
        if(PioWeb.BrName == "IE"){
            pnlFlyWindow.style.setExpression("top", "document.getElementsByTagName('body')[0].scrollTop+" + iY + "+'px'");            
        }else{
            pnlFlyWindow.style.top = iY + "px";            
        }
    }
}

PioWeb.attachEvent(window, "resize", gal_hdlResizeForFlyWindow);
PioWeb.attachEvent(window, "resize", forum_hdlResizeForFlyWindow);

window.onunload = function() { 
     window["__flash__removeCallback"] = function (instance, name) { 
     return; 
     }; 
} 

function gal_CloseFlyGalery(button){
    gal_lstCurrent = null;
    gal_iIndexCurrent = -1;
    
    var pnlFlyWindow = document.getElementById("flyGalWindow");
    f_ModalBehaivor_Close();
    pnlFlyWindow.style.visibility = "hidden";
    pnlFlyWindow.style.display = "none";       
}

function gal_OpenFlyGallery(button, list){
    if(list == null || list.length == 0) gal_CloseFlyGalery(button); 
    
    gal_lstCurrent = list;
    gal_iIndexCurrent = -1;
    
    var pnlFlyWindow = document.getElementById("flyGalWindow");
    
    f_ModalBehaivor_Open();
    pnlFlyWindow.style.display = "";
    gal_NextPrevFlyGalery(button, 1);
    //gal_hdlResizeForFlyWindow(null, true);
    pnlFlyWindow.style.visibility = "visible";
}
function gal_OpenFlyGallery_MediaTabs(button){    
    var sFullSizeHtml = button.nextSibling.innerHTML;
    var sDescr = button.alt;
    var oItem = new gal_Item_Class(null, null, sFullSizeHtml, sDescr);
    var ar_oItems = new Array();
    ar_oItems[0] = oItem;
    gal_OpenFlyGallery(button, ar_oItems);
}
function gal_OpenFlyGallery_MediaTabs1(button){
    var oButton = button.parentNode.parentNode.rows[0].cells[0].childNodes[0];
    gal_OpenFlyGallery_MediaTabs(oButton);
}

function gal_NextPrevFlyGalery(button, dir){
    if(gal_lstCurrent == null) return;
    
    var iNewIndex = gal_iIndexCurrent + dir;
    if(iNewIndex >= 0 && iNewIndex < gal_lstCurrent.length){
        gal_iIndexCurrent = iNewIndex;
        
        var oGalleryItem = gal_lstCurrent[gal_iIndexCurrent];
        
        var sHtml = oGalleryItem.fullsizeHtml;
        if(sHtml == null || sHtml == ""){
            sHtml = oGalleryItem.previewHtml;
            if(sHtml == null || sHtml == ""){
                sHtml = oGalleryItem.thumbnanilHtml;
            }
        }
        
        //document.getElementById("flyGalPrevNext").style.display = (gal_lstCurrent.length > 1) ? "" : "none";
        document.getElementById("flyGalPrev").style.display = (gal_lstCurrent.length > 1) ? "" : "none";
        document.getElementById("flyGalNext").style.display = (gal_lstCurrent.length > 1) ? "" : "none";
        
        document.getElementById("flyGalPreview").innerHTML = sHtml;
        document.getElementById("flyGalTitle").innerHTML = oGalleryItem.descr;
        
        document.getElementById("flyGalPrev").className = (gal_iIndexCurrent == 0) ? "half-transparent" : "pointer";
        document.getElementById("flyGalNext").className = (gal_iIndexCurrent == gal_lstCurrent.length -1) ? "half-transparent" : "pointer";        
        
        gal_hdlResizeForFlyWindow(null, true);
    }    
}

var gal_lstCurrent = null;
var gal_iIndexCurrent = -1;


function f_OrderPrint()
{
    window.print();
}
function f_doSaveAs(){
	if (document.execCommand && document.all){
		document.execCommand('SaveAs');
	}
	else {
		alert("Save-feature available only from Internet Exlorer 5.x.")
	}
}

var imOb=new Array();
imOb[0]=new Image();imOb[0].src="files/miscs/diagrams/null.gif";
imOb[1]=new Image();imOb[1].src="files/miscs/diagrams/bt1.gif";
imOb[2]=new Image();imOb[2].src="files/miscs/diagrams/bt2.gif";
imOb[3]=new Image();imOb[3].src="files/miscs/diagrams/bt3.gif";
imOb[4]=new Image();imOb[4].src="files/miscs/diagrams/bt4.gif";
imOb[5]=new Image();imOb[5].src="files/miscs/diagrams/bt5.gif";
imOb[6]=new Image();imOb[6].src="files/miscs/diagrams/bt6.gif";
imOb[7]=new Image();imOb[7].src="files/miscs/diagrams/bt7.gif";
imOb[8]=new Image();imOb[8].src="files/miscs/diagrams/bt8.gif";
imOb[9]=new Image();imOb[9].src="files/miscs/diagrams/bt9.gif";

function f_changeDiagram(n)
{
    eval("document.bt.src=imOb[n].src;");
}

function forum_hdlResizeForFlyWindow(e, forse){
    var pnlFlyWindow = document.getElementById("flyPostWindow");
    if (pnlFlyWindow != null)
        f_hdlResizeForFlyWindow(pnlFlyWindow,forse);
}


function f_CloseFly(button,flyWindowId){
    
    var pnlFlyWindow = document.getElementById(flyWindowId);
    f_ModalBehaivor_Close();
    pnlFlyWindow.style.visibility = "hidden";
    pnlFlyWindow.style.display = "none";       
}

function f_OpenFly(modal,flyWindowId){
    var pnlFlyWindow = document.getElementById(flyWindowId);
    if (pnlFlyWindow != null)
    {
        if (modal) f_ModalBehaivor_Open();
        pnlFlyWindow.style.display = "";
        pnlFlyWindow.style.visibility = "visible";
        f_hdlResizeForFlyWindow(pnlFlyWindow,true);
    }
}

var f_flyPostWindow_PageLoaded_Arr = new Array();
function f_flyPostWindow_PageLoaded(sender, args){
    if(f_flyPostWindow_PageLoaded_Arr != null){
        for(var i = 0; i < f_flyPostWindow_PageLoaded_Arr.length; i++){        
            f_flyPostWindow(f_flyPostWindow_PageLoaded_Arr[i]);
        }
    }
}
function f_flyPostWindow(id){
    f_SetRank(document.getElementById(id).value);
}

function f_OpenLoginFly(pnlLogin){
    var pnlFlyWindow = document.getElementById(pnlLogin);
    if (pnlFlyWindow != null)
    {
        var iX = (document.body.clientWidth - pnlFlyWindow.offsetWidth) / 2;
        pnlFlyWindow.style.left = iX + "px";
        
        if(PioWeb.BrName == "IE"){
            pnlFlyWindow.style.setExpression("top", "document.getElementsByTagName('body')[0].scrollTop+10+'px'");            
        }
        
        f_ModalBehaivor_Open();
        
        var hdl = function(){pnlFlyWindow.style.visibility = "visible";}       
        window.setTimeout(hdl, 10);                
    }
}
function f_CloseLoginFly(pnlLogin){
    var pnlFlyWindow = document.getElementById(pnlLogin);
    if (pnlFlyWindow != null)
    {
        f_ModalBehaivor_Close();
        pnlFlyWindow.style.visibility = "hidden";
    }
}
function f_isNumberKey(evt)
{
     var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode > 31 && (charCode < 48 || charCode > 57))
         return false;
     return true;
}
/*   Campaign function and links                                                     */
function f_ParseQueryStringParameter(querystring,param)
{
	var iParamBegin;
	var iParamEnd;
	var sParamValue = "";
	if ((iParamBegin = querystring.indexOf(param + "=")) != -1)
	{
		if ((iParamEnd = querystring.indexOf("&",iParamBegin)) != -1)
			sParamValue = querystring.substring(iParamBegin+param.length+1,iParamEnd);
		else
			sParamValue = querystring.substring(iParamBegin+param.length+1);
	}
	return sParamValue;
}
function f_CampaignSrc(querystring)
{
	var iLink = 0;
	if ((iLink = f_ParseQueryStringParameter(querystring,"t")) != "")
		return arrLinks[iLink];
	else
		return "";	
}		
var arrLinks=new Array();
arrLinks[1] = "http://www.next-in.com/minisites/isrotel/frames/1.html";
arrLinks[2] = "http://www.next-in.com/minisites/isrotel/frames/2.html";
arrLinks[3] = "http://www.next-in.com/minisites/isrotel/frames/3.html";
arrLinks[4] = "http://www.next-in.com/minisites/isrotel/frames/4.html";
arrLinks[5] = "http://www.next-in.com/minisites/isrotel/frames/5.html";
arrLinks[6] = "http://www.next-in.com/minisites/isrotel/frames/6.html";
arrLinks[7] = "http://www.next-in.com/minisites/isrotel/frames/7.html";

/*************************************************************************/
            	    
