

function openCalendar(date,who){
	if (who==undefined) {
		who = "&who=1";
	} else { who = "&who="+who; }
	window.open('inc.small.calendar.php?date='+date+who,'Calendar', 'left=650,top=305,width=190,height=180,toolbar=0,resizable=1,scrollbars=1');
}

function popHotel(id){
	window.open('/export/pop.hotelinfo.php?id='+id,'popHotel', 'left=650,top=305,width=490,height=480,toolbar=0,resizable=1,scrollbars=1');
}
function popImg(url){
	window.open(url,'popImg', 'left=650,top=305,width=640,height=480,toolbar=0,resizable=1,scrollbars=1');
}


function openBWrekins(ebill){
	window.open('<?=SSL_SITE_URL;?>/export/rekins.BW.php?ebill='+ebill,'ebill', 'left=20,top=20,width=600,height=700,toolbar=0,resizable=1,scrollbars=1');
}
function openBWbiltete(eticket_id){
	window.open('<?=SSL_SITE_URL;?>/export/bilete.BW.php?eticket_id='+eticket_id,'eticket', 'left=20,top=20,width=600,height=700,toolbar=0,resizable=1,scrollbars=1');
}


	
function changeHREF(url, pname, pvalue, todel) {
if(url==""){url = window.location.href;}
if(todel==undefined) {var todel = new Array();}
for(i=0;i<todel.length;i++){
	if (url.indexOf(todel[i]+"=") != -1) {
	  var before = url.substring(0, url.indexOf(todel[i]+"=")-1);
	  var after = url.substring(url.indexOf(todel[i]+"="));
	  if (after.indexOf('&') != -1)
	   after = after.substring(after.indexOf("&"), after.length);
	  else
	   after = "";	
	url = before + after;
	}
}
//alert(url);
	
 if (url.indexOf(pname+"=") != -1) {
  var before = url.substring(0, url.indexOf(pname+"="));
  var after = url.substring(url.indexOf(pname+"="));
  if (after.indexOf('&') != -1)
   after = after.substring(after.indexOf("&"), after.length);
  else
   after = "";
   gohere = before + pname + "=" + pvalue + after;
   	if(gohere.indexOf("?")==-1){
		pos=gohere.indexOf("&");		
		if(pos!=-1) gohere = gohere.substr(0,pos)+"?"+gohere.substr(pos+1,gohere.length);
	}
  return gohere;
 } else{
    gohere = url+(url.indexOf("?")=="-1"?"?":"&")+pname+"="+pvalue
  return gohere;
 }
} 



function getURLParamValueFrom(name, url) {
 // case sensitive!
 if (url.indexOf(name+"=") != -1) {
  var currparams;
  var paramarr = url.split('?');
  var paramstr = paramarr[1];
  var params = paramstr.split('&');
  for (var a = 0; a < params.length; a++) {
   currparams = params[a].split('=');
   if (currparams[0] == name) {
    if (currparams.length == 1)
     return true;
    else
     return currparams[1];
   }
  }
 }
 return false;
}

function checkMail(x)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {
		return true;
	} else {
		return false;
	}
}

var isNumeric = function(x) {
   // returns true if x is numeric and false if it is not.
   var RegExp = /^(-)?(\d*)(\.?)(\d*)$/; 
   return String(x).match(RegExp);
}

var isLetter = function(x) {
	if(String(x).match(/^[a-zA-Zа-яА-ЯЙйЁёĀāČčĢģĒēĶķĪīĻļŠšŪū_-]+$/)) {
		return true;
	} else return false;
}


function refresh_close(){
	var refresh;
	if(window.opener.location.href.indexOf('#')!=-1){
		refresh = window.opener.location.href.substring(0, window.opener.location.href.indexOf('#'));
	}else refresh = window.opener.location;
	window.opener.location=refresh;
	window.close();
}





/* COOKIES START */
function createCookie(name,value,mins) {
	if (mins) {
		var date = new Date();
		date.setTime(date.getTime()+(mins*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);
}
/* COOKIES END */

Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}