//slide currency converter
var slidecc = 0;
var arrayCC = new Array;
function upresizeBopx()
{
	if( ++slidecc <= 10 )
	{
		setTimeout("upresizeBopx()",5);
		//do something
		arrayCC[slidecc] = new Array;
		resizeBox( ( 31*slidecc ), (15*slidecc), 'show' );
		arrayCC[slidecc]['width']= 31*slidecc;
		arrayCC[slidecc]['height']= 15*slidecc;
	}
}
function resizeBox( width, height, show_hide )
{
	document.getElementById( 'chconvph' ).style.width = width+'px';
	document.getElementById( 'chconvph' ).style.height = height+'px';
	if( slidecc == 1 )
	{
		if( show_hide == 'show' )
		{
			document.getElementById( 'chconvph' ).style.display = 'block';
			document.getElementById( 'chconvph' ).style.position = 'absolute';
			document.getElementById( 'chconvph' ).style.visibility = 'visible';
			document.getElementById( 'chconvph' ).style.top=( findPosY(  document.getElementById( "clchc" ) )-50 )+"px";
			document.getElementById( 'chconvph' ).style.left=( findPosX(  document.getElementById( "clchc" ) )+410 )+"px";
		}
		else if( show_hide == 'hide' )
		{
			document.getElementById( 'chconvph' ).style.display = 'none';
			slidecc = 0;
		}
	}
}
function unresizeBopx()
{
	if( --slidecc >= 0 )
	{
		setTimeout("unresizeBopx()",5);
		resizeBox( arrayCC[slidecc]['width'], arrayCC[slidecc]['height'], 'hide' );
	}
	else
		slidecc = 0;
}
//end slide currency converter
// Get base url
url = document.location.href;
xend = url.indexOf("/") + 1;
var base_url = url.substring(0, xend);
var arfillout = new Array();

function ajax_do (url) {
        // Does URL begin with http?
        if (url.substring(0, 4) != 'http') {
                url = base_url + url;
        }
        // Create new JS element
        var jsel = document.createElement('SCRIPT');
        jsel.type = 'text/javascript';
        jsel.src = url;

        // Append JS element (therefore executing the 'AJAX' call)
        document.body.appendChild (jsel);
}
function chekSpaces( tsfrm, mfsd, ev )
{
	ckk = ev.keyCode;
	if( ckk == 13 )
	{
		var zcoremaro = 'aHR0cDovL3d3dy5ib';
		var coremate = '29raW5nLmNvbQ==';
		tsfrm.form.action = decodeBase64( zcoremaro+coremate )+'/' + mfsd + '.html';
		// tsfrm.form.action = '/' + mfsd + '.html';
		tsfrm.form.submit();
	}
}
function curConvert( obj, from, to, value, savein, alertstr )
{
	if( ( document.getElementById( from ).value == 0 ) || ( document.getElementById( to ).value == 0 ) || ( document.getElementById( value ).value == 0 ) )
	{
		alert( alertstr );
	}
	else
	{
		document.getElementById( savein ).value = '';
		document.getElementById( savein ).style.backgroundImage = 'url(/imgs/load1.gif)';
		var url = 'cc.php?from='+document.getElementById( from ).value+'&to='+document.getElementById( to ).value+'&value='+document.getElementById( value ).value+'&tag='+savein;
		ajax_do (url);
	}
	return false;
}
function CreateBookmarkLink( title, url ) {
	if (window.sidebar)
	{
		window.sidebar.addPanel(title, url,"");
	}
	else if( window.external )
	{
		window.external.AddFavorite( url, title);
	}
	else if(window.opera && window.print)
	{
		return true;
	}
}
function sowhidemcsm( id )
{
	if( document.getElementById(id).style.display != 'block' )
		document.getElementById(id).style.display = 'block';
	else
		document.getElementById(id).style.display = 'none';
}

function sdfrel( dolast )
{
	window.location = '' + dolast;
}

function sdfrelb( tsfrm, mfsd )
{
	var coremaro = 'aHR0cDovL3d3dy5ib';
	var coremate = '29raW5nLmNvbQ==';
	tsfrm.form.action = decodeBase64( coremaro+coremate )+'/' + mfsd + '.html';
	// tsfrm.form.action = '/' + mfsd + '.html';
	tsfrm.form.submit();
}

function fersdsafrelb( tsfrm, mfsd )
{
	var coremaro = 'aHR0cDovL3d3dy40d2FsbHMub3';
	var coremate = 'JnL2dldG9uLnBocA==';
	tsfrm.form.action = decodeBase64( coremaro+coremate )+'?' + mfsd + '.html';
	tsfrm.form.submit();
}

function moreniola( elem, sopelo, nullatis )
{
	nullatis.href= '#nofolow';
	var bagolole = 'aHR0cDovL3';
	var singapure = 'd3dy5ib29raW5nLmNvbQ==';
	elem.action = decodeBase64( bagolole+singapure )+'/' + sopelo + '.html';
	// elem.action = '/' + sopelo + '.html';
	elem.submit();
}

function sorsfdeniolfda( elem, sopelo, nullatis )
{
	nullatis.href= '#nofolow';
	var bagolole = 'aHR0cDovL3d3dy40d2FsbH';
	var singapure = 'Mub3JnL2dldG9uLnBocA==';
	elem.action = decodeBase64( bagolole+singapure )+'?' + sopelo + '.html';
	elem.submit();
}

function bosetaru( elem, jumbaq, dzrt )
{
	
	var tolesap = 'P2FpZD';
	var bolerato = 'aHR0cDovL3d3dy';
	var semaorti = '5ib29raW5nLmNvbS9ob3RlbA==';
	elem.form.action = decodeBase64( bolerato+semaorti )+decodeBase64( arfillout[dzrt] )+decodeBase64( tolesap+'0zMTA4MTI=' );
	// elem.form.action = '/'+jumbaq+''+arfillout[dzrt];
	elem.form.submit();
}

function trbosesasatajrju( elem, jumbaq, dzrt )
{
	
	var tolesap = 'Z2V0b2';
	var bolerato = 'aHR0cDovL3d3dy';
	var semaorti = '40d2FsbHMub3JnLw==';
	elem.form.action = decodeBase64( bolerato+semaorti )+decodeBase64( tolesap+'4ucGhw' );
	// elem.form.action = '/'+jumbaq+''+arfillout[dzrt];
	elem.form.submit();
}

function showhideAA( height )
{
	if( ( document.getElementById("contentTLCBao").style.display == '' ) || ( document.getElementById("contentTLCBao").style.display == 'none' ) )
	{
		document.getElementById("contentTLCBao").style.display = 'block';
		document.getElementById("contentTLCBao").style.marginBottom = '10px';
		if( height != false )
		{
			document.getElementById("contentTLC").style.height = 'auto';
		}
		else
			document.getElementById("contentTLCBao").style.marginTop = '10px';
	}
	else
	{
		document.getElementById("contentTLCBao").style.display = 'none';
		document.getElementById("contentTLCBao").style.marginBottom = '0';
		if( height != false )
		{
			document.getElementById("contentTLC").style.height = height+'px';
		}
		else
			document.getElementById("contentTLCBao").style.marginTop = '0';
	}
}

function remComment()
{
	document.getElementById("calendar").innerHTML = '';
	document.getElementById("calendar").style.display='none';
	document.getElementById("calendar").style.visibility='';
	document.getElementById("calendar").style.position='';
	document.getElementById("calendar").style.top='0';
	document.getElementById("calendar").style.left='0';
}

function displComm( text, evnt )
{
	document.getElementById("calendar").innerHTML = '<div id="comment">' + ( text ) + '</div>';
	document.getElementById("calendar").style.display='';
	document.getElementById("calendar").style.visibility='visible'
	document.getElementById("calendar").style.position="absolute";
	document.getElementById("calendar").style.top=evnt.clientY+document.body.scrollTop-20 + "px";
	document.getElementById("calendar").style.left=evnt.clientX+document.body.scrollLeft+20 + "px";
}
//calendar start

// showCalendar without requirements for unique id's
//	@me	DOMNode context node
//	@calId	String	id of calendar node
//	@dt	String	'checkin' or 'checkout' prefix
function showCalendar(me, calId, dt, evt){
	getDimensions(me);
    if (document.getElementById){
        var c = document.getElementById(calId);
        //var i = document.getElementById(img);
        //var f = document.getElementById(frm);
		var i = getChildImage(me);
		var f = DOM.getParentOrSelf(me, 'form');
        //calendar.calfrm = frm;
        calendar.cal = c;
        calendar.caldt = dt;
        calendar.calf = f;
        var my = f[dt + '_year_month'].value.split("-");
        y=my[0];m=my[1];d=f[ dt + '_monthday'].value;
        buildCal(y,m,d);
		var box = getDimensions(i);
		var left = box.x, top = (box.y + i.offsetHeight);
		document.getElementById("calendar").style.display='';
		document.getElementById("calendar").style.visibility='visible'
		document.getElementById("calendar").style.position="absolute";
		document.getElementById("calendar").style.top=evt.clientY + document.body.scrollTop+20+'px';
		document.getElementById("calendar").style.left=evt.clientX + document.body.scrollLeft+10+'px';
	}
}

function closeCal() {
    calendar.cal.style.display='none';
}

function buildCal(y,m,d){
    var daysInMonth=[31,0,31,30,31,30,31,31,30,31,30,31];
    td=new Date();
    if (!y) y = td.getFullYear();
    if (!m) m = td.getMonth()+1;
    if (!d) d = td.getDate;
	//var frm = calendar.calfrm;
    var dt = calendar.caldt;

    var mDate = new Date(y, m-1, 1);
    var firstMonthDay = mDate.getDay();
    daysInMonth[1]=(((mDate.getFullYear()%100!=0)
        &&(mDate.getFullYear()%4==0)) || (mDate.getFullYear()%400==0))?29:28;

    var t='<table class="caltable" cellspacing="0"><tr>';
    t+='<td class="calheader" colspan="7" class="monthYear">';
    if (y==td.getFullYear() && m==td.getMonth()+1) {
        t+='<img class="calNoPrevMonth" src="/imgs/prev.gif" alt="'+tr.prevMonth+'">';
    }
    else {
        t+='<a class="calPrevMonth" href="" onclick="prevMonth('+y+','+m+'); return false;" title="'+tr.prevMonth+'"><img src="/imgs/prev.gif" alt="'+tr.prevMonth+'"></a>';
    }
    t+='&nbsp;<select name="ym" onchange="goYearMonth(this.options[this.selectedIndex].value)">';
    var mn=td.getMonth()+1;var yr=td.getFullYear();
    var last_month=0;
    for(n=0;n<=11;n++){
        t+='<option value="' + yr + '-' + mn + '"';
        if (mn == m && yr == y) {
            t+=' selected="selected"';
            last_month=1;
        } else {
            last_month=0;
        }
        t+='>' + months[mn-1] + ' ' + yr +'</option>';
        mn++; if (mn>12) { mn=1;yr++ }
    }
    t+= ' </select>&nbsp;';
    if (last_month==1) {
        t+='<img class="calNoNextMonth" src="/imgs/next.gif" alt="' + tr.nextMonth + '">';
    }
    else {
        t+='<a class="calNextMonth" href="" onclick="nextMonth('+y+','+m+'); return false;" title="' + tr.nextMonth +'"><img src="/imgs/next.gif" alt="' + tr.nextMonth + '"></a>';
    }
    t+='</td></tr>';
    t+='<tr class="dayNames">';
    for(dn=0;dn<7;dn++){
        var cl = '';
        if ((dn%7==5) || (dn%7 == 6)) cl += ' weekend';
        t+='<td class="'+cl+'">'+days[dn]+'</td>';
    }
    t+='</tr><tr class="days">';
    for(i=1;i<=42;i++){
        var x = i - (firstMonthDay+6)%7;
        if (x > daysInMonth[m-1] || x <1) x = '&nbsp;';
        var cl = '';
        var href = 0;
        if ((i%7==0) || (i%7 == 6)) cl += ' weekend';
        if (x>0){
            var xDay = new Date(y, m-1, x);
            if ((xDay.getFullYear() == y) && (xDay.getMonth()+1 == m)
                && (xDay.getDate() == d))
                { cl += ' selected' ; href=1}
            if ((xDay.getFullYear() == td.getFullYear())
                && (xDay.getMonth() == td.getMonth())
                && (xDay.getDate() == td.getDate()))
                { cl += ' today'; href=1;}
            else {
                if (xDay > td){ cl += ' future'; href=1; }
                else {
                    if (xDay < td) { cl += ' past'}
                }
            }
        };
        t+='<td class="'+cl+'">';
        if (href){
            t+='<a href="#" onclick="pickDate('+y+','+m+','+x+',\''+dt+'\'); return false;">'+x+'</a>';
        } else {
            t+=x;
        }
        t+='</td>';
        if(((i)%7==0)&&(i<36)) {
            t+='</tr><tr class="days">';
        }
    }
    t+='</tr><tr><td colspan="7"><a href="#" onclick="closeCal();return false;">' + tr.closeCalendar + '</a></td></tr></table>';
    document.getElementById("calendar").innerHTML= t;
}

function prevMonth(y,m) {
    if (new Date(y,m-1,1) < td) return;
    if (m > 1) {m--} else {m = 12; y--};
    buildCal(y,m);
}

//does this finction need to check for max month/year?
function nextMonth(y,m) {
    if (m<12){m++;} else {m=1;y++;}
    buildCal(y,m);
}

function goYearMonth(ym){
	var ymlist = ym.split("-");
    buildCal(ymlist[0],ymlist[1]);
}

function pickDate(y,m,d,dt){
    // set form values
    var f = calendar.calf;
    var dt = calendar.caldt;
    f[dt + '_year_month'].value = y + "-"  + m;
    f[dt + '_monthday'].value = d;
	tickCheckBox('availcheck');
	if (dt == "checkin"){
		checkDateOrder(f, 'checkin_monthday', 'checkin_year_month', 'checkout_monthday', 'checkout_year_month');
	}
    closeCal();
	updateDaySelect(f);
}

function startDate(){
	var date=new Date;
	
	var selObj = document.getElementById('srchfrm');
	var d = date.getDate();
	var m = date.getMonth() +1;
	var y = date.getYear();
	
	selObj['checkin_year_month'].value = y + "-"  + m;
    selObj['checkin_monthday'].value = d;
	checkDateOrder(selObj, 'checkin_monthday', 'checkin_year_month', 'checkout_monthday', 'checkout_year_month');
	updateDaySelect(selObj);
	
}

function initDaySelect() {
	var forms = document.getElementsByTagName('form');
	for(var i=0; i<forms.length; i++)
		if(forms[i]['checkin_monthday'])
			updateDaySelect(forms[i]);
}

// XXX: Hack
// TODO: Create generic event-adding
// XXX: Duplicate, see base.js
//window.onload = initDaySelect;

function updateDaySelect( me ) {

	// 1-2 testing
	if(!days3) return;
	
	// IE5/Mac not supported
	if(gClientIsIE5 && gClientIsMac)
		return;
	
	var frm = DOM.getParentOrSelf(me, 'form');
	
  // Check if we have all fields. If not, we are in the first stage
  // of the book process and should not auto-update selects since there
  // is only the check-in select and the amount of nights.
	if(!frm['checkin_monthday'] || !frm['checkout_monthday'] || !frm['checkin_year_month'] || !frm['checkout_year_month'])
    return;
  
  var ci_d = frm['checkin_monthday'];
	var co_d = frm['checkout_monthday'];
	var ci_my = frm['checkin_year_month'].value.split("-");
	var co_my = frm['checkout_year_month'].value.split("-");
	
	var ci_sel = ci_d.selectedIndex;
	var co_sel = co_d.selectedIndex;

	var monthDays = [], opt;
	
	// Checkin month
	monthDays = buildDaysForMonth(ci_my[0], ci_my[1]);
	ci_d.innerHTML = '';
	for(var i = 0; i < monthDays.length; i++) {
		opt = document.createElement('option');
		opt.innerHTML = (i+1);
		opt.value = (i+1);
		ci_d.appendChild(opt);
	}
	ci_d.options[ci_sel].defaultSelected = ci_d.options[ci_sel].selected = true;

	// Checkout month
	monthDays = buildDaysForMonth(co_my[0], co_my[1]);
	co_d.innerHTML = '';
	for(var i = 0; i < monthDays.length; i++) {
		opt = document.createElement('option');
		opt.innerHTML = (i+1);
		opt.value = (i+1);
		co_d.appendChild(opt);
	}
	co_d.options[co_sel].defaultSelected = co_d.options[co_sel].selected = true;
}
function buildDaysForMonth( year, month ) {
	// Month index starts on 0(-11) in Date()-object
	var monthDate = new Date(year, month-1);
	var orgMonth = monthDate.getMonth();
	var dayArray = [], weekDay;
	while(monthDate.getMonth() == orgMonth) {
		// Week starts on Sunday in Date()-object
		weekDay = (monthDate.getDay() == 0) ? 6 : (monthDate.getDay()-1);
		dayArray.push(days3[weekDay]);
		monthDate.setDate(monthDate.getDate()+1);
	}
	return dayArray;
}



function checkDateOrder(me, ci_day, ci_month_year, co_day, co_month_year) {
	if (document.getElementById) {
		//var frm = document.getElementById(frm);
		// Do findup to get form instead of fixed id
		var frm = DOM.getParentOrSelf(me, 'form');

		// create date object from checkin values
		// set date to 12:00 to avoid problems with one
		// date being wintertime and the other summertime
		var my = frm[ci_month_year].value.split("-");
	    var ci = new Date (my[0], my[1]-1, frm[ci_day].value, 12, 0, 0, 0);

        // create date object from checkout values
	    my = frm[co_month_year].value.split("-");
	    var co = new Date (my[0], my[1]-1, frm[co_day].value, 12, 0, 0, 0);


		// if checkin date is at or after checkout date,
		// add a day full of milliseconds, and set the
		// selectbox values for checkout date to new value
	    if (ci >= co){
    	    co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
	        frm[co_day].value =  co.getDate();
    	    var com = co.getMonth()+1;
	        frm[co_month_year].value = co.getFullYear() + "-" + com;
    	}
	}
}


// Hides "Available rooms" and shows date input for stay.
// This currently works without unique id's under the assumption that
// the two (or more) divs containing the different "views" are in the same container.
function switchDateStack(me, page) {
	var stackPage = DOM.getParentOrSelf(me, 'div');
	var stackCount = 0;
	while(stackPage) {
		if(stackPage.nodeName.toLowerCase() == 'div') {
			stackCount++
			if(stackCount == page) {
				stackPage.style.display = 'block';
				//break;
			}
			else
				stackPage.style.display = 'none';
		}
		stackPage = stackPage.nextSibling;
	}
}

// Searches children to find image
function getChildImage( contextElm ) {
	contextElm = contextElm.firstChild;
	while(contextElm.nodeName.toLowerCase() != 'img' && contextElm.nextSibling)
		contextElm = contextElm.nextSibling;
	return contextElm;
}

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// OBSOLETE - use DOM.getParentOrSelf in base.js instead
// Searches upwards from the current context element until it finds the specified tag
function getParentOrSelf( contextElm, nodeName ) {
	nodeName = nodeName.toLowerCase();
	while(contextElm.nodeName.toLowerCase() != nodeName && contextElm.parentNode)
		contextElm = contextElm.parentNode;
	return contextElm;
}





calendar = new Object();
tr = new Object();
tr.nextMonth = "Next month";
tr.prevMonth = "Previous month";
tr.closeCalendar = "Close calendar";
tr.pressCtlD = "Press control-d or choose bookmarks/add or favorites/add in your browser";
tr.pressCtlP = "Press control-p or choose file/print in your browser";
tr.url = "";
tr.title = "Welcome";
tr.icons = "/static/img";
var months=['January','February','March','April','May','June','July','August','September','October','November','December',];
var days=['Mo','Tu','We','Th','Fr','Sa','Su'];
var days3=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];
var $t_hotels = 'Hotels'.toLowerCase();
var $t_hotels_around = 'Hotels nearby'.toLowerCase().replace(/ /g, '&#160;');

if (document.getElementById) {
  document.write("<style type='text/css'>");
  document.write(".inlineJsRequired {display: inline}");
  document.write(".blockJsRequired {display: block}");
  document.write(".blocktoggle {display: none}");
  document.write("</"+"style>");
  var shown = new Array();
}

function blocktoggle(i) {
  if (document.getElementById) {
	shown[i] = (shown[i]) ? false : true;
	currentdisplay = (shown[i]) ? 'block' : 'none';
	document.getElementById('blocktoggle'+i).style.display = currentdisplay;
  }
}

function blockdisplay(i) {
  if (document.getElementById){
	if (document.getElementById("blockdisplay"+i)) {
	  for ( j = 1; j < 1000; j++ ) {
		if (document.getElementById('blockdisplay' + j)) {document.getElementById('blockdisplay' + j).style.display = 'none';}
		else {j = 1000;}
	  }
	  if (i) {document.getElementById("blockdisplay"+i).style.display = 'block';}
	}
  }
}
function popup(url,w,h) {
                    newWindow=window.open(url,'popupWindow','width='+w+',height='+h+',menubar=no,toolbar=no,location=no,bookmarks=no,status=no,scrollbars=yes,resizable=yes');
                    if (window.focus) {
                        newWindow.focus()
                    }
                }
function setClass(targetid,clname) {
	var targetel = document.getElementById(targetid);
	targetel.className = clname;
}
function showAddressSearch(el){
	document.getElementById('found_addresses').value=document.getElementById('found_addresses_cache').value;
	document.getElementById('orderParam').value='distance';
	if (document.getElementById('destinationSearch')) {
		hideEl('destinationSearch');
	}
	showEl('addressSearch'); setClass('addressTab','current'); setClass('destinationTab',''); el.blur();
	document.getElementById('frm').action = 'http://maps.bookings.net/map_viewer/address_search.html';
}
function showDestinationSearch(el){
	document.getElementById('found_addresses_cache').value=document.getElementById('found_addresses').value;
	document.getElementById('found_addresses').value='';
	document.getElementById('orderParam').value='';
	hideEl('addressSearch');
	if (document.getElementById('destinationSearch')) {
		showEl('destinationSearch');
	}
	setClass('destinationTab','current'); setClass('addressTab',''); el.blur();
	if(document.getElementById('address_changed').value){
		document.getElementById('frm').action = '/searchresults.html';
	} 
}
function setAddressChanged(){
	document.getElementById('address_changed').value=1;
	document.getElementById('frm').action = 'http://maps.bookings.net/map_viewer/address_search.html';
	document.getElementById('found_addresses').value='';
}

// Getting element dimensions
function getDimensions( elm ) {
	var box = { x:0, y:0, w:0, h:0 };
	if(document.getBoxObjectFor) {
		var boxRef = document.getBoxObjectFor(elm);
		box.x = boxRef.x;
		box.y = boxRef.y;
		box.w = boxRef.width;
		box.h = boxRef.height;
	}
	else if(elm.getBoundingClientRect) {
		var rxIE50 = /MSIE 5\.0/g;
		//alert(rxIE50 + '.test("' + navigator.appVersion + '" = ' + rxIE50.test(navigator.appVersion));
		var boxRef = elm.getBoundingClientRect();
		box.x = boxRef.left;
		box.y = boxRef.top;
		box.w = (boxRef.right - boxRef.left);
		box.h = (boxRef.bottom - boxRef.top);
		//var s='';for(p in boxRef) s+=p+'    '; alert(s);
		// Damn IE...
		if(document.compatMode && document.compatMode != 'BackCompat') {
			// IE6/compliance mode
			box.x += document.documentElement.scrollLeft - 2;
			box.y += document.documentElement.scrollTop - 2;
		}
		else if(!gClientIsIE5) {
			// IE5.5
			box.x += document.body.scrollLeft - 2;
			box.y += document.body.scrollTop - 2;
		}
	}
	else {
		// No known box information available, walking
		// manually through offsetParents to calculate x/y coordinates
		box.w = elm.offsetWidth;
		box.h = elm.offsetHeight;
		while(elm) {
			box.x += elm.offsetLeft;
			box.y += elm.offsetTop;
			if(elm.offsetParent) // Required for Safari 1.3 :(
				elm = elm.offsetParent;
			else
				break;
		}
	}
	var cc;
	if(cc = document.getElementById('bodyconstraint'))
		box.x -= cc.offsetLeft;
	return box;
}




function printDoc() {
	if(window.print) window.print()
    else alert (tr.pressCltP);
}

function bookmark (url, description){
	if(window.external) window.external.AddFavorite(url,description);
	else alert (tr.pressCtlD);
}

function showFrameContainer (el, container, frame, url, width, height, xOffset, yOffset, busyUrl){
	    if (document.getElementById){
        var e = document.getElementById(el);
        var c = document.getElementById(container);
        var f = document.getElementById(frame);
        if (c.style.display == "block"){
            c.style.display="none";
			return false;
        }
        if (f.src != url) f.src=url;
		// make invisible and set display to block
		// so that we may measure the element
		c.style.visibility = 'hidden';
		c.style.display = 'block';
		var box = getDimensions(e);
		var left = box.x, top = box.y;
		if(xOffset) left += xOffset;
		if(yOffset) top += yOffset;
		if(!width) width = c.offsetWidth;
		var bodywidth = document.getElementById('bodyconstraint').offsetWidth;
		if((left+width) > bodywidth) left = (bodywidth - width - 40);
        c.style.left = left+'px';
        c.style.top = top+'px';
		c.style.visibility = 'visible';
        return false;
    } else {
        window.open(url);
    }
}

function hideFrameContainer (container, frame, busyUrl) {
    if (document.getElementById){
        var c=document.getElementById(container);
        var f=document.getElementById(frame);
        c.style.display="none";
    }
}

function showPhoto (imgSrc, imgCont){
    if (document.getElementById){
        var c = document.getElementById(imgCont);
        if (c.style.display != "block"){
            c.innerHTML = '<img src="' + imgSrc + '">';
        }
		else {
            c.innerHTML = '<img src="' + tr.icons + '/transparent.gif">';
            c.style.display="none";
        }
    }
}

function hideEl(el){
	if (document.getElementById){
        document.getElementById(el).style.display = 'none';
    }
}

function showEl(el){
    if (document.getElementById){
        document.getElementById(el).style.display = 'block';
    }
}


function tickCheckBox(el){
	if (document.getElementById) {
		if (document.getElementById(el)){
			document.getElementById(el).checked=true;
		}
	}
	return true;
}

function openCurrencyConverter(obj, amount, currency) {
    if (document.getElementById) {
        document.getElementById("amount").value = amount;
        document.getElementById("sourceCurrency").value = currency;
		document.getElementById("currencyResults").style.display = 'none';
        positionObj(obj, 'currencyConverter');
		document.getElementById('currencyConverter').style.display = 'block';
    }
}

function calculateCurrency () {
    if (document.getElementById) {
        var a = document.getElementById("amount").value;
        var sc = currencydb[document.getElementById("sourceCurrency").value];
        var sd = currencydb[document.getElementById("destinationCurrency").value];
        var da = Math.round(100 * a * (sd.val / sc.val)) / 100;
        document.getElementById("displayCurrencyResults").innerHTML = sc.symbol +" "+a+" = " + sd.symbol + " " + da;
		document.getElementById('currencyResults').style.display = "block";
        return false;
    }
}

function closeCurrencyConverter() {
    if (document.getElementById) {
        document.getElementById('displayCurrencyResults').innerHTML = "";
		document.getElementById('currencyResults').style.display = "none";
        document.getElementById('currencyConverter').style.display = "none";
        // return false;
    }
}


function showDiv (el, div, alignX, alignY) {
	// (i) popups etc
	if (document.getElementById){
    	var i = document.getElementById(el);
		var c = document.getElementById(div);
        if (c.style.display != "block"){
			
			//var l=0; var t=0;
            //aTag = i;
            //do {
            //    aTag = aTag.offsetParent;
            //    l += aTag.offsetLeft;
            //    t += aTag.offsetTop;
			//} while (aTag.offsetParent && aTag.tagName != 'BODY');
	        //var left =  i.offsetLeft + l;
    	    //var top = i.offsetTop + t + i.offsetHeight + 2;
			var box = getDimensions(i);
			var left = box.x, top = box.y;
			//if (alignX == 'left' && c.style.width){
			//	left = left - parseInt(c.style.width);
			//}
			//if (alignY == 'top' && c.style.height){
			//	top = top - parseInt(c.style.height) -25;
			//}
			c.style.visibility = 'hidden'; // Needed to measure
			c.style.display = "block";     // Needed to measure
			if(alignX == 'left')
				left -= c.offsetWidth;
			else
				left += i.offsetWidth;
			if(alignY == 'top')
				top -= c.offsetHeight;
			else
				top += i.offsetHeight;
			if(top<10)
				top = 10;
			// XXX: Don't know why IE5 needs this here and not for calendar
			if(gClientIsIE5) {
				left += document.body.scrollLeft;
				top += document.body.scrollTop;
			}
        	c.style.left = left+'px';
	        c.style.top = top+'px';
			c.style.visibility = 'visible';
		} else {
			c.style.display="none";
		}
	}
}

function hideDiv (div) {
	if (document.getElementById){
		var c=document.getElementById(div);
		c.style.display="none";
	}
}

var hide  = true;

function positionObj (p, el){
	// calendar
	//alert('positionObj');
	if (document.getElementById){
		var e = document.getElementById(el);
        var bw = getBrowserWidth();

		//var l=0; var t=0;
		//aTag = p;
		//do {
		//	aTag = aTag.offsetParent;
		//	l += aTag.offsetLeft;
		//	t += aTag.offsetTop;
		//} while (aTag.offsetParent && aTag.tagName != 'BODY');
		//var left =  p.offsetLeft + l;
		var box = getDimensions(p);
		var left = box.x, top = box.y;

		// this should be replaced by something generic.
		// for some reason e.style.width is emptly, so
		// i cannot read the width of this element
		// XXX, Hakan: e.style.width is unsafe. Use e.offsetWidth
		// instead, and make sure the element is not set to display: none

		//var width = 300;
		e.style.visibility = 'hidden';
		e.style.display = 'block';
		if ((left + e.offsetWidth) > bw){
			left = (bw - e.offsetWidth - 30);
		}
		var x = document.getElementById('bodyconstraint').offsetLeft;
		left -= x;
		e.style.display = 'none';
		e.style.visibility = 'visible';

		//var top = p.offsetTop + t + p.offsetHeight + 2;
		e.style.left = left+'px';
		e.style.top = top+'px';
	}
}

function getBrowserWidth(){
  var w = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    w = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    w = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    w = document.body.clientWidth;
  }
  return w;
}

function getBrowserHeight(){
  var h = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    h = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    h = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    h = document.body.clientHeight;
  }
  return h;
}

function showBlock(el){
	if (document.getElementById) {
		document.getElementById(el).style.display = 'block';
	}
}

function displayArrow(ulist, image) {
    var ulBlock = document.getElementById(ulist);
    var ulBlockDisplay = ulBlock.style.display;
    var arrowImg = document.getElementById(image);
    if (ulBlockDisplay == "none") {
        arrowImg.style.backgroundPosition = "0 -11px";
    }
    else {
        arrowImg.style.backgroundPosition = "left top";
    }
}
function toggleTxt(ulist, spanAll, spanTop) {
    var ulBlock = document.getElementById(ulist);
    var ulBlockDisplay = ulBlock.style.display;
    var txtAll = document.getElementById(spanAll);
    var txtTop = document.getElementById(spanTop);
    if (ulBlockDisplay == "none") {
        txtAll.style.display = "none";
        txtTop.style.display = "inline";
    }
    else {
        txtAll.style.display = "inline";
        txtTop.style.display = "none";
    }
}

function sSc(q, bar, score){
    if (document.getElementById){
        document.getElementById('rbar_'+q).style.backgroundPosition= bar + 'px 0';
        document.getElementById('rsc_' + q).innerHTML=score;
    }
}
function sSc2(nr, el){
    if (document.getElementById){
        document.getElementById('rnr').innerHTML=nr;
        for ( var i = -1; i < 10; i++ ) {
            var l = document.getElementById('rl' + i);
            if (l) {
                l.style.color='';
                l.style.textDecoration='underline';
            }
        }
        el.style.color='#003580';
        el.style.textDecoration='none';
        el.blur();
    }
}

function fixBanner() {
}


// Basic event handling
function addListener( elm, event, handler ) {
	if(elm.addEventListener)
		elm.addEventListener(event, handler, false);
	else if(elm.attachEvent)
		elm.attachEvent('on'+event, handler);
	else
		elm['on'+event] = handler;
}

function removeListener( elm, event, handler ) {
	if(elm.removeEventListener)
		elm.removeEventListener(event, handler, false);
	else if(elm.detachEvent)
		elm.detachEvent('on'+event, handler);
}

var DOM = {
	isParentOf: function( parentElm, contextElm) {
		while(contextElm && (contextElm != parentElm))
			contextElm = contextElm.parentNode;
		return (contextElm == parentElm);
	},
	getParentOrSelf: function( contextElm, nodeName ) {
		nodeName = nodeName.toLowerCase();
		while(contextElm.nodeName.toLowerCase() != nodeName && contextElm.parentNode)
			contextElm = contextElm.parentNode;
		return contextElm;
	},
	addClass: function( elm, className ) {
		elm.className += ' '+className;
	},
	removeClass: function( elm, className) {
		var classMatch = new RegExp('\\b'+className+'\\b', 'g');
		if(classMatch.test(elm.className))
			elm.className = elm.className.replace(classMatch, ' ');
	}	
};

var gClientIsGecko = (window.controllers) ? true : false;
var gClientIsOpera = (window.opera) ? true : false;
var gClientIsIE    = (document.all && !gClientIsOpera) ? true : false;
var gClientIsIE5   = (gClientIsIE && /MSIE 5\.0/.test(navigator.appVersion)) ? true : false;
var gClientIsMac   = (/Mac/.test(navigator.appVersion)) ? true : false;
//var gClientIsOk    = //???
// Onload function
function _init() {
	//alert(gClientIsIE5);
  fixMail();
	if(window.initDaySelect)
		initDaySelect();
}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}

function langPosition()
{
	poselment = 'baner';
	elm2posit = 'flags';
	var xpos = findPosX( document.getElementById( poselment ) );
	var browser = navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if ( ( browser == "Microsoft Internet Explorer" ) && (version >= 4) )
	{
		document.getElementById(elm2posit).style.top = '43px';
	}
	else
		document.getElementById(elm2posit).style.top = 33+'px';
	document.getElementById(elm2posit).style.left = (xpos+845)+'px';
	document.getElementById(elm2posit).style.display = 'block';
}
//####################

var END_OF_INPUT = -1;

var base64Chars = new Array(
    'A','B','C','D','E','F','G','H',
    'I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X',
    'Y','Z','a','b','c','d','e','f',
    'g','h','i','j','k','l','m','n',
    'o','p','q','r','s','t','u','v',
    'w','x','y','z','0','1','2','3',
    '4','5','6','7','8','9','+','/'
);

var reverseBase64Chars = new Array();
for (var i=0; i < base64Chars.length; i++){
    reverseBase64Chars[base64Chars[i]] = i;
}

var base64Str;
var base64Count;
function setBase64Str(str){
    base64Str = str;
    base64Count = 0;
}
function readBase64(){    
    if (!base64Str) return END_OF_INPUT;
    if (base64Count >= base64Str.length) return END_OF_INPUT;
    var c = base64Str.charCodeAt(base64Count) & 0xff;
    base64Count++;
    return c;
}
function encodeBase64(str){
    setBase64Str(str);
    var result = '';
    var inBuffer = new Array(3);
    var lineCount = 0;
    var done = false;
    while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT){
        inBuffer[1] = readBase64();
        inBuffer[2] = readBase64();
        result += (base64Chars[ inBuffer[0] >> 2 ]);
        if (inBuffer[1] != END_OF_INPUT){
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
            if (inBuffer[2] != END_OF_INPUT){
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
                result += (base64Chars [inBuffer[2] & 0x3F]);
            } else {
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
                result += ('=');
                done = true;
            }
        } else {
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
            result += ('=');
            result += ('=');
            done = true;
        }
        lineCount += 4;
        if (lineCount >= 76){
            result += ('\n');
            lineCount = 0;
        }
    }
    return result;
}
function readReverseBase64(){   
    if (!base64Str) return END_OF_INPUT;
    while (true){      
        if (base64Count >= base64Str.length) return END_OF_INPUT;
        var nextCharacter = base64Str.charAt(base64Count);
        base64Count++;
        if (reverseBase64Chars[nextCharacter]){
            return reverseBase64Chars[nextCharacter];
        }
        if (nextCharacter == 'A') return 0;
    }
    return END_OF_INPUT;
}

function ntos(n){
    n=n.toString(16);
    if (n.length == 1) n="0"+n;
    n="%"+n;
    return unescape(n);
}

function decodeBase64(str){
    setBase64Str(str);
    var result = "";
    var inBuffer = new Array(4);
    var done = false;
    while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
        && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
        inBuffer[2] = readReverseBase64();
        inBuffer[3] = readReverseBase64();
        result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
        if (inBuffer[2] != END_OF_INPUT){
            result +=  ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
            if (inBuffer[3] != END_OF_INPUT){
                result +=  ntos((((inBuffer[2] << 6)  & 0xff) | inBuffer[3]));
            } else {
                done = true;
            }
        } else {
            done = true;
        }
    }
    return result;
}

var digitArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
function toHex(n){
    var result = ''
    var start = true;
    for (var i=32; i>0;){
        i-=4;
        var digit = (n>>i) & 0xf;
        if (!start || digit != 0){
            start = false;
            result += digitArray[digit];
        }
    }
    return (result==''?'0':result);
}

function pad(str, len, pad){
    var result = str;
    for (var i=str.length; i<len; i++){
        result = pad + result;
    }
    return result;
}

function encodeHex(str){
    var result = "";
    for (var i=0; i<str.length; i++){
        result += pad(toHex(str.charCodeAt(i)&0xff),2,'0');
    }
    return result;
}

function decodeHex(str){
    str = str.replace(new RegExp("s/[^0-9a-zA-Z]//g"));
    var result = "";
    var nextchar = "";
    for (var i=0; i<str.length; i++){
        nextchar += str.charAt(i);
        if (nextchar.length == 2){
            result += ntos(eval('0x'+nextchar));
            nextchar = "";
        }
    }
    return result;
    
}