var btnlight = "btnlight";
var btn = "btn";
var win=null;
var formstatus = "invalid";

function initialDraw() {

}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function getSpan(Div_ID)
{
  if (window.document.all)
    return eval("window.document.all."+Div_ID);
  if (typeof(window.document.getElementById)=="function")
    return window.document.getElementById(Div_ID);
  return eval("window.document."+Div_ID);
}

function redirect(path)
{
	window.location = path;
}



// Album Type 2
function getAlbum(iid, albumId) {
	var xmlHttp = GetXmlHttpObject();
	var url = "albumdata.php?imgId="+ iid + "&albumId=" + albumId;
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{   
			$('album_container').innerHTML = xmlHttp.responseText;
			opacity("showImage", 0, 100, 1000);
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	xmlHttp.close;
}

function menuRedirect(page, lang) {
	window.location = "index.php?page=" + page + "&lang=" + lang;
}

function grayOut(vis, options) {  
	// Pass true to gray out screen, false to ungray  
	// options are optional.  This is a JSON object with the following (optional) properties  
	// opacity:0-100         
	// Lower number = less grayout higher = more of a blackout   
	// zindex: #             
	// HTML elements with a higher zindex appear on top of the gray out  
	// bgcolor: (#xxxxxx)    
	// Standard RGB Hex color code  
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});  
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear  
	// in any order.  Pass only the properties you need to set.  
	var options = options || {};   
	var zindex = options.zindex || 50;  
	var opacity = options.opacity || 70;  
	var opaque = (opacity / 100);  
	var bgcolor = options.bgcolor || '#000000';  
	var dark=document.getElementById('darkenScreenObject');  
	if (!dark) {    
		// The dark layer doesn't exist, it's never been created.  So we'll    
		// create it here and apply some basic styles.    
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917    
		var tbody = document.getElementsByTagName("body")[0];    
		var tnode = document.createElement('div');          
		// Create the layer.        
		tnode.style.position='absolute';                 
		// Position absolutely        
		tnode.style.top='0px';                           
		// In the top        
		tnode.style.left='0px';                          
		// Left corner of the page        
		tnode.style.overflow='hidden';                   
		// Try to avoid making scroll bars                    
		tnode.style.display='none';                      
		// Start out Hidden        
		tnode.id='darkenScreenObject';                   
		// Name it so we can find it later    
		tbody.appendChild(tnode);                            
		// Add it to the web page    
		dark=document.getElementById('darkenScreenObject');  
		// Get the object.  
	}  if (vis) {    
		// Calculate the page width and height     
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {        
			/*var pageWidth = document.body.scrollWidth+'px';        
			var pageHeight = document.body.scrollHeight+'px';    
		} else if( document.body.offsetWidth ) {      
			var pageWidth = document.body.offsetWidth+'px';      
			var pageHeight = document.body.offsetHeight+'px';    
		} else {     */  
			var pageWidth='100%';       
			var pageHeight='100%';  
		}       
		//set the shader to cover the entire page and make it visible.    
		dark.style.opacity=opaque;                          
		dark.style.MozOpacity=opaque;                       
		dark.style.filter='alpha(opacity='+opacity+')';     
		dark.style.zIndex=zindex;            
		dark.style.backgroundColor=bgcolor;      
		dark.style.width= pageWidth;    
		dark.style.height= pageHeight;    
		dark.style.display='block';                            
	} else {    
		dark.style.display='none';  
	}
}

			var lnr = 0;
			var scrolling = false;
			function startScrollDown() { scrolling = true; scrollDown();}
			function startScrollUp() { scrolling = true; scrollUp(); }
			function stopScrolling() { scrolling = false; }
			
			function scrollDown() {
				$('scrollBox').scrollTop = lnr;
				if(lnr <= ($('scrollBox').scrollHeight-$('scrollBox').offsetHeight)) {
					lnr+= 3;
				}
				if(scrolling) {
					setTimeout("scrollDown()", 10);
				}
			}
			function scrollUp(){
				$('scrollBox').scrollTop = lnr;
				if(lnr > 0) {
					lnr -= 3;
				}
				if(scrolling) {
				 	setTimeout("scrollUp()", 10);
				}
			}
			
function mailto(s)	{
	var number=0;
	var result="";
	for(var i=0; i<s.length; i++) {
		number=s.charCodeAt(i);
		if (number>=8364) {
			number = 128;
		}
		result += String.fromCharCode(number-2); 
	}
	location.href="mailto:" + result;
}

function sendrequest() {
	validateMailForm();
	if(formstatus == "verified"){
		sendRequest();
	} else {
	}
}

function formatPString(out) {
	
	out = out.replace(/&/g, "[amp]");
	
	return out;
}

function sendRequest() {
	ps_name = $F('inp_name');
	ps_street= $F('inp_street');
	ps_plz = $F('inp_plz');
	ps_country = $F('inp_country');
	ps_email = $F('inp_email');
	ps_remark = $F('inp_remark');

	ps_name = formatPString(ps_name);
	ps_street = formatPString(ps_street);
	ps_plz = formatPString(ps_plz);
	ps_country = formatPString(ps_country);
	ps_email = formatPString(ps_email);
	ps_remark = formatPString(ps_remark);
	new Ajax.Request("mailto.php", 
		{ 
		method: 'post', 
		postBody: "send_mail=confirmed&name=" + ps_name + "&street=" + ps_street + "&plz=" + ps_plz  +  "&country=" + ps_country + "&email=" + ps_email + "&remark=" + ps_remark,
		onComplete: function(transport) {showMailResponse(transport); }
	});
}

function validateField(obj, filter) {
	var returnValue = false;
	$(obj).setStyle({backgroundColor:'#FFFFFF'});
	if ($(obj).getValue() == "") {
		$(obj).setStyle({backgroundColor:'#fac8b7'});
		returnValue = false;
	} else {
		returnValue = true;
	}
	if(filter != null) {
		if (!filter.test($(obj).getValue())) {
			$(obj).setStyle({backgroundColor:'#fac8b7'});
			returnValue = false;
		} else {
			returnValue = true;
		}
	}
	return returnValue;
}

function showMailResponse(transport){
	if(transport.responseText.match("success") != null) {
	$('inp_name').value = "";
	$('inp_street').value = "";
	$('inp_plz').value = "";
	$('inp_country').value = "";
	$('inp_email').value = "";
	$('inp_remark').value = "";
	alert("Anfrage gesendet!");
	} else {
		alert("Mail Error!");
	}
}

function validateMailForm() {
	formstatus = "verified";
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(validateField('inp_name', null) == false) { formstatus = "invalid" ;}
	if(validateField('inp_street', null) == false) { formstatus = "invalid";}
	if(validateField('inp_plz', null) == false) { formstatus = "invalid";}
	if(validateField('inp_country', null) == false) { formstatus = "invalid";}
	if(validateField('inp_email', filter) == false) { formstatus = "invalid";}
}

// End -->
