function getElement(aID)  {
	var rv = (document.getElementById) ? document.getElementById(aID) : document.all[aID];
	return rv;
	}

var Mx = 0;
var My = 0;
function MakeWin(url,ww,hh,scrl)
	{
	NLWindow = window.open("","SAMOSINFOCONTROL","toolbar=no,location=no,status=no,scrollbars="+scrl+",width="+ww+",innerWidth="+ww+",height="+hh+",innerheight="+hh+",screenX=100,screenY=100,pageXoffset=100,pageYoffset=100,resizable=yes");

	if (NLWindow.frames.length == 0)
		{
		NLWindow = window.open(url,"SAMOSINFOCONTROL","toolbar=no,location=no,status=no,scrollbars="+scrl+",width="+ww+",innerWidth="+ww+",height="+hh+",innerheight="+hh+",screenX=100,screenY=100,pageXoffset=100,pageYoffset=100,resizable=yes");
		}
	else
		{
		 NLWindow.location.href = url;
		 }
	NLWindow.focus();
	}
	
function Commit(url,Comtext)
	{
	if(confirm(Comtext) == true)
		{
		document.location.href=url;
		}
	else
		{
		return false;
		}
	}

function showSub(area)	{
	areas = new Array('pricesform','contactform','googlemap');
	for(i = 0;i < areas.length;i++)	{
		dis = areas[i] + "_link";
		dsub = areas[i] + "_div";
		lnn = areas[i];
		if(area == areas[i])	{
			document.getElementById(dis).className='menuactive';
			document.getElementById(dsub).className =   'menuactive';
/*			document.getElementById(dis).style.backgroundColor='#3199FF';
			document.getElementById(dis).style.borderColor='#3199FF';*/
			document.getElementById(lnn).style.display='block';
			}
		else	{
			document.getElementById(dis).className='menu';
			document.getElementById(dsub).className = 'menu';
/*			document.getElementById(dis).style.backgroundColor='#039';
			document.getElementById(dis).style.borderColor='#039';*/
			document.getElementById(lnn).style.display='none';
			}
		}
	if(area == "googlemap")	{
		mapper = getElement("mapcontainer");
		mapper_url = getElement("mapurl");
		maptags = '<iframe id="mapframe" src="' + mapper_url.value + '" width="100%" height="400" border="0"></iframe>';
		mapper.innerHTML = maptags;

		
		document.getElementById('mapframe').src=mapper_url.value;
/*		alert(mapper_url.value);*/
		}
	}

function showMap()	{
	if(document.getElementById('mapmap').style.display == 'none')	{
		document.getElementById('mapmap').style.display='block';
		}
	else	{
		document.getElementById('mapmap').style.display='none';
		}
	}

function setArea(aid)	{
	document.getElementById('area').selectedIndex = aid;
	}
	
function setMapImg(ImgId)	{
	document.getElementById('map_imagemap').src='/images/map/Map_' + ImgId + '.gif';
	}	
function enlargeImg(Url)	{
	leftM = (Mx - 300);
	topM = (My - 100);
	document.getElementById('hotel_detailimg').style.left=leftM + "px";
	document.getElementById('hotel_detailimg').style.top=topM + "px";
	document.getElementById('hotel_detailimg_container').innerHTML='<img src=' + Url +'>';
	document.getElementById('hotel_detailimg').style.display='block';
	}		
	
function setBasicDescr()	{
	leftM = (Mx - 0);
	topM = (My - 50);
/*	alert(leftM + "->" + Mx + "::" + topM + "->" + My);*/
	document.getElementById('hotel_basicinfo').style.left=leftM + "px";
	document.getElementById('hotel_basicinfo').style.top=topM + "px";
	}		

function CPos(e) {
/*	var posx = 0;
	var posy = 0;*/
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		Mx = e.pageX;
		My = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		Mx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		My = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}	

function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_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=MM_findObj(n,d.layers[i].document); return x;
}

function getSelVal(elm)	{
	return(elm.options[elm.selectedIndex].value);
	}
	
function CheckDates()	{
	var jetzt = new Date();
	var Jahr = jetzt.getFullYear();
	fmonth = getSelVal(getElement('fmonth'));
	tmonth = getSelVal(getElement('tmonth'));
	fday = getSelVal(getElement('fday'));
	tday = getSelVal(getElement('tday'));
	from = Jahr+fmonth + fday;
	to = Jahr+tmonth + tday
	if(parseInt(from) >= parseInt(to))	{
		alert("Departure date should be after arrival date!");
		return false;
	}
	MM_validateForm('Name','','R','Email','','RisEmail','Message','','R');
	return document.MM_returnValue		
	}

document.onmousedown = CPos;
