//for use as copyright year
curDate = new Date();
var curYear = curDate.getFullYear();
var menuBaseHref = '';
var menuBaseHref2 = 'http://www.gelighting.com';
if (window.location.href.indexOf('EULCTLG')>0) {
  menuBaseHref = 'http://www.gelighting.com';
  menuBaseHref2 = '';
}

//TEXT SIZE SELECTION
function makeSmall() {
  var t=document.getElementById("document");
  if (t!=null) {
    t.style.fontSize="85%";    
  }
  setImage(1);
  return false;
}
function makeMedium() {
  var t=document.getElementById("document");
  if (t!=null) {
    t.style.fontSize="100%";
  }
  setImage(2);
  return false;
}
function makeBig() {
  var t=document.getElementById("document");
  if (t!=null) {
    t.style.fontSize="115%";
  }
  setImage(3);
  return false;
}
var isrc = new Array();
for (iTemp=1; iTemp<7; iTemp++) {
isrc[iTemp] = new Image();
}
isrc[1].src = '/de/imgs/topnav/s.gif';
isrc[2].src = '/de/imgs/topnav/m.gif';
isrc[3].src = '/de/imgs/topnav/b.gif';
isrc[4].src = '/de/imgs/topnav/sa.gif';
isrc[5].src = '/de/imgs/topnav/ma.gif';
isrc[6].src = '/de/imgs/topnav/ba.gif';
function setImage(imgIndex) {
  var t1=document.getElementById("ts");
  var t2=document.getElementById("tm");
  var t3=document.getElementById("tb");
    
  if (t1 != null) {
    if (imgIndex==1) {
      t1.src=isrc[4].src;
    }
    else {
      t1.src = isrc[1].src;
    }
  }
  if (t2 != null) {
    if (imgIndex==2) {
      t2.src = isrc[5].src;
    }
    else  {
      t2.src = isrc[2].src;
    }    
  }
  if (t3 != null) {
    if (imgIndex==3) {
      t3.src = isrc[6].src;
    }
    else {
      t3.src = isrc[3].src;
    }
  }
}


// 2 Functions for GE Fast Search
function fnSiteSearch(fm) {
	if (fm.textToSearch.value=="") { return false; }
	return true;
}
function fnSiteSearchLink(fm) {
	if (fm.textToSearch.value != "") { fm.submit(); } 
}

// global vars
var popupWin;
var largerWin;
var largerWin2;
var largerWin3;
var glossaryWin;
var scrnwidth=screen.width;
var scrnheight=screen.height;
var message = "Hier kommen Sie auf die Internetseiten von Lighting Europe. Folgende Seiten sind derzeit nur in Englisch verf\374gbar."

//NN4 window resize fix
if(!window.saveInnerWidth) {
  window.onresize = resizeIt;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}
function resizeIt() {
    if (saveInnerWidth < window.innerWidth || 
        saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || 
        saveInnerHeight < window.innerHeight ) 
    {
        window.history.go(0);
    }
}


// "only 1 open at a time" popup function //
function openPop(url,width,height,addloptions){
	var xspot=Math.round((scrnwidth/2)-(width/2));
	var yspot=Math.round((scrnheight/2)-(height/2)-30);
	features = "height="+height+",width="+width+",top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot;
	if (addloptions && addloptions!="") { features += ","+addloptions; }
	if (!popupWin || popupWin.closed){
		popupWin = window.open(url, '', features);
	}
	else {
		window.popupWin.close();
		popupWin = window.open(url, '', features);
	}
}

// openPop wrapper function with message box
function openMsg(url,width,height,addloptions){
	if ( confirm(message) ){
		openPop(url,width,height,addloptions);
	}
}




//	NORMAL Function to View Larger Image.
//	Opens window which contains only a 500 x 500 image
function openLarger(imgurl,imgalt) {
	var xspot=Math.round((scrnwidth/2)-(250));
	var yspot=Math.round((scrnheight/2)-(280));
	if (!largerWin || largerWin.closed) {
		largerWin = window.open("","","width=500,height=500,top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot);
	}
	else {
		window.largerWin.close();
		largerWin = window.open("","","width=500,height=500,top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot);
	}
	drawstr =  '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
	drawstr += '<html><head><META NAME="Robots" content="index,follow"><title>'+imgalt+'</title></head>';
	drawstr += '<body bgcolor="white" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">';
	drawstr += '<img src="';
	drawstr += imgurl;
	drawstr += '" width="500" height="500" border="0" alt="';
	drawstr += imgalt;
	drawstr += '">';
	drawstr += '</body></html>';
	largerWin.document.open();
	largerWin.document.write(drawstr);
	largerWin.document.close();
}


//	Function to View Larger Fluorescent (HORIZONTAL) Image.
//	Opens window which contains only a ????? x 128 image
function openLarger2(imgurl,imgalt) {
	var xspot=Math.round((scrnwidth/2)-(250));
	var yspot=Math.round((scrnheight/2)-(100));
	if (!largerWin2 || largerWin2.closed) {
		largerWin2 = window.open("","","scrollbars,width=500,height=150,top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot);
	}
	else {
		window.largerWin2.close();
		largerWin2 = window.open("","","scrollbars,width=500,height=150,top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot);
	}
	drawstr =  '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
	drawstr += '<html><head><META NAME="Robots" content="index,follow"><title>'+imgalt+'</title></head>';
	drawstr += '<body bgcolor="white" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">';
	drawstr += '<img src="';
	drawstr += imgurl;
	drawstr += '" height="128" border="0" alt="';
	drawstr += imgalt;
	drawstr += '">';
	drawstr += '</body></html>';
	largerWin2.document.open();
	largerWin2.document.write(drawstr);
	largerWin2.document.close();
}

//	Function to View Larger Fluorescent (VERTICAL) Image.
//	Opens window which contains only a 303 x ?????? image
function openLarger3(imgurl,imgalt) {
	var xspot=Math.round((scrnwidth/2)-(160));
	var yspot=Math.round((scrnheight/2)-(280));
	if (!largerWin3 || largerWin3.closed) {
		largerWin3 = window.open("","","scrollbars,width=323,height=500,top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot);
	}
	else {
		window.largerWin3.close();
		largerWin3 = window.open("","","scrollbars,width=323,height=500,top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot);
	}
	drawstr =  '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
	drawstr += '<html><head><META NAME="Robots" content="index,follow"><title>'+imgalt+'</title></head>';
	drawstr += '<body bgcolor="white" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">';
	drawstr += '<img src="';
	drawstr += imgurl;
	drawstr += '" width="303" border="0" alt="';
	drawstr += imgalt;
	drawstr += '">';
	drawstr += '</body></html>';
	largerWin3.document.open();
	largerWin3.document.write(drawstr);
	largerWin3.document.close();
}

function confirmsite(url){ 
	if ( confirm(message) ){ 
		open(url) 
	}
}




function closepopups(){
	if (popupWin && popupWin.open){
		window.popupWin.close();
	}
	if (largerWin && largerWin.open){
		window.largerWin.close();
	}
	if (largerWin2 && largerWin2.open){
		window.largerWin2.close();
	}
	if (largerWin3 && largerWin3.open){
		window.largerWin3.close();
	}
	if (glossaryWin && glossaryWin.open){
		window.glossaryWin.close();
	}
}


// 3 functions used by various searches (Retained from previous site)
function fnLtrim(strString){
	var i=0;
	var intLen = strString.length;
	while((strString.charAt(i) == " ") && ( i < intLen)) {
		i++;
	}
	strString = strString.substring(i,intLen);
	return  strString;
}

function fnRtrim(strString){
	var intLen = strString.length;
	var i= intLen-1;
	while((strString.charAt(i) == " ") && ( i > 0 )){
		i--;
	}
	strString = strString.substring(0,i+1);
	return strString;
}

function SearchSubmit(frm,section) {
	var strSKU = frm.txtSearch.value;
	if(strSKU=="") {
		return false;
	}
	strSKU = fnLtrim(fnRtrim(frm.txtSearch.value));
	var strFinal = "";
	var i;
	for(i=0; i<strSKU.length; i++){
		if( strSKU.charAt(i) != '*' ) {
			strFinal = strFinal + strSKU.charAt(i);
		}
	}
	//frm.REQUEST.value = "GECOMSEARCH";
	frm.SITEID.value = "LIGHTINGHOME";
	frm.searchPageNo.value="1";
	frm.FOLDER.value=section;
	frm.web_server.value = "http://www.gelighting.com";
	//frm.SEARCHTEXT.value = strFinal + "*";
	frm.SEARCHTEXT.value = strFinal;
	//frm.action = "http://genet.geappliances.com/geasearch/Dispatcher";
	frm.action = "http://genet.geappliances.com/geasearch/Dispatcher?REQUEST=GECOMSEARCH";
	return true;
}



// function linktoOpener(url) is called from popups. Places url in opener, and closes popup. 
function linktoOpener(url) {
	if(self.opener) {
		self.opener.top.document.location=url;
		self.opener.focus();
		self.close();
	} else {
		self.top.document.location=url;
		self.focus();
	}
}

// turnonTab() sniffs the document location and turns on the appropriate tab in the navbar.
// Used on HOME LIGHTING site
function turnonTab() {
	var currurl=document.location+"";
	var locindex="0";
	if(currurl.indexOf("/products/") != -1) { locindex="1"; }
	if(currurl.indexOf("/design_with_light/") != -1) { locindex="2"; }
	if(currurl.indexOf("/where_to_buy/") != -1) { locindex="3"; }
	if(currurl.indexOf("/ask_us/") != -1) { locindex="4"; }
	if(locindex!="0" && document.getElementById) {
		document.getElementById("navimgcell"+locindex).className="navbarLinkOn";
		document.getElementById("navimg"+locindex).src="/de/imgs/shim.gif";
		document.getElementById("navlinkcell"+locindex).className="navbarLinkOn";
		document.getElementById("navlink"+locindex).className="navbarLinkOn";
	}
}

// turnonTab2() sniffs the document location and turns on the appropriate tab in the navbar.
// Used on COMMERCIAL LIGHTING site -- all except its home page where navbar is hard coded to have "home" selected.
function turnonTab2() {
	var currurl=document.location+"";
	var locindex="0";
	if(currurl.indexOf("/product_portfolio/") != -1) { locindex="1"; }
	if(currurl.indexOf("/products/") != -1) { locindex="2"; }
	if(currurl.indexOf("/lighting_applications/") != -1) { locindex="3"; }
	if(currurl.indexOf("/resources/") != -1) { locindex="4"; }
	if(locindex!="0" && document.getElementById) {
		document.getElementById("navbarCell_"+locindex).className="selected";
		document.getElementById("navbarImg_"+locindex).src="/de/imgs/nav1Link_selected.gif";
	}
}

// needforSubmit() builds INFM URL from two select elements and redirects user to INFM page
function needforSubmit() {
	var infm_url = "/de/home_lighting/infm/";
	var form = document.needforForm;
	var Ineed = form.needSel.options[form.needSel.selectedIndex].value;
	var ForMy = form.forSel.options[form.forSel.selectedIndex].value;
	infm_url = infm_url + Ineed + "_" + ForMy + ".htm";
	document.location = infm_url;
}

// setINFMform() reads URL and sets select elements of INFM form to reflect the current page
function setINFMform() {
	var curl = unescape(document.location);
	if (curl.indexOf("/infm/")!=-1) {
		var infm = curl.slice((curl.indexOf('/infm/')+6),curl.indexOf('.htm'));
		var infm_arr = infm.split("_");
		var form = document.needforForm;
		form.needSel.selectedIndex = (infm_arr[0]=="light")?0:(infm_arr[0]=="life")?1:2;
		for(i=0;i<6;i++) {
			if (form.forSel.options[i].value == infm_arr[1]) {
				form.forSel.selectedIndex = i;
			}
		}
	}
}

/* SELECT ELEMENT NAVIGATION */
/* selectNav function -- a select (dropdown) element navigation function
   called from onChange event of select element,
   i.e. onChange="selectNav('formName','archive');"
   where 'formName' is the id/name of the containing form, and
   where 'archive' is the id/name of the specific select element to be tested.
   the value of the option elements should be the target URLs.
*/
function selectNav(form,fName) {
  fRef = eval('top.document.'+form);
  var selIdx = fRef[fName].selectedIndex 
  var selURL = fRef[fName].options[selIdx].value 
  document.location = selURL;
}

/* setSelected function -- sets select element navigation dropdown to reflect the current page
   called inline after the code for the select element navigation,
   i.e. within a javascript code block
      setSelected(top.document.formName,'archive');
   where 'archive' is the name of the specific select element to be effected
   the value of the option elements will be compared to the current URL and, if an option matches, it will be set as selected.
*/
function setSelected(form,fName) {
  fRef = eval('top.document.'+form);
	var curl = unescape(document.location);
  i = curl.indexOf('/de/');
  curl = curl.slice(i);
  for(i=0;i<fRef[fName].options.length;i++) {
    if (fRef[fName].options[i].value.indexOf(curl)>=0) {
      fRef[fName].options[i].selected = true;
      break;
    }
  }
}
/* END SELECT ELEMENT NAVIGATION */


/*  Edison Awards openPop wrapper function */
  function eaPop(url) {
    		openMsg("http://www.gelighting.com/eu/resources/edison_award/" + url,"710","550","resizable,scrollbars");
  }
/*/Edison Awards openPop wrapper function */

/* Learn About Light's Distribution Curves openPop wrapper function */
function openCurve(idx) {
	openPop("http://www.gelighting.com//de/resources/learn_about_light/pop_curves.htm?"+idx,"710","520","resizable,scrollbars");
}
/*/Learn About Light Distribution Curves openPop wrapper function */


/* COMMERCIAL Glossary opener function */
/* Calls absolutely so it can be used within ecatalog also */
/* Cannot use generic openPop because of feature override behavior */
function openGlossary(anchr) {
	if (!glossaryWin || glossaryWin.closed){
		glossaryWin = window.open("http://www.gelighting.com/de/resources/glossary.htm#"+anchr,"","width=770,height=300,resizable,scrollbars,toolbar,location,status,top=1,screenY=1,left=1,screenX=1");
	}
	else {
		glossaryWin.focus();
		glossaryWin.document.location = "http://www.gelighting.com/de/resources/glossary.htm#"+anchr;
	}
}
/*/Glossary opener function */



/**********************************************************************/
// Cascading Menus for Standard GE Corporate Top Navbar
// By Matthew Rasnake and Scott Henderson, GE Consumer & Industrial
// March 2005
/**********************************************************************/

//Create the only array we'll need.
geMenuArray = new Array();

/* All calls are absolute b/c it must be used within ecatalog & search results also */

/* The first menu */
/*geMenuArray[0] = [
				"Automotive||"          + menuBaseHref + "/de/product_portfolio/automotive/",
				"General Lamps||"       + menuBaseHref + "/de/product_portfolio/general_lighting/",
				"SHOWBIZ&#174;||"       + menuBaseHref + "/de/product_portfolio/showbiz/",
				"Specialty||"           + menuBaseHref + "/de/product_portfolio/specialty/",
				"Electronic Ballasts||" + menuBaseHref + "/de/product_portfolio/ballasts/",
				"Fittings||"            + menuBaseHref + "/de/product_portfolio/fittings/",
             ];*/
geMenuArray[0] = [
				"Wohnraumbeleuchtung||"     + menuBaseHref + "/de/product_portfolio/home_lighting/",
				"Automobilbeleuchtung||"    + menuBaseHref + "/de/product_portfolio/automotive/",
				"Gewerbliche Beleuchtung||" + menuBaseHref + "/de/product_portfolio/commercial_lighting/"
		  ];
geMenuArray[0]['id']    = "navbarCell_1";
geMenuArray[0]['width'] = "125";
geMenuArray[0]['left']  = "";

/* The second menu */
geMenuArray[1] = [
			        "Gl&uuml;hlampen||javascript:confirmsite('"+menuBaseHref2+"/EULCTLG/Dispatcher?REQUEST=GETSUBMENU&MarketCode=UF&CountryCode=EN&Site=de&category=INC&text=Incandescent');",
				"Halogenlampen||javascript:confirmsite('"+menuBaseHref2+"/EULCTLG/Dispatcher?REQUEST=GETSUBMENU&MarketCode=UF&CountryCode=EN&Site=de&category=HAL&text=Halogen');",
				"Hochdruck-Entladungslampen||javascript:confirmsite('"+menuBaseHref2+"/EULCTLG/Dispatcher?REQUEST=GETSUBMENU&MarketCode=UF&CountryCode=EN&Site=de&category=HID&text=High%20Intensity%20Discharge');",
				"Leuchtstofflampen||javascript:confirmsite('"+menuBaseHref2+"/EULCTLG/Dispatcher?REQUEST=GETSUBMENU&MarketCode=UF&CountryCode=EN&Site=de&category=LFL&text=Fluorescent');",
				"Kompakt-Leuchtstofflampen||javascript:confirmsite('"+menuBaseHref2+"/EULCTLG/Dispatcher?REQUEST=GETSUBMENU&MarketCode=UF&CountryCode=EN&Site=de&category=CFL&text=Compact%20Fluorescent');",
				"SHOWBIZ&#174 Lampen||javascript:confirmsite('"+menuBaseHref2+"/EULCTLG/Dispatcher?REQUEST=GETSUBMENU&MarketCode=UF&CountryCode=EN&Site=de&category=SS&text=Showbiz');",
				"Spezielle Produkte||javascript:confirmsite('"+menuBaseHref2+"/EULCTLG/Dispatcher?REQUEST=GETSUBMENU&MarketCode=UF&CountryCode=EN&Site=de&category=SP&text=Speciality');"
             ];
geMenuArray[1]['id']    = "navbarCell_2"; // id of Parent object for this menu
geMenuArray[1]['width'] = "135";          // width of this menu
geMenuArray[1]['left']  = "";             // left offset (positive or negative)


/* The first menu */
geMenuArray[2] = [
			   	"Wohnraumbeleuchtung||"               + menuBaseHref + "/de/product_portfolio/home_lighting/",
				"Hotel-und Freitzeitbeleuchtung||"    + menuBaseHref + "/de/lighting_applications/hotel/",
				"B&uuml;robeleuchtung||"              + menuBaseHref + "/de/lighting_applications/office/",
				"Einzelhandelsbeleuchtung||"          + menuBaseHref + "/de/lighting_applications/retail/",
				"SHOWBIZ&#174; and Entertainment||"   + menuBaseHref + "/de/lighting_applications/showbiz/",
				"Strassenbeleuchtung||"               + menuBaseHref + "/de/lighting_applications/street/",
				"Spezielle Beleuchtungsanwendungen||" + menuBaseHref + "/de/lighting_applications/specialist/"
];
geMenuArray[2]['id']    = "navbarCell_3";
geMenuArray[2]['width'] = "145";
geMenuArray[2]['left']  = "";

/* The third menu */
geMenuArray[3] = [
				"Pressemitteilungen||"             + menuBaseHref + "/de/resources/press_room/",
				"Informationen zum Thema Licht||"  + menuBaseHref + "/de/resources/learn_about_light/history_of_light/",
				"Produktliteratur||"               + menuBaseHref + "/de/resources/literature_library/",
				"Umweltschutz||"                   + menuBaseHref + "/de/resources/environmental/",
				"Ratgeber||javascript:confirmsite('http://www.gelighting.com/eu/resources/solutions_advisor/index.htm');",
				"GE Edison Award||"                + menuBaseHref + "/de/resources/edison_award/",
                "E-Business||"					   +menuBaseHref+	"/de/resources/e_business/index.htm"

];

geMenuArray[3]['id']    = "navbarCell_4";
geMenuArray[3]['width'] = "100";
geMenuArray[3]['left']  = "-20";

//Write additional styles required for menus.
ourStyles = '<style type="text/css">';
ourStyles += 'div.ddmenu {position:absolute; margin-top:7px; visibility:hidden; text-transform:none; border-top:1px solid #CCCCCC; z-index:1;}';
ourStyles += 'a.ddcell       {background-color:#F7F7F7; border:1px solid #CCCCCC; border-top:0px; padding: 6px 7px 6px 8px; text-transform:none; display:block;}';
ourStyles += 'a.ddcell:hover {background-color: #FFFFFF;}';
ourStyles += '</style>';
document.write(ourStyles);


//fnBuildMenu(mNum) returns the html for a single menu.
function fnBuildMenu(mNum) {
	mArr = geMenuArray[mNum];
	mWidth = "width:"+mArr.width+"px;";                      // a CSS style width statement string
	mLeft = (mArr.left)?"margin-left:"+mArr.left+"px;":"";   // a CSS style left-margin statement string
	menuString =  '<br><div id="menudiv'+mNum+'" class="ddmenu" style="'+mWidth+mLeft+'">'; // start menuString with opening DIV
	for (mItem in mArr) {                           // loop through this sub-array
		if (parseInt(mItem)||(parseInt(mItem)==0)) {  // if array item name is a number (i.e. it's not "id" or "width")
			linky = mArr[mItem].split('||');            // split the contents of this array item to get Link Text and Link URL
			menuString += '<a href="'+linky[1]+'" class="ddcell" id="m'+mNum+'-'+mItem+'" style="'+mWidth+'">'+linky[0]+'</a>'; // add this menu item to HTML DIV string
		}
	}
	menuString += '</div>';                         // close HTML DIV string
	return menuString;                              // return the constructed Menu HTML 
}

//fnDefineMenus() uses fnBuildMenu to create the HTML, insert it into the page, and attach event listeners to the Parent Objects  
function fnDefineMenus() {
	if(!document.getElementById(geMenuArray[geMenuArray.length-1].id)) { //a test for final Parent object that's supposed to spawn a menu
		fred = setTimeout("fnDefineMenus()",500);  //if it doesn't exist yet, wait a bit longer
	} else {
		for (men in geMenuArray) {                      // loop through main menu Array
	  		tempObj = document.getElementById(geMenuArray[men].id); //get obj ref. to this menu's Parent Object
	  		tempObj.innerHTML  += fnBuildMenu(men);     //build menu HTML string and add it to Parent Object's HTML
	  		tempObj.onmouseover = fnOpenMen;          //define Parent Object's mouseover event to call fnOpenMen
	  		tempObj.onmouseout  = fnCloseMen;         //define Parent Object's mouseout event to call fnCloseMen
    	}
	}
}

function fnOpenMen() {
  menObj = this.getElementsByTagName('div')[0];  // Our menu is the first div within the Parent Object (this)
  menObj.style.zIndex = "1";
  menObj.style.visibility = "visible";           
}
function fnCloseMen() {
  menObj = this.getElementsByTagName('div')[0];  // Our menu is the first div within the Parent Object (this)
  menObj.style.zIndex = "0";
  menObj.style.visibility = "hidden";
}

//Let's get things started!!
//We're NOT using document.onload -- It could conflict with an onload already in the BODY tag.
if (document.getElementsByTagName) { // if we're DOM capable
	fnDefineMenus();  //start _trying_ to define menus
}

/*********************************************/
// Cascading Menus Section Ended
/*********************************************/

/**********************************************************/
// This should be the end.
// Place any/all new stuff ABOVE the menus section please.
/**********************************************************/