/*
$Id: global.js,v 1.5 2006/09/22 08:47:15 dfraszczak Exp $
*/

/* DHTML OPTIONS */
var isCSS, isW3C, isIE4, isNN4, isIE6CSS;
var isNN, isIE;

function initDHTMLAPI() {
    if (document.images) {
		isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isIE4 = (isCSS && document.all) ? true : false;
        isNN4 = (document.layers) ? true : false;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
    }
	isNN = (navigator.appName.indexOf('Netscape') != -1) ? true : false;
	isIE = (navigator.appName.indexOf('Explorer') != -1) ? true : false;
}
//window.onload = initDHTMLAPI;
initDHTMLAPI();

// for NN4
function findLayer(doc, name) {
    var object;
    for (var i = 0; i < doc.layers.length; i++) {
        if (doc.layers[i].name == name) {
            object = doc.layers[i];
            break;
        }
        if (doc.layers[i].document.layers.length > 0) object = findLayer(document.layers[i].document, name);
    }
    return object;
}//end func

function getObject(ob) {
	var object;
	if(typeof ob != "string") return ob;
	if(isW3C) object = document.getElementById(ob);
	else if (isIE4) object = document.all(ob);
	else if (isNN4) object = findLayer(document, ob);
    return object;
}//end func

function getObjectStyle(ob) {
    var object = getObject(ob);
    if (object && isCSS) object = object.style;
    return object;
}//end func
/* END DHTML OPTIONS */

function openWindow(url, width, height, scroll){
	var options = "fullscreen=no, toolbar=no, location=no, directories=no, resizable=no, menubar=no, status=no";
	if(scroll) options += ",scrollbars=yes";
	var left = 150;
	var top = 150;
	if(width > 0) {	 options += ",width=" + width;	left = (screen.width / 2) - (width / 2); }
	if(height > 0) { options += ",height=" + height; top = (screen.height / 2) - (height / 2); }
	options += ",left=" + left;
	options += ",top=" + top;
	try {
		newwindow = window.open(url, "mywindow", options);
		if(typeof newwindow == 'object') newwindow.focus();
	} catch(e){}
} // end func


/* CURRENCY CALCULATOR */
function calcFillOptions(id_form) {
	var obj = getObject(id_form);
	if (obj == undefined) return;
	var elem1 = obj.currency1;
	var elem2 = obj.currency2;
	for(var i=0; i<calc_curr_amount; i++) {
		elem1.options[i] = new Option(calc_curr_code[i], calc_curr_value[i], 0, 0);
		elem2.options[i] = new Option(calc_curr_code[i], calc_curr_value[i], 0, 0);
	}
	if(calc_selectedIndex >= 0) {
		elem1.options[calc_selectedIndex].selected = true;
		elem2.options[calc_selectedIndex].selected = true;
	}
	obj.value1.value = 0;
	obj.value2.value = 0;
} // end func

function calcCurrencyCount(id_form) {
	var obj = getObject(id_form);
	if (obj == undefined) return;
	var currency1, currency2, value1, value2;
	currency1 = obj.currency1.options[obj.currency1.selectedIndex].value;
	currency2 = obj.currency2.options[obj.currency2.selectedIndex].value;
	value1 = obj.value1.value;
	value2 = obj.value2.value;
	if(value1.indexOf(",") >= 0) value1 = value1.replace(",", ".");
	if(isNaN(value1) || value1=="") value1 = "0";
	if(isNaN(value2) || value2=="") value2 = "0";
	value2 = Math.round(100*parseFloat(currency1)*parseFloat(value1)/parseFloat(currency2))/100.0;
 	obj.value2.value = value2;
} //end func
/* END CURRENCY CALCULATOR */

function setMyHotel(htid){
	var myhotels = getcookie("myhotels");
	if(myhotels != null) {
		var re = eval("/(^|\|)"+htid+"(\||$)/gi");
		if(r = myhotels.match(re)) return;
		myhotels = myhotels + "|" + htid;
	}
	else myhotels = htid;
	setcookie("myhotels", myhotels);
	document.location.reload();
} // end func

function delMyHotel(htid){
	var myhotels = getcookie("myhotels");
	if(myhotels.length == 0) return;
	//var re = eval("/(^|\|)"+htid+"(\||$)/gi");
	//myhotels = myhotels.replace(re, "");
	if(myhotels.indexOf("|") == -1) myhotels = "";
	else myhotels = delHotelFromString(myhotels, htid);
	setcookie("myhotels", myhotels);
	document.location.reload();
} // end func

function delHotelFromString(myhotels, htid){
	if(myhotels.indexOf("|") == -1) return;
	var tmp = new Array();
	tmp = myhotels.split("|");
	var all = tmp.length;
	var last = all-1;
	for(var i in tmp) { if(tmp[i] == htid) {tmp[i] = tmp[last]; break;}	}
	--tmp.length;
	if(tmp.length > 1) myhotels = tmp.join("|");
	else myhotels = tmp[0];
	return myhotels;
} // end func

function setcookie(name, value){
	var nw = new Date();
	if(value == "") nw.setTime(tout = (2400) + nw.getTime());
	else nw.setTime(tout = (2400*60*60*1000) + nw.getTime());
	var tout= (nw.toGMTString());
	document.cookie= name +"=" + escape(value) + "; expires="+tout;
} // end func

function getcookie(name){
	var search = name + "=";
	var offset = 0;
	if(document.cookie.length == 0) return;
	offset = document.cookie.indexOf(search);
	if(offset == -1) return;
	offset += search.length;
	end = document.cookie.indexOf(";", offset);
	if(end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(offset, end));
} // end func

var re_zip = new Array();
re_zip["AT"] = /^\d{4}$/gi;
re_zip["CH"] = /^\d{4}$/gi;
re_zip["CZ"] = /^\d{3}[ \-]?\d{2}$/gi;
re_zip["SK"] = /^\d{3}[ \-]?\d{2}$/gi;
re_zip["ES"] = /^\d{5}$/gi;
re_zip["FR"] = /^\d{5}$/gi;
re_zip["HU"] = /^\d{4}$/gi;
re_zip["IT"] = /^\d{5}$/gi;
re_zip["PL"] = /^\d{2}-\d{3}$/gi;
re_zip["RO"] = /^\d{6}$/gi;
re_zip["BG"] = /^\d{4}$/gi;
re_zip["PT"] = /^\d{4}(-\d{3})?$/gi;

// Universal form validation
function CheckForm(n){
	var v,i,e,code,depend,minlen;
	for(i=0;e=n[i++];) {
		if(!e.getAttribute('pass')) continue; // for Konqueror browser
		switch(e.getAttribute('type')){
			case 'checkbox':
				if(v=window[e.getAttribute('pass')])
				if(!v(e.checked)){ alert(alert_msg[e.getAttribute("alert")]);e.focus();return 1; };
				break;
			case 'radio':
				if(v=window[e.getAttribute('pass')]) if(!v(e)){ alert(alert_msg[e.getAttribute("alert")]);e.focus();return 1; }
				break;
			default:
				e.value = Trim(e.value);
				if(e.getAttribute('param')) code = e.getAttribute('param');
				if(e.getAttribute('code')) code = e.getAttribute('code');
				if(e.getAttribute('minlen')) code = e.getAttribute('minlen');
				if(e.getAttribute('depend')){
					depend = e.getAttribute('depend'); if(checkDependency(e.form, depend)) continue;
				}
				if(v=window[e.getAttribute('pass')]) if(!v(e.value, code)){ alert(alert_msg[e.getAttribute("alert")]);e.focus();return 1; }
		}
	}
} // end func

function checkDependency(obj_form, elems){
	var tmp = new Array();
	if(elems.indexOf(",") != -1) tmp = elems.split(",");
	else tmp = [elems];
	for(var i in tmp) if(noempty(obj_form.elements[tmp[i]].value)) return false;
	return true;
}

// requirements:
function noempty(x){return x>'';}
function _checked(e){ return e; }
function radiochk(e){rnm = e.name;rfm = e.form.name;rdc = eval("document."+rfm+"."+rnm);for(i=0;f=rdc[i++];)if(f.checked) return true;return false;}
function email(e){return (/^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/i.test(e));}
function noemptymail(e){return noempty(/^[\w\.-]{1,}@[\w\.-]+\.[a-z]{2,5}$/i.test(e));}
function optnumber(x){return x==~~x;}
function number(x){return x==parseInt(x);}
function checkzip(x, code) {
	if(typeof re_zip[code] == "undefined") return noempty(x);
	//x = Trim(x);
	x = x.replace(/\s+/gi, "");
	return x.match(re_zip[code]);
}
function empass(s){
	return s.match(/^\d{13}$/gi);
}
function mlen(x, minlen){
	return x.length>=minlen;
}

//Usage: <input bla bla bla pass="requirement" alert="message_if_requirement_not_executed">
// for example: <input type="text" name="name" value="" pass="noempy" alert="Please do not leave it empty!"
// for example: <input type="text" name="name" value="" pass="email" alert="Please type valid email address!"
// To the <FORM> tag add: onsubmit="return(!CheckForm(this.elements))"
// and submit using: <input type=submit>.


function Trim(x){return x.replace(/\s+$|^\s+/g,'');}

function opinion_setcountry()
{
 for(i=0; i<nracn;i++)
 {
   kk1=document.opinion.countries;
   kk1.options[i]=new Option(acn[i],acv[i],0,0);
 }

 for(i=0; i<nraln;i++)
 {
   kk1=document.opinion.languages;
   kk1.options[i]=new Option(aln[i],alv[i],0,0);
 }
}//end func

//------------------------------------------------------------------------
function opinion_entry()
{
   for(i=0; i<nracn;i++)
   {
      kk1=document.opinion_entry.gb_country;
      if (i!=0)
         kk1.options[i]=new Option(acn[i],acv[i],0,0);
      else
         kk1.options[i]=new Option('','',0,0);
   }
}//end func

function opinion_entry_fillboxes()
{
   for(i=0; i<nracn;i++)
   {
      kk1=document.opinion.country;
      if (i!=0)
         kk1.options[i]=new Option(acn[i],acv[i],0,0);
      else
         kk1.options[i]=new Option('','',0,0);
   }
}//end func

// Hotel Search for Rank & not only!

sreg={};
scit={};
csreg={};
function add_country_search(id,countryname){ sreg[id]={cn:countryname};csreg[id]={cn:countryname};}
function add_region_search(id,id_country, regname){ sreg[id_country][id]=regname;}
function add_city_search(id_city,id_region,id_country, cityname){scit[id_city]={ctn:cityname,id_region:id_region};csreg[id_country][id_city]=cityname;}
function show_region_search(elm,n,a,i){if(n==''){clear_region_search(elm);clear_city_search(elm);} else{a=1;for(i in sreg[n]){if(i!="cn"){if(a==1){show_all_city_search(elm,n);};elm.rid.length=a+1;elm.rid[a].text=sreg[n][i];elm.rid[a++].value=i;}}elm.rid.length=a;}}
function show_city_search(elm,n,k){if(n==''){show_all_city_search(elm,k);} else {a=1;for(i in scit)if(scit[i].id_region==n){elm.ctid.length=a+1;elm.ctid[a].text=scit[i].ctn;elm.ctid[a++].value=i;}elm.ctid.length=a;}}
function show_all_city_search(elm,n){a=1;for(i in csreg[n]){if(i!="cn"){	 elm.ctid.length=a+1;elm.ctid[a].text=csreg[n][i];elm.ctid[a++].value=i;}elm.rid.length=a;}}
cits={};hots={};cshots={};

function add_country(id,countryname){ cits[id]={cn:countryname};cshots[id]={cn:countryname}; }
function add_city(id,id_country,cityname){ cits[id_country][id]=cityname; }
function add_hotel(id,id_city,id_country,hotelname){ hots[id]={hn:hotelname,id_city:id_city};cshots[id_country][id]=hotelname; }
function show_city(elm,n,a,i){if(n==''){clear_hotel(elm);clear_city(elm);} else{a=1; for(i in cits[n]){ if(i!="cn"){ if(a==1){show_all_hotel(elm,n)}; elm.entry_city.length=a+1; elm.entry_city[a].text=cits[n][i]; elm.entry_city[a++].value=i;}} elm.entry_city.length=a;}}
function show_hotel(elm,n,k){if(n==''){show_all_hotel(elm,k)} else {a=1;for(i in hots)if(hots[i].id_city==n){elm.entry_hotel.length=a+1;elm.entry_hotel[a].text=hots[i].hn;elm.entry_hotel[a++].value=i;}elm.entry_hotel.length=a;}}
function show_all_hotel(elm,n){a=1;for(i in cshots[n]){if(i!="cn"){elm.entry_hotel.length=a+1;elm.entry_hotel[a].text=cshots[n][i];elm.entry_hotel[a++].value=i;}}elm.entry_hotel.length=a;elm.entry_hotel.selectedIndex=0;}
function clear_region_search(elm){elm.rid.length=1;}
function clear_city_search(elm){elm.ctid.length=1;}
function clear_city(elm){elm.entry_city.length=1;}
function clear_hotel(elm){elm.entry_hotel.length=1;}
// end block

// Register
rreg={};rsreg={};rchot={};rcit={};rrhot={};rshot={};
function add_country_reg(id,countryname){rreg[id]={cn:countryname};rsreg[id]={cn:countryname};rchot[id]={cn:countryname};}
function add_region_reg(id,id_country, regname){rreg[id_country][id]=regname;}
function add_city_reg(id_city,id_region,id_country,cityname){rcit[id_city]={ctn:cityname,id_region:id_region};rsreg[id_country][id_city]=cityname;}
function add_hotel_reg(id,id_city,id_region,id_country,hotelname){rchot[id_country][id]=hotelname; rrhot[id]={hn:hotelname,id_region:id_region};rshot[id]={hn:hotelname,id_city:id_city};}
// show regions for country
function show_region_register(elm,n,a,i){if(n==''){clear_region_register(elm);clear_city_register(elm);clear_hotel_register(elm);}else{a=1;for(i in rreg[n]){if(i!="cn"){if(a==1){show_all_city_register(elm,n);show_all_hotel_register(elm,n)};elm.rid.length=a+1;elm.rid[a].text=rreg[n][i];elm.rid[a++].value=i;}}elm.rid.length=a;}}
//show  all cities for country
function show_all_city_register(elm,n){a=1;for(i in rsreg[n]){if(i!="cn"){elm.ctid.length=a+1;	elm.ctid[a].text=rsreg[n][i];elm.ctid[a++].value=i;}elm.ctid.length=a;}}
// Show cities for region
function show_city_register(elm,n,k){if(n==''){show_all_city_register(elm,k);show_all_hotel_register(elm,k);}else{show_all_hotel_region_register(elm,n);a=1;for(i in rcit)if(rcit[i].id_region==n){elm.ctid.length=a+1;elm.ctid[a].text=rcit[i].ctn;elm.ctid[a++].value=i;}elm.ctid.length=a;}}
// Show all hotels for country
function show_all_hotel_register(elm,n){a=1;for(i in rchot[n]){if(i!="cn"){elm.htid.length=a+1;elm.htid[a].text=rchot[n][i];elm.htid[a++].value=i;}elm.htid.length=a;}}
// show all hotels for region
function show_all_hotel_region_register(elm,n){	a=1;for(i in rrhot)if(rrhot[i].id_region==n){elm.htid.length=a+1;elm.htid[a].text=rrhot[i].hn;elm.htid[a++].value=i;}elm.htid.length=a;}
// show all hotels for city
function show_hotel_city_register(elm,n,k){if(n==''){if(elm.cid.value!='')show_all_hotel_register(elm,elm.cid.value);if(elm.rid.value!='') show_all_hotel_region_register(elm,elm.rid.value);}else{a=1;for(i in rshot)if(rshot[i].id_city==n){elm.htid.length=a+1;elm.htid[a].text=rshot[i].hn;elm.htid[a++].value=i;}elm.htid.length=a;}alert(hots);}
function clear_region_register(elm){elm.rid.length=1;}
function clear_city_register(elm){elm.ctid.length=1;}
function clear_hotel_register(elm){elm.htid.length=1;}
// end
function checkvalue(a,b){ return (a<=b&&a>0)?true:false;}
function checkperiod(x,y){
e = document.book;tsa1 = new Date(e.fy.value,e.fm.value-1,1);tsa2 = new Date(e.fy.value,e.fm.value,1);
dtsa1 = tsa1.getTime();dtsa2 = tsa2.getTime();tdiff1 = Math.round((dtsa2-dtsa1)/(1000*60*60*24));fd = (fd<=tdiff1)?fd:tdiff1;tsb1 = new Date(e.dy.value,e.dm.value-1,1);tsb2 = new Date(e.dy.value,e.dm.value,1);dtsb1 = tsb1.getTime();dtsb2 = tsb2.getTime();tdiff2 =Math.round((dtsb2-dtsb1)/(1000*60*60*24));dd = (dd<=tdiff2)?dd:tdiff2;for(i=0;i<e.fd.length;i++){if(e.fd[i].value==fd) va=i};e.fd.selectedIndex=va;
for(i=0;i<e.dd.length;i++){if(e.dd[i].value==dd) va=i};e.dd.selectedIndex=va;a = new Date(e.fy.value,e.fm.value-1,fd);b = new Date(e.dy.value,e.dm.value-1,dd);ma = a.getTime();mb = b.getTime();mc=(((mb-ma)/(1000*60*60*24))+1);return (mc<=y&&mc>1)?true:false;}

hotels = {};
hotels_alt = {};
function add_h(id,l){hotels[id] = {l:l};hotels_alt[id] = {l:l};}
function add_h_date(id,dat,l){hotels[id][l] = dat;}
function add_h_date_alt(id,dat,l){hotels_alt[id][l] = dat;}
function validchequeperiod(x,y){e = document.book;hid = e.htid.value;c = hotels[hid].l;poczatek=new Array();koniec=new Array();fy = e.fy.value;fm = e.fm.value;fd = e.fd.value;dy = e.dy.value;dm = e.dm.value;dd = e.dd.value; rok=(fy<dy)?dy:fy;if(c==0){sa = hotels[hid][0].substr(0,2);sb = hotels[hid][0].substr(3,2);ea = hotels[hid][0].substr(6,2);eb = hotels[hid][0].substr(9,2);if(sa=="01" && sb=="01" && ea=="31" && eb=="12")return true;else{  if(fy<dy && eb=="01" && dm=="1") rok=dy;else rok = fy; da = new Date(rok,sb-1,sa); mda = da.getTime(); db = new Date(rok,eb-1,ea);mdb = db.getTime();ca = new Date(fy,fm-1,fd);mca = ca.getTime();cb = new Date(dy,dm-1,dd);mcb = cb.getTime();if(mca>=mda && mca <= mdb && mcb>=mda && mcb <= mdb) return true;}}else{ca = new Date(fy,fm-1,fd);mca = ca.getTime();cb = new Date(dy,dm-1,dd);mcb = cb.getTime();l=0;for(i=0;i<=c;i++){sa = hotels[hid][i].substr(0,2);sb = hotels[hid][i].substr(3,2);ea = hotels[hid][i].substr(6,2);eb = hotels[hid][i].substr(9,2);if(fy<dy && sb=="01" && dm=="1") rok=dy; else rok = fy;da = new Date(rok,sb-1,sa);mda = da.getTime();db = new Date(rok,eb-1,ea);mdb = db.getTime();poczatek[i]=mda;koniec[i]=mdb;}ppocz=-1;kkon=-1;for(j=0;j<=i;j++){if(mca>=poczatek[j] && mca<=koniec[j] && mcb>=poczatek[j] && mcb<=koniec[j])return true;if(mca>=poczatek[j] && mca<=koniec[j]){ ppocz=j;}
if(mcb>=poczatek[j] && mcb<=koniec[j]){ kkon=j;}}if(ppocz >=0 && kkon>=0){diff = ((poczatek[kkon]-koniec[ppocz])/((1000*60*60*24)+1));if(diff<=1) return true;}}	return false;}

function cheqerr(id){var a = hotels_alt[id];var st=" ";for (b in a)if(b!="l"){st += b>0?", "+a[b]:" "+a[b];} alert_msg[604] = strcheqerr+st;}

// reklama dla Ehita
function openEhitAdvert(file,width,height,cnt,zn,type){

var ext=new Array();
ext=file.split("."); //rzbicie pliku na nazwe i rozszerzenie
/*
type - 1: popunder
type - 2: popup
*/
newWindow=window.open('','ehit','width='+width+',height='+height+',resizable=no,scrollbars=no,menubar=no,left='+(screen.width-width)/2+',top='+(screen.height-height)/2);
if(type==1){
newWindow.blur();
window.focus();
} else {
newWindow.focus();
}

var txt='';
newWindow.document.open();

if(ext[1]=='gif' || ext[1]=='jpg'){
newWindow.document.write('<html>'+
'<head><title>eHIT Collection</title></head>'+
'<body bgcolor="#000000" leftMargin="0" rightMargin="0" topMargin="0" marginheight="0" marginwidth="0">'+
'<a href="#" onclick="window.open(\'http://ehitcollection.com/'+cnt+'/?zn='+ zn + '&ads_refer=eurorest.net\');self.close();"><img src="' + file + '" width="' + width + '" height="' + height + '" border="0" /></a>'+
'</body>'+
'</html>');
}
else if(ext[1]=='swf'){
newWindow.document.write('<html>'+
'<head><title>eHIT Collection</title></head>'+
'<body bgcolor="#000000" leftMargin="0" rightMargin="0" topMargin="0" marginheight="0" marginwidth="0">'+
'<OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" WIDTH='+ width +' HEIGHT='+ height+'>'+
'<PARAM NAME=movie VALUE="'+file+'"> <PARAM NAME=quality VALUE=high>'+
'<EMBED src="'+file+'" menu=false quality=high WIDTH='+width+' HEIGHT='+height+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'+
'</EMBED></OBJECT>'+
'</body>'+
'</html>');
}
newWindow.document.close();
}//end func
function submitPHForm(el){
    var oPhForm = document.getElementById("phform");
    if (oPhForm){
	    oPhForm.action = el.href;
    	oPhForm.submit();
    }
    else{
    	window.location(el.href);
    }
}

function divider() {
	if (isIE) document.write('<div style="font-size:7px">&nbsp;</div>');
	else document.write('<div style="font-size:4px">&nbsp;</div>');
}

function acceptPayment(f,ppl) {
	if (ppl == 15) {
		document.getElementById('pplType').style.display = 'block';
		document.getElementById('pplPackets').style.display = 'none';
		document.getElementById('pplEnd').style.display = 'none';
	} else {
		f.submit();	
	}
}
function checkPayType(f,message) {
	if (f.pay_type.value == '') {
		alert(message);
	} else {
		f.submit();
	}
}

function pplDrawRadioImg(colls) {
	if ( !colls ) colls = 4;
	if ( PlnPayTypeArray ) {
		var c = 1;
		document.write('<table border="0" cellpadding="" cellspacing="0"><tr>');
		for ( var i = 0; i < 19; i++ ) {
			// wylaczenie przelewu i karty
			if (i==10 || i==11) continue;
			if ( c > colls ) {
				document.write('</tr><tr>'); c = 1;
			}
			document.write('<td align="center"><table border="0" cellpadding="0" cellspacing="0"><tr><td><input id="PlnRI' + i + '" type="radio" name="pay_type" value="' + PlnPayTypeArray[i].type + '"' + (PlnPayTypeArray[i].enable != 'true' ? ' disabled' : '') + '></td>');
			document.write('<td align="center">');
			if ( PlnPayTypeArray[i].enable == 'true' ) {
				document.write('<a href="javascript:PlnSel(\'PlnRI' + i + '\')">');
			}
			document.write('<img src="' + PlnPayTypeArray[i].img + '" border="0" align="center">');
			if ( PlnPayTypeArray[i].enable == 'true' ) {
				document.write('</a>');
			}
			document.write('<br />' + PlnPayTypeArray[i].name + '</tr></td></table></td>');
			c++;
		}
		if ( c <= colls ) {			
			document.write('<td colspan="' + (colls - c + 1)  + '">&nbsp;</td>');
		}
		document.write('</tr></table>');
	}
}

/**
 * przeliczenie kwot na podstawie kodu promocji
 * @param {Object} form
 */
function calculateGPCode(form) {
	var objCode = document.getElementById('id_gpCode');
	if (jQuery.trim(objCode.value) != '') {
		form.gpcdhdn.value = 'p';
		form.step_referer.value = '6';
		form._return.value = '1';
		form.submit();
	}
}

/**
 * pokazuje modal dialog z informacja o nie rozpoznanmym kodzie promocji
 */
function showModalGPCode() {
	jQuery(document).ready(function() {
		var objForm = jQuery('#ordfrm');
		var objContainer = jQuery('#container');
		var left = jQuery(objForm).position().left + jQuery(objContainer).position().left - 0;
		var width = jQuery(objForm).width();
		
		var top = jQuery(objForm).position().top + 180 - 0;
		
		jQuery('#simplemodal-container').css({
			"width": width + "px"
		});

		jQuery('#simplemodal-container').modal({
			position: [top,left],
			closeClass: '#dpCodeModalCloseButton',
			onClose: focusGPCode	
		});
	});
}

function focusGPCode() {
	jQuery.modal.close();
	jQuery('#id_gpCode').focus();
}

function gpCodeAccepted() {
	document.getElementById('gpCalculate').disabled='disabled';
	document.getElementById('id_gpCode').disabled='disabled';
}

function initHotelPhotos(strSmallPath, strBigPath) {
	if (arrBigPhotos.length == 0) {		
		jQuery(".hotelBigShow").hide();
	} else {
		// jest co najmniej jedno duze zdjecie - ustawiam pierwsze
		document.getElementById("hbBigPhoto").src = strBigPath + arrBigPhotos[0];
	}
	if (arrSmallPhotos.length < 2) {
		jQuery(".hotelSmlShow").hide();
	} else {
		// są co najmniej 2 zdjęcia
		document.getElementById("hbSmallPhoto1").src = strSmallPath + arrSmallPhotos[0];
		document.getElementById("hbSmallPhoto2").src = strSmallPath + arrSmallPhotos[1];
		if (arrSmallPhotos.length > 2) {
			document.getElementById("hbSmallPhoto3").src = strSmallPath + arrSmallPhotos[2];
		} else {
			jQuery("#hbSmallPhoto3").hide();
		}
	}
	
	// poakzanie zdjecia male -> duze
	jQuery("#hbSmallPhoto1").click(function(){
		document.getElementById("hbBigPhoto").src = this.src.replace(/sml/gi,'big');		
		currentBiglIdx = currentStartSmallIdx;		
		drawHotelPhotoArrows();
	});
	jQuery("#hbSmallPhoto2").click(function(){
		document.getElementById("hbBigPhoto").src = this.src.replace(/sml/gi,'big');
		currentBiglIdx = currentStartSmallIdx + 1;	
		drawHotelPhotoArrows();				
	});
	jQuery("#hbSmallPhoto3").click(function(){
		document.getElementById("hbBigPhoto").src = this.src.replace(/sml/gi,'big');
		currentBiglIdx = currentStartSmallIdx + 2;	
		drawHotelPhotoArrows();				
	});
	
	// nastepne male zdjcie
	jQuery("#hsRight").click(function(){
		currentStartSmallIdx++;
		document.getElementById("hbSmallPhoto1").src = strSmallPath + arrSmallPhotos[currentStartSmallIdx];
		document.getElementById("hbSmallPhoto2").src = strSmallPath + arrSmallPhotos[currentStartSmallIdx+1];
		document.getElementById("hbSmallPhoto3").src = strSmallPath + arrSmallPhotos[currentStartSmallIdx+2];
		drawHotelPhotoArrows();
	});

	// poprzednie male zdjcie
	jQuery("#hsLeft").click(function(){
		currentStartSmallIdx--;
		document.getElementById("hbSmallPhoto1").src = strSmallPath + arrSmallPhotos[currentStartSmallIdx];
		document.getElementById("hbSmallPhoto2").src = strSmallPath + arrSmallPhotos[currentStartSmallIdx+1];
		document.getElementById("hbSmallPhoto3").src = strSmallPath + arrSmallPhotos[currentStartSmallIdx+2];
		drawHotelPhotoArrows();
	});

	// nastepne duze zdjcie
	jQuery("#hbRight").click(function(){
		currentBiglIdx++;
		document.getElementById("hbBigPhoto").src = strBigPath + arrBigPhotos[currentBiglIdx];
		drawHotelPhotoArrows();
	});

	// poprzednie duze zdjcie
	jQuery("#hbLeft").click(function(){
		currentBiglIdx--;
		document.getElementById("hbBigPhoto").src = strBigPath + arrBigPhotos[currentBiglIdx];
		drawHotelPhotoArrows();
	});

	jQuery(document).ready(function(){
		drawHotelPhotoArrows();
	})	
}

function drawHotelPhotoArrows() {
	// nastepne male zdjecie
	if (currentStartSmallIdx + 3 >= arrSmallPhotos.length) {
		jQuery("#hsRight").hide();
	} else {
		jQuery("#hsRight").show();
	}

	// poprzednie male zdjecie
	if (currentStartSmallIdx > 0) {
		jQuery("#hsLeft").show();
	} else {
		jQuery("#hsLeft").hide();
	}

	// nastepne duze zdjecie
	if (currentBiglIdx + 1 >= arrBigPhotos.length) {
		jQuery("#hbRight").hide();
	} else {
		jQuery("#hbRight").show();
	}

	// poprzednie duze zdjecie
	if (currentBiglIdx > 0) {
		jQuery("#hbLeft").show();
	} else {
		jQuery("#hbLeft").hide();
	}
}

function hprRegisterActions() {
	jQuery("#hprRegRead").click(function(){
		hprShowTerms();
	});
	jQuery("#hprRegShortContent").click(function(){
		hprShowTerms();
	});

	jQuery("#hprRegClose").click(function(){
		jQuery("#hprRegShortContent").show();
		jQuery("#hprRegFullContent").hide();
	});
}

function hprShowTerms() {
	var pos = jQuery("#hprRegShortContent").position();	
	jQuery("#hprRegShortContent").hide();
	jQuery("#right_flash_cmap").hide();
	jQuery("#right_flash_rmap").hide();
	var scr = getWindowSize();
	jQuery("#hprRegFullContent").modal({
		position: [200,scr[0]/2-400],
		closeClass: "#hprRegClose",
		onClose: function() {
			jQuery("#hprRegShortContent").show();
			jQuery("#hprRegFullContent").hide();
			jQuery("#hprRegClose").hide();
			jQuery("#right_flash_cmap").show();
			jQuery("#right_flash_rmap").show();
			jQuery.modal.close();
		}
	});
}

/**
 * parametry scrola okna
 */
function getScrollXY() {
 	var scrOfX = 0, scrOfY = 0;
  	if( typeof( window.pageYOffset ) == 'number' ) {
    	//Netscape compliant
    	scrOfY = window.pageYOffset;
    	scrOfX = window.pageXOffset;
  	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    	//DOM compliant
    	scrOfY = document.body.scrollTop;
    	scrOfX = document.body.scrollLeft;
  	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    	//IE6 standards compliant mode
    	scrOfY = document.documentElement.scrollTop;
    	scrOfX = document.documentElement.scrollLeft;
  	}
  	return [ scrOfX, scrOfY ];
}

/**
 * wymiary okna
 */
function getWindowSize() {
 	var myWidth = 0, myHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	myWidth = window.innerWidth;
    	myHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	myWidth = document.body.clientWidth;
    	myHeight = document.body.clientHeight;
  	}
	return [myWidth, myHeight];
}

/**
 * rejestracja tooltipów formularza zamówienia
 */
function registerFormTooltips() {
	jQuery("#emailTip").hover(function(event){
		var top = event.clientY - 10;
		var left = event.clientX + 5;
		var pos = "fixed";
		if (jQuery.browser.msie && jQuery.browser.version == "6.0") {
			left = 360;
			top = event.pageY - 215;
			pos = "absolute";
		}
		jQuery("#emailTipContent").css({
			top: top + "px",
			left: left + "px",
			position: pos
		}).show();
	},function(){
		jQuery("#emailTipContent").hide();
	});

	jQuery("#phoneTip").hover(function(event){
		var top = event.clientY - 10;
		var left = event.clientX + 5;
		var pos = "fixed";
		if (jQuery.browser.msie && jQuery.browser.version == "6.0") {
			left = 360;
			top = event.pageY - 215;
			pos = "absolute";
		}
		jQuery("#phoneTipContent").css({
			top: top + "px",
			left: left + "px",
			position: pos
		}).show();
	},function(){
		jQuery("#phoneTipContent").hide();
	});
}

jQuery(document).ready(function(){
	// pokazanie szczegolow platnosci
	jQuery(".pDetails").click(function(){
		var state = this.getAttribute("state");
		var val = this.getAttribute(state);
		var uid = this.getAttribute("uid");
		jQuery(this).find("div").html(val);
		if (state == "show") {
			state = "hide";
			jQuery(this).find("div").css("background-image","url(/images/img_www/ppl/pshow.png)");
			jQuery("#pDesc"+uid).hide();
		} else {
			state = "show";
			jQuery(this).find("div").css("background-image","url(/images/img_www/ppl/phide.png)");
			jQuery("#pDesc"+uid).show();
		}
		this.setAttribute("state",state);
	});
});

function executeH03Scripts() {
	jQuery("#gh").click(function(){
		location.href = 'index.php';
	});
	
	jQuery("a[href='#ordh03']").click(function() {
		var pos = jQuery("#ordfrm").position();
		var pos2 = jQuery("#orgform").position();
		if (pos) {
			var containerPos = jQuery("#container").position();
			var t = pos.top - 24;
			var l = pos2.left + containerPos.left + 6;
			var c = 'modalClose';
			
			if (jQuery.browser.msie) {
				t = t + 2;
				c = 'modalCloseIE';
			}
			
			jQuery("#formData").modal({
				opacity: 50,
				closeHTML: '<div align="right">[x]</div>',
				closeClass: c,
				position: [t, l],
				containerId: 'tooltipContainer'
			});
			jQuery("#first_name").focus();
			jQuery("#tooltipContainer").css({position:"absolute"});
		}
	});	

	reloadRegions("search_hot_form");
	
	setInterval(changeH03CounterBck, 500);
}

function changeH03CounterBck() {
	var state = jQuery(".h03F9").attr("state");
	var bck = "cnt.jpg";
	if (state == "off") {
		bck = "cnton.jpg";
		jQuery(".h03F9").attr("state","on");
	} else {
		jQuery(".h03F9").attr("state","off");
	}	
	jQuery(".h03F9").css("background-image","url(/images/img_www/alt/h03/"+bck+")");
}