var ypos = 0;
var cssLocation = "fileadmin/templates/css/prudsys_script.css";
function getcss() {
	if(document.createStyleSheet) {   // IE
	    document.createStyleSheet(cssLocation);
	} else {                // the world
	    var objStyle = document.createElement('style');
	    var objTextNode = document.createTextNode("@import url("+cssLocation+") screen;");
	    objStyle.setAttribute('type', 'text/css');
	    objStyle.appendChild(objTextNode);
	    document.getElementsByTagName('head')[0].appendChild(objStyle);
	}	
}
getcss();


/// Flashfilm Höhe bei Änderung der Fensterbreite anpassen
function flashResize(){
	if(document.getElementById('embed_swf')) document.getElementById('embed_swf').height = (document.getElementById('containerdiv').offsetWidth - 420)*0.5;
	if(document.getElementById('object_swf')) document.getElementById('object_swf').style.height = (document.getElementById('containerdiv').offsetWidth - 420)*0.5 +"px";
}

function Fensterweite () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function neuAufbau () {
  if (Weite != Fensterweite())
    flashResize();
//    location.href = location.href;
}

/* Überwachung von Netscape initialisieren */
if (!window.Weite && window.innerWidth) {
  window.onresize = neuAufbau;
  Weite = Fensterweite();
//  Hoehe = Fensterhoehe();
}





var browser;

function browserweiche(){
if(navigator.userAgent.indexOf("MSIE 6.0") != -1)browser="ie6";
if(navigator.userAgent.indexOf("MSIE 7.0") != -1)browser="ie7";

if	(navigator.userAgent.indexOf("Safari") != -1)
	{
	if(navigator.userAgent.indexOf("Version/3")!= -1) browser="Safari3";
	if(navigator.userAgent.indexOf("Version/4")!= -1) browser="Safari4";
	}
	
if(navigator.userAgent.indexOf("Firefox") != -1)browser="Firefox";
//alert(browser);
}

function trimForms(){
email();
//trimLangMenu();
}


function trimLangMenu(){
document.getElementById('langBody').style.display = 'none';
if(browser == 'ie7' || browser == 'ie6')
document.getElementById('langHead').style.display = 'block';
else
document.getElementById('langHead').style.display = 'table-row-group';
document.getElementById('langArrow').src= 'fileadmin/templates/img/arrow_down.gif';
}

function langMenu(mousepos){
if (mousepos == 'over')
	if(browser == 'ie7' || browser == 'ie6')
		document.getElementById('langBody').style.display = 'block';
	else
		document.getElementById('langBody').style.display = 'table-row-group';
	    document.getElementById('langArrow').src= 'fileadmin/templates/img/blank.gif';
if (mousepos =='out'){
	document.getElementById('langBody').style.display = 'none';
	document.getElementById('langArrow').src= 'fileadmin/templates/img/arrow_down.gif';
	}
}

function trim_a(){
all_a = document.getElementsByTagName('a');
for(i=0;i < all_a.length;i++){
	var linkImg = document.createElement('img');
		linkImg.style.width = 12;
		linkImg.style.height = 16;
		linkImg.src = "fileadmin/templates/img/link.gif";
		if((all_a[i].parentNode.className == 'bodytext' || all_a[i].parentNode.parentNode.parentNode.parentNode.parentNode.className == 'contenttable')&& all_a[i].className != 'xmail')
	       document.getElementsByTagName('a')[i].parentNode.insertBefore(linkImg, all_a[i]);
	}
}

function email(){
all_a = document.getElementsByTagName('a');
for(i=0;i < all_a.length;i++){
	if(all_a[i].className=="xmail") {
           var mail = all_a[i].firstChild.innerHTML + "@prudsys.de";
           all_a[i].firstChild.innerHTML = mail;
           all_a[i].title = "Oeffnet ein Fenster zum Versenden der E-Mail";
           all_a[i].href = "mailto:" + mail;
      }  
   }
}


function show(element){
	if(browser=="ie6"){
		if(element.className == "menu"){
			element.className = "menu_hover";
    	 	Level2 = element.getElementsByTagName('div');
    	 	if(Level2.length > 0)
    	 		Level2[0].style.overflow = 'visible';   
    	}
//    	if(element.className == "content"){
//    		element.nextSibling.className = "port_right_1";
//   	 	Level3 = element.parentElement.getElementsByTagName('div');
//    	 	Level3[0].style.overflow = 'visible';
//    	}  
//    	if(element.className == "port_right_0"){
//    	    Level3 = element.getElementsByTagName('div');
//    	 	Level3[0].style.overflow = 'visible';
//    	 	element.className = "port_right_1";
//    	}  
    }
}

function hideelement (element){
	if(browser=="ie6"){
 	 	if(element.className == "menu_hover"){
 	 		element.className = "menu";
 	    	Level2 = element.getElementsByTagName('div');
 		   	if(Level2.length > 0)
   		  		Level2[0].style.overflow = 'hidden';
   		}
//    	if(element.className == "content"){
//     		Level3 = element.parentElement.getElementsByTagName('div');
//   			Level3[0].style.overflow = 'hidden';
//   			element.nextSibling.className = "port_right_0";
//   		}
//   		if(element.className == "port_right_1"){
//   			element.className = "port_right_0";
//    	 	Level3 = element.getElementsByTagName('div');
//    	 	Level3[0].style.overflow = 'hidden';
//    	}  
   	}
}


function trimInputsxxxx(){
allInputs = document.getElementsByTagName('input');

for(i=0;i < allInputs.length;i++){

	if(allInputs[i].type == 'text' || allInputs[i].type == 'password'){
	var inputType = allInputs[i].type;
	var inputName = allInputs[i].name;
	var inputValue = allInputs[i].value;
	var inputId = allInputs[i].id;	
	var inputDiv = document.createElement('div');
		inputDiv.innerHTML = '<table cellspacing=0 cellpadding=0>'
		+ '<tr>'
 		+ '<td class="input_left"><\/td>'
 		+ '<td class="input_content">'
 		+ '<input type="'+inputType+'" name="'+inputName+'" value="'+inputValue+'" id="'+inputId+'"/>'
 		+ '<\/td>'
 		+ '<td class="input_right"><\/td>'
 		+ '<\/tr>'
 		+ '<\/table>';
 //		alert(inputDiv.innerHTML);
 		document.getElementsByTagName('input')[i].parentNode.replaceChild(inputDiv, allInputs[i]);
		}
	}

}

function trimInputs(){
allInputs = document.getElementsByTagName('input');

for(i=0;i < allInputs.length;i++){

	if(allInputs[i].type == 'text' || allInputs[i].type == 'password'){

	var	inputLeft = document.createElement('img');
		inputLeft.src ='fileadmin/templates/img/input_bg_left.gif';
		inputLeft.className = 'input_left';
 		
 	var	inputRight = document.createElement('img');
 		inputRight.src ='fileadmin/templates/img/input_bg_right.gif';
 		inputRight.className = 'input_right';
 
 		document.getElementsByTagName('input')[i].parentNode.insertBefore(inputLeft, allInputs[i]);
 		document.getElementsByTagName('input')[i].parentNode.insertBefore(inputRight, allInputs[i].nextSibling);
 		

		}
	}
// alert(allInputs[0].parentNode.innerHTML)
}


function option_hl(id,i){

options = document.getElementById('option'+i).getElementsByTagName('td');
	for(n=0;n < options.length;n++){
		options[n].className = 'option';
		document.getElementById(id).className='option_hover';
	}
}
 
var o=0;

function selectWithKeys(i){
var optionsLength = allSelects[i].options.length - 1;
if(window.event.keyCode == 40){
	o++;
	if(o>optionsLength)o=optionsLength; 
	}
if(window.event.keyCode == 38){
	o--;
	if(o<0)o=0;
	}
document.getElementById('select' + i).firstChild.nodeValue = allSelects[i].options[o].value;
allSelects[i].value = allSelects[i].options[o].value;
} 


function trimSelects(){

cursor_in=0;
allSelects = document.getElementsByTagName('select');
if	(browser=='ie7'){
	for(i=0;i < allSelects.length;i++){ 
		allSelects[i].style.display = 'none';
		var optionsText = allSelects[i].innerHTML;
			optionsText = optionsText.replace(/value/g,"id");
			optionsText = optionsText.replace(/<OPTION/g,"<tr><td class='option' onclick='option_hl(id,"+i+"); allSelects["+i+"].value = id; select"+i+".firstChild.nodeValue=id' onmouseover='option_hl(id,"+i+"); cursor_in=1' onmouseout='cursor_in=0' ");
			optionsText = optionsText.replace(/<\/OPTION>/g,"<\/td><\/tr>");
						

		var selectDiv = document.createElement('div');
			selectDiv.innerHTML = '<table style="width:174px; height:24px; margin-bottom:5px"><tr>'
			+ '<td style="width:7px"><img src="fileadmin/templates/img/input_bg_left.gif">'
			+ '<td id="select'+i+'" style="background-image:url(fileadmin/templates/img/input_bg.gif);"'
			+ 'onclick="if(option'+i+'.className==\'option\'){option'+i+'.className=\'option_hover\';} else option'+i+'.className=\'option\'; button'+i+'.focus()"'
			+ '>'
			+ allSelects[i].options[o].text 
			+ '<br>'
			+ '<table cellspacing=0 id="option'+i+'" class="option" onmouseover="this.className = \'option_hover\'">'
			+ optionsText
			+ '<\/table>'
			+ '<\/td>'
			+ '<td style="width:7px; background-image:url(fileadmin/templates/img/select_bg_right.gif);background-position:right;padding-right:2px">'
			+ '<input id="button'+i+'" type="button" name="" value="v" style="width:20px; height:20px; color:#003C74; line-height:5px; font-weight:bold"'
			+ 'onmouseup="if(option'+i+'.className==\'option\')option'+i+'.className=\'option_hover\'; else option'+i+'.className=\'option\';"'
			+ 'onblur="if(cursor_in==0)option'+i+'.className=\'option\'; select'+i+'.style.backgroundColor=\'#fff\'; cursor_in=0;"'
			+ 'onkeydown="selectWithKeys('+i+')"'
			+ '/><\/td>'
			+ '<\/tr><\/table>';

			document.getElementsByTagName('select')[i].parentNode.insertBefore(selectDiv, allSelects[i]);
			document.getElementById('option'+i).style.width = document.getElementById('option'+i).parentElement.offsetWidth;		
		}
	}
if	(browser == "Firefox" || browser == "Safari4")
	{
	if	(browser == "Safari4"){
		bgYOffset = '-2px';
		tdYOffset = '2px';
		}
	if	(browser == "Firefox"){
		bgYOffset = '0px';
		tdYOffset = '0px';
		}

	for(i=0;i < allSelects.length;i++){
		var optionsCopy = allSelects[i].innerHTML;
		var selectClass = allSelects[i].className;
		var selectName = allSelects[i].name;
		var selectId = allSelects[i].id;
		var selectDiv = document.createElement('div')
			selectDiv.innerHTML = '<table cellspacing=0 cellpadding=0>'
			+ '<tr>'
 			+ '<td class="input_left"><\/td>'
 			+ '<td class="input_content" style="padding-top:'+tdYOffset+'">'
 			+ '<select class="'+selectClass+'" name="'+selectName+'" id="'+selectId+'"style="background-position:0 '+bgYOffset+'">'
			+ optionsCopy
			+ '</select>'
 			+ '<\/td>'
 			+ '<td class="input_right"><\/td>'
 			+ '<\/tr>'
 			+ '<\/table>';
 			if(allSelects[i].id != 'sprache')
 			document.getElementsByTagName('select')[i].parentNode.replaceChild(selectDiv, allSelects[i]);
			}

	}
if	(browser == "Safari3")
	{
	for	(i=0;i < allSelects.length;i++){
		allSelects[i].style.width = '160px';
		allSelects[i].style.height = '22px';
		allSelects[i].style.backgroundcolor = '#fff';
		allSelects[i].style.backgroundImage = '';
		allSelects[i].style.font = '12px MS Sans-Serif,Arial,Verdana';
		}

	}
	
}





function trimTextarea(){
allTextareas = document.getElementsByTagName('textarea');
//alert(allTextareas[0].innerHTML);

for(i=0;i < allTextareas.length;i++){
	var taName = allTextareas[i].name;
	var taClassName = allTextareas[i].className;
	var taRows = allTextareas[i].getAttribute('rows');
	var taInnerHTML = allTextareas[i].innerHTML;
	var taDiv = document.createElement('div')
		taDiv.innerHTML = '<table cellspacing=0 cellpadding=0 style="margin-bottom:5px">'
		+ '<tr>'
 		+ '<td class="innen_top_left"><img src="fileadmin/templates/img/blank.gif" class="blank7x7"><\/td>'
 		+ '<td class="innen_top"><\/td>'
 		+ '<td class="innen_top_right"><img src="fileadmin/templates/img/blank.gif" class="blank7x7"><\/td>'
 		+ '<\/tr>'
 		+ '<tr>'
 		+ '<td class="innen_left"><\/td>'
 		+ '<td class="" id="xyz">'
 		+ '<textarea name='+ taName +' rows='+ taRows +' class='+ taClassName +'>'+ taInnerHTML +'<\/textarea>'
 		+ '<\/td>'
 		+ '<td class="innen_right"><\/td>'
 		+ '<tr>'
 		+ '<\/tr>'
 		+ '<td class="innen_bottom_left"><\/td>'
 		+ '<td class="innen_bottom"><\/td>'
 		+ '<td class="innen_bottom_right"><\/td>'
 		+ '<\/tr>'
 		+ '<\/table>';
	document.getElementsByTagName('textarea')[i].parentNode.replaceChild(taDiv, allTextareas[i]);
	}

}


















