var c = null;

function showImprint()
{
	c = 'imprint';
	showOverlay();
	
	return false;
}
function showNewsletter()
{
	c = 'newsletter';
	showOverlay();
	
	return false;
}
function showOverlay()
{
	var arrayPageSize = getPageSize();
	Element.setHeight('overlay', arrayPageSize[1]);
	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8, afterFinish:showContent});
}
function showContent()
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var boxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);
	Element.setTop('overlaycontent', boxTop);
	Element.show('overlaycontent');
	
	var lmnt = document.getElementById('overlaycontent');
	lmnt.style.display = "block";
	
	if(c=='imprint') {
		var content = '<div id="imprint">';
	
		content += '<h1>IMPRINT</h1>';
		content += '<div id="close" onclick="hideImprint()">close</div>';
		content += '<br class="reset" />';
		content += '<div class="spacer"></div>';
		content += '<br />';
		content += '<p>Bullet Event GmbH<br />';
		content += 'Alexanderstr. 7<br />';
		content += '10178 Berlin<br />';
		content += '<br />';
		content += 'T +49 30 24631676<br />';
		content += 'F +49 30 24639816<br />';
		content += '<br />';
		content += 'Register-Nr. HRB 94419 B<br />';
		content += 'Ust-Id-Nr.    DE 814122547<br /><br />';

		content += 'Geschäftsführer:<br />';
		content += 'Marcus Christian Trojan</p>';
	
		content += '<br /><p>Website by&nbsp;';
		content += '<a href="http://www.hopeglory.com/" target="_blank">HOPE/GLORY</a></p>';
		content += '</div><br class="reset" />';
	}else if(c=='newsletter') {
		var content = '<div id="imprint">';
	
		content += '<h1>WEEKEND WORLD</h1>';
		content += '<div id="close" onclick="hideImprint()">close</div>';
		content += '<br class="reset" />';
		content += '<div class="spacer"></div>';
		content += '<br />';
		content += '<form name="subscribe" id="subscribe" action="http://redirect2.mailingwork.de/addabo.php" method="post" enctype="multipart/form-data">';		
		content += '<p>you want to know the weekend dates:</p>';
		content += '<p>First name<br />';
		content += '<input type="text" id="stdIn2" name="Vorname" value="" /></p>';
		content += '<p>Last name<br />';
		content += '<input type="text" id="stdIn1" name="Nachname" value="" /></p>';
		content += '<p>Email*:<br />';
		content += '<input type="text" id="stdIn3" name="eMail" value="" /></p>';
		content += '<br />';
		content += '<p>you want to know the roof top opening hours and receive last minutes news:</p>';
		content += '<p>Mobile:<br />';
		content += '<input type="text" id="stdIn17" name="HandyVorwahl" value="" class="small" />';
		content += '<input type="text" id="stdIn18" name="HandyNummer" value="" class="medium" /></p>';
		content += '<br />';
		content += '<p>you want to get an invitation for special events. here is your chance:</p>';
		content += '<p>Street/No:<br />';
		content += '<input type="text" id="stdIn7" name="Strasse" value="" class="mediums" />';
		content += '<input type="text" id="stdIn8" name="Nummer" value="" class="smalls" />';
		content += '<p>City/Zip:<br />';
		content += '<input type="text" id="stdIn9" name="PLZ" value="" class="small" />';
		content += '<input type="text" id="stdIn10" name="Ort" value="" class="medium" /></p>';
		content += '<br />';
		
		content += '<p>';
		content += '<input type="button" value="SEND" onclick="checkFieldsIn()" class="button" />';
		content += '</p>';
		content += '<input type="hidden" name="formtype" value="eMail" />';
		content += '<input type="hidden" name="customerID" value="MTI0Mw%3D%3D" />';
		content += '<input type="hidden" name="Liste[1]" value="NjE5Mw%3D%3D" />';
		content += '</form></div><br class="reset" />';
	}

	lmnt.innerHTML = content;
}

function hideImprint()
{
	var lmnt = document.getElementById('overlaycontent');
	lmnt.style.display = "none";
	lmnt.innerHTML = "";
	new Effect.Fade('overlay', { duration: 0.2, from: 0.8, to: 0 });
}

function getPageScroll()
{
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}




function getPageSize()
{
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},

	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},

	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},

	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},

	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},

	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},

	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// FORM VALIDATION
var compulsoryFieldsIn=new Array();
compulsoryFieldsIn[0]="stdIn3";
function checkFieldsIn ()
{
	var checkOK=true;
	for (var i=0; i<compulsoryFieldsIn.length; i++) {
			var cfObj=document.getElementById(compulsoryFieldsIn[i]);
			if (cfObj!=null) {
				if (cfObj.type.toLowerCase()=="text") {
					if (cfObj.value.match(/^\s*$/)) 
						checkOK=false;
				} else if (cfObj.type.toLowerCase()=="radio" || cfObj.type.toLowerCase()=="checkbox") {
					var tmpObj=document.getElementsByName(cfObj.name);
					var tmpCheck=false;
					for (var j=0; j<tmpObj.length; j++) {
						if (tmpObj[j].checked==true) {
							tmpCheck=true;
							break;
						}
					}
					checkOK=tmpCheck;
				}else if (cfObj.type.toLowerCase().indexOf("select")>=0) {
					if (compulsoryFieldsIn[i]=="stdIn12" && cfObj.selectedIndex==0)
						checkOK=false;
				}
			}
			if (!checkOK) 
				break;
		}
		if (checkOK) 
			document.getElementById('subscribe').submit();
		else
			window.alert("Bitte füllen Sie alle mit einem * markierten Felder aus.");
}