
<!--
/******************************************************************
 *master.js
 * This is the main generic script library for Infocus.com
 * This library contains sue functions to assist with cross browser
 * compatibility and to simplify common, yet complex tasks
 *
 *
 *
 ******************************************************************/

/**************** GLOBAL VARIABLES ******************/

var g_sBaseProjectorCompareURL = "/Marketing/CompareProjectorResults.aspx";   //URL passed to showPopOver(),  need projector IDs as query params
var g_sProjectorCompareQuery = "";          // should have the form: ?p1=<GUID1>&p2=<GUID2>&p3=<GUID3>
var g_aCompareItems = new Array();			//An array of Item IDs (GUIDs) to be compared

var MAC=(navigator.userAgent.indexOf('Mac')!=-1)?1:0;
var IE=(document.all)?1:0;
var NS6=(document.getElementById&&!document.all)?1:0;

var flash_version=7;
var obj='ShockwaveFlash.ShockwaveFlash.'+eval(flash_version);
var NS6=(document.getElementById&&!document.all)?1:0; var nsv=0; if (NS6) nsv=navigator.vendorSub;
var MAC=(navigator.userAgent.indexOf('Mac')!=-1)?1:0; var SWF=0;
var SAFARI = (navigator.userAgent.toLowerCase().indexOf('safari')!=-1)?1:0;
var VBS='<SCRIP'; VBS+='T LANGUAGE=VBScript\> \n'; VBS+='on error resume next \n'; VBS+='SWF=IsObject(CreateObject(obj)) \n'; VBS+='</S'; VBS+='CRIPT\> \n';
if (!MAC) {document.write(VBS);}
var plugin=(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]?navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin:0);
if (plugin&&parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=flash_version) {SWF=1;} 


/**************** GLOBAL CONSTANTS *****************/

var POP_OVER_DEVICE_STRING = "po=1";

/**
 * All thrown exceptions should be funnelled through this function
 * To ensure proper handling of error conditions
 **/
function logException(e)
{
	status = e.descripion;

	
}


function preloadImages() 
{ 
	var d=document; if(d.images){ if(!d.p) d.p=new Array();
	var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function swapImgRestore() 
{ 
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) 
{ 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}

function swapImage() 
{ 
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}


// VALIDATE FORM FIELD - NUMBER
function IsNumeric(PossibleNumber)
{
	var PNum = new String(PossibleNumber);
	var regex = /[^0-9]/;
	return !regex.test(PNum);
}


// HIDE LAYER
function closePopupLayer(sLayer)
{
	HideLayer(sLayer);
}
		
// SHOW LAYER	
function openPopupLayer(sLayer)
{
	ShowLayer(sLayer)
}


// ShowLayer -	Makes a hidden and/or non-displayed element visible and sets display to 'block'
function ShowLayer(layerID)
{

  var style_sheet = getStyleObject(layerID);
  
  if (style_sheet)
  {
    //hideAll();
    changeObjectVisibility(layerID, "visible");
    changeObjectDisplay(layerID, "block");
  }
  else 
  {
    status = "Layer not found: " + layerID;
  }
 
}

// HideLayer -	Makes a visible and/or displayed element hidden and sets display to 'none'
function HideLayer(layerID)
{
  var style_sheet = getStyleObject(layerID);
  if (style_sheet)
  {
    //hideAll();
    changeObjectVisibility(layerID, "hidden");
    changeObjectDisplay(layerID, "none");
  }
  else 
  {
    status = "Layer not found: " + layerID;
  }
}



// getStyleObject - Get the style object for a given element, required for cross-browser compatability
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
   if(objectId == null)
  {
	return null;
  }
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return null;
   }
}


// getObject - Get the object for a given element, required for cross-browser compatability
function getObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(objectId == null)
  {
	return null;
  }
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId);
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId);
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return null;
   }
}


// Change Object Visability
function changeObjectVisibility(objectId, newVisibility) {
    // first get the object's stylesheet
    var styleObject = getStyleObject(objectId);

    // then if we find a stylesheet, set its visibility
    // as requested
    //
    if (styleObject) {
		styleObject.visibility = newVisibility;
		return true;
    } else {
		return false;
    }

}


// Change Object Display
function changeObjectDisplay(objectId, newDisplay) {
    // first get the object's stylesheet
    var styleObject = getStyleObject(objectId);

    if (styleObject) {
	styleObject.display = newDisplay;
	return true;
    } else {
	return false;
    }

}

// DROP DOWN MENU - JUMP
function jumpToURL(myField)
{
	location.href = myField.options[myField.selectedIndex].value;
}

// HIDE SHOW LAYERS
function showHide(id,vis) 
{ 
	document.getElementById(id).style.visibility=vis; 
} 


//***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){
	
	try
	{
		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) };
		}
	}
	catch(e)
	{
	
	}
} 

//The following are for browsers like NS4 or IE5Mac which don't support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc){
	try
	{
		if (!obj.myEvents) obj.myEvents={};
		if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
		var evts = obj.myEvents[evt];
		evts[evts.length]=fnc;
	} catch (e) {}
}
function MyFireEvent(obj,evt){
	try
	{
		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]();
	} catch (e){}
}

function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    status = "Handler could not be removed";
  }
}

/**
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}

function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

/**
 *  Useful style functions to follow
 *
 *
 **/

// ugly workaround for missing support for selectorText in Netscape6/Mozilla
// call onLoad() or before you need to do anything you would have otherwise used
// selectorText for.
var ugly_selectorText_workaround_flag = false;
var allStyleRules;
// code developed using the following workaround (CVS v1.15) as an example.
// http://lxr.mozilla.org/seamonkey/source/extensions/xmlterm/ui/content/XMLTermCommands.js


function ugly_selectorText_workaround() {
	if((navigator.userAgent.indexOf("Gecko") == -1) ||
	   (ugly_selectorText_workaround_flag)) {
		return; // we've already been here or shouldn't be here
	}
	var styleElements = document.getElementsByTagName("style");
	
	for(var i = 0; i < styleElements.length; i++) {
		var styleText = styleElements[i].firstChild.data;
		// this should be using match(/\b[\w-.]+(?=\s*\{)/g but ?= causes an
		// error in IE5, so we include the open brace and then strip it
		allStyleRules = styleText.match(/\b[\w-.]+(\s*\{)/g);
	}

	for(var i = 0; i < allStyleRules.length; i++) {
		// probably insufficient for people who like random gobs of 
		// whitespace in their styles
		allStyleRules[i] = allStyleRules[i].substr(0, (allStyleRules[i].length - 2));
	}
	ugly_selectorText_workaround_flag = true;
}



// setStyleById: given an element id, style property and 
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

// getStyleById: given an element ID and style property
// return the current setting for that property, or null.
// args:
//  i - element id
//  p - property
function getStyleById(i, p) {
	var n = document.getElementById(i);
	var s = eval("n.style." + p);

	// try inline
	if((s != "") && (s != null)) {
		return s;
	}

	// try currentStyle
	if(n.currentStyle) {
		var s = eval("n.currentStyle." + p);
		if((s != "") && (s != null)) {
			return s;
		}
	}
	
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
			//		ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[y] == i) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) ||
						   (rules[y].selectorText == i)) {
							return z[p];
						}
					}
				}
			}
		}
	}
	return null;
}

// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value
var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

// getStyleByClass: given an element type, a class selector and a property,
// return the value of the property for that element type.
// args:
//  t - element type
//  c - class identifier
//  p - CSS property
function getStyleByClass(t, c, p) {
	// first loop over elements, because if they've been modified they
	// will contain style data more recent than that in the stylesheet
	var elements;
	var length;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}

	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		try {
			length = node.attributes.length;
		}
		catch (e) { length = 0; }
		
		for(var j = 0; j < length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					var theStyle = eval('node.style.' + p);
					if((theStyle != "") && (theStyle != null)) {
						return theStyle;
					}
				}
			}
		}		
	}
	
	
	// if we got here it's because we didn't find anything
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
	
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			
			try {
				length = rules.length;
			}
			catch (e) { length = 0; }
			if(length > 0) {
		
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					//ugly_selectorText_workaround();
					if(allStyleRules) {
						if((allStyleRules[y] == c) ||
						   (allStyleRules[y] == (t + "." + c))) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) &&
						   ((rules[y].selectorText == c) ||
						    (rules[y].selectorText == (t + "." + c)))) {
							return z[p];
						}
					}
				}
			}
		}
	}

	return null;
}

// setStyleByTag: given an element type, style property and 
// value, and whether the property should override inline styles or
// just global stylesheet preferences, apply the style.
// args:
//  e - element type or id
//  p - property
//  v - value
//  g - boolean 0: modify global only; 1: modify all elements in document
function setStyleByTag(e, p, v, g) {
	var length;
	if(g) {
		var elements = document.getElementsByTagName(e);
		for(var i = 0; i < elements.length; i++) {
			elements.item(i).style[p] = v;
		}
	} else {
	
		var sheets = document.styleSheets;
		try {
			length = sheets.length;
		}
		catch (e) { length = 0; }
		if(length > 0) {
			for(var i = 0; i < sheets.length; i++) {
				var rules = sheets[i].cssRules;
				
				try {
					length = rules.length;
				}
				catch (e) { length = 0; }
				if(length > 0) {
					for(var j = 0; j < rules.length; j++) {
						var s = rules[j].style;
						// selectorText broken in NS 6/Mozilla: see
						// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					//	ugly_selectorText_workaround();
						if(allStyleRules) {
							if(allStyleRules[j] == e) {
								
								s[p] = v;
							}			
						} else {
							// use the native selectorText and style stuff
							if(((s[p] != "") && (s[p] != null)) &&
							   (rules[j].selectorText == e)) {
								s[p] = v;
							}
						}

					}
				}
			}
		}
	}
}

// getStyleByTag: given an element type and style property, return
// the property's value
// args:
//  e - element type
//  p - property
function getStyleByTag(e, p) {
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		for(var i = 0; i < sheets.length; i++) {
			var rules = sheets[i].cssRules;
			if(rules.length > 0) {
				for(var j = 0; j < rules.length; j++) {
					var s = rules[j].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
				//	ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[j] == e) {
							return s[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((s[p] != "") && (s[p] != null)) &&
						   (rules[j].selectorText == e)) {
							return s[p];
						}
					}

				}
			}
		}
	}

	// if we don't find any style sheets, return the value for the first
	// element of this type we encounter without a CLASS or STYLE attribute
	var elements = document.getElementsByTagName(e);
	var sawClassOrStyleAttribute = false;
	for(var i = 0; i < elements.length; i++) {
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if((node.attributes.item(j).nodeName == 'class') ||
			   (node.attributes.item(j).nodeName == 'style')){
			   sawClassOrStyleAttribute = true;
			}
		}
		if(! sawClassOrStyleAttribute) {
			return elements.item(i).style[p];
		}
	}
}


//Functions for handling modal layer pop over 'window'



var g_iPopOverStartHist = 0;
var g_iPopOverCurHist = 0;
var g_sPopOverStartURL = "";
var g_bIsPopOverInit = false;
function showPopOver(url)
{

	//Fade("popOverWindow",0,100,5);
	//changeOpac(0, "popOverWindow") 
    //opacity("popOverWindow",0,100   ,500);
	
	//g_iPopOverStartHist = g_iPopOverCurHist = top.frames["popOverWindow_IFRAME"].history.length;
	//alert("fg");
	
	window.parent.g_bIsPopOverInit = true;
	
	var popOver = window.parent.getStyleObject("popOverWindow");
	var popOverObj = window.parent.getObject("popOverWindow");
	var popOverMask = window.parent.getStyleObject("popOverWindowMask");
	var x,y;
	var oContentFrame = window.parent.getObject("popOverWindow_IFRAME");


	if(window.parent.document.body.scrollHeight)
	{
		popOverMask.height = window.parent.document.body.scrollHeight + "px";
		
	}
	window.parent.viewport.getWinHeight();
	window.parent.viewport.getScrollY();

    popOver.top = window.parent.viewport.scrollY + 30+ "px";
	popOverMask.display = "block";
	popOver.display = "block";
	
	window.parent.centerPopover("popOverWindow");
	

	oContentFrame.src = url;
	
	var str = "";
	
	
	
	//var aHist = top.frames["popOverWindow_IFRAME"].history;
	//top.frames["popOverWindow_IFRAME"].onbeforeunload = testit;
	
	
	//showPagedObjectProperties(top.frames["popOverWindow_IFRAME"]);
	//alert(aHist.current);
	//clearHistory("popOverWindow_IFRAME");
	//addHistoryItem("popOverWindow_IFRAME",url);
//
}
function initPopOver()
{
	try
	{
		if(window.parent.g_bIsPopOverInit == true)
		{
			
			window.parent.g_sPopOverStartURL =  String(window.location);
			window.parent.g_bIsPopOverInit = false;
		}
	}
	catch(ex)
	{
	}


	try
	{
		document.onkeyup = popOverKeyUp;
		document.onkeydown = popOverKeyDown; 
	}
	catch(e)
	{
	}
	window.onkeyup = popOverKeyUp;
	window.onkeydown = popOverKeyDown; 
	//alert(window.parent.g_sPopOverStartURL +" == "+ top.frames["popOverWindow_IFRAME"].location);


}

AttachEvent(top.frames["popOverWindow_IFRAME"],"load",initPopOver,false);
//AttachEvent(top.frames["popOverWindow_IFRAME"],"beforeunload",testit2,false);

function popOverGoBack()
{

//alert(String(window.parent.g_sPopOverStartURL) +" == "+ top.frames["popOverWindow_IFRAME"].location);
	if(window.parent.g_sPopOverStartURL == top.frames["popOverWindow_IFRAME"].location)
	{
		hidePopOver();
	}
	else
	{
		top.frames["popOverWindow_IFRAME"].history.back();
	}
}
     


function popOverKeyUp(e)

{

   var KeyID = (window.event) ? event.keyCode : e.keyCode;

   switch(KeyID)

   {

      case 8:


		window.event.keyCode = 505;		//An arbitrary code to prevent event bubbling
		event.returnValue=false;
		event.cancelBubble = true;					
	
      	window.parent.popOverGoBack();
		return false;
      break; 

   }

}

function popOverKeyDown(e)

{

   var KeyID = (window.event) ? event.keyCode : e.keyCode;
//alert("KeyCheck" + KeyID);
   switch(KeyID)

   {

      case 8:


		window.event.keyCode = 505;		//An arbitrary code to prevent event bubbling
		event.returnValue=false;
		event.cancelBubble = true;					
		return false;
      break; 

   }

}


/**
 *For now we will assume that this function is only ever invoked from within the IFRAME content
 * itself.  
 *
 **/
function hidePopOver()
{
	try
	{

		var popOver = window.parent.getStyleObject("popOverWindow");
		var popOverMask = window.parent.getStyleObject("popOverWindowMask");
		var oContentFrame = window.parent.getObject("popOverWindow_IFRAME");
		
		oContentFrame.src = window.parent.getPopOverLoadingPage();
		popOverMask.display = "none";
		popOver.display = "none";
	}
	catch (e)
	{
		logException(e);
	}
}


function getPopOverLoadingPage()
{
	return  "javascript:'Loading...'";
}

/*************************************************************************

  dw_viewport.js
  version date Nov 2003
  
  This code is from Dynamic Web Coding 
  at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.

*************************************************************************/  
  
var viewport = {
  getWinWidth: function () {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
  	else if (document.documentElement && document.documentElement.clientHeight) 
  		this.height = document.documentElement.clientHeight;
  	else if (document.body && document.body.clientHeight) 
  		this.height = document.body.clientHeight;
  },
  
  getScrollX: function () {
    this.scrollX = 0;
  	if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		this.scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		this.scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) this.scrollX = window.scrollX;
  },
  
  getScrollY: function () {
    this.scrollY = 0;    
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
  		this.scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		this.scrollY = document.body.scrollTop; 
  	else if (window.scrollY) this.scrollY = window.scrollY;
  },
  
  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }
  
}

/****************** END VIEWPORT CODE *******************/

// PRINT IFRAME CONTENTS
function CheckIsIE() 
{ 
	if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER')
	{
		return true;
	} 
	else
	{
		return false;
	} 
} 

function PrintThisPage() 
{ 
	
	if (CheckIsIE() == true) 
	{ 
		document.popOverWindow_IFRAME.focus(); 
		document.popOverWindow_IFRAME.print(); 
	} 
	else 
	{ 
		window.frames['popOverWindow_IFRAME'].focus(); 
		window.frames['popOverWindow_IFRAME'].print(); 
	} 
} 

	 


// Function to create page elements within a specified container element
function insertElement(oContainer,elementType, oAttributes)
{
    var newElement = document.createElement(elementType);
    
    for(att in oAttributes)
    {
        newElement.setAttribute(att,oAttributes[att]);
         //
        if(att == "style")
        {
			var aStyles = String(oAttributes[att]).split(";");
			var oStyle = newElement.getAttribute("style");
			for(i = 0; i < aStyles.length; i++)
			{
			
				var aParts = String(aStyles[i]).split(':');
				try
				{
					newElement.style.setAttribute(aParts[0],aParts[1],0);
					newElement.style[aParts[0]] = aParts[1];
				//	alert(aParts[0] + "  " + aParts[1]);
				} catch(e) {
				//	alert("ERROR " + aParts[0]);
				}
				
				//newElement.style.textOverflow = "hidden";
				//newElement.style.overflowX = "hidden";

			}
		//	showPagedObjectProperties(newElement.style)
			//alert(att + " = " + newElement.getAttribute(att).width);
        }
    }
    oContainer.appendChild(newElement);
   
    return newElement;
}


/**
 * Toggle the Details / Compare states
 **/
function toggleCompare()
{
	var sDisplay = getStyleByClass("DIV", "prodCompareButtons", "display");

	if(sDisplay == "none" || sDisplay == null)
	{
		setStyleByClass("DIV", "prodCompareButtons", "display", "block");
		setStyleByClass("DIV", "prodDetailsButtons", "display", "none");
	}
	else
	{
		setStyleByClass("DIV", "prodCompareButtons", "display", "none");
		setStyleByClass("DIV", "prodDetailsButtons", "display", "block");
	}
}


function toggleCompareItem(sProdGuid)
{
	var bDoNotAdd = false;
	
	for(i = 0; i < g_aCompareItems.length; i++)
	{
		if(g_aCompareItems[i] == sProdGuid)
		{
			g_aCompareItems.splice(i,1);
			bDoNotAdd = true;
		}
	}
	
	if(!bDoNotAdd)
	{
		g_aCompareItems.push(sProdGuid);
	}
	
	var str = "";

	
	if(g_aCompareItems.length > 0)
	{
		str = "?";
	}
	
	for(i = 0; i < g_aCompareItems.length; i++)
	{

		str += "p" + (i+1) + "=" + g_aCompareItems[i] + "\n" ;
		if(i < g_aCompareItems.length -1)
		{
			str += "&";
		} 

	}
	g_sProjectorCompareQuery = str + "&" + POP_OVER_DEVICE_STRING;

}


function getCompareURL()
{
	return g_sBaseProjectorCompareURL + g_sProjectorCompareQuery;
}

function compareNow()
{
	if(g_aCompareItems.length > 1 && g_aCompareItems.length < 4)
	{
		showPopOver(getCompareURL());
	}
	else
	{
		alert("You must select 2 or 3 projectors to perform a comparison");
	}
	
}

function showPagedObjectProperties(obj)
{
	var str = "";
	var i = 0;
	for(o in obj)
	{
		str += o + " = " + obj[o] + "\n ** ";
		i++;
		
		if(i % 20 == 0)
		{
			alert(str);
			str = "";
		}
	}
	
	alert(str);
}


function Fade(objID,CurrentAlpha,TargetAlpha,steps){

	var obj = document.getElementById(objID);

	CurrentAlpha = parseInt(CurrentAlpha);
	if (isNaN(CurrentAlpha)){
	   CurrentAlpha = parseInt(obj.style.opacity*100);
	   if (isNaN(CurrentAlpha))CurrentAlpha=100;
	}

	var DeltaAlpha=parseInt((CurrentAlpha-TargetAlpha)/steps);
	var NewAlpha = CurrentAlpha - DeltaAlpha;

	obj.style.opacity = (NewAlpha / 100);
	obj.style.MozOpacity = obj.style.opacity;
	obj.style.filter = 'alpha(opacity='+NewAlpha+')';

	if (steps>1){
	   setTimeout('Fade("'+objID+'",'+NewAlpha+','+TargetAlpha+','+(steps-1)+')', 1);
	}
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 101);
    object.MozOpacity = (opacity / 101);
    object.KhtmlOpacity = (opacity / 101);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

//Dummmy function for non-linking anchors used in tabs
function clickTab()
{
}

function	(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}






function flash_banner(src, oFlashVars, color, width, height, noflash) { 
	var EC;
//FlashVars are passed as an object in {key:value} form,	
//and turned into a query string like "key=value", with url-encoding applied to values.
	var sFlashVars='';
	if(String(noflash).length <= 0)
	{
		
		noflash = '<A class="linkGreen" HREF="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" TARGET="_blank"><IMG SRC="/i/eng/imagesize/noflash.gif" WIDTH="648" HEIGHT="462" BORDER="0" ALT="Flash version ' +  flash_version + ' required"></A>>';

	}
	for (key in oFlashVars) {
        sFlashVars += key + '=' + escape(oFlashVars[key]) +'&'
    }

	if (SWF && String(src).length > 0) { 
		EC='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flash_version
		+',0,0,0" ID=themovie WIDTH='+width+' HEIGHT='+height+'><PARAM NAME=movie VALUE="'+src+
		'"><PARAM NAME="FlashVars" VALUE="' + sFlashVars + 
		
		'"><PARAM NAME=loop VALUE="false">' + 
		'<PARAM name="wmode" value="transparent"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE='+color+
		'><EMBED NAME="themovie" SRC="'+src+'" wmode="transparent" quality=high bgcolor='+color+'  WIDTH='+width+' FlashVars="' + sFlashVars
		+ '" HEIGHT='+height+' TYPE="application/x-shockwave-flash" swLiveConnect="true" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>'; 
	} else { 
		EC=noflash; 
	} 
	document.write(EC); 
}



/**
 * Invokes the provided javascript when all of the elements are not null
 *
 *
 **/
 
 var invokeIfNotNullInterval = -1;
 var temp = "";
function invokeIfNotNull(sFunction, sElements)
{
	var bAreNull = false;
	var aElements = new Array();
	var i = 0;
	
	
	aElements = String(sElements).split(",");
	
	if(!aElements || aElements.length <= 0)
	{
		temp += "NO ELEMENTS";
		return;
	}
	for(i = 0; i < aElements.length; i++)
	{
		var oElem = getObject(aElements[i]);
		if(!oElem || oElem == null || (oElem && oElem.offsetLeft < 0))
		{
			temp += "\n" + aElements[i];
			bAreNull = true;

		}
		try
		{
			temp += "  " + oElem.offsetLeft;
		}
		catch(e)
		{
			
		}
	}
	
	
	if(bAreNull == true)
	{
		//alert("ARENBUKK");
		temp += "invokeIfNotNull(\"" + sFunction + "\",\"" + sElements + "\")";
		//clearInterval(invokeIfNotNullInterval);
		invokeIfNotNullInterval = setTimeout("invokeIfNotNull(\"" + sFunction + "\",\"" + sElements + "\")",1000);
	}
	else
	{
	//alert(temp);
		eval(sFunction);
	}
	

}



function centerPopover(sLayerID) 
{
	var y1=50;
	if (!document.all)
	{
		getStyleObject(sLayerID).top = window.pageYOffset + (window.innerHeight - (window.innerHeight-y1))
	}
	if (document.layers) {
		document.layers[sLayerID].top = window.pageYOffset + (window.innerHeight - (window.innerHeight-y1))
	}
	if (document.all) {
		document.all[sLayerID].style.top = document.body.scrollTop + (document.body.clientHeight - (document.body.clientHeight-y1));
	}
	if(getStyleObject(sLayerID).display != "none" && getStyleObject(sLayerID).visibility != "hidden")
	{
		window.setTimeout("centerPopover('" + sLayerID + "')", 300); 
	}
}


// -->


