function checkForm(formID){
	myForm = document.getElementById(formID);
	// alert(formID);
	if (typeof(myForm) != "object") return false;
	myElements = myForm.elements;
	myError = new Array();
	for (f=0; f<myElements.length; f++){
		
		
		myElement = myElements[f];
		
		
		if (myElement.id.indexOf('_req') != -1){
			// REQUIRED FIELD
			if (myElement.value == "" || (myElement.type == "checkbox" && myElement.checked != true)) {
				myError.push(myElement);
			}
		}
	}
	if (myError.length > 0){
		alert(FeldError);
		myError[0].focus();
		return false;
	} else { 
		return true;
	}
	return false;
}


function findPosLeft(obj) {
	if (obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return curleft;
	}
}
 function findPosTop(obj) {
	if (obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return curtop;
	}
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MainHolderInit() {
	ob = document.getElementById('MainHolder');
	ob.style.height='400px';
	ob.style.overflow='hidden';
	
}
var MyFoxStatus = 'hidden';
var MyFoxSearchStatus = 'hidden';

function MyFox() {
	posTop = parseInt(findPosTop(Get('LoginButton'))) + 23;
	posLeft = parseInt(findPosLeft(Get('LoginButton'))) + 379 - 173;
	
	Get('MyFoxBox').style.top = posTop + 'px';
	Get('MyFoxBox').style.left = posLeft + 'px';
	
	if(MyFoxStatus=='hidden') {
		haus=new Effect.SlideDown('MyFoxBox', {duration: 1, scaleFrom: 2});
		MyFoxStatus='shown';
		if (MyFoxSearchStatus == 'shown') {
			haus2=new Effect.Fade('MyFoxSearch', {duration: 1, scaleFrom: 100, scaleTo:4});	
			MyFoxSearchStatus='hidden';
		}
		//window.setTimeout('SelectFoxFields()',1500);
	} else {
		haus=new Effect.Fade('MyFoxBox', {duration: 1, scaleFrom: 100, scaleTo:4});
		MyFoxStatus='hidden';
		
    }

}

function SelectFoxFields() {
	Get('myFoxLogin').focus();
	Get('myFoxLogin').select();
}


function Get(o) {
	return document.getElementById(o);	
}

function FoxSearch(o) {
	if (o.value == 'Event,Startnummer') {
		o.value = '';	
	}
	MyFoxSearch();
}

function MyFoxSearch() {
	posTop = parseInt(findPosTop(Get('FoxFastSearch'))) + 40;
	posLeft = parseInt(findPosLeft(Get('FoxFastSearch'))) - 9;
	Get('MyFoxSearch').style.top = posTop + 'px';
	Get('MyFoxSearch').style.left = posLeft + 'px';
	
	if(MyFoxSearchStatus=='hidden') {
		haus=new Effect.SlideDown('MyFoxSearch', {duration: 1, scaleFrom: 2});
		MyFoxSearchStatus='shown';
		if (MyFoxStatus == 'shown') {
			haus2=new Effect.Fade('MyFoxBox', {duration: 1, scaleFrom: 100, scaleTo:4});	
			MyFoxStatus='hidden';
		}
	} else {
		haus=new Effect.Fade('MyFoxSearch', {duration: 1, scaleFrom: 100, scaleTo:4});
		MyFoxSearchStatus='hidden';
		
    }

}

function SwtichBoxC() {
	SwtichBox('cart');	
}

function SwtichBoxL() {
	SwtichBox('lightbox');	
}

function SwtichBox(wich) {
	if (wich == 'cart') {
		Get('BTNLightbox').src='images/lightbox-inactive'+ dblang +'.gif';
		Get('BTNCart').src='images/warenkorb-active'+ dblang +'.gif';
	}
	
	if (wich == 'lightbox') {
		Get('BTNLightbox').src='images/lightbox-active'+ dblang +'.gif';
		Get('BTNCart').src='images/warenkorb-inactive'+ dblang +'.gif';	
	}
	SendRequestFF('LoadBox','','Wich=' + wich);
	Get('LightWare').style.display='block';
	Get('LightWareContent').style.height=137+'px';
}

function ExpandBasket(wich) {
	SendRequestFF('LoadBox','','Wich=' + wich + '&All=true');
}
 
function BlendBoxDown(w) {	
	
	nh = Math.ceil(w/2) ;
	// alert(nh);
	if (nh == 1) nh = 1;
	
	nh = nh * 72;
	nh = nh + 60;
	
	
	Start = parseInt(Get('LightWareContent').offsetHeight);
	Get('LightWareContent').style.height= nh + 'px';
 	 
}

function getKeyCode(e) {
	if(window.event) {
		keynum = e.keyCode;
	}
		else if(e.which) 	{
			keynum = e.which;
	}
	 return keynum;
}

function BuyFlat(EventID,Startnummer) {
	SendRequestFF('AddToCart','','ID='+ EventID +'&type=flat&startnummer=' + Startnummer );
}

function replaceQPayForm() {
	ReplaceFields = Array('userOpening_req','userName_req','userSurname_req','userStrasse_req','userPLZ_req','userOrt_req');
	
	for (var i = 0; i < ReplaceFields.length; ++i) {
		// alert(ReplaceFields);
		Value = document.getElementById(ReplaceFields[i]).value;
		Value = Value.replace(/\W/gi, '');
		
		
		//Value = escapeURI(Value);
		
		document.getElementById(ReplaceFields[i]).value = Value;
		
 
	}

}