// filename: jbl_gen.js
// version 1.0 - 2005-08-31 - mkr
//
// martin dot krause at gpm dot de
//

// set window name
window.name = "jbl";

// escape from framesets
if (parent.frames && parent.frames.length != 0) top.location.href = document.location.href;
else self.focus();

// pageInit
function pageInit() {
	is = new BrowserCheck();
	adjust_colums();
}


// hover effects / mainnavigation
function navfocus(eventhandler, obj){
	id = obj.name;
	if (obj.className.indexOf("active") == -1) {
		
		switch (eventhandler)
		{
		case 'onmouseover' :
			document.getElementById(id).style.background = "#FFED00";
			document.getElementById(id+"-span").style.background = "#fff url(/fileadmin/maintemplate/img/gen_nav_bg_sliding.gif) 9px -38px no-repeat";
			//11px instead of 9px if browser is ie
			break;
		case 'onmouseout' :
			document.getElementById(id).style.background = "transparent";
			document.getElementById(id+"-span").style.background = "#fff url(/fileadmin/maintemplate/img/gen_nav_bg_sliding.gif) 9px 2px no-repeat";
			break;
		case 'onfocus' :
			document.getElementById(id).style.background = "#FFED00";
			document.getElementById(id+"-span").style.background = "#fff url(/fileadmin/maintemplate/img/gen_nav_bg_sliding.gif) 9px -38px no-repeat";
			//11px instead of 9px if browser is ie
			break;
		case 'onblur' :
			document.getElementById(id).style.background = "transparent";
			document.getElementById(id+"-span").style.background = "#fff url(/fileadmin/maintemplate/img/gen_nav_bg_sliding.gif) 9px 2px no-repeat";
			break;
		}
	}
}

// adjusting the height of the two colums - blue and yellow - according to the height of the higher one 
function adjust_colums() {
	var id_blueheight;
	var id_yellowheight;
	var blueheight;
	var yellowheight;

	id_blueheight = "homeblue";
	id_yellowheight = "homeyellow";

	if ( (document.getElementById(id_blueheight)) && (document.getElementById(id_yellowheight)) ) 
	{
		blueheight = document.getElementById(id_blueheight).offsetHeight ;
		yellowheight =  document.getElementById(id_yellowheight).offsetHeight;
		
		(blueheight >= yellowheight) ? yellowheight = blueheight : "";
		(blueheight <= yellowheight) ? 	blueheight = yellowheight : "";
		
		document.getElementById(id_blueheight).style.height = blueheight + "px";
		document.getElementById(id_yellowheight).style.height = yellowheight + "px";
	}
}

// substitute input type=text containing "password" with input type=password
function add_asterix() {

		obj = document.getElementById('jbl4utext');

		newinput = document.createElement('input');
		newinput.type = "password";
		newinput.id = "jbl4upass";
		newinput.className = "text";
		newinput.onblur = remove_asterix;

		inputparentnode = obj.parentNode;
		inputparentnode.replaceChild(newinput,obj);
		
		setTimeout('document.getElementById("jbl4upass").focus()', 150);

}


// restoring "Passwort" without asterix
function remove_asterix(e) {
	if (!e) var e = window.event;
		//obj = this;
		obj = document.getElementById('jbl4upass');

			if (obj.value == "") 
			{
				newinput = document.createElement('input');
				newinput.type = "text";
				newinput.id = "jbl4utext";
				newinput.className = "text";
				newinput.value = "Password:";
				newinput.onfocus = add_asterix;

				inputparentnode = inputparentnode = obj.parentNode;
				inputparentnode.replaceChild(newinput,obj);
			}
}

//removes and restores (based on name="") default text
function switch_value(obj,eventhandler,defaultText) {
	
	var defaultText = (obj.name == 'sword') ? 'Search Jungbunzlauer' : defaultText ;
	defaultText = (!defaultText) ? obj.name : defaultText;

	switch(eventhandler) {
	
	case "onfocus":
		obj.value = "";
		break;
	
	case "onblur":
		obj.value = !obj.value ? defaultText : obj.value;
		break;
	
	}

}

var frms = new Array('eu','na','me','sa','af','ap');
function setViewOptions(opt) {
	for(var i=0; i<frms.length; i++) {
		document[frms[i]].companies.value = opt;
	}
} 