function booking(url) {

    var width = 1000;
    var height = 700;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status=0,resizable=1,scrollbars=1,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    var bookwin = window.open(url, 'booking', windowFeatures);
}

function OpenWin(url){
	window.open(url, '', 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}

function OpenWindow(url, width, height, options){

	if (options == "") options = ',scrollbars=yes,menubar=no,resizable=yes,toolbar=no,location=no,status=no'

	window.open(url, '', 'height=' + height + ',width=' + width + '' + options);
}

function OpenDialog(url, width, height, arg){

	if (arg == '') arg = ''

	retVal = window.showModalDialog(url, arg, 'dialogHeight: ' + height + 'px; dialogWidth: ' + width + 'px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; scroll: Yes; status: No;');

	if (retVal != ''){
		eval(retVal)
	}
}

function ResizeWindowToPicture(pic){
  var pwidth = pic.width + 4;
  var pheight = pic.height + 28;

  if (window.showModalDialog){
    window.dialogHeight = pheight + 'px';
    window.dialogWidth = pwidth + 'px';
  } else {
    window.resizeTo(pwidth,pheight);
  }
}

function SendToFriend(){

	var url = escape(document.location.href);
	OpenWindow('/tipfriend.aspx?url=' + url, 450, 550, '')
}

function SubmitNewsletter(){
	name = document.forms[0].newslettername.value;
	email = document.forms[0].newsletteremail.value;
	document.location.href = '/newsletter.aspx?name=' + name + '&email=' + email;
	return false;
}

function SubmitSearch(){
	country = document.forms[0].country.value;
	//area = document.forms[0].area.value;
	persons = document.forms[0].persons.value;
	price = document.forms[0].price.value;
	keyword = document.forms[0].keyword.value;
	document.location.href = '/search.aspx?c=' + country + '&s=' + persons + '&p=' + price + '&q=' + keyword;
	return false;
}

function bookmark() {

    var title = "Billige hytter til skiferien - Skihytte.com";
    var url = "http://www.skihytte.com";

    track_bookmark()

    if (window.sidebar) { // Mozilla Firefox Bookmark
	window.sidebar.addPanel(title, url,"");
    } else if( window.external ) { // IE Favorite
	window.external.AddFavorite( url, title);
    } else if(window.opera && window.print) { // Opera Hotlist
	return true;
    }
    return false;
}

function track_bookmark(){

wa_account="8C949697868B8B9AA09C9092";
wa_location=214;
wa_pageName=location.pathname;
ec_Bookmark_orderID='Bookmark';
ec_Bookmark_orderAmt='0';

document.cookie='__support_check=1';
wa_hp='http';
wa_rf=document.referrer;
wa_sr=window.location.search;
wa_tz=new Date();
if(location.href.substr(0,6).toLowerCase()=='https:')
wa_hp='https';
wa_data='&an='+escape(navigator.appName)+ 
'&sr='+escape(wa_sr)+'&ck='+document.cookie.length+
'&rf='+escape(wa_rf)+'&sl='+escape(navigator.systemLanguage)+
'&av='+escape(navigator.appVersion)+'&l='+escape(navigator.language)+
'&pf='+escape(navigator.platform)+'&pg='+escape(wa_pageName);
wa_data=wa_data+'&cd='+
screen.colorDepth+'&rs='+escape(screen.width+ ' x '+screen.height)+
'&tz='+wa_tz.getTimezoneOffset()+'&je='+ navigator.javaEnabled();
wa_img=new Image();
wa_img.src=wa_hp+'://loc1.hitsprocessor.com/statistics.asp'+
'?v=1&s='+wa_location+'&eacct='+wa_account+wa_data+'&tks='+wa_tz.getTime()+
'&ec_type=126734&ec_uniqueId='+ec_Bookmark_orderID+'&ec_orderAmount='+ec_Bookmark_orderAmt;
document.getElementById('wa_u').src=wa_hp+'://loc1.hitsprocessor.com/track.js';
}

function frontbox_tabs(tab) {

	var tabnames = "FR,IT,NO,CH,SE,CZ,DE,AT";
	var tabarray = tabnames.split(",");

	for (var i=0;i<tabarray.length;i++){
		if (document.getElementById("teaserbox_" + tabarray[i])!=null){
			document.getElementById("teaserbox_" + tabarray[i]).style.display='none';
		}
	}

	if (document.getElementById("teaserbox_" + tab)!=null)
		document.getElementById("teaserbox_" + tab).style.display='block';
}

document.onkeydown = keydown;

function keydown(evt){

	if (!evt) evt = event;
	
	if (document.all){
		if (evt.ctrlKey && evt.altKey && evt.keyCode==76){ 
			// CTRL+ALT+L
		} else if (evt.shiftKey && evt.keyCode == 9){ 
			// Shift+TAB
		} else if (evt.keyCode == 13){
		  if (evt.srcElement.getAttribute("id") == 'NewsletterEmail'){
		  	SubmitNewsletter();
		  	return false;
		  }
		  if (evt.srcElement.getAttribute("id") == 'SearchCountry'
			|| evt.srcElement.getAttribute("id") == 'SearchArea'
			|| evt.srcElement.getAttribute("id") == 'SearchPersons'
			|| evt.srcElement.getAttribute("id") == 'SearchPrice'
			|| evt.srcElement.getAttribute("id") == 'SearchKeyword'
			){
		  	SubmitSearch();
		  	return false;
		  }
		}
	} else {
		var key = evt.which;
		if (key==13){
		  if (evt.target.getAttribute("id") == 'NewsletterEmail'){
		  	SubmitNewsletter();
		  	return false;
		  }
		  if (evt.target.getAttribute("id") == 'SearchCountry'
			|| evt.target.getAttribute("id") == 'SearchArea'
			|| evt.target.getAttribute("id") == 'SearchPersons'
			|| evt.target.getAttribute("id") == 'SearchPrice'
			|| evt.target.getAttribute("id") == 'SearchKeyword'
			){
		  	SubmitSearch();
		  	return false;
		  }
		}
	}
	return true;
}