function getWindowSize(){
	var size = new Array();
	size["width"]  = (window.innerWidth) ? window.innerWidth  : document.body.offsetWidth;
	size["height"] = (window.innerHeight)? window.innerHeight : document.body.offsetHeight;
	return size;
}

function neuAufbau () {
  var size = getWindowSize();
  if(size["width"]<950){
	  document.getElementById("box1").style.margin =document.getElementById("box2").style.margin = "0 0 0 0"; 
	  document.getElementById("box1").style.left =  document.getElementById("box2").style.left = "5px";
  }else{
      document.getElementById("box1").style.margin  = document.getElementById("box2").style.margin = "0 0 0 -467px"; 
	  document.getElementById("box1").style.left  =  document.getElementById("box2").style.left =  "50%";
  }
}

// ____________________________________________________________________________________________________________________ //
function getLocation(){
	var urlStr = window.location.toString();
	if(urlStr.indexOf("hamlet") != -1) return "hamlet";
	else return "prime";
}

function emailValdation(email) {
	if (email.indexOf("@") != -1 && email.indexOf(".") != -1) {
		var ename = email.substr(0, email.indexOf("@"));
		var ehost = email.substr(email.indexOf("@")+1, email.lastIndexOf(".")-ename.length-1);
		var ecountry = email.substr(email.lastIndexOf(".")+1, email.length);
		return (ename.length>0 && ehost.length>2 && ecountry.length>1) ? true : false;
	} else {
		return false;
	}
}

function checkRecommendedForm(s_adr, r_adr, name, site) {
	var errorStr = "";
	if(name.length < 2) errorStr += "Falscher Name!\n";
	if(!emailValdation(s_adr)) errorStr += "Falscher Absender!\n";
	if(!emailValdation(r_adr)) errorStr += "Falscher Empfänger!\n";	
	if(errorStr == "") window.location = "sende_empfehlung.php?site="+site+"&name="+name+"&s_adr="+s_adr+"&r_adr="+r_adr;
	else alert(errorStr);
}

function checkLogin(knr, pwd) {
	var errorStr = "";
	if(knr.length < 2) errorStr += "Falsche Kundennummer!\n";
	if(pwd.length < 2) errorStr += "Falsches Password!\n";
	if(errorStr == "") parent.location = "index.php?site="+site+"&name="+name+"&s_adr="+s_adr+"&r_adr="+r_adr;
	else alert(errorStr);
}

function checkForgotPWD(email) {
	var errorStr = "";
	if(!emailValdation(email)) errorStr += "Falscher Email!\n";
	if(errorStr == "") window.location = "?email="+email;
	else alert(errorStr);
}

function StartUp() {
	neuAufbau();
	setVisibility('services_menue');
	setVisibility('servicesloggedin_menue');
	setVisibility('katalog_menue');
	setVisibility('magazin_menue');
	setVisibility('home_menue');
	setVisibility('profil_menue');
	document.getElementById(getLocation()+'_button').style.color = "#FFFFFF";
	document.getElementById('home_button').style.color = "#FFFFFF";
}

function setVisibility(target) {
	if(document.getElementById(target).style.display == "none")document.getElementById(target).style.display = "block";
    else document.getElementById(target).style.display = "none";
}

function showSubMenue(target) {
	var Menues = new Array('start_menue', 'services_menue', 'magazin_menue','katalog_menue', 'home_menue', 'profil_menue', 'servicesloggedin_menue');
	var i;
	for(i=0;i<Menues.length;i++)
	document.getElementById(Menues[i]).style.display = "none";
	document.getElementById(target).style.display = "block";

}

function dropDownJump(value) {
	window.iframe.location = "contentpages/start_menue/die_modelle.php?model="+value;
}
var lastMainTarget = null;
function hiLiteMainMenue(target) {
	document.getElementById('home_button').style.color = "#C7C7C7";
	target.style.color = "#FFFFFF";	
	if(lastMainTarget != null)lastMainTarget.style.color = "#C7C7C7";
	lastMainTarget = target;
}
var lastSubTarget = null;
function hiLiteSubMenue(target) {
	target.style.color = "#232323";	
	if(lastSubTarget != null)lastSubTarget.style.color = "#676767";
	lastSubTarget = target;
}