$(document).ready(function() {
 
 // Expand Panel
 $("#open").click(function(){
 $("div#panel").slideDown("slow");
 
 }); 
 
 // Collapse Panel
 $("#close").click(function(){
 $("div#panel").slideUp("slow"); 
 }); 
 
 // Switch buttons from "Log In | Register" to "Close Panel" on click
 $("#toggle a").click(function () {
 $("#toggle a").toggle();
 }); 
 
});

window.onerror=function(desc,page,line,chr){
/* alert('JavaScript error occurred! \n'
 +'\nError description: \t'+desc
 +'\nPage address: \t'+page
 +'\nLine number: \t'+line
 );*/
}

$(function(){
 $('a').focus(function(){this.blur();});
 SI.Files.stylizeAll();
 slider.init();
// mc.init();

 $('input.text-default').each(function(){
 $(this).attr('default',$(this).val());
 }).focus(function(){
 if($(this).val()==$(this).attr('default'))
 $(this).val('');
 }).blur(function(){
 if($(this).val()=='')
 $(this).val($(this).attr('default'));
 });

 $('input.text,textarea.text').focus(function(){
 $(this).addClass('textfocus');
 }).blur(function(){
 $(this).removeClass('textfocus');
 });

 var popopenobj=0,popopenaobj=null;
 $('a.popup').click(function(){
 var pid=$(this).attr('rel').split('|')[0],_os=parseInt($(this).attr('rel').split('|')[1]);
 var pobj=$('#'+pid);
 if(!pobj.length)
 return false;
 if(typeof popopenobj=='object' && popopenobj.attr('id')!=pid){
 popopenobj.hide(50);
 $(popopenaobj).parent().removeClass(popopenobj.attr('id').split('-')[1]+'-open');
 popopenobj=null;
 }
 return false;
 });
 $('p.images img').click(function(){
 var newbg=$(this).attr('src').split('bg/bg')[1].split('-thumb')[0];
 $(document.body).css('backgroundImage','url('+_siteRoot+'images/bg/bg'+newbg+'.jpg)');
 
 $(this).parent().find('img').removeClass('on');
 $(this).addClass('on');
 return false;
 });
 $(window).load(function(){
/* $.each(css_ims,function(){(new Image()).src=_siteRoot+'css/images/'+this;});
 $.each(css_cims,function(){
 var css_im=this;
 $.each(['blue','purple','pink','red','grey','green','yellow','orange'],function(){
 (new Image()).src=_siteRoot+'css/'+this+'/'+css_im;
 });
 });*/
 }); 
 $('div.sc-large div.img:has(div.tml)').each(function(){
 $('div.tml',this).hide();
 $(this).append('<a href="#" class="tml_open">&nbsp;</a>').find('a').css({
 left:parseInt($(this).offset().left)+864,top:parseInt($(this).offset().top)+1
 }).click(function(){
 $(this).siblings('div.tml').slideToggle();
 return false;
 }).focus(function(){this.blur();}); 
 });
});
var slider={
 num:-1,
 cur:0,
 cr:[],
 al:null,
 at:10*1000,
 ar:true,
 init:function(){
 if(!slider.data || !slider.data.length)
 return false;

 var d=slider.data;
 slider.num=d.length;
 var pos=Math.floor(Math.random()*1);//slider.num);
 for(var i=0;i<slider.num;i++){
 $('#'+d[i].id).css({left:((i-pos)*1000)});
 $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();">'+(i+1)+'</a>');
 }

 $('img,div#slide-controls',$('div#slide-holder')).fadeIn();
 slider.text(d[pos]);
 slider.on(pos);
 slider.cur=pos;
 window.setTimeout('slider.auto();',slider.at);
 },
 auto:function(){
 if(!slider.ar)
 return false;

 var next=slider.cur+1;
 if(next>=slider.num) next=0;
 slider.slide(next);
 },
 slide:function(pos){
 if(pos<0 || pos>=slider.num || pos==slider.cur)
 return;

 window.clearTimeout(slider.al);
 slider.al=window.setTimeout('slider.auto();',slider.at);

 var d=slider.data;
 for(var i=0;i<slider.num;i++)
 $('#'+d[i].id).stop().animate({left:((i-pos)*1000)},1000,'swing');
 
 slider.on(pos);
 slider.text(d[pos]);
 slider.cur=pos;
 },
 on:function(pos){
 $('#slide-nav a').removeClass('on');
 $('#slide-nav a#slide-link-'+pos).addClass('on');
 },
 text:function(di){
 slider.cr['a']=di.client;
 slider.cr['b']=di.desc;
 slider.ticker('#slide-client span',di.client,0,'a');
 slider.ticker('#slide-desc',di.desc,0,'b');
 },
 ticker:function(el,text,pos,unique){
 if(slider.cr[unique]!=text)
 return false;

 ctext=text.substring(0,pos)+(pos%2?'-':'_');
 $(el).html(ctext);

 if(pos==text.length)
 $(el).html(text);
 else
 window.setTimeout('slider.ticker("'+el+'","'+text+'",'+(pos+1)+',"'+unique+'");',30);
 }
};
// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07
if(!window.SI){var SI={};};
SI.Files={
 htmlClass:'SI-FILES-STYLIZED',
 fileClass:'file',
 wrapClass:'cabinet',
 
 fini:false,
 able:false,
 init:function(){
 this.fini=true;
 },
 stylize:function(elem){
 if(!this.fini){this.init();};
 if(!this.able){return;};
 
 elem.parentNode.file=elem;
 elem.parentNode.onmousemove=function(e){
 if(typeof e=='undefined') e=window.event;
 if(typeof e.pageY=='undefined' && typeof e.clientX=='number' && document.documentElement){
 e.pageX=e.clientX+document.documentElement.scrollLeft;
 e.pageY=e.clientY+document.documentElement.scrollTop;
 };
 var ox=oy=0;
 var elem=this;
 if(elem.offsetParent){
 ox=elem.offsetLeft;
 oy=elem.offsetTop;
 while(elem=elem.offsetParent){
 ox+=elem.offsetLeft;
 oy+=elem.offsetTop;
 };
 };
 };
 },
 stylizeAll:function(){
 if(!this.fini){this.init();};
 if(!this.able){return;};
 }
};
/*!
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 2.04 (11-FEB-2010)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * @author Dave Methvin (http://methvin.com/jquery/jq-corner.html)
 * @author Mike Alsup (http://jquery.malsup.com/corner/)
 */

/**
 * corner() takes a single string argument: $('#myDiv').corner("effect corners width")
 *
 * effect: name of the effect to apply, such as round, bevel, notch, bite, etc (default is round). 
 * corners: one or more of: top, bottom, tr, tl, br, or bl. (default is all corners)
 * width: width of the effect; in the case of rounded corners this is the radius. 
 * specify this value using the px suffix such as 10px (yes, it must be pixels).
 */
;(function($) { 

var ua = navigator.userAgent;
var moz = $.browser.mozilla && /gecko/i.test(ua);
var webkit = $.browser.safari && /Safari\/[5-9]/.test(ua);

var mode = document.documentMode || 0;
var noBottomFold = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);

var expr = $.browser.msie && (function() {
 var div = document.createElement('div');
 try { div.style.setExpression('width','0+0'); div.style.removeExpression('width'); }
 catch(e) { return false; }
 return true;
})();
 
function sz(el, p) { 
 return parseInt($.css(el,p))||0; 
};
function hex2(s) {
 var s = parseInt(s).toString(16);
 return ( s.length < 2 ) ? '0'+s : s;
};
function gpc(node) {
 for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) {
 var v = $.css(node,'backgroundColor');
 if (v == 'rgba(0, 0, 0, 0)')
 continue; // webkit
 if (v.indexOf('rgb') >= 0) { 
 var rgb = v.match(/\d+/g); 
 return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
 }
 if ( v && v != 'transparent' )
 return v;
 }
 return '#ffffff';
};

function getWidth(fx, i, width) {
 switch(fx) {
 case 'round': return Math.round(width*(1-Math.cos(Math.asin(i/width))));
 case 'cool': return Math.round(width*(1+Math.cos(Math.asin(i/width))));
 case 'sharp': return Math.round(width*(1-Math.cos(Math.acos(i/width))));
 case 'bite': return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
 case 'slide': return Math.round(width*(Math.atan2(i,width/i)));
 case 'jut': return Math.round(width*(Math.atan2(width,(width-i-1))));
 case 'curl': return Math.round(width*(Math.atan(i)));
 case 'tear': return Math.round(width*(Math.cos(i)));
 case 'wicked': return Math.round(width*(Math.tan(i)));
 case 'long': return Math.round(width*(Math.sqrt(i)));
 case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
 case 'dogfold':
 case 'dog': return (i&1) ? (i+1) : width;
 case 'dog2': return (i&2) ? (i+1) : width;
 case 'dog3': return (i&3) ? (i+1) : width;
 case 'fray': return (i%2)*width;
 case 'notch': return width; 
 case 'bevelfold':
 case 'bevel': return i+1;
 }
};

$.fn.corner = function(options) {
 // in 1.3+ we can fix mistakes with the ready state
 if (this.length == 0) {
 if (!$.isReady && this.selector) {
 var s = this.selector, c = this.context;
 $(function() {
 $(s,c).corner(options);
 });
 }
 return this;
 }

 return this.each(function(index){
 var $this = $(this);
 var o = [ options || '', $this.attr($.fn.corner.defaults.metaAttr) || ''].join(' ').toLowerCase();
 //var o = (options || $this.attr($.fn.corner.defaults.metaAttr) || '').toLowerCase();
 var keep = /keep/.test(o); // keep borders?
 var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]); // corner color
 var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]); // strip color
 var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
 var re = /round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/;
 var fx = ((o.match(re)||['round'])[0]);
 var fold = /dogfold|bevelfold/.test(o);
 var edges = { T:0, B:1 };
 var opts = {
 TL: /top|tl|left/.test(o), TR: /top|tr|right/.test(o),
 BL: /bottom|bl|left/.test(o), BR: /bottom|br|right/.test(o)
 };
 if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
 opts = { TL:1, TR:1, BL:1, BR:1 };
 
 // support native rounding
 if ($.fn.corner.defaults.useNative && fx == 'round' && (moz || webkit) && !cc && !sc) {
 if (opts.TL)
 $this.css(moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px');
 if (opts.TR)
 $this.css(moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px');
 if (opts.BL)
 $this.css(moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px');
 if (opts.BR)
 $this.css(moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px');
 return;
 }
 
 var strip = document.createElement('div');
 strip.style.overflow = 'hidden';
 strip.style.height = '1px';
 strip.style.backgroundColor = sc || 'transparent';
 strip.style.borderStyle = 'solid';
 
 var pad = {
 T: parseInt($.css(this,'paddingTop'))||0, R: parseInt($.css(this,'paddingRight'))||0,
 B: parseInt($.css(this,'paddingBottom'))||0, L: parseInt($.css(this,'paddingLeft'))||0
 };

 if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE
 if (!keep) this.style.border = 'none';
 strip.style.borderColor = cc || gpc(this.parentNode);
 var cssHeight = $.curCSS(this, 'height');

 for (var j in edges) {
 var bot = edges[j];
 // only add stips if needed
 if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
 strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
 var d = document.createElement('div');
 $(d).addClass('jquery-corner');
 var ds = d.style;

 bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

 if (bot && cssHeight != 'auto') {
 if ($.css(this,'position') == 'static')
 this.style.position = 'relative';
 ds.position = 'absolute';
 ds.bottom = ds.left = ds.padding = ds.margin = '0';
 if (expr)
 ds.setExpression('width', 'this.parentNode.offsetWidth');
 else
 ds.width = '100%';
 }
 else if (!bot && $.browser.msie) {
 if ($.css(this,'position') == 'static')
 this.style.position = 'relative';
 ds.position = 'absolute';
 ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
 
 // fix ie6 problem when blocked element has a border width
 if (expr) {
 var bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
 ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"');
 }
 else
 ds.width = '100%';
 }
 else {
 ds.position = 'relative';
 ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
 (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px'; 
 }

 for (var i=0; i < width; i++) {
 var w = Math.max(0,getWidth(fx,i, width));
 var e = strip.cloneNode(false);
 e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
 bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
 }
 
 if (fold && $.support.boxModel) {
 if (bot && noBottomFold) continue;
 for (var c in opts) {
 if (!opts[c]) continue;
 if (bot && (c == 'TL' || c == 'TR')) continue;
 if (!bot && (c == 'BL' || c == 'BR')) continue;
 
 var common = { position: 'absolute', border: 'none', margin: 0, padding: 0, overflow: 'hidden', backgroundColor: strip.style.borderColor };
 var $horz = $('<div/>').css(common).css({ width: width + 'px', height: '1px' });
 switch(c) {
 case 'TL': $horz.css({ bottom: 0, left: 0 }); break;
 case 'TR': $horz.css({ bottom: 0, right: 0 }); break;
 case 'BL': $horz.css({ top: 0, left: 0 }); break;
 case 'BR': $horz.css({ top: 0, right: 0 }); break;
 }
 d.appendChild($horz[0]);
 
 var $vert = $('<div/>').css(common).css({ top: 0, bottom: 0, width: '1px', height: width + 'px' });
 switch(c) {
 case 'TL': $vert.css({ left: width }); break;
 case 'TR': $vert.css({ right: width }); break;
 case 'BL': $vert.css({ left: width }); break;
 case 'BR': $vert.css({ right: width }); break;
 }
 d.appendChild($vert[0]);
 }
 }
 }
 }
 });
};

$.fn.uncorner = function() { 
 if (moz || webkit)
 this.css(moz ? '-moz-border-radius' : '-webkit-border-radius', 0);
 $('div.jquery-corner', this).remove();
 return this;
};

// expose options
$.fn.corner.defaults = {
 useNative: true, // true if plugin should attempt to use native browser support for border radius rounding
 metaAttr: 'data-corner' // name of meta attribute to use for options
};
 
})(jQuery);


function subMenuTab(obj)
{document.getElementById('navbarMenu').innerHTML=obj}
function goHist(a)
{history.go(a);}
ns=(document.layers)?true:false
ie=(document.all)?true:false
s_userAgent=window.navigator.userAgent
KON=(s_userAgent.indexOf("KHTML")>-1)?1:0;isMac=(navigator.userAgent.indexOf("Mac")>-1)?1:0;isIE=(navigator.userAgent.indexOf("MSIE")>-1)?1:0;isMacIE=(isMac&&isIE)?1:0;function showID(id)
{document.getElementById(id).style.display="block";}
function hideID(id)
{document.getElementById(id).style.display="none";}
function OnLoginSubmitBooking()
{return DoSubmitBooking();return false;}
function DoSubmitBooking()
{if(document.booking_login.username.value=="")
{alert('Please enter your Username');booking_login.username.focus();return false;}
if(document.booking_login.password.value=="")
{alert('Please enter your Password');booking_login.password.focus();return false;}}
function openpopup(url,width,height)
{window.open(url,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+width+',height='+height)}
function add_city_from()
{document.frmSearch.FromCityCode.value=document.frmSearch.id_department_from.value;}
function add_city_to()
{document.frmSearch.ondCityCode.value=document.frmSearch.id_department_to.value;}
function setState(trip){if(trip.value=="1"){document.frmSearch.return2.disabled=true;}
else{document.frmSearch.return2.disabled=false;}}
function doreset()
{document.frmSearch.reset();document.frmSearch.from.value='';document.frmSearch.to.value='';document.frmSearch.depart.value='';document.frmSearch.return2.value='';if(document.frmSearch.flighttype.value=="1"){document.frmSearch.return2.disabled=true;document.frmSearch.returncal.disabled=true;}
else{document.frmSearch.return2.disabled=false;document.frmSearch.returncal.disabled=false;}}

function ajaxReq(url,desid,data){
 var str = '';
 if(data != null && data !='') str = jQuery('#'+data).serialize();
 jQuery.ajax({
 type: "POST",
 url: url,
 data: str,
 success: function(transport){
 if(transport){
 document.getElementById(desid).innerHTML = transport|| "no response text";
 document.getElementById('autoLoading').style.display='none';
 }
 }
 });
};


function FlightSchedules(fid,from,to){
document.getElementById('showSchedules').className="";
ajaxReq('index2.php?act=air_flight&fid='+fid+'&from='+from+'&to='+to,showSchedules,'');}

function submitonce(theform){if(document.all||document.getElementById){for(i=0;i<theform.length;i++){var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset"||tempobj.type.toLowerCase()=="button")
tempobj.disabled=true}}}
function changePage(obj,divID){
 document.getElementById('autoLoading').style.display='block';
 var url = wgServer + obj;
 var desid = divID;
 var data = '';
 ajaxReq(url,desid,data);
}
function postComment(url,idName,vMethod){var str=document.getElementById("guest_comment");document.getElementById('autoLoading').style.display='block';new Ajax.Request(url,{parameters:$(vMethod).serialize(true),onSuccess:function(transport){document.getElementById(idName).innerHTML=transport.responseText||"no response text";document.getElementById('autoLoading').style.display='none';str.value="";}});}
function OnOf(obj){obj=document.getElementById(obj);if(obj.className=="Header")
obj.className="HeaderPlus";else
obj.className="Header";}
function getposOffset(overlay,offsettype){var totaloffset=(offsettype=="left")?overlay.offsetLeft:overlay.offsetTop;var parentEl=overlay.offsetParent;while(parentEl!=null){totaloffset=(offsettype=="left")?totaloffset+parentEl.offsetLeft:totaloffset+parentEl.offsetTop;parentEl=parentEl.offsetParent;}
return totaloffset;}
function overlay(curobj,subobjstr,opt_position){if(document.getElementById){var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")?"block":"none"
var xpos=getposOffset(curobj,"left")+((typeof opt_position!="undefined"&&opt_position.indexOf("right")!=-1)?-(subobj.offsetWidth-curobj.offsetWidth):0)
var ypos=getposOffset(curobj,"top")+((typeof opt_position!="undefined"&&opt_position.indexOf("bottom")!=-1)?curobj.offsetHeight:0)
if(opt_position=='above'){var xpos=getposOffset(curobj,"left")-198;var ypos=getposOffset(curobj,"top")-108;}
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false}
else
return true}
function overlayclose(subobj){document.getElementById(subobj).style.display="none"}
function fetch_object(idname)
{if(document.getElementById)
{return document.getElementById(idname);}
else if(document.all)
{return document.all[idname];}
else if(document.layers)
{return document.layers[idname];}
else
{return null;}}
function fetch_tags(parentobj,tag)
{if(parentobj==null)
{return new Array();}
else if(typeof parentobj.getElementsByTagName!='undefined')
{return parentobj.getElementsByTagName(tag);}
else if(parentobj.all&&parentobj.all.tags)
{return parentobj.all.tags(tag);}
else
{return new Array();}}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
function setnscookie(){var ns=document.getElementById('dict_ns').value;var name='namespace';if(readCookie(name)!=null){eraseCookie(name);createCookie(name,ns,1);}
else{createCookie(name,ns,1);}}
function setDivcCookie(str){var ns=str;var name='namespace';document.getElementById('dict_ns').value=str;if(readCookie(name)!=null){eraseCookie(name);createCookie(name,ns,1);}
else{createCookie(name,ns,1);}}
function fetch_tag_count(parentobj,tag)
{return fetch_tags(parentobj,tag).length;}
function getCookie(Name){var re=new RegExp(Name+"=[^;]+","i");if(document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1]
return null}
function setCookie(name,value,days){var expireDate=new Date()
var expstring=(typeof days!="undefined")?expireDate.setDate(expireDate.getDate()+parseInt(days)):expireDate.setDate(expireDate.getDate()-5)
document.cookie=name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";}
function MM_preloadImages(){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_swapImgRestore(){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_findObj(n,d){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(){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 swapImg(o,obj){o.src=obj;}
function getURLParam(strParamName){var strReturn="";var strHref=window.location.href;if(strHref.indexOf("?")>-1){var strQueryString=strHref.substr(strHref.indexOf("?")).toLowerCase();var aQueryString=strQueryString.split("&");for(var iParam=0;iParam<aQueryString.length;iParam++){if(aQueryString[iParam].indexOf(strParamName+"=")>-1){var aParam=aQueryString[iParam].split("=");strReturn=aParam[1];break;}}}
return strReturn;}
function log_out(confirmation_message)
{var ht=document.getElementsByTagName("html")[0];ht.style.filter="progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";if(confirm(confirmation_message))
{return true;}
else
{ht.style.filter="";return false;}}
function getAllQuery(){var strURL=document.location.href;var query=strURL.substr(strURL.indexOf("#")+1);return query;}
function getQuery(variable){var strURL=document.location.href;var query=strURL.substr(strURL.indexOf("#")+1);var vars=query.split("&");for(var i=0;i<vars.length;i++){var pair=vars[i].split("=");if(pair[0]==variable){return pair[1];}}
return"";}
function gotoTop()
{window.scrollTo(0,0);}
var xmlHttp;function createXMLHttpRequest(){if(window.ActiveXObject){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
else if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest();}}
function changeBoxSearch(id,option,str)
{url='search_from.php?id='+id+'&option='+option;startRequest(url,str);}
function startRequest(strUrl,strDivName){createXMLHttpRequest();xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){document.getElementById(strDivName).innerHTML=xmlHttp.responseText;}}
else
document.getElementById(strDivName).innerHTML="<br><p align=\"center\"><img border=\"0\" src=\"images/loading.gif\"></p><br>";};xmlHttp.open("GET",strUrl,true);xmlHttp.send(null);}
function startPostRequest(strUrl,strDivName){createXMLHttpRequest();xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){document.getElementById(strDivName).innerHTML=xmlHttp.responseText;}}
else
document.getElementById(strDivName).innerHTML="<br><p align=\"center\"><img border=\"0\" src=\"images/loading.gif\"></p><br>";};var strQuery=strUrl.substr(strUrl.indexOf('?')+1,strUrl.length);xmlHttp.open("POST",strUrl,true);xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");xmlHttp.send(strQuery);}
function alignRight(intW,obj){intScreen=window.screen.availWidth;fetch_object(obj).style.left=parseInt(intScreen-intW-50)+"px";}
function ShowHideDiv(obj){if(fetch_object(obj).style.display==''){fetch_object(obj).style.display='none';}
else{fetch_object(obj).style.display='';}}
function out(e){if(e.srcElement.tagName=="DIV"){hideDiv();}}

$(function() {
 $('#gallery a').lightBox();
 $('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
 });
 
$(document).ready(function(){
 $(".livehelp_home").click(function(){
 $("#div_livehelp").toggle("slow");
 });

 $(".test_close").click(function(){
 $("#div_livehelp").hide("slow");
 });
 
 $('.cover').hover(function(){
 $(this).animate({ "top" : "-260px" }, 300)
 // $(".cover").toggle("slow").animate({top:'-260px'},{queue:false,duration:300});
 });
 
});

 $(function () {
 var tabContainers = $('div.tabs > div');
 tabContainers.hide().filter(':first').show();
 
 $('div.tabs ul.tabNavigation a').click(function () {
 tabContainers.hide();
 tabContainers.filter(this.hash).show("slow");
 $('div.tabs ul.tabNavigation a').removeClass('selected');
 $(this).addClass('selected');
 return false;
 }).filter(':first').click();
 });
 
 $(function () {
 // conner plugin
 $("div.conner-plugin").corner();
 $(".bg_conner").corner();
 
 var msie6 = $.browser == 'msie' && $.browser.version < 7;
 
 if (!msie6) {
 var top = $('#toppanel').offset().top - parseFloat($('#toppanel').css('margin-top').replace(/auto/, 0));
 $(window).scroll(function (event) {
 // what the y position of the scroll is
 var y = $(this).scrollTop();
 
 // whether that's below the form
 if (y >= top) {
 // if so, ad the fixed class
 $('#toppanel').addClass('fixed');
 } else {
 // otherwise remove it
 $('#toppanel').removeClass('fixed');
 }
 });
 } 
 });
var numberOfDaysPerMonthHashTable = {'9,2007' :30, '10,2007' :31, '11,2007' :30, '12,2007' :31, '1,2008' :31, '2,2008' :29, '3,2008' :31, '4,2008' :30, '5,2008' :31, '6,2008' :30, '7,2008' :31, '8,2008' :31, '9,2008' :30}
var ControlID = "ctl00_SSearchBox_";
var ErrorAjax = "Your webbrowser does not seem to be AJAX capable. Please reload the page to try again or upgrade your webbrowser";
var ErrorCallBack = "There is a problem retrieving the City or Hotel list from the server. Please reload the page, use an AJAX compatible webbrowser or report this problem with the feedback form link on the bottom of this page.";
var ErrorPast = "Check-in Date is in the past.\nPlease select a new date.";
var ErrorLater = "Check-out Date must be later than Check-in Date.";
var ErrorDays = "Number of Nights must be between 1 and 120. Maximum Number of Nights allowed is 120.\nFor stays of longer than 120 days, please contact our Customer Service Agents.";
var ErrorCountry = "Please Select a Country.";
var ErrorCity = "Please Select a City.";
var More3Rooms = "If you wish to book more than 3 rooms please contact an Online Agent.";
var AdultChildMax = "The number of adults and children selected must not exceed a total of 4 per room.";
var RoomsMoreGuest = "Searching for rooms that hold 4 guests can reduce the search results. You can now: click OK to continue this search. Click cancel to change your search or contact a customer service agent.";
var ErrorNoArrival = "Please select Arrival date or no dates at all!";
var ErrorNoDepart = "Please select Departure date or no dates at all!";
var WaitText = "Loading"+"...";
var WaitHotel = "Select City first";
var WaitCity = "Select Country first";
var ErrorDate = "Please select a date";
var txtDay = "Day";
var txtMonth = "Month";
var IsSmartSearchResult='False';
var DateDiff = 1;
var DateShift = 1;
var dNow = new Date()


TimeShift();
function TimeShift(){
 var dNow = new Date();
 if((((dNow.getUTCHours()*60)+dNow.getUTCMinutes()) >= ((10*60)+5)) && ((dNow.getUTCHours()*60) < (17*60))){
 DateShift = 2;
 }
 else{
 DateShift = 1;
 }
}

var jsLang =
{ 
txtGoCurrentMonth : "Go To Current Month",
txtTodayIs : "Today is",
txtWeek : "Wk",
txtScrollLeftMessage : "Click to scroll to previous month. Hold mouse button to scroll automatically.",
txtDayDisabled : "Can not book this day",
txtSelectYear : "Click to select a year.",
txtSelectMonth : "Click to select a month.",
txtSelectDay: "Click to select this day.",
txtNextYear : "Next Year",
txtNextMonth : "Next Month",
txtPrevYear : "Previous Year",
txtPrevMonth : "Previos Month",
txtClose : "Close Window",

//Messages
txtMsgInvalidDate :"Invalid date!! \n\nUse following format:mm/dd/yyyy",
txtMsgInvalidRange : "Selected date out of valid range!!\n Must be within a year range.",
txtMsgMaxNumerOfNights : "Number of Nights must be between 1 and 120. Maximum Number of Nights allowed is 120.\nFor stays of longer than 120 days, please contact our Customer Service Agents.",
txtMsgCheckindayInPast : "Check-in Date is in the past.\nPlease select a new date."
};

var cal_monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var cal_shortDays = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
var cal_monthOutput = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var cal_cmbMonthFormat = "mmm, yyyy";
var cal_dsplMonthFormat = "mmmm yyyy";
var cal_dsplComboFormat = "month";

var cal_fixedX = -1; // x position (-1 if to appear below control)
var cal_fixedY = -1; // y position (-1 if to appear below control)
var cal_startAt = 0; // 0 - sunday ; 1 - monday
var cal_showWeekNumber = 0; // 0 - don't show; 1 - show
var cal_showToday = 1; // 0 - don't show; 1 - show
var cal_imgDir = "/images/"; // directory for images ... e.g. var cal_imgDir="/img/"
var cal_enablehistory=false;
var cal_gotoString = jsLang.txtGoCurrentMonth;
var cal_todayString = jsLang.txtTodayIs;
var cal_weekString = jsLang.txtWeek;
var cal_scrollLeftMessage = jsLang.txtPrevMonth;
var cal_scrollRightMessage = jsLang.txtNextMonth;
var cal_selectMonthMessage = jsLang.txtSelectMonth;
var cal_selectYearMessage = jsLang.txtSelectYear;
var cal_crossObj, cal_crossMonthObj, cal_crossYearObj, cal_monthSelected, cal_yearSelected, cal_dateSelected, ocal_monthSelected, ocal_yearSelected, ocal_dateSelected, cal_monthConstructed, cal_yearConstructed, cal_intervalID1, cal_intervalID2
var cal_timeoutID1, cal_timeoutID2, cal_ctlToPlaceValue, cal_ctlNow, cal_dateFormat, cal_nStartingYear;

//Browser checks
var cal_bPageLoaded=false;
var ie=document.all;
var dom=document.getElementById;
var ns4=document.layers;
var cal_today = new Date();
var cal_dateNow = cal_today.getDate();
var cal_monthNow = cal_today.getMonth();
var cal_yearNow = cal_today.getYear();
var oFunctions;
var bShow = false;

if (dom) {
 var calwidth=200;
 calwidth=425;
 document.write("<div onclick='bShow=true' id='calendar' class='div-style'><table width="+((cal_showWeekNumber==1)?calwidth:(calwidth-25))+" class='table-style' border='0' cellpadding='0' cellspacing='0'><tr class='title-background-style'><td><table width='100%' border='0'><tr><td class='title-style'><B><span id='caption'></span></B></td></tr></table></td></tr><tr><td class='body-style'><span id='strContent'></span></td></tr>");
 if (cal_showToday==1) {
 document.write("<tr class='today-style'><td><span id='lblToday'></span></td></tr>");
 } 
 document.write("</table></div><div id='selectMonth' class='div-style'></div><div id='selectYear' class='div-style'></div>");

}

var cal_monthName = cal_monthNames;
if (cal_startAt==0) {
 cal_dayName = cal_shortDays; 
} 
else {
 cal_dayName = new Array(cal_shortDays[1],cal_shortDays[2],cal_shortDays[3],cal_shortDays[4],cal_shortDays[5],cal_shortDays[6],cal_shortDays[0]);
}



/* hides <select> and <applet> objects (for IE only) */

function hideElement( elmID, overDiv ) {
 if (ie) {
 for( i = 0; i < document.all.tags( elmID ).length; i++ ) {
 obj = document.all.tags( elmID )[i];
 if (!obj || !obj.offsetParent) {
 continue;
 }

 // Find the element's offsetTop and offsetLeft relative to the BODY tag.
 objLeft = obj.offsetLeft;
 objTop = obj.offsetTop;
 objParent = obj.offsetParent;

 // Add HTML check solved problem using calendar within box_search
 while( objParent.tagName.toUpperCase() != "BODY" && objParent.tagName.toUpperCase() != "HTML") {
 objLeft += objParent.offsetLeft;
 objTop += objParent.offsetTop;
 objParent = objParent.offsetParent;
 }

 objLeft = chkLeftPos(objLeft);
 objHeight = obj.offsetHeight;
 objWidth = obj.offsetWidth;

 // condition to check if there is no need to hide obj
 if ((overDiv.offsetLeft+overDiv.offsetWidth ) <= objLeft);
 else if((overDiv.offsetTop+overDiv.offsetHeight) <= objTop);
 else if(overDiv.offsetTop >= (objTop+objHeight));
 else if(overDiv.offsetLeft >= (objLeft+objWidth));
 else {
 obj.style.visibility = "hidden";
 }
 }
 }
}

/* unhides <select> and <applet> objects (for IE only) */
function showElement(elmID) {
 if (ie) {
 for(i=0; i<document.all.tags(elmID).length;i++) {
 obj = document.all.tags(elmID)[i];
 if (!obj || !obj.offsetParent) {
 continue;
 }
 obj.style.visibility = "";
 }
 }
}

function swapImage(srcImg, destImg){
 if (ie) { 
 document.getElementById(srcImg).setAttribute("src",cal_imgDir + destImg); 
 }
}



function init_calendar() {
 if (!ns4) {
 // correction for browsers as Opera
 if (cal_yearNow<1900) { 
 cal_yearNow+=1900; 
 }

 cal_crossObj=(dom)?document.getElementById("calendar").style : ie? document.all.calendar : document.calendar;
 hideCalendar();
 cal_crossMonthObj=(dom)?document.getElementById("selectMonth").style : ie? document.all.selectMonth : document.selectMonth;
 cal_crossYearObj=(dom)?document.getElementById("selectYear").style : ie? document.all.selectYear : document.selectYear;
 cal_monthConstructed=false;
 cal_yearConstructed=false;

 if (cal_showToday==1) {
 document.getElementById("lblToday").innerHTML=cal_todayString+" <a class='today-style' title='"+cal_gotoString+"' href='javascript:cal_monthSelected=cal_monthNow;cal_yearSelected=cal_yearNow;constructCalendar();'>"+cal_dayName[(cal_today.getDay()-cal_startAt==-1)?6:(cal_today.getDay()-cal_startAt)]+", "+cal_dateNow+" "+cal_monthName[cal_monthNow].substring(0,3)+" "+cal_yearNow+"</a>";
 }
 document.getElementById("lblToday").innerHTML="<a href='javascript:hideCalendar()' class='closecal' title='"+jsLang.txtClose+"'>"+jsLang.txtClose+"</a>";

 sHTML1="<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr height='20'>";
 sHTML1+="<td width='25' class'titles' style='width:15px'><span id='spanLeft' title='"+cal_scrollLeftMessage+"' class='title-control-normal-style' onmouseover='this.className=\"title-control-select-style\";' onclick='javascript:decMonth()' onmouseout='clearInterval(cal_intervalID1);this.className=\"title-control-normal-style\";' onmousedown='clearTimeout(cal_timeoutID1);cal_timeoutID1=setTimeout(\"StartDecMonth()\",500)' onmouseup='clearTimeout(cal_timeoutID1);clearInterval(cal_intervalID1)'>< </span></td>";
 sHTML1+="<td width='44%' class'titles' align='center'><span id='spanMonth' class='title-control-style'></span></td>";
 sHTML1+="<td width='44%' class'titles' align='center'><span id='spanMonth2' class='title-control-style'></span></td>";
 sHTML1+="<td width='25' class'titles' style='width:15px' align='right'><span id='spanRight' title='"+cal_scrollRightMessage+"' style='width:18px; text-align:right' class='title-control-normal-style' onmouseover='this.className=\"title-control-select-style\";' onmouseout='clearInterval(cal_intervalID1);this.className=\"title-control-normal-style\";' onclick='incMonth()' onmousedown='clearTimeout(cal_timeoutID1);cal_timeoutID1=setTimeout(\"StartIncMonth()\",500)' onmouseup='clearTimeout(cal_timeoutID1);clearInterval(cal_intervalID1)'> ></span></td>";
 sHTML1+="</tr></table>";

 document.getElementById("caption").innerHTML=sHTML1;
 cal_bPageLoaded=true;

 } else {
 alert("Your browser does not support this feature!");
 }
}

function hideCalendar() {
 if(cal_crossObj){
 cal_crossObj.visibility="hidden";
 if (cal_crossMonthObj != null){cal_crossMonthObj.visibility="hidden";}
 if (cal_crossYearObj != null){cal_crossYearObj.visibility="hidden";}
 if (document.getElementById("spanLeft")) { document.getElementById("spanLeft").style.visibility = "hidden";}
 if (document.getElementById("spanRight")) { document.getElementById("spanRight").style.visibility = "hidden";}
 showElement( 'SELECT' );
 showElement( 'APPLET' );
 }
}

function padZero(num) {
 return (num < 10)? '0' + num : num ;
}


function cal_constructDate(d,m,y) {
 var sTmp = cal_dateFormat;
 sTmp = sTmp.replace("dd",padZero(d));
 sTmp = sTmp.replace("d",d);
 sTmp = sTmp.replace("mmm",cal_monthName[m]);
 sTmp = sTmp.replace("mm",padZero(m+1));
 return sTmp.replace("yyyy",y);
}

function frmtDate(frmt,d,m,y) {
 var sTmp = frmt;
 sTmp = sTmp.replace("dd",padZero(d));
 sTmp = sTmp.replace("d",d);
 sTmp = sTmp.replace("mmmm",cal_monthNames[m]);
 sTmp = sTmp.replace("MMMM",cal_monthNames[m]);
 sTmp = sTmp.replace("mmm",cal_monthOutput[m]);
 sTmp = sTmp.replace("MMM",cal_monthOutput[m]);
 sTmp = sTmp.replace("mm",padZero(m+1));
 sTmp = sTmp.replace("MM",m+1);
 return sTmp.replace("yyyy",y);
}

function closeCalendar() {
 hideCalendar();
 cal_ctlToPlaceValue.value = cal_constructDate(cal_dateSelected,cal_monthSelected,cal_yearSelected);
 if(typeof(oFunctions)== "function"){
 oFunctions(cal_ctlToPlaceValue,cal_dateSelected,cal_monthSelected,cal_yearSelected);
 }
}

/*** Month Pulldown ***/
function StartDecMonth() {
 cal_intervalID1=setInterval("decMonth()",80);
}

function StartIncMonth() {
 cal_intervalID1=setInterval("incMonth()",80);
}

function incMonth () {
 cal_monthSelected++;
 if (cal_monthSelected>11) {
 cal_monthSelected=0;
 cal_yearSelected++;
 }
 constructCalendar();
}

function decMonth () {
 cal_monthSelected--;
 if (cal_monthSelected<0) {
 cal_monthSelected=11;
 cal_yearSelected--;
 }
 constructCalendar();
}

function getLeftPos(obj) {
 // Find the element's offsetLeft relative to the BODY tag.
 var objLeft = obj.offsetLeft;
 var objParent = obj.offsetParent;
 while( objParent.tagName.toUpperCase() != "BODY" ) {
 objLeft += objParent.offsetLeft;
 objParent = objParent.offsetParent;
 }
 return objLeft;
}

/*** Year Pulldown ***/
function incYear() {
 for (i=0; i<7; i++){
 newYear = (i+cal_nStartingYear)+1;
 if (newYear==cal_yearSelected) { 
 txtYear="&nbsp;<B>"+newYear+"</B>&nbsp;";
 } else { 
 txtYear="&nbsp;"+newYear+"&nbsp;"; 
 }
 document.getElementById("y"+i).innerHTML = txtYear;
 }
 cal_nStartingYear++;
 bShow=true;
}

function decYear() {
 for (i=0; i<7; i++){
 newYear = (i+cal_nStartingYear)-1;
 if (newYear==cal_yearSelected) { 
 txtYear="&nbsp;<B>"+newYear+"</B>&nbsp;";
 }
 else { 
 txtYear = "&nbsp;" + newYear + "&nbsp;";
 }
 document.getElementById("y"+i).innerHTML = txtYear;
 }
 cal_nStartingYear--;
 bShow=true;
}

/*** calendar ***/
function WeekNbr(today) {
 Year = takeYear(today);
 Month = today.getMonth();
 Day = today.getDate();
 now = Date.UTC(Year,Month,Day+1,0,0,0);
 var Firstday = new Date();
 Firstday.setYear(Year);
 Firstday.setMonth(0);
 Firstday.setDate(1);
 then = Date.UTC(Year,0,1,0,0,0);
 var Compensation = Firstday.getDay();
 if (Compensation > 3) Compensation -= 4;
 else Compensation += 3;
 NumberOfWeek = Math.round((((now-then)/86400000)+Compensation)/7);
 return NumberOfWeek;
}

function takeYear(theDate) {
 x=theDate.getYear();
 var y=x%100;
 y += (y < 38) ? 2000 : 1900;
 return y;
}

function cal_seletion(nDay,nMonth,nYear) {
 cal_dateSelected=nDay;
 cal_monthSelected=nMonth;
 cal_yearSelected=parseInt(nYear);
 closeCalendar();
}

function getMonthTable(selYear,selMonth) {
 // correction for doublemonths
 if (selMonth==12) {
 selMonth=0;
 selYear+=1;
 }
 var dateMessage;
 var startDate = new Date (selYear,selMonth,1);
 var endDate = new Date (selYear,selMonth+1,1);
 endDate = new Date (endDate - (24*60*60*1000));
 numDaysInMonth = endDate.getDate();
 datePointer = 0;
 dayPointer = startDate.getDay() - cal_startAt;
 if (dayPointer<0) {
 dayPointer = 6;
 }
 var sHTML = "<table border='0' class='body-style' cellpadding='0' cellspacing='0' width='100%'><tr class='dayofweeks'>";
 if (cal_showWeekNumber==1) {
 sHTML += "<td width='25' align='center'><b>" + cal_weekString + "</b></td><td width='1' rowspan='7' class='weeknumber-div-style'><img src='"+cal_imgDir+"divider.gif' width='1'></td>";
 }
 for (i=0; i<7; i++) {
 if((i==0)||(i==6)){
 sHTML += "<td width='25' align='right' style='padding-right:2px' bgcolor='#DFDFDF'><span style='color:#FF0000;'>"+ cal_dayName[i]+"</span></td>";
 }
 else{
 sHTML += "<td width='25' align='right' style='padding-right:2px' bgcolor='#DFDFDF'>"+ cal_dayName[i]+"</td>";
 }
 }
 sHTML +="</tr><tr>";
 if (cal_showWeekNumber==1) {
 sHTML += "<td align=right>" + WeekNbr(startDate) + "&nbsp;</td>";
 }
 for ( var i=1; i<=dayPointer;i++ ) {
 sHTML += "<td>&nbsp;</td>";
 }
 var bDayEnabled;
 var sDisabled="";
 for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ ) {
 dayPointer++;
 bDayEnabled=true;
 //Check if day should be enabled or disabled for selection
 if (typeof(chkEnableDay)=="function") {
 bDayEnabled=chkEnableDay(datePointer,selMonth,selYear);
 }
 sHTML += "<td align='right' class='cal_day'>";
 var sStyle="normal-day-style"; //regular day
 if ((datePointer==cal_dateNow)&&(selMonth==cal_monthNow)&&(selYear==cal_yearNow)) { //today
 sStyle = "current-day-style"; 
 } 
 else if ((dayPointer % 7 == (cal_startAt * -1) +1)||(dayPointer % 7 == (cal_startAt * -1) )) { //end-of-the-week day
 sStyle = "end-of-weekday-style"; 
 }
 //selected day
 if ((datePointer==ocal_dateSelected) && (selMonth==ocal_monthSelected) && (selYear==ocal_yearSelected)) {
 sStyle += " selected-day-style"; 
 }
 sDisabled="";
 sHint = jsLang.txtSelectDay;
 if (bDayEnabled==false) {
 sStyle="disabled-"+sStyle;
 sDisabled=" disabled";
 sHint=jsLang.txtDayDisabled;
 }
 var regexp= /\"/g;
 sHint=sHint.replace(regexp,"&quot;");
 dateMessage = ""; 
 if (bDayEnabled)
 sHTML += "<a class='"+sStyle+"' "+dateMessage+" title=\"" + sHint + "\" href='javascript:cal_seletion("+datePointer+","+selMonth+","+selYear+");'>&nbsp;" + datePointer + "&nbsp;</a>"
 else
 sHTML += "<label class='"+sStyle+"' "+sDisabled+" title=\"" + sHint + "\" >&nbsp;" + datePointer + "&nbsp;</label>"
 sHTML += "";
 if ((dayPointer+cal_startAt) % 7 == cal_startAt) { 
 sHTML += "</tr><tr>";
 if ((cal_showWeekNumber==1)&&(datePointer<numDaysInMonth)) {
 sHTML += "<td align=right>" + (WeekNbr(new Date(selYear,selMonth,datePointer+1))) + "&nbsp;</td>";
 }
 }
 }
 sHTML+="</tr></table>"
 return sHTML;
}

function constructCalendar () {
 var dateMessage;
 var startDate = new Date (cal_yearSelected,cal_monthSelected,1);
 var endDate = new Date (cal_yearSelected,cal_monthSelected+1,1);
 endDate = new Date (endDate - (24*60*60*1000));
 numDaysInMonth = endDate.getDate();
 datePointer = 0;
 dayPointer = startDate.getDay() - cal_startAt;
 if (dayPointer<0) {
 dayPointer = 6;
 }
 //Check if day should be enabled or disabled for selection
 var bPrevEnabled=true;
 var bNextEnabled=true;
 if (cal_monthSelected<=cal_monthNow && cal_yearSelected==cal_yearNow && cal_enablehistory==false) {
 bPrevEnabled=false;
 }
 if (bPrevEnabled) 
 bPrevEnabled=chkEnableDay(1,cal_monthSelected,cal_yearSelected);
 if (typeof(chkEnableDay)=="function") {
 bNextEnabled=chkEnableDay(1,cal_monthSelected+2,cal_yearSelected);
 }
 if (bPrevEnabled) {
 document.getElementById("spanLeft").style.visibility = (dom||ie)? "visible" : "show";
 document.getElementById("spanLeft").disabled=false;
 } else {
 document.getElementById("spanLeft").style.visibility = "hidden";
 document.getElementById("spanLeft").disabled=true;
 } 
 if (bNextEnabled) {
 document.getElementById("spanRight").style.visibility = (dom||ie)? "visible" : "show";
 document.getElementById("spanRight").disabled=false;
 } else {
 document.getElementById("spanRight").style.visibility = "hidden";
 document.getElementById("spanRight").disabled=true;
 } 
 // script for month table
 var mnt1Html = getMonthTable(cal_yearSelected,cal_monthSelected);
 var mnt2Html = "";
 mnt2Html = getMonthTable(cal_yearSelected,cal_monthSelected+1);
 sHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top' align='left'>"+mnt1Html+"</td><td></td><td bgcolor='#909090' width='2'></td><td></td><td valign='top' align='right'>"+mnt2Html+"</td></tr></table>"
 document.getElementById("strContent").innerHTML = sHTML;
 document.getElementById("spanMonth").innerHTML=frmtDate(cal_dsplMonthFormat,cal_dateSelected,cal_monthSelected,cal_yearSelected);
 var calMonth2=cal_monthSelected+1;
 var calYear2=cal_yearSelected;
 if (calMonth2==12) {
 calMonth2=0;
 calYear2+=1;
 }
 document.getElementById("spanMonth2").innerHTML=frmtDate(cal_dsplMonthFormat,cal_dateSelected,calMonth2,calYear2);
}

function popUpCalendar(ctl, ctl2, format, OtherFunctions) {
 var leftpos=0;
 var toppos=0;
 oFunctions = OtherFunctions;
 if (cal_bPageLoaded) {
 if (cal_crossObj.visibility=="hidden") {
 cal_ctlToPlaceValue = ctl2;
 cal_dateFormat=format;
 formatChar = " ";
 aFormat = cal_dateFormat.split(formatChar);
 if (aFormat.length<3) {
 formatChar = "/";
 aFormat = cal_dateFormat.split(formatChar);
 if (aFormat.length<3) {
 formatChar = ".";
 aFormat = cal_dateFormat.split(formatChar);
 if (aFormat.length<3) {
 formatChar = "-";
 aFormat = cal_dateFormat.split(formatChar);
 if (aFormat.length<3)
 {
 // invalid date format
 formatChar="";
 }
 }
 }
 }
 tokensChanged = 0;
 if ( formatChar != "" ) {
 // use user's date
 aData = ctl2.value.split(formatChar);
 for (i=0;i<3;i++) {
 if ((aFormat[i]=="d") || (aFormat[i]=="dd")) {
 cal_dateSelected = parseInt(aData[i], 10);
 tokensChanged++;
 }
 else if ((aFormat[i]=="m") || (aFormat[i]=="mm")) {
 cal_monthSelected = parseInt(aData[i], 10) - 1;
 tokensChanged++;
 }
 else if (aFormat[i]=="yyyy") {
 cal_yearSelected = parseInt(aData[i], 10);
 tokensChanged++;
 }
 else if (aFormat[i]=="mmm") {
 for (j=0; j<12; j++) {
 if (aData[i]==cal_monthName[j]) {
 cal_monthSelected=j;
 tokensChanged++;
 }
 }
 }
 }
 }
 if ((tokensChanged!=3)||isNaN(cal_dateSelected)||isNaN(cal_monthSelected)||isNaN(cal_yearSelected)) {
 cal_dateSelected = cal_dateNow;
 cal_monthSelected = cal_monthNow;
 cal_yearSelected = cal_yearNow;
 }
 ocal_dateSelected = cal_dateSelected;
 ocal_monthSelected = cal_monthSelected;
 ocal_yearSelected = cal_yearSelected;
 aTag = ctl;
 do {
 aTag = aTag.offsetParent;
 leftpos += aTag.offsetLeft;
 toppos += aTag.offsetTop;
 } while(aTag.tagName!="BODY" && aTag.tagName!="HTML");
 // Add HTML check solved problem using calendar within box_search
 //Need to convert to string for firefox
 var posleft=ctl.offsetLeft+leftpos;
 // Check leftpos to document.body.offsetWidth
 posleft = chkLeftPos(posleft);
 var strLeft = new String(posleft+"px");
 var postop=ctl.offsetTop + toppos + ctl.offsetHeight + 2;
 var strTop = new String(postop+"px");
 cal_crossObj.left = cal_fixedX==-1 ? strLeft : cal_fixedX;
 cal_crossObj.top = cal_fixedY==-1 ? strTop : cal_fixedY;
 constructCalendar(1, cal_monthSelected, cal_yearSelected);
 cal_crossObj.visibility=(dom||ie)? "visible" : "show";
 hideElement( 'SELECT', document.getElementById("calendar") );
 hideElement( 'APPLET', document.getElementById("calendar") ); 
 bShow = true;
 }
 }
 else {
 init_calendar();
 popUpCalendar(ctl, ctl2, format, OtherFunctions);
 }
}

function chkLeftPos(lefpos) {
 var retval = lefpos;
 var rightpos = lefpos+document.getElementById("calendar").offsetWidth;
 var winWidth = document.body.offsetWidth;
 var offset=0;
 if (rightpos>winWidth) {
 offset=rightpos-winWidth+1;
 retval -= offset;
 if (retval<0) 
 retval=0;
 }
 return retval
}

document.onkeypress = function hidecal1 () { 
 if (event.keyCode==27) {
 hideCalendar();
 }
}
document.onclick = function hidecal2 () { 
 if (!bShow) {
 hideCalendar();
 }
 bShow=false;
}

function y2k(d) { 
 return (d < 1000) ? d + 1900 : d;
}

function daysElapsed(date1, date2) {//date1=Out , date2 = In
 
 var TempDate1 = new Array();
 var TempDate2 = new Array();
 TempDate1 = date1.split('/');
 TempDate2 = date2.split('/'); 
 var difference = Date.UTC(y2k(TempDate1[2]),TempDate1[1],TempDate1[0],0,0,0) - Date.UTC(y2k(TempDate2[2]),TempDate2[1],TempDate2[0],0,0,0);
 //alert(date1+ ' , ' + date2 + ' , ' + difference/1000/60/60/24);
 return difference/1000/60/60/24;
}

//End added more code 26/01/2007
function chkEnableDay(chkday,chkmonth,chkyear) {
 //correction when roll over into next year
 if (chkmonth>=12) {
 chkmonth-=12;
 chkyear+=1;
 }
 
 var retval=true;
 var date = new Date();
 var dateNow = date.getDate();
 var monthNow = date.getMonth();
 var yearNow = date.getFullYear();
 if (yearNow<1900) { 
 yearNow+=1900; 
 }


 var nDaMo=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
 if(yearNow%4==0){ nDaMo[1]=29;}
 
 
 if(monthNow == 11){
 if((dateNow + DateShift) > nDaMo[monthNow]){
 dateNow = 1;
 monthNow = 0;
 yearNow = yearNow+1;
 }
 else{
 dateNow = dateNow + DateShift;
 }
 }
 else{
 if((dateNow + DateShift) > nDaMo[monthNow]){
 dateNow = 1;
 monthNow = monthNow+1;
 }
 else{
 dateNow = dateNow + DateShift;
 }
 }
 
 // Check past
 if ((chkyear-yearNow) <= 0 && (chkmonth<monthNow || (chkmonth==monthNow && chkday<dateNow))) {
 retval=false;
 }
 // Check more then 1 year
 if (chkyear>yearNow && ((chkmonth>=monthNow && chkday>dateNow) || chkmonth>monthNow)) {
 retval=false;
 }
 if (chkyear<yearNow || (chkyear-yearNow>1))
 retval=false;
 return retval;
}

function fnSetDate(obj,nDay,nMonth,nYear){
 nMonth++;
 if (obj.id=="dchkin"){
 
 var nDaMo=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
 if(nYear%4==0){ nDaMo[2]=29;}
 
 if(nMonth == 12){
 if((nDay + DateDiff) > nDaMo[nMonth]){
 nDay = 1;
 nMonth = 1;
 nYear = nYear+1;
 }
 else{
 nDay = nDay + DateDiff;
 }
 }
 else{
 if((nDay + DateDiff) > nDaMo[nMonth]){
 nDay = 1;
 nMonth = nMonth+1;
 }
 else{
 nDay = nDay + DateDiff;
 }
 }
 
 if((nDay.toString().length)==1){nDay='0'+nDay.toString()}
 if((nMonth.toString().length)==1){nMonth='0'+nMonth.toString()}
 document.getElementById('dchkout').value = nDay+'/'+nMonth+'/'+nYear;
 }
 else{
 if(document.getElementById('dchkin') != 'dd/mm/yyyy'){

 var checkInDate = document.getElementById('dchkin').value;
 var checkOutDate = document.getElementById('dchkout').value;
 var now = new Date();
 var nDayNow = now.getDate();
 var nMonthNow = now.getMonth()+1;
 var nYearNow = now.getYear();
 
 if((nDayNow.toString().length)==1){nDayNow='0'+nDayNow.toString()}
 if((nMonthNow.toString().length)==1){nMonthNow='0'+nMonthNow.toString()}
 var strNow = nDayNow+'/'+nMonthNow+'/'+nYearNow;
 
 if (daysElapsed(checkInDate, strNow) < 0) { 
 document.getElementById('dchkout').value = 'dd/mm/yyyy';
 alert(ErrorPast); 
 }
 else if(daysElapsed(checkOutDate, checkInDate) < 1 ) { 
 document.getElementById('dchkout').value = 'dd/mm/yyyy';
 alert(ErrorLater);
 }
 else if (daysElapsed(checkOutDate, checkInDate) > 120){
 document.getElementById('dchkout').value = 'dd/mm/yyyy';
 alert(ErrorDays);
 }
 else{
 if((nDay.toString().length)==1){nDay='0'+nDay.toString()}
 if((nMonth.toString().length)==1){nMonth='0'+nMonth.toString()}
 document.getElementById('dchkout').value = nDay+'/'+nMonth+'/'+nYear;
 }
 }
 else{
 if((nDay.toString().length)==1){nDay='0'+nDay.toString()}
 if((nMonth.toString().length)==1){nMonth='0'+nMonth.toString()}
 document.getElementById('dchkout').value = nDay+'/'+nMonth+'/'+nYear;
 }
 }
}
