﻿// GGO
// 20-Sep-07
function toggleKeyView(el1,el2)
{
    var el1 = document.getElementById(el1);
    var el2 = document.getElementById(el2);
	if (el1.style.display == 'none')
	{
	    el1.style.display = 'block';
	    el2.style.display = 'none';
	}
	else {
	    el1.style.display = 'none';
	    el2.style.display = 'block';
	}
}

function MailME(imagePath, imageID, apID)
{
    self.opener.assignToTB(imagePath, imageID, apID);
    self.close();
    return false;
} 

function UnCheckSelectAll (Id, e)
{
    
    var selectAll = document.getElementById(Id);
   
    if (selectAll.checked==true)
    {
        selectAll.checked = e.checked;
    }     

}

function UnCheckEnableAll(e, season, rate, minstay, inclusion, arrival, depart, panelrates, panelinclusions)
{
       
       var season = document.getElementById(season);
       var rate = document.getElementById(rate);
       var minstay = document.getElementById(minstay);
       var inclusion = document.getElementById(inclusion);
       var arrival = document.getElementById(arrival);
       var depart = document.getElementById(depart);
      
      var panelrates = document.getElementById(panelrates);
      var panelinclusions = document.getElementById(panelinclusions); 
      
       var disable = false;
      
      try
      {
       
       //Check or uncheck the selection options 
       season.checked = e.checked;
       rate.checked = e.checked;
       minstay.checked = e.checked;
       inclusion.checked = e.checked;
       arrival.checked = e.checked;
       depart.checked = e.checked;
      
      if(e.checked == false)
        disable = true;
       
      }
      catch (ex)
      {
        alert(ex.message)
      }
       
}

function actionpage (action, shortdescription, url)
{
    if (action == "bookmark")
    {
        favoris(shortdescription, url);
    }
    else if (action == "signout")
    {
        window.close();
    }
}  

function favoris(shortdescription, url) 
{

    var ua=navigator.userAgent.toLowerCase();
    var isKonq=(ua.indexOf('konqueror')!=-1);
    var isSafari=(ua.indexOf('webkit')!=-1);
    var isMac=(ua.indexOf('mac')!=-1);
    var buttonStr=isMac?'Command/Cmd':'CTRL';
    
    if (window.external)
    {
        try
            {
                window.external.AddFavorite(url, shortdescription); 
            }
        catch (e)
            {
                
            }
        
    } else if (isKonq) {
      alert('You need to press CTRL + B to bookmark our site.');
    } else if (window.opera) {
      void(0); // do nothing here (Opera 7+)
    } else if (window.home || isSafari) { // Firefox, Netscape, Safari, iCab
      //window.sidebar.addPanel(shortdescription,url,""); 
      alert('You need to press '+buttonStr+' + D to bookmark our site.');
    } else if (!window.print || isMac) { // IE5/Mac and Safari 1.0
      alert('You need to press Command/Cmd + D to bookmark our site.');    
    } else {
      alert('In order to bookmark this site you need to do so manually '+
        'through your browser.');
    }

} 

function selfclose()
{
window.close;
} 
 
function isInteger(s)
{   
    var i;
    if ((!(parseInt(s)>=0)) || (parseInt(s) < 0))
        return false;

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (c == '.') return false;
    }
         
    if(s.length == 0)
    {
        return false;
    }
    
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function isDecimal(s)
{
    if (isInteger(s))
        return true;
	else if (s.match(/^\d+\.\d{2}$/ ) )
		return true;
	else
    	return false;
}

// added generic js docount function as it was inline vb code which made it not reusable across pages
function docount(maxlength, xtextbox, xlabel) {
	
	try
	{
		var kC = event.keyCode;
		if(kC == 37 || kC == 38 || kC == 39 || kC == 40 || kC == 16 || kC == 27 || kC == 17) // exclude key pressed like arrows escape and shift
			return;
		//window.status = kC;
	}catch(e){}
	xtextbox = document.getElementById(xtextbox);
	xlabel = document.getElementById(xlabel);
	var charsleft
	charsleft = (maxlength - xtextbox.value.length);
	if(charsleft <= 0){
		alert('Character limit reached. Only ' + maxlength + ' characters will be saved. \n Do not enter any more characters.');
		xlabel.innerHTML = 'Characters remaining: 0';
		xtextbox.value = String(xtextbox.value).substring(0,maxlength);
	}else{
		xlabel.innerHTML = 'Characters remaining: ' + (maxlength - xtextbox.value.length);
	}
}
