// Image Replace for Macintosh
		
function quadReplace() {
   			if(navigator.platform == 'MacPPC'){
				for (i = 0; i < document.images.length; ++i) {
					 if (document.images[i].src.indexOf('black_menu') >-1) document.images[i].src=document.images[i].src.replace(/black_menu/, 'black_menu_mac');
						else if (document.images[i].src.indexOf('blue_menu') >-1) document.images[i].src=document.images[i].src.replace(/blue_menu/, 'blue_menu_mac');
						else if (document.images[i].src.indexOf('grey_menu') >-1) document.images[i].src=document.images[i].src.replace(/grey_menu/, 'grey_menu_mac');
				}
			}
}
			

// Browsercheck

function BrowserCheck() {
	var b = navigator.appName
    var minor = parseFloat(navigator.appVersion);

	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer" || b=="msie") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns6 = (this.b=="ns" && this.v==5)
	this.ns61=(this.b=="ns"&& navigator.userAgent.indexOf('6/6.1') != -1)
	this.ns6up=(this.b=="ns"&& this.v >= 5)

	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.b=="ie" && this.v==4 &&  navigator.userAgent.indexOf('MSIE 4')!=-1)
	this.ie5 = (this.b=="ie" &&  this.v==4 && navigator.userAgent.indexOf('MSIE 5.0')!=-1)
	this.ie55 = (this.b=="ie" &&  navigator.userAgent.indexOf('MSIE 5.5')!=-1)
	this.ie5up =  (this.b == "ie" && !this.ie4 )
	this.ie6 = (this.b=="ie" && this.v==4 && this.b == navigator.userAgent.indexOf('MSIE 6.')!=-1)
	this.ie6up =  (this.b == "ie" && !this.ie4 && !this.ie5 && !this.ie55)

	if (this.ie5 || this.ie55) this.v = 5
	this.min = (this.ns||this.ie)
	this.Mac = (navigator.appVersion.indexOf("Mac") != -1)
}

// Creates the is Objekt
is = new BrowserCheck();

//Kerzhenevych Oleksandr 05.06.2003
//NS4 resize fix:

function reDo() {  //alert ("Resize fix test !!!");
     if (innerWidth != origWidth || innerHeight != origHeight)
        location.reload();
  }

 if(is.ns4) {

   NS4 = document.layers;
    if (NS4) {
             origWidth = innerWidth;
             origHeight = innerHeight;
     }

      if (NS4) onresize = reDo;

  }



// Reformating Form Fields at Startup
function init() {
    if (typeof(HM_ScriptLoaded) != "undefined" && HM_ScriptLoaded) {setTimeout("HM_f_StartIt()",10);}
	if (is.Mac) { quadReplace(); }
	for (f = 0; f < document.forms.length; f++) {		
		if (document.forms[f]) {
	        e = document.forms[f].elements
	        for (x = 0; x < e.length; x++) {
				if (e[x]) {			
					if (e[x].type=="select-one" || e[x].type=="select-multiple") {
						if (e[x].options[0].text.indexOf("---")>-1) {
							e[x].options[0] = null;
							if (e[x].selectedIndex == -1) {
								 e[x].options[0].selected = true;
							}
						}
					} //type = select
        			if (!document.layers && !is.Mac) {
	 			        if (is.ns61) {
                           if (e[x].type=="text" || e[x].type=="password") {
                              if (e[x].size== 6) e[x].size = 10;
						      if (e[x].size== 20) e[x].size = 15;
                           } //type = text, password
                        } else if (is.ns6up && ! is.ns61) {
                              if (e[x].type=="text" || e[x].type=="password") {
                                 if (e[x].size== 6) e[x].size = 12;
                                 if (e[x].size== 9) e[x].size = 12;
                              } //type = text, password
                              if (e[x].type=="textarea" && (e[x].name != "dontresizeme")) {
                                 e[x].style.setAttribute("fontFamily","Arial","true");
							     e[x].style.setAttribute("fontSize","9pt","false");
                                 e[x].cols=29;
                                 e[x].rows=6;
                              }
                        } else if (is.ie){
					          if (e[x].type=="text" || e[x].type=="password") {
								 switch (e[x].size) {
								    case 1 : e[x].size = 2;break;
								    case 2 : e[x].size = 4;break;
								    case 3 : e[x].size = 5;break;
								    case 4 : e[x].size = 6;break;
								    case 5 : e[x].size = 8;break;
								    case 6 : e[x].size = 10;break;
								    case 9 : e[x].size = 14;break;
								    case 12 : e[x].size = 20;break;
								    default : e[x].size = 22;break;
							     }
				   	          } //type = text, password
     		   	              if (e[x].type=="textarea" && (e[x].name != "dontresizeme")) {
		          		         e[x].style.setAttribute("fontFamily","Arial","true");
							     e[x].style.setAttribute("fontSize","9pt","false");
			        		     e[x].cols=29;
					  		     e[x].rows=6;
						      } //type = textarea
						} // browser check
			         } // adjust check
                     if (is.ns4) {
                        if (e[x].type=="textarea" && (e[x].name != "dontresizeme")) {
		          		   e[x].style.setAttribute("fontFamily","Arial","true");
						   e[x].style.setAttribute("fontSize","9pt","false");
			        	   e[x].cols=14;
					  	   e[x].rows=6;
                        }
			         } //is.ns4
				}	// if e[x] ...
			} // for x ...
		} //if document.forms ...
	} //for f ...
}			

// Submit Function for Redirect
function go(x) {
		document.forms['data'].elements["gehe"].value=x;
		document.forms['data'].submit();
}

// Image Preloading
function preload(imgObj,imgSrc) {
	if (document.images){
	 	eval(imgObj + ' = new Image()');
	  	eval(imgObj + '.src = "' + imgSrc + '"');
	}
}

// Image Swapping
function changeImage(imgName, imgObj) {
		document.images[imgName].src = eval(imgObj+".src");
}

// Get the Window Height and Width
function findWH() {
	winW = (is.ns)? window.innerWidth : document.body.offsetWidth-20;
	winH = (is.ns)? window.innerHeight : document.body.offsetHeight-4;
}

// Reload Page after Resizing (netscape only)
function makeLiquid() {
	if ((is.ns && (winW!=window.innerWidth || winH!=window.innerHeight)))
	history.go(0);
}

// Open Popups
function openpopup (myfile, myname, breite, hoehe, posX, posY, resizable, scrollbars){
	if (myname == '') myname = 'planethome';
	if (posX == '') posX = '0';
	if (posY== '') posY = '0';
	if(resizable == null) resizable = '0';
	if(scrollbars == null) scrollbars = '0';
	if(scrollbars == '1')  breite = parseInt(breite) + 22;
	if (hoehe == '0') {
		neuehoehe = screen.availHeight-screen.availHeight/10;
		if (neuehoehe>900) neuehoehe=900;
			hoehe = neuehoehe;
	}
	var params;
	if(is.ns)
		var params = "width=" + breite + ",height=" + hoehe + ",screenX=" +posX+ ",screenY=" +posY+ ",resizable=" + resizable + ",status=1,scrollbars=" + scrollbars + ",toolbar=0,location=0,directories=0,menubar=0";
	else if(is.ie)
		var params = "width=" + breite + ",height=" + hoehe + ",left=" +posX+ ",top=" +posY+ ",resizable=" + resizable + ",status=1,scrollbars=" + scrollbars + ",toolbar=0,location=0,directories=0,menubar=0";   
	var newwin = window.open(myfile ,myname ,params);
	newwin.focus();
}

// Open Popups - for partner includes
//the reason why I copied this function with a different name: 
//some-partners (e.g. dab) have an own openpopup-function 
function openpopupPH (myfile, myname, breite, hoehe, posX, posY, resizable, scrollbars){
	if (myname == '') myname = 'planethome';
	if (posX == '') posX = '0';
	if (posY== '') posY = '0';
	if(resizable == null) resizable = '0';
	if(scrollbars == null) scrollbars = '0';
	if(scrollbars == '1')  breite = parseInt(breite) + 22;
	if (hoehe == '0') {
		neuehoehe = screen.availHeight-screen.availHeight/10;
		if (neuehoehe>900) neuehoehe=900;
			hoehe = neuehoehe;
	}
	var params;
	if(is.ns)
		var params = "width=" + breite + ",height=" + hoehe + ",screenX=" +posX+ ",screenY=" +posY+ ",resizable=" + resizable + ",status=1,scrollbars=" + scrollbars + ",toolbar=0,location=0,directories=0,menubar=0";
	else if(is.ie)
		var params = "width=" + breite + ",height=" + hoehe + ",left=" +posX+ ",top=" +posY+ ",resizable=" + resizable + ",status=1,scrollbars=" + scrollbars + ",toolbar=0,location=0,directories=0,menubar=0";   
	var newwin = window.open(myfile ,myname ,params);
	newwin.focus();
}

//************************************
// openpopup with Title PlanetHome
// author: Antje Richter-Merk
//
//at the moment this functions is not used
//maybe we use it for the Login of the Expertise files
//opens a frame with a title in which the content of the window is displayed
//I don't know whether this works for all browsers!
//************************************************
function openpopupTitle (myfile, myname, breite, hoehe, posX, posY, resizable, scrollbars){
	if (myname == '') myname = 'planethome';
	if (posX == '') posX = '0';
	if (posY== '') posY = '0';
	if(resizable == null) resizable = '0';
	if(scrollbars == null) scrollbars = '0';
	if(scrollbars == '1')  breite = parseInt(breite) + 22;
	if (hoehe == '0') {
		neuehoehe = screen.availHeight-screen.availHeight/10;
		if (neuehoehe>900) neuehoehe=900;
			hoehe = neuehoehe;
	}
	var params;
	if(is.ns)
		var params = "width=" + breite + ",height=" + hoehe + ",screenX=" +posX+ ",screenY=" +posY+ ",resizable=" + resizable + ",status=1,scrollbars=" + scrollbars + ",toolbar=0,location=0,directories=0,menubar=0";
	else if(is.ie)
		var params = "width=" + breite + ",height=" + hoehe + ",left=" +posX+ ",top=" +posY+ ",resizable=" + resizable + ",status=1,scrollbars=" + scrollbars + ",toolbar=0,location=0,directories=0,menubar=0";


    var output = "<html><head><title>PlanetHome</title></head>";
        output += "<frameset rows=\"100%, *\" border=\"0\" frameborder=\"0\" framespacing=\"0\">";
        output += "<frame src=\"" + myfile + "\"></frameset></html>";

        var newwin = window.open("" ,myname ,params);
	    newwin.document.write(output);
	    newwin.focus();
}

// Empty Dropdown List
function empty(feld) {
	document.forms["data"].elements[feld].options.length = 0;
} 

// formatiert Wert in einem Input Feld ( 10.000,00 )
function formatValue(wert) {

		wert = wert + '';
		if (wert.indexOf(",") > 0) {
			if ((wert.length-wert.indexOf(",")-1) == 1) wert = wert + "0";
		}
		else {
			wert = wert + ",00";
		}
		if (wert.length > 6) {
			wert_tausend = wert.substr(0,wert.indexOf(",")-3) + ".";
			wert_untertausend =wert.substring(wert.indexOf(",")-3, wert.length);
			wert = wert_tausend + wert_untertausend
		}
		return wert;
}

function readValue (feld) {
// Liest ein Inputfeld aus und gibt den entsprechenden Zahlenwert zurück

	wert = makeString(feld.value);

	if (wert.indexOf(".") >= 0) {
		wert_links = wert.substring(0,wert.indexOf(".")); 
		wert_mitte = wert.substring(wert.indexOf(".")+1,wert.length); 
		wert = wert_links + wert_mitte;
	}
	if (wert.indexOf(",") >= 0) {
		wert_links = wert.substring(0,wert.indexOf(",")); 
		wert_rechts = wert.substring(wert.indexOf(",")+1,wert.length);
		wert = wert_links + "." + wert_rechts;
	}

	wert = makeNumber(wert);
	return wert;
}

function makeString (wert) {
// wandelt Zahl in String um
	wert = wert + '';
	return wert;
}

function makeNumber (wert) {
// wandelt String in Zahl um

	wert = parseFloat(wert);
	return wert;
}


