﻿function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        { 
            c_start=c_start + c_name.length+1; 
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return null;
}
function setCookie(c_name,value)
{
    document.cookie=c_name+ "=" +escape(value);
}
function clearCookie ( c_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = c_name += "=; expires=" + cookie_date.toGMTString();
}
function loadDoc(url)
{
    xmlhttp=null;
    if (window.XMLHttpRequest)
    {// code for IE7, Firefox, Opera, etc.
        xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET",url,false);
    xmlhttp.send(null);

    if (xmlhttp!=null)
    {
        return xmlhttp.responseText;
    }
    else
    {
        alert("Your browser does not support XMLHTTP.");
    }
}



/** 
* set idrop drop feature's version
*/
function setIDrop() {
    activexs = document.getElementsByName("iDrop");
    if (activexs == null)
        return;
    for (var i = 0; i < activexs.length; i++) {
        activex = document.getElementsByName("iDrop")[i];

        //Checking appVersion to load appropriate ActiveX control (32-bit or 64-bit)
        var appVersionName = navigator.appVersion;
        var index = appVersionName.indexOf("x64");
        if (index != -1) {
            //clsid for 64-bit control
            activex.classid = "clsid:32290CD1-D585-4803-AF20-F16E20FF377A";
        }
        else {
            //clsid for 32 bit control
            activex.classid = "clsid:21E0CB95-1198-4945-A3D2-4BF804295F78";
        }
    }
}


function setMyIDrop(pn) {
    var name = pn + "idrop"
    activexs = document.getElementsByName(name);
    if (activexs == null)
        return;

    //Checking appVersion to load appropriate ActiveX control (32-bit or 64-bit)
    var appVersionName = navigator.appVersion;
    var index = appVersionName.indexOf("x64");
    
    for (var i = 0; i < activexs.length; i++) {
        activex = activexs[i];
        if (index != -1) {
            //clsid for 64-bit control
            if (activex.classid == null || activex.classid=="")
                activex.classid = "clsid:32290CD1-D585-4803-AF20-F16E20FF377A";
        }
        else {
            //clsid for 32 bit control
            if (activex.classid == null || activex.classid == "")
                activex.classid = "clsid:21E0CB95-1198-4945-A3D2-4BF804295F78";
        }
    }
   }

   function showLEDMountDetail(mountSpan, imgHtml, detailHtml, idx) {
   	    var thumbSPAN = document.getElementById(mountSpan);
   	    thumbSPAN.style.top = (-100 + idx * 25) + "px";
    	thumbSPAN.innerHTML = imgHtml;
   	    thumbSPAN.innerHTML += "<div style=\"float:left;width:90px; padding-left:10px;  \">" + detailHtml.toString().replace("inch", "\"").replace("inch", "\"").replace("inch", "\"").replace("inch", "\"") + "<\div>";
   	    thumbSPAN.style.visibility = "visible";
   	thumbSPAN.style.zIndex = 50;
   	thumbSPAN.style.position = "absolute";
   	thumbSPAN.style.right = "35px";
   	thumbSPAN.style.marginTop = "100px";
   	thumbSPAN.style.display = "block";
   	thumbSPAN.style.background = "black";
   	thumbSPAN.style.color = "white";
   	thumbSPAN.style.width = "165px";
   	thumbSPAN.style.height = "62px";
   }

   function hideLEDMountDetail(mountSpan) {
   	var thumbSPAN = document.getElementById(mountSpan);
   	thumbSPAN.innerHTML = "";
   	thumbSPAN.style.visibility = "hidden";
   	thumbSPAN.style.zIndex = 1;
   }

   function showXMountDetail(mountSpan, imgHtml, detailHtml, idx) {
   	var thumbSPAN = document.getElementById(mountSpan);
   	thumbSPAN.style.top = (-100 + idx * 25) + "px";
   	thumbSPAN.innerHTML = imgHtml;
   	thumbSPAN.innerHTML += "<div style=\"float:left; width:90px; padding-left:10px; \">" + detailHtml.toString().replace("inch", "\"").replace("inch", "\"").replace("inch", "\"").replace("inch", "\"") + "<\div>";
   	thumbSPAN.style.visibility = "visible";
   	thumbSPAN.style.zIndex = 50;
   	thumbSPAN.style.position = "absolute";
   	thumbSPAN.style.right = "30px";
   	thumbSPAN.style.marginTop = "100px";
   	thumbSPAN.style.display = "block";
   	thumbSPAN.style.background = "black";
   	thumbSPAN.style.color = "white";
   	thumbSPAN.style.width = "165px";
   	thumbSPAN.style.height = "62px";
   }

   function hideXMountDetail(mountSpan) {
   	var thumbSPAN = document.getElementById(mountSpan);
   	thumbSPAN.innerHTML = "";
   	thumbSPAN.style.visibility = "hidden";
   	thumbSPAN.style.zIndex = 1;
   }

   function showPMountDetail(mountSpan, imgHtml, detailHtml, idx) {
   	var thumbSPAN = document.getElementById(mountSpan);
   	thumbSPAN.style.top = (-100 + idx * 25) + "px";
   	thumbSPAN.innerHTML = imgHtml;
   	thumbSPAN.innerHTML += "<div style=\"float:left; width:90px; padding-left:10px; \">" + detailHtml.toString().replace("inch", "\"").replace("inch", "\"").replace("inch", "\"").replace("inch", "\"") + "<\div>";
   	thumbSPAN.style.visibility = "visible";
   	thumbSPAN.style.zIndex = 50;
   	thumbSPAN.style.position = "absolute";
   	thumbSPAN.style.right = "30px";
   	thumbSPAN.style.marginTop = "100px";
   	thumbSPAN.style.display = "block";
   	thumbSPAN.style.background = "black";
   	thumbSPAN.style.color = "white";
   	thumbSPAN.style.width = "165px";
   	thumbSPAN.style.height = "90px";
   }

   function hidePMountDetail(mountSpan) {
   	var thumbSPAN = document.getElementById(mountSpan);
   	thumbSPAN.innerHTML = "";
   	thumbSPAN.style.visibility = "hidden";
   	thumbSPAN.style.zIndex = 1;
   }

   function showGMountDetail(mountSpan, imgHtml, detailHtml, idx) {
   	var thumbSPAN = document.getElementById(mountSpan);
   	thumbSPAN.style.top = (-100 + idx * 25) + "px";
   	thumbSPAN.innerHTML = imgHtml;
   	thumbSPAN.innerHTML += "<div style=\"float:left; width:90px; padding-left:10px; \">" + detailHtml.toString().replace("inch", "\"").replace("inch", "\"").replace("inch", "\"").replace("inch", "\"") + "<\div>";
   	thumbSPAN.style.visibility = "visible";
   	thumbSPAN.style.zIndex = 50;
   	thumbSPAN.style.position = "absolute";
   	thumbSPAN.style.right = "30px";
   	thumbSPAN.style.marginTop = "100px";
   	thumbSPAN.style.display = "block";
   	thumbSPAN.style.background = "black";
   	thumbSPAN.style.color = "white";
   	thumbSPAN.style.width = "165px";
   	thumbSPAN.style.height = "62px";
   }

   function hideGMountDetail(mountSpan) {
   	var thumbSPAN = document.getElementById(mountSpan);
   	thumbSPAN.innerHTML = "";
   	thumbSPAN.style.visibility = "hidden";
   	thumbSPAN.style.zIndex = 1;
   }


   function setMenus() {
       //set mainmenu
       if ((window.Menu) && (document.getElementById(window.Menu) != null)) {
           document.getElementById(window.Menu).style.color = "#000";
       }
   }



//tooltip start



// This code is from Dynamic Web Coding www.dyn-web.com 
// Copyright 2002 by Sharon Paine Permission granted to use this code as long as this entire notice is included.
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/

var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

if (nodyn) { event = "nope" }
var tipFollowMouse	= true;
var tipWidth = 55;
var offX		 	= 12;	// how far from mouse to show tip
var offY		 	= 12; 
var tipFontFamily 	= "Verdana, arial, helvetica, sans-serif";
var tipFontSize		= "8pt";
var tipFontColor		= "#000000";
var tipBgColor		= "#ffffff"; 
var origBgColor 		= tipBgColor; // in case no bgColor set in array
var tipBorderColor 	= "#ffffff";
var tipBorderWidth 	= 0;
var tipBorderStyle 	= "none";
var tipPadding	 	= 0;

var messages = new Array();
messages[0] = new Array('http://www.mplighting.com/product/images/NGL_Logo09_MP.jpg', '', "#FFFFFF");
messages[1] = new Array('http://www.mplighting.com/product/images/NGL_Logo09_MP.jpg', '', "#FFFFFF");

if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}

var startStr = '<table cellpadding="0" cellspacing="0" width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';

var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = (ns4)? document.tipDiv: tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		if (ns4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = trackMouse;
	}
}

window.onload = initTip;

var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,num) {

	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ns4) {
		var tip = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + curBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td>'+ startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr + '</td></tr></table></td></tr></table>';
		tooltip.write(tip);
		tooltip.close();
	} else if (ie4||ie5||ns5) {
		var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
	mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	if (tipOn) positionTip(evt);
}

function positionTip(evt) {
	if (!tipFollowMouse) {
		mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
		mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
	var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
	else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
	else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}
//-->
