function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showMenu() {
    var x = findPosX(document.getElementById('bookNowURL'))-120;
    var y = findPosY(document.getElementById('bookNowURL'))-150;

    //r = document.getElementById('ratesParent');
    r = document.getElementById('resFormContainer');
    r.style.top = y+'px';
    r.style.left = x+'px';

    formOutMenu.showMenu('resForm');
}

function showdiv(sid, id) {
    var so = document.getElementById(sid);
    var o = document.getElementById(id);

    if (o != null) {
        var x = findPosX(so); 
        var y = findPosY(so)+60; 

        o.style.left = x+'px';
        o.style.top = y+'px';
        o.style.display = "";
    }
}

function hidediv(id) {
    var o = document.getElementById(id);
    if (o != null) {
        o.style.display = "none";
    }
}
function upclock(){ 
    var dte = new Date();
    var hrs = dte.getHours();
    var min = dte.getMinutes(); 
    var sec = dte.getSeconds();
    var col = ":";
    var spc = " ";
    var apm;
    
    if (12 < hrs) { 
    apm="pm";
    hrs-=12;
    }

    else {
    apm="am";
    }

    if (hrs == 0) hrs=12;
    if (min<=9) min="0"+min;
    if (sec<=9) sec="0"+sec;
    
    if(navigator.appName == "Netscape") {
    document.clock.document.write(hrs+col+min+col+sec+spc+apm);
    document.clock.document.close();
    }

    if (navigator.appVersion.indexOf("MSIE") != -1){
    clock.innerHTML = hrs+col+min+col+sec+spc+apm;
    }
} 

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function swapInnerHtml(id,newHtml) {
    var obj = document.getElementById(id);
    obj.innerHTML = newHtml;
}


//use this to reload form security image - securityCodeDiv is div id
var cakeGlobalSecurityImageSeq = Math.floor(Math.random()*50000);
function reloadSecurityCode(style) {
    var obj = document.getElementById('securityCodeDiv');
    var txt = '<img src="/getImage/formCode/180/35/' + cakeGlobalSecurityImageSeq;
        txt+= '/code.gif" title="please type text from this image to field below" alt="" style="'+style+'">';
    obj.innerHTML = txt;
    cakeGlobalSecurityImageSeq++;
}


/* Get date element part */
function getDatePart(form, fieldName, part){
    var field = 'data[form][VALUE_'+fieldName+'_'+part+']';
    return parseInt(document.forms[form][field].value);
}

/* Set date element part */
function setDatePart(form, fieldName, part, newValue){
    var field = 'data[form][VALUE_'+fieldName+'_'+part+']';
    document.forms[form][field].value = newValue;
}

/* Copy date fields from one element to other */
function cmsSetDateTo(form, fieldTo, fieldFrom){
    setDatePart(form, fieldTo, 'year',  getDatePart(form, fieldFrom, 'year'));
    setDatePart(form, fieldTo, 'month', getDatePart(form, fieldFrom, 'month'));
    setDatePart(form, fieldTo, 'day',   getDatePart(form, fieldFrom, 'day'));
}

/* If date in second arg is less than date in third sets value of the smaller to be equal */
function cmsSetDateNoLess(form, fieldTo, fieldFrom){
    var fromYV  = getDatePart(form, fieldFrom, 'year');
    var fromMV  = getDatePart(form, fieldFrom, 'month');
    var fromDV  = getDatePart(form, fieldFrom, 'day');
    var toYV    = getDatePart(form, fieldTo, 'year');
    var toMV    = getDatePart(form, fieldTo, 'month');
    var toDV    = getDatePart(form, fieldTo, 'day');
    var wrong = false;

    if(toYV < fromYV){
        //check year
        wrong = true;
    } else {
        //check month if same year
        if(toYV == fromYV && toMV < fromMV){
            wrong = true;
        }else{
            //check day if year and month the same
            if(toYV == fromYV && toMV == fromMV && toDV < fromDV){
                wrong = true;
            }
        }
    }

    if( wrong == true ){
        cmsSetDateTo(form, fieldTo, fieldFrom);
    }
}

function show_popup(what, w, h)
{
        w=window.open(what,"Image","width=" + w + ",height=" + h + ",scrollbars=YES,resizable=YES",1);
}




function swapInnerHtml(id,newHtml) {
    var obj = document.getElementById(id);
    obj.innerHTML = newHtml;
}

function show_popup(what, w, h)
{
        w=window.open(what,"Image","width=" + w + ",height=" + h + ",scrollbars=YES,resizable=YES",1);
}

/*function floating(iX,iY,id){
    var L=dD.getElementById?dD.getElementById(id):dD.all?dD.all[id]:dD.layers[id];              
    this[id+'O']=L;if(dD.layers)L.style=L;L.nX=L.iX=iX;L.nY=L.iY=iY;
    L.P=function(x,y){this.style.left=x+px;this.style.top=y+px;};L.Fm=function(){var pX, pY;    
    pX=(this.iX >=0)?0:nn?innerWidth:nn&&dH.clientWidth?dH.clientWidth:dB.clientWidth;  
    pY=nn?pageYOffset:nn&&dH.scrollTop?dH.scrollTop:dB.scrollTop;       
    if(this.iY<0)pY+=nn?innerHeight:nn&&dH.clientHeight?dH.clientHeight:dB.clientHeight;        
    this.nX+=.1*(pX+this.iX-this.nX);this.nY+=.1*(pY+this.iY-this.nY);this.P(this.nX,this.nY);
    setTimeout(this.id+'O.Fm()',63);};
    return L;
}


function closefl(o){
        var o = document.getElementById(o);
        o.style.display = 'none';
}
*/

//use this to reload form security image - securityCodeDiv is div id
var cakeGlobalSecurityImageSeq = Math.floor(Math.random()*50000);
function reloadSecurityCode(style) {
    var obj = document.getElementById('securityCodeDiv');
    var txt = '<img src="/getImage/formCode/180/35/' + cakeGlobalSecurityImageSeq;
        txt+= '/code.gif" title="please type text from this image to field below" alt="" style="'+style+'">';
    obj.innerHTML = txt;
    cakeGlobalSecurityImageSeq++;
}

function floating(iX,iY,id){
    var L=dD.getElementById?dD.getElementById(id):dD.all?dD.all[id]:dD.layers[id];              
    this[id+'O']=L;if(dD.layers)L.style=L;L.nX=L.iX=iX;L.nY=L.iY=iY;
    L.P=function(x,y){this.style.left=x+px;this.style.top=y+px;};L.Fm=function(){var pX, pY;    
    pX=(this.iX >=0)?0:nn?innerWidth:nn&&dH.clientWidth?dH.clientWidth:dB.clientWidth;  
    pY=nn?pageYOffset:nn&&dH.scrollTop?dH.scrollTop:dB.scrollTop;       
    if(this.iY<0)pY+=nn?innerHeight:nn&&dH.clientHeight?dH.clientHeight:dB.clientHeight;        
    this.nX+=.1*(pX+this.iX-this.nX);this.nY+=.1*(pY+this.iY-this.nY);this.P(this.nX,this.nY);
    setTimeout(this.id+'O.Fm()',63);};
    return L;
}

function closefl(o){
        var o = document.getElementById(o);
        o.style.display = 'none';
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function show_image(what, w, h){
    w=window.open(what,"Image","width=" + w + ",height=" + h + ",scrollbars=NO,resizeable=YES",1);
}



var visibleFields = new Array();
function showHideForm(partId, fieldNnumber){
    if(visibleFields[fieldNnumber] && visibleFields[fieldNnumber]==true){
        visibleFields[fieldNnumber] = false;
        new Effect.SlideUp(partId+fieldNnumber, {duration:1});
    }else{
        visibleFields[fieldNnumber] = true;
        new Effect.SlideDown(partId+fieldNnumber, {duration:1});
    }
}
function swapInnerHtml(id,newHtml) {
    var obj = document.getElementById(id);
    obj.innerHTML = newHtml;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
        window.open(theURL,winName,features);
}

function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function showImageDiv(divId, image, className, alt){
    element = document.getElementById(divId);
    element.innerHTML = '<img src="' + image + '" border=0 class="'+className+'" alt="'+alt+'">';
}

function replaceHtml(divId, newHtml){
    element = document.getElementById(divId);
    element.innerHTML = newHtml;
}

//Step 2: Define a "callback" function to process the data returned by the Ajax request:
function replaceDivFromAjax(){
    var myajax=ajaxpack.ajaxobj
    var myfiletype=ajaxpack.filetype
    if (myajax.readyState == 4){
        //if request of file completed
        if (myajax.status==200 || window.location.href.indexOf("http")==-1){
            //if request was successful or running script locally
            if (myfiletype=="txt"){
                replaceHtml("divFromAjax", myajax.responseText);
            }else{
                replaceHtml("divFromAjax", myajax.responseXML);
            }
        }
    }
}


function swapInnerHtml(id,newHtml) {
    var obj = document.getElementById(id);
    obj.innerHTML = newHtml;
}


//use this to reload form security image - securityCodeDiv is div id
var cakeGlobalSecurityImageSeq = Math.floor(Math.random()*50000);
function reloadSecurityCode(style) {
    var obj = document.getElementById('securityCodeDiv');
    var txt = '<img src="/getImage/formCode/180/35/' + cakeGlobalSecurityImageSeq;
        txt+= '/code.gif" title="please type text from this image to field below" alt="" style="'+style+'">';
    obj.innerHTML = txt;
    cakeGlobalSecurityImageSeq++;
}


/* Get date element part */
function getDatePart(form, fieldName, part){
    var field = 'data[form][VALUE_'+fieldName+'_'+part+']';
    return parseInt(document.forms[form][field].value);
}

/* Set date element part */
function setDatePart(form, fieldName, part, newValue){
    var field = 'data[form][VALUE_'+fieldName+'_'+part+']';
    document.forms[form][field].value = newValue;
}

/* Copy date fields from one element to other */
function cmsSetDateTo(form, fieldTo, fieldFrom){
    setDatePart(form, fieldTo, 'year',  getDatePart(form, fieldFrom, 'year'));
    setDatePart(form, fieldTo, 'month', getDatePart(form, fieldFrom, 'month'));
    setDatePart(form, fieldTo, 'day',   getDatePart(form, fieldFrom, 'day'));
}

/* If date in second arg is less than date in third sets value of the smaller to be equal */
function cmsSetDateNoLess(form, fieldTo, fieldFrom){
    var fromYV  = getDatePart(form, fieldFrom, 'year');
    var fromMV  = getDatePart(form, fieldFrom, 'month');
    var fromDV  = getDatePart(form, fieldFrom, 'day');
    var toYV    = getDatePart(form, fieldTo, 'year');
    var toMV    = getDatePart(form, fieldTo, 'month');
    var toDV    = getDatePart(form, fieldTo, 'day');
    var wrong = false;

    if(toYV < fromYV){
        //check year
        wrong = true;
    } else {
        //check month if same year
        if(toYV == fromYV && toMV < fromMV){
            wrong = true;
        }else{
            //check day if year and month the same
            if(toYV == fromYV && toMV == fromMV && toDV < fromDV){
                wrong = true;
            }
        }
    }

    if( wrong == true ){
        cmsSetDateTo(form, fieldTo, fieldFrom);
    }
}


function show_popup(what, w, h)
{
        w=window.open(what,"Image","width=" + w + ",height=" + h + ",scrollbars=YES,resizable=YES",1);
}

