/* ************************************** */
/* blkEditorialTheme functions            */
/* ************************************** */

// Flash detection script.
// Retrieves the version of the Flash Player - if they have less than the minimum required player, it redirects.
// If they have the correct version of the player, it stays put and plays the movie...

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

/* ---- detection functions ---- */
function getFlashVersion() {
   var pvArr = new Array ();
   pvArr[0] = 0;
   pvArr[1] = 0;
   pvArr[2] = 0;
   var PlayerVersionVar = new PlayerVersion(pvArr);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersionVar = new PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (window.ActiveXObject){
	   try {
   	   var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
   		PlayerVersionVar = new PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
	   } catch (e) {}
	}
	return PlayerVersionVar;
}
function PlayerVersion(arrVersion){
	this.major = parseInt(arrVersion[0]) || 0;
	this.minor = parseInt(arrVersion[1]) || 0;
	this.rev = parseInt(arrVersion[2]) || 0;
}
function versionIsValid (fv){
    if (fv.major > 5) return true;
	return false;
}


function hideFlash() {
    var supportsFlash = versionIsValid(getFlashVersion());


    if (( document.getElementById("flash") != null) && supportsFlash == false) {
        objDiv = (document.getElementById) ? document.getElementById("flash").style : document.layers["flash"];

        // hide the div tag
        objDiv.display = "none";
        objDiv.visibility = (document.getElementById) ? "hidden" : "hide";

        objDiv = (document.getElementById) ? document.getElementById("theme").style : document.layers["theme"];
        // show the div tag
        objDiv.display = "block";
        objDiv.visibility = "inherit";
    }
}

/* ************************************** */
/* blkEditorialSituation functions        */
/* ************************************** */
var extraLeftPos = -4;
var extraTopPos = -130;
var openSituationDiv = null;

function showSituationDiv(idx) {
    topDiv = getDiv('situation0');
    topDivPostion = getPositions(topDiv);

    divId = 'situationContent'+idx;
    currentDiv = getDiv(divId);
    currentDiv.style.left = topDivPostion[0]+extraLeftPos + "px";
    currentDiv.style.top = topDivPostion[1]+extraTopPos + "px";
    currentDiv.style.position = 'absolute';
    currentDiv.style.zIndex = 999;

    display(divId, true);

    openSituationDiv = divId;
}

function closeSituationDiv() {
    if (openSituationDiv) {
        display(openSituationDiv, false);
        openSituationDivs = null;
    }
}

function getPositions(divObj) {
    var xPos = 0;
    var yPos = 0;
    if (divObj.offsetParent) {
        while (divObj.offsetParent) {
            xPos += divObj.offsetLeft;
            yPos += divObj.offsetTop;
            divObj = divObj.offsetParent;
        }
    } else if (divObj.x && divObj.y) {
        xPos += divObj.x;
        yPos += divObj.y;
    }

    return new Array(xPos, yPos);
}


/* ************************************** */
/* blkEditorialTopList functions          */
/* ************************************** */
function displayDestinations(puffFormId){
    selBox = document.forms["puffForm_" + puffFormId].departures;
    if (selBox) {
        for (i=0; i < selBox.options.length; i++){
            divId = "dest_div_" + i + "_" + puffFormId;
            displayType = (i == selBox.options.selectedIndex ? "block" : "none");
            if (document.getElementById(divId) != null){
                document.getElementById(divId).style.display = displayType;
            }

            divIdPack = "dest_div_package_" + i + "_" + puffFormId;
            displayTypePack = (i == selBox.options.selectedIndex ? "block" : "none");
            if (document.getElementById(divIdPack) != null){
                document.getElementById(divIdPack).style.display = displayTypePack;
            }
        }
    }
}

function addDepartures (textValue, puffFormId ){
    selBox = document.forms["puffForm_" + puffFormId].departures;
    idx = (selBox.options ? selBox.options.length : 0);
    selBox.options[idx] = new Option();
    selBox.options[idx].value = idx-1;
    selBox.options[idx].text = textValue;
}

function visibility (noOfDest, puffFormId){
    if (noOfDest < 2) {
        if (document.all && document.all["selBoxDiv_" + puffFormId]) {
            document.all["selBoxDiv_" + puffFormId].style.visibility = 'hidden';
            document.all["selBoxDiv_" + puffFormId].style.display = 'none';
        } else if (document.getElementById && document.getElementById("selBoxDiv_" + puffFormId)) {
            document.getElementById("selBoxDiv_" + puffFormId).style.visibility = 'hidden';
            document.getElementById("selBoxDiv_" + puffFormId).style.display = 'none';
        }
    }
}

/* ************************************** */
/* blkHotelOffers functions               */
/* ************************************** */
function selectDestinationTabs(destId){
    inTabDestinationIndex = document.forms['hotelpuff'].cboHotelDestination.value;
    for (i=0;i<destId+1;i++){
    	if (!getDiv('tabdestination'+i))
    		continue;

    	display('tabdestination'+i, (i == inTabDestinationIndex));
    }
}

function selectTab (inDest,inTab,path){
    for (i=0;i<3;i++){
        if (i == inTab){
            if (( document.getElementById('tab'+inDest+'0') != null ) ) {
                document.getElementById(('tabHotelFold'+inDest)+i).className = "hotel-menu-links-current";
                document.getElementById('tabcontent'+inDest+i).style.visibility = "visible";
                document.getElementById('tabcontent'+inDest+i).style.display = "block";
            }
        } else {
            if (( document.getElementById('tab'+inDest+'0') != null ) ) {
                document.getElementById(('tabHotelFold'+inDest)+i).className = "hotel-menu-links";
                document.getElementById('tabcontent'+inDest+i).style.visibility = "hidden";
                document.getElementById('tabcontent'+inDest+i).style.display = "none";
            }
        }
    }
}

/* ************************************** */
/* blkEvents functions                    */
/* ************************************** */
function showEvents(listLength) {
    // close all event layers
    for (i = 0; i < listLength; i++) {
        if (( document.getElementById("event" + i) != null ) ) {
            objDiv = (document.getElementById) ? document.getElementById("event" + i).style : document.layers["event" + i];

            // hide the div tag
            objDiv.display = "none";
            objDiv.visibility = (document.getElementById) ? "hidden" : "hide";
        } // end if
    }
    // show current event layar
    currentEvent = document.events['event-selector'].value;
    if (( document.getElementById(currentEvent) != null ) ) {
            objDiv = (document.getElementById) ? document.getElementById(currentEvent).style : document.layers[currentEvent];

            // show the div tag
            objDiv.display = "block";
            objDiv.visibility = "inherit";
    }
}


/* ************************************** */
/* addTraveller functions                 */
/* ************************************** */
function defaultEventDisable(evt) {
    if (isIE){
        evt.returnValue=false;
    } else {
        evt.preventDefault();
        return false;
    }
}