function chkmail(mailstring) {
	var resmail=mailstring.match(/\b(^(\S+@).+((\..{2,10}))$)\b/gi);
	if (resmail==null){ return false; }else{ return true; }
}

function checkData(theForm) {
	theForm.action = 'inquiry.php';

	if(theForm.subject.value=="") {
		theForm.subject.focus();
		return(false);
	}

	if(theForm.fullname.value=="") {
		theForm.fullname.focus();
		return(false);
	}

	if(theForm.address.value=="") {
		theForm.address.focus();
		return(false);
	}

	if(theForm.phone.value=="") {
		theForm.phone.focus();
		return(false);
	}

	if(theForm.email.value!="") {
		var mailres=chkmail(theForm.email.value);
		if (mailres==false) {
			theForm.email.focus();
			return(false);
		}
	}
}

function doPos(){
	var contentHeight=document.getElementById('outer').offsetHeight;
	var contentWidth=document.getElementById('outer').offsetWidth;
	var h=0;
	var w=0;

	if (window.innerHeight) h=window.innerHeight; else if (document.body && document.body.offsetHeight) h=document.body.offsetHeight;
	if (window.innerWidth) w=window.innerWidth; else if (document.body && document.body.offsetWidth) w=document.body.offsetWidth;

	if(h==0) h=document.documentElement.clientHeight;
	if(w==0) w=document.documentElement.clientWidth;

	if(h>contentHeight){
		document.getElementById('outer').style.top=Math.round((h-contentHeight)/2)+'px';	
		document.getElementById('outer').style.marginTop='0px';	
	}else{
		document.getElementById('outer').style.top='0px';
		document.getElementById('outer').style.marginTop='0px';	
	}
	if(w>contentWidth){
		document.getElementById('outer').style.left=Math.round((w-contentWidth)/2)+'px';	
		document.getElementById('outer').style.marginLeft='0px';	
	}else{
		document.getElementById('outer').style.left='0px';
		document.getElementById('outer').style.marginLeft='0px';	
	}
}

window.onresize=doPos;

function email(name, domain, tld) {
	var printemail = '<a href="mailto:'+name+'@'+domain+'.'+tld+'" title="'+name+'@'+domain+'.'+tld+'">'+name+'@'+domain+'.'+tld+'</a>';
	document.write(printemail);
}

var ros=new Array('pension','weingut','kontakt','wohnen','freizeit','preis','weinberg','weine','info','anfahrt','impressum','privacy');
var imgson=new Array();
var imgsoff=new Array();

function initimgs(){
	for(var i=0; i<ros.length; i++){
		imgson[i]=new Image();
		imgson[i].src="img/"+ros[i]+"-on.gif";
		imgsoff[i]=new Image();
		imgsoff[i].src="img/"+ros[i]+"-off.gif";
	}
}

function imageon(iname){
	for(var i=0; i<ros.length; i++){
		if (ros[i]==iname) document.getElementById(iname).src = imgson[i].src;
	}
}

function imageoff(iname){
	for(var i=0; i<ros.length; i++){
		if (ros[i]==iname) document.getElementById(iname).src = imgsoff[i].src;
	}
}

function on(name){
	imageon(name);
}

function off(name){
	imageoff(name);
}

initimgs();