var numpops=6;
var offsetX=-265;
var offsetY=570; 

var imgpath="/img2/markets/pv/";
var imgheight=100;
var imgwidth=100;
//-------------------------------------------------------------------------------
var arList1 = new Array();
var arList2 = new Array();
var arList3 = new Array();
var arList4 = new Array();
var arList5 = new Array();
var arList6 = new Array();

arList1[0]="CAST-X Circulation Heaters||products.cfm||cast-x-family_100.jpg";

arList2[0]="Large Radiant Panel Heaters||products.cfm||panel1_100.jpg";
arList2[1]="EZ-ZONE&reg; Temperature Controllers||products.cfm||ezrm1_100.jpg";
arList2[2]="DIN-A-MITE Power Controllers||products.cfm||dinamite_100.jpg";

arList3[0]="High-Temperature Large Radiant Panel Heaters||products.cfm||panel3_100.jpg";
arList3[1]="EZ-ZONE&reg; Temperature Controllers||products.cfm||ezrm1_100.jpg";
arList3[2]="DIN-A-MITE Power Controllers||products.cfm||dinamite_100.jpg";

arList4[0]="Large Radiant Panel Heaters||products.cfm||panel1_100.jpg";
arList4[1]="EZ-ZONE&reg; Temperature Controllers||products.cfm||ezrm1_100.jpg";
arList4[2]="DIN-A-MITE Power Controllers||products.cfm||dinamite_100.jpg";

arList5[0]="Large Conductive Heater Plate||products.cfm||ifc_100.jpg";
arList5[1]="EZ-ZONE&reg; Temperature Controllers||products.cfm||ezrm1_100.jpg";
arList5[2]="Temperature Sensors||products.cfm||tst_sensor_100.jpg";

arList6[0]="CAST-X Circulation Heaters||products.cfm||cast-x-family_100.jpg";

//-------------------------------------------------------------------------------
//browser check
//if( typeof( window.innerWidth ) == 'number' ) { //Non-IE

//} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { 
//IE 6+ in 'standards compliant mode'

//} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible


//-------------------------------------------------------------------------------
//does not work with image map in FF
function findPos(obj) {
	
	var curleft = curtop = 0;
	
	//If the browser supports offsetParent we proceed.
	if (obj.offsetParent) {
		
		//Every time we find a new object, we add its offsetLeft and offsetTop to curleft and curtop.
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		while (obj = obj.offsetParent);
	
		/*The loop continues until the object currently being investigated does not have an offsetParent any more. 
		While the offsetParent is still there, it still adds the offsetLeft of the object to curleft, and the offsetTop to curtop.
		Finally, when the while loop has quit, we return an array with the calculated coordinates to whichever script asked for it.*/
		
		//alert("curleft=" + curleft + "\ncurtop=" + curtop)
		return [curleft,curtop];
	}
}
function findPos2() {
	var x = document.images.pop0.offsetLeft;
	var y = document.images.pop0.offsetTop;
	alert("top=" + y + "\nleft=" + x);
	return [x,y];
}
function findPos3(obj) {
	x = obj.offsetLeft;
	alert("x=" + x);
}

function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //alert("width=" + myWidth + "\nheight=" + myHeight)
  return [myWidth,myHeight];
}

function GetCursor(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
	return cursor;
}

function popit(obj,e,id) {
	
	if (!document.all&&!document.getElementById)
		return
	
	hideall(id)
	clearhidepopup()
	
	arTemp=eval("arList" + id);
	
	//get default img
	strTemp=arTemp[0];
	arTemp2=strTemp.split("||");
	deflink=arTemp2[1];
	defimg=imgpath + arTemp2[2];
	//deflink="/";
	//defimg="no_image_100.jpg";
	imgname="popimg" + id;
	
	htmlstr='<div id="pop3" class="pop" onMouseover="clearhidepopup();" onmouseout="delayhidepopup()">';
	htmlstr='<a href="' + deflink + '"><img src="' + defimg + '" width="' + imgwidth + '" height="' + imgheight + '" name="' + imgname +  '" id="' + imgname + '"></a>';
	//alert(htmlstr);

	htmlstr+='<ul>';
	
	for(k=0;k<arTemp.length;k++)
	{
		strTemp=arTemp[k];
		arTemp2=strTemp.split("||");
		temptitle=arTemp2[0];
		templink=arTemp2[1];
		tempimg= imgpath + arTemp2[2];
		//alert("k=" + k + "  tempimg=" + tempimg);
		mouseovertxt="document." + imgname + ".src='" + tempimg + "'";
		
		htmlstr+='<li><a href="' + templink + '" onmouseover="' + mouseovertxt + '">' + temptitle + '</a></li>';
	}
	htmlstr+='</ul>';

	//alert(htmlstr);
	
	//get position of element
	
	if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
		//get cursor pos
		//alert("non-IE");
		
		curPos=GetCursor(e);
		posX = curPos.x;
		posY = curPos.y;
		
		newX = posX + 10;
		newY = posY + 10;
		
	} else { //IE
		curPos=findPos(obj);
		posX=curPos[0];
		posY=curPos[1];
		
		//get window size
		wSize = getWindowSize();
		wWidth = wSize[0];
		wHeight = wSize[1];
		newX = posX + wWidth/2 + offsetX;
		newY = posY + offsetY;
	}
	
	//alert("newX=" + newX + "\nnewY=" + newY);
	//alert("posX=" + posX + "\nposY=" + posY);
	
	temp="document.getElementById('pop" + id + "')";
	
	popobj=eval(temp);
	popobj.style.left=newX;
	popobj.style.top=newY;
	popobj.innerHTML = htmlstr;
	popobj.style.visibility="visible";
}


function hideall(id) {
	for(i=1;i<=numpops;i++) {
		if(i!=id) {
			tempobj=document.getElementById("pop" + i);
			tempobj.style.visibility="hidden";
		}
	}
}

function unpop(obj) {
	popobj=document.getElementById("pop0");
	popobj.style.visibility="hidden";
}

function hidepopup(){
if (window.popobj)
popobj.style.visibility="hidden"
}

function delayhidepopup(){
delayhide=setTimeout("hidepopup()",1500)
}

function clearhidepopup(){
	if (window.delayhide)
		clearTimeout(delayhide)
}

//if (ie5||ns6)
//document.onclick=hidepopup();

function swapimg(divid,imgid,count) {
	for(i=1;i<=count;i++) {
		tempobj=document.getElementById("img" + divid + imgid);
		if(i==imgid) {
			tempobj.style.visibility="visible";
		} else {
			tempobj.style.visibility="hidden";
		}
	}
	
}

