function findObj(n, d) { //v3.0
  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=findObj(n,d.layers[i].document); return x;
}

function SwapImgRestore() {
  if (document.SwapImgData != null)
    for (var i=0; i<(document.SwapImgData.length-1); i+=2)
      document.SwapImgData[i].src = document.SwapImgData[i+1]; 
}

function SwapImage() {
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.SwapImgData;
  for (i=0; i < (SwapImage.arguments.length-2); i+=3) {
    objStr = SwapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = SwapImage.arguments[i+2];
  } }
  document.SwapImgData = swapArray; //used for restore
}

function replaceGalleryImage(imageSrc,textSrc,widthSrc,heightSrc){

	document.getElementById('GalleryImage').src = imageSrc;
	document.getElementById('GalleryImage').width = widthSrc;
	document.getElementById('GalleryImage').height = heightSrc;

	var textToReplace = document.getElementById('GalleryText');
			textToReplace.firstChild.nodeValue=textSrc;
			
	document.getElementById('GalleryLink').setAttribute('href',imageSrc);
}

function RunEmailControl(adresa){
	 re = /^[+_a-zA-Z0-9-]+(\.[+_a-zA-Z0-9-]+)*@[\.a-zA-Z0-9-]+\.[a-zA-Z0-9-]{2,4}$/;
    return adresa.search(re) == 0;
}
function EmailControl(address,lang){
	if(RunEmailControl(address)){
		return true;
	}else{
		if(lang=="en")
             alert('Wrong e-mail address.')
		if(lang=="cz")
             alert('patně vyplněný e-mail.')
		return false
	}
}

function changeProp(objName,theProp,theValue) { //v3.0
  //var obj = findObj(objName);
  if (document.getElementById!= null)
  {
    obj = "document.getElementById('"+objName+"')";
    eval(obj+"."+theProp+" = '"+theValue+"'");
  }
  else if (document.all)
  {
    obj = "document.all."+objName;
    eval(obj+"."+theProp+" = '"+theValue+"'");
  }
  else
  {
    obj = "document."+objName;
    eval(obj+"."+theProp+" = '"+theValue+"'");
  }
}

function showcalendar(page,pwidth,pheight) {
	createPopUp(page,"CalendarWindow",pwidth,pheight,"no","no");
}
function createPopUp(theURL, Name, popW, popH, scroll, resize) {
	var winleft = (screen.width - popW) / 2;
	var winUp = (screen.height - popH) / 2;
	winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable='+resize+'';
	Win = window.open(theURL, Name, winProp);
	Win.window.focus();
}
function showhelp(page,pwidth,pheight) {
	createPopUp(page,"HelpWindow",pwidth+50,pheight,"yes","no");
}

function getCheckInDate(year,month,day){
	self.close();
	opener.setCheckInDates(day,month,year);
}
function getCheckOutDate(year,month,day){
	self.close();
	opener.setCheckOutDates(day,month,year);
}

function setCheckInDates(day,month,year) {
	date=day+'/'+month+'/'+year;
	document.calform.checkin.value = date;
}
function setCheckOutDates(day,month,year) {
	date=day+'/'+month+'/'+year;
	document.calform.checkout.value = date;
}

function getExpireDate(year,month,day){
	self.close();
	opener.setExpireDates(day,month,year);
}
function setExpireDates(day,month,year) {
	date=day+'/'+month+'/'+year;
	document.calform.expiredate.value = date;
}