// ------[ Event Handlers ]------------------------------------------------- //
//*** This code is copyright 2003 by Gavin Kistner, gavin@refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
//*** Reuse or modification is free provided you abide by the terms of that license.
//*** (Including the first two lines above in your source code satisfies the conditions.)
//***Cross browser attach event function. For 'evt' pass a string value with the leading "on" omitted
//***e.g. AttachEvent(window,'load',MyFunctionNameWithoutParenthesis,false);
 function AttachEvent(obj,evt,fnc,useCapture){
	if (!useCapture) useCapture=false;
	if (obj.addEventListener) {
		obj.addEventListener(evt,fnc,useCapture);
		return true;
	} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
	else {
		MyAttachEvent(obj,evt,fnc);
		obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
	}
	return true; //added 2/4/08
}
 
//The following are for browsers like NS4 or IE5Mac which don't support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc) {
    if (!obj.myEvents) obj.myEvents={};
    if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
    var evts = obj.myEvents[evt];
    evts[evts.length]=fnc;
	}

function MyFireEvent(obj,evt) {
	if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
	var evts = obj.myEvents[evt];
	for (var i=0,len=evts.length;i<len;i++) evts[i]();
	}

// ------[ Event Registration ]------------------------------------------------- //
// AttachEvent(window,'load',initPanel,false);

	// ------[ Product Descriptions Panel ]------------------------------------------------- //
	function initProductDescriptions() {
		var obj = document.getElementById('product-descriptions');	
		if(obj != null) {
			obj.className = "panel";
			linkObj = obj.getElementsByTagName('h3');
			
			var h3pos = 0;
			for(x=0; x<linkObj.length; x++) {
				// h3 
				linkObj[x].style.display = 'block';
				linkObj[x].child = document.getElementById(linkObj[x].className);
				if(x == 0) linkObj[x].className = "selected";
				linkObj[x].onclick = openProductDescription;
				linkObj[x].style.left = h3pos + "px";
				
				h3pos = h3pos + 152 + 1;
				
				if(x != 0) linkObj[x].child.style.display = "none";
				else linkObj[x].child.style.display = "block";		
				}	
			obj.style.display = 'block';
			}
		}
		
//**************
	function openProductDescription() {
		var obj = document.getElementById('product-descriptions');	
		linkObj = obj.getElementsByTagName('h3');
		
		for(x=0; x<linkObj.length; x++) {
			if(this == linkObj[x]) {
				linkObj[x].className = "selected";
				linkObj[x].child.style.display = "block";
			} else {
				linkObj[x].className = "";
				linkObj[x].child.style.display = "none";			
				}
			}
		}
	AttachEvent(window,'load',initProductDescriptions,false);

 //***********************
	function isUSTerritory(country) {
	    return (
	        false
	         || country == "AS" || country == "GU" || country == "MH" || country == "FM" || country == "MP" || country == "PW" || country == "PR" || country == "UM" || country == "VI"
	        );
	    }
	    
	 
	function openPopup(width, height, location) {
		window.open(location, "rainvilleWindow","width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no");
	}
