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 swapElement(elm,src) {
	obj = MM_findObj(elm);
	if ( src.checked )
		obj.style.display = 'block';
	else
		obj.style.display = 'none'; 
}

function openWindow( url, name, width, height, scroll ) {
	newWindow = window.open( url, name,"toolbar=0, status=no, menubar=0, width=" + width + ", height=" + height + ", resizable=0, scrollbars=" + scroll);
	newWindow.focus();
} 

function validateTextField(field,alerttxt)
{
	with (field) {
  		if (value==null||value=="") {
    		alert(alerttxt);
			return false;
    	}
  		else
    	{
    		return true;
    	}
  	}
}

function validateForm() {

	var a1Obj = MM_findObj('anrede1');
	var a2Obj = MM_findObj('anrede2');
	if ( !(a1Obj.checked || a2Obj.checked ) ) {
		alert('Pflichtfelder: Anrede'); return false;
	}

	var vObj = MM_findObj('vorname');
	if ( validateTextField(vObj,'Pflichtfelder: Vorname') == false ) {
		vObj.focus(); return false;
	}
	
	var vObj = MM_findObj('nachname');
	if ( validateTextField(vObj,'Pflichtfelder: Nachname') == false ) {
		vObj.focus(); return false;
	}
	
	var vObj = MM_findObj('email');
	if ( validateTextField(vObj,'Pflichtfelder: Email') == false ) {
		vObj.focus(); return false;
	}	
	
	var vObj = MM_findObj('telefon');
	var rObj = MM_findObj('ruckruf');
	if ( rObj.checked && validateTextField(vObj,'Pflichtfelder: Telefon') == false ) {
		vObj.focus(); return false;
	}
	
	return true;		

}

function validateNewForm() {

	var a1Obj = MM_findObj('anrede1');
	var a2Obj = MM_findObj('anrede2');
	if ( !(a1Obj.checked || a2Obj.checked ) ) {
		alert('Pflichtfelder: Anrede'); return false;
	}

	var vObj = MM_findObj('vorname');
	if ( validateTextField(vObj,'Pflichtfelder: Vorname') == false ) {
		vObj.focus(); return false;
	}
	
	var vObj = MM_findObj('nachname');
	if ( validateTextField(vObj,'Pflichtfelder: Nachname') == false ) {
		vObj.focus(); return false;
	}
	
	var vObj = MM_findObj('email');
	if ( validateTextField(vObj,'Pflichtfelder: Email') == false ) {
		vObj.focus(); return false;
	}	
	
	var vObj = MM_findObj('telefon');
	if ( validateTextField(vObj,'Pflichtfelder: Telefon') == false ) {
		vObj.focus(); return false;
	}
	
	var iArr = new Array("MBA-GM","MBA-UF","MBA-UC","MBA-GB","MBA-IM","MBA-FV","MBA-CTS","MPA","TUAS","LG-PM","LG-BO","LG-FC","LG-IM","LG-UC","LG-VM");
	var iChecked = false;
	for(var i = 0; i < iArr.length ; i++){
		iObj = MM_findObj(iArr[i]);
		if (iObj && iObj.checked) {
			iChecked = true;
			break;
		}
	}
	if ( !iChecked ) {
		alert('Pflichtfelder: Interesse an'); return false;
	}	
	
	return true;		

}

function gotoUrl( elm ) {
	var index = elm.selectedIndex
	if (elm.options[index].value != "0") {
		location= elm.options[index].value;
	}
}

function getScrollTop() {
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    return window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    return document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    return document.documentElement.scrollTop;
  }
  return 0;
}

function getIEVersion() {
    var version = 999; 
    if (navigator.appVersion.indexOf("MSIE") != -1)
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
}

function getInnerWindowHeight() {
  if( typeof( window.innerWidth ) == 'number' ) {
    return window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    return document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    return document.body.clientHeight;
  }
}

function getInnerWindowWidth() {
  if( typeof( window.innerWidth ) == 'number' ) {
    return window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    return document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    return document.body.clientWidth;
  }
}

window.onscroll = changeVisibleBlock;
window.onresize = changeVisibleBlock;
window.onload = changeVisibleBlock;

function changeVisibleBlock() {

	scrollY = getScrollTop();
	
	if ( getIEVersion() >= 7 && getInnerWindowHeight() > 560 && getInnerWindowWidth() > 1015 && scrollY > 167 ) {
		bObj = MM_findObj('visibleBlock');
		bObj.style.top = '0px'; 
		bObj.style.left = '50%'; 
		bObj.style.position = 'fixed';
		if ( getIEVersion() > 7 )
			bObj.style.marginLeft = '266px';
		else
			bObj.style.marginLeft = '265px';
	} else {
		bObj = MM_findObj('visibleBlock');
		bObj.style.top = '0px'; 
		bObj.style.left = '0px'; 
		bObj.style.position = 'static';
		bObj.style.marginLeft = '0px';	
	}
	
	if ( getIEVersion() >= 7 && getInnerWindowHeight() > 560 && getInnerWindowWidth() > 1015 ) {
		stObj = MM_findObj('stwrapper');
		if ( stObj ) {
			stObj.style.top = '50%'; 
			stObj.style.right = '50%';
			stObj.style.marginLeft = '-177px';
			stObj.style.marginTop = '-221px'; 
			stObj.style.position = 'fixed';
		}
	}
}
