//for use as copyright year
curDate = new Date();
var curYear = curDate.getFullYear();

// 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;

//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);
    }
}


/* image switcher function for Edison Awards Winners pop-up pages */
/* does show/hide on divs rather than a src swap, because images can be different sizes */
/* assumes first image is visible by default */
visible="1";
function switchImage(num) {
  if (num!=visible) {
    document.getElementById('switchBox'+visible).style.display = 'none';
    document.getElementById('switchBox'+num).style.display = 'block';
    visible = num;
  }
}
/* image switcher */

// "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);
	}
}

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();
	}
}

function confirmsitecn(url) //Chinese site
{ if (confirm("本页只有英语内容。如需转到指定页面，请按OK按钮。"))
   { window.open(url,'_self') }
}

// 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();
	}
}

/* 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('/eu/');
  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 applPop(url) {
    openPop("/chn/applications/" + url,"650","550","resizable");
  }
  
/*  Edison Awards openPop wrapper function */
  function referPop(url) {
    openPop("/chn/applications/" + url,"600","500","resizable");
  }
  
/*/Edison Awards openPop wrapper function */

/* Learn About Light's Distribution Curves openPop wrapper function */
function openCurve(idx) {
	openPop("/chn/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/eu/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/eu/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
/**********************************************************************/

var menuBaseHref = "";

//if NOT teamsite AND NOT gelighting, make menuBaseHref absolute
hoststring=window.location.host.toLowerCase();
//if(hoststring.indexOf('teamsite') == -1 && hoststring.indexOf('gelighting') == -1) {
//	menuBaseHref = "http://www.gelighting.com";
//}

//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 */

geMenuArray[0] = [
			  "冷藏设备||"+menuBaseHref+"/cn/products/appliances/refrigeration/index.htm",
			  "洗碗机||"+menuBaseHref+"/cn/products/appliances/cooking/index.htm",
			  "衣物护理||"+menuBaseHref+"/cn/products/appliances/dishwashers/index.htm",
			  "衣物护理||"+menuBaseHref+"/cn/products/appliances/clothes_care/index.htm",
			  "饮水系统||"+menuBaseHref+"/cn/products/appliances/water_systems/index.htm",
			  "空调||"+menuBaseHref+"/cn/products/appliances/air_conditioning/index.htm",
				];
geMenuArray[0]['id']    = "navbarCell_1";
geMenuArray[0]['width'] = "125";
geMenuArray[0]['right']  = "";


geMenuArray[1] = [
				"配电设备||"+menuBaseHref+"/cn/products/industrial/equipment/index.htm",
				"中压配电设备||"+menuBaseHref+"/cn/products/industrial/med_volt_equipment/index.htm",
				"保护、计量和通信设备||"+menuBaseHref+"/cn/products/industrial/electrical_distribution/index.htm",
				"工业元器件||"+menuBaseHref+"/cn/products/industrial/component/index.htm",
				"电力质量||"+menuBaseHref+"/cn/products/industrial/power_quality/index.htm",
				"电机和控制||"+menuBaseHref+"/cn/products/industrial/motors_control/index.htm",
				];			 
geMenuArray[1]['id']    = "navbarCell_2"; // id of Parent object for this menu
geMenuArray[1]['width'] = "150";          // width of this menu
geMenuArray[1]['left']  = "";             // left offset (positive or negative)

geMenuArray[2] = [
				"汽车照明||"+menuBaseHref+"/cn/products/lighting/automotive/index.htm",
				"白炽灯||"+menuBaseHref+"/cn/products/lighting/incandescent/index.htm",
				"碘钨灯||"+menuBaseHref+"/cn/products/lighting/halogen/index.htm",
				"荧光灯||"+menuBaseHref+"/cn/products/lighting/fluorescent/index.htm",
				"紧凑型荧光灯||"+menuBaseHref+"/cn/products/lighting/compact_fluorescent/index.htm",
				"高强度气体放电灯||"+menuBaseHref+"/cn/products/lighting/hid/index.htm",
				"灯架||"+menuBaseHref+"/cn/products/lighting/fixtures/index.htm",
				"专业电灯||"+menuBaseHref+"/cn/products/lighting/specialty/index.htm",
				];			 
geMenuArray[2]['id']    = "navbarCell_3"; // id of Parent object for this menu
geMenuArray[2]['width'] = "135";          // width of this menu
geMenuArray[2]['left']  = "";             // left offset (positive or negative)


/* The second menu */
geMenuArray[3] = [
				"商厦||"+menuBaseHref+"/cn/applications/commercial_building/index.htm",
				"电厂||"+menuBaseHref+"/cn/applications/power_plant/index.htm",
				"体育馆||"+menuBaseHref+"/cn/applications/stadium_arena/index.htm",
				"油气精炼厂||"+menuBaseHref+"/cn/applications/onshore_oil_gas/index.htm",
				"近海油气勘测||"+menuBaseHref+"/cn/applications/offshore_oil_gas/index.htm",
				"钢厂||"+menuBaseHref+"/cn/applications/steel_works/index.htm",
				];			 
geMenuArray[3]['id']    = "navbarCell_4"; // id of Parent object for this menu
geMenuArray[3]['width'] = "145";          // width of this menu
geMenuArray[3]['left']  = "";             // left offset (positive or negative)


/* The first menu */
geMenuArray[4] = [
			  "文献库||"+menuBaseHref+"/cn/resources/library/index.htm",
			  "电子简讯||"+menuBaseHref+"/cn/resources/newsletter/index.htm?CN",
			  "工业产品销售商||"+menuBaseHref+"/cn/resources/where_to_buy/index.htm?0&type=Industrial",
			  "照明产品销售商||"+menuBaseHref+"/cn/resources/where_to_buy/index.htm?1&type=Lighting",
			  "在线工具||"+menuBaseHref+"/cn/resources/online_tools/index.htm",
			  "能源优化||"+menuBaseHref+"/cn/resources/energy_optimiser/index.htm",
			  "软件||"+menuBaseHref+"/cn/resources/software/index.htm",
			  "了解电灯||"+menuBaseHref+"/cn/resources/learn_about_light/index.htm",
			  "照明术语||"+menuBaseHref+"/cn/resources/glossary.htm",
];
geMenuArray[4]['id']    = "navbarCell_5";
geMenuArray[4]['width'] = "145";
geMenuArray[4]['left']  = "";

/* The third menu */
geMenuArray[5] = [
				"公司信息||"+menuBaseHref+"/cn/about/info/index.htm",
				"职业||"+menuBaseHref+"/cn/about/careers/index.htm",
				"联系我们||"+menuBaseHref+"/cn/about/feedback/index.htm",
             ];
geMenuArray[5]['id']    = "navbarCell_6";
geMenuArray[5]['width'] = "85";
geMenuArray[5]['left']  = "";

//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;}';
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.visibility = "visible";

	/* in IE, select boxes overlap everything, no matter what you set
	their z-index to, we create iframes, which somehow *do* overlap
	select boxes, under the menus. */
	if (!menObj.iframe) {
		var iframe = document.createElement("iframe");
		menObj.iframe = iframe;
		var x = menObj.offsetLeft;
		var y = menObj.offsetTop;
		var w = menObj.offsetWidth;
		var h = menObj.offsetHeight;
		iframe.style.position = "absolute";
		iframe.style.top    = y + "px";
		iframe.style.left   = x + "px";
		iframe.style.width  = w + "px";
		iframe.style.height = h + "px";
		menObj.parentNode.insertBefore(iframe, menObj);
	}
	menObj.iframe.style.visibility = "visible";
}

function fnCloseMen() {
	menObj = this.getElementsByTagName('div')[0];  // Our menu is the first div within the Parent Object (this)
	menObj.style.visibility = "hidden";
	if (menObj.iframe) {
		menObj.iframe.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.
/**********************************************************/


