//fixes background flicker in ie
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


// JavaScript Document
// Example:

// alert( readCookie("myCookie") );

//need to rename this function it was brought in and used by WICS
function adjustIFrameSize (iframeWindow) {
  if (iframeWindow.document.height) {
    var iframeElement = document.getElementById(iframeWindow.name);
    iframeElement.style.height = iframeWindow.document.height + 5 + 'px';
   // iframeElement.style.width = iframeWindow.document.width + 5 +  'px';
  }else if (document.all) {
    var iframeElement = document.all[iframeWindow.name];
    if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') 
    {
      iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 5 + 'px';
      //iframeElement.style.width = iframeWindow.document.documentElement.scrollWidth + 5 + 'px';
    }
    else {
      iframeElement.style.height = iframeWindow.document.body.scrollHeight + 5 + 'px';
      //iframeElement.style.width = iframeWindow.document.body.scrollWidth + 5 + 'px';
    }
  }
}



function global_readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}
// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function global_writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

// Popup java browser window
function global_start(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=650,height=350");
}

// CODE TO USE IN HTML: <a href="javascript:Start('http://put_url_here.com')";>LINK NAME HERE</a>


// Popup Java Window Type 2 (used by item.php)
function global_openWindow(theURL,winName,features) {                                                                   
window.open(theURL,winName,features);                                                                                           
}

// CODE TO USE IN HTML: <a href="javascript:MM_openBrWindow('large_item.php?selected_item=<?= $product_info["product_id"] ?>','large_item','width=600,height=500')">



/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

//alert("this is testing the new flash catcher issue with the new adobe update on flash.");

/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
 
/*if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;*/

/*
CODE TO USE FOR FLASH:
<img src="images/noFlash.jpg" border="0" />
	<script type="text/javascript">
		// <![CDATA[
		var so = new SWFObject("NAMEOFFLASHFILE.swf", "flashIntro", "483", "398", "8", "#ffffff");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.addParam("menu", "false");
		so.write("bodyflash");
		// ]]>
</script>
*/


/*
this is used to for the dropdown navigation
*/

function global_findCssRule(selText)
{
	for (var j=document.styleSheets.length-1;j>=0;j--)
	{
		var ss = document.styleSheets[j];
		var cache = ss.cssRulesCache = ss.cssRulesCache || {};
	
		//screw case sensitivity; IE and Mozilla don't agree on case for elements themselves
		selText=selText.toLowerCase();
	
		if (cache[selText]) return cache[selText];
		var rules = ss.cssRules || ss.rules;
		for (var i=0,len=rules.length;i<len;i++)
		{
			var rule=rules[i], ruleSelText = rule.selectorText;
			
			// Clean up Safari's weirdness
			ruleSelText = ruleSelText.replace(/\.(\w+)\[CLASS~="\1"\]/g,'.$1').replace(/\[ID"([^"]+)"\]/g,'#$1');
			
			// Clean up IEMac's weirdness
			ruleSelText = ruleSelText.replace(/\*([.#])/g,'$1');
	
			//screw case sensitivity; IE and Mozilla don't agree on case for elements themselves
			ruleSelText = ruleSelText.toLowerCase();
	
			if (ruleSelText==selText) return (cache[selText]=rules[i]);
		}
	}
	return null;
}

function global_SfHover(objNav) {
	var strNav = ( typeof( objNav ) == "undefined" ) ? "nav" : objNav;
	if(document.getElementById(strNav)){
		var sfEls = document.getElementById(strNav).getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}

//this needs to reside in the drop menus
if (window.attachEvent) window.attachEvent("onload", function(){global_SfHover()});

function global_changepage(obj) {
	var pagelist = document.getElementById(obj);
	window.location.href = pagelist.options[pagelist.selectedIndex].value;
}

var global_BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
global_BrowserDetect.init();

var global_browser = new Object;
global_browser["browser"] = global_BrowserDetect.browser;
global_browser["version"] = global_BrowserDetect.version;
global_browser["OS"] = global_BrowserDetect.OS;

function global_submitSearchForm(type)
{
	var strKeyWord = document.getElementById("coreSearchInput").value;
	if(type == "furniture")
	{
		document.coreSearchForm.submit();
	}else if(type == "appliance")
	{
		document.location.href="appliances.php?url=/_CGI/SEARCH?pn="+strKeyWord.replace(/ /g,"+");
	}
}

// Example:
// global_preload( '01.gif', '02.gif' ); 

function global_preload()
{ 
  var args = global_preload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function global_target_blank() {
	if(!document.getElementsByTagName ) { return; }
	var anchors = document.getElementsByTagName( "a" );
	for( var loop = 0; loop < anchors.length; loop++ ) {
		var anchor = anchors[ loop ];
		if( anchor.getAttribute( "href" ) && anchor.getAttribute( "rel" ) == "external" ) {
			anchor.target = "_blank";
		}
	}
} 

function global_createRequest(){
	try {
		request = new XMLHttpRequest();
	} catch(trymicrosoft)	{
		try	{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}	catch (othermicrosoft) {
			try	{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}	catch (failed) {
				request = null;
			}
		}
	}
}


function global_XHConn(){
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone){
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET"){
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }else{
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete){
          bComplete = true;
          fnDone(xmlhttp);
        }
	  };
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

function global_objLoad(strPage, strQuery, objDisplay ){
	var myConn = new global_XHConn();
	var fnWhenDone = function (oXML){ 
		var checked = (oXML.responseText);
		if(objDisplay){
			var objectShow = document.getElementById(objDisplay);
			objectShow.innerHTML = checked;
		}
	};
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	check = myConn.connect(strPage, "POST", strQuery, fnWhenDone);
}

function global_loadElement(strPage, strQuery, strObjectId){
	global_objLoad(strPage,strQuery, strObjectId);
}

function global_addListener(element, type, expression, bubbling) {
	bubbling = bubbling || false;

	if(window.addEventListener) { // Standard
		element.addEventListener(type, expression, bubbling);
		return true;
	}
	else if(window.attachEvent) { // IE
		element.attachEvent('on' + type, expression);
		return true;
	} 
	else return false;
}

function global_get_element(el) {
	return document.getElementById(el);
}

function global_destroyElement(el){
/*	var objectShow = document.getElementById(strObj);
	objectShow.parentNode.removeChild( objectShow );*/
	global_destroyObject(global_get_element(el));
}

function global_destroyObject(obj) {
	obj.parentNode.removeChild(obj);
}


function global_createElement(strObj, strId) {//, objStyle){
	var newDiv = document.createElement(strObj);
	newDiv.id = strId;
	return newDiv;
}

function global_insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

function global_select_scroll_position( selectObj, index) {
	if (selectObj.length == 0 || index < 0) return false;
	
	var optionObj = selectObj.options[index];
	
	var scroll_height = selectObj.scrollHeight;
	var option_height = optionObj.offsetHeight;
	var select_height = selectObj.offsetHeight;
	var option_position = option_height * index;

	var scroll_position = 0; // first element
	
	if (select_height >= scroll_height) scroll_position = option_position + option_height;
	else { // there is a scrollbar
		scroll_position = ((option_position + (option_height/2))*2 - select_height + (option_height/2)) / 2;
	}
	selectObj.scrollTop = scroll_position;
	return true;
}

function global_select_move_up(selectObj) {
	var index = selectObj.selectedIndex;
	if (index > 0 && selectObj.length > 1) {
		var option = selectObj.options[index];
		var temp_option = selectObj.options[index - 1];
		var old_option = new Option(temp_option.text, temp_option.value);
		var cur_option = new Option(option.text, option.value);
		selectObj.options[index - 1] = cur_option;
		selectObj.options[index] = old_option;
		selectObj.options[index - 1].selected = true;
		return true;
	}
	return false;
}

function global_select_move_down(selectObj) {
	var index = selectObj.selectedIndex;
	if (index < selectObj.length - 1 && selectObj.length > 1) {
		var option = selectObj.options[index];
		var temp_option = selectObj.options[index + 1];
		var old_option = new Option(temp_option.text, temp_option.value);
		var cur_option = new Option(option.text, option.value);
		selectObj.options[index + 1] = cur_option;
		selectObj.options[index] = old_option;
		selectObj.options[index + 1].selected = true;
		return true;
	}
	return false;
}

function global_select_remove(selectObj) {
	var index = selectObj.selectedIndex;
	if (index != -1) {
		var child = selectObj.options[index];
		child.parentNode.removeChild(child);
		if (index < selectObj.length) index = index;
		else if (selectObj.length > 0) index = selectObj.length -1;
		if (index >= 0 && selectObj.length != 0) {
			selectObj.options[index].selected = true;
		}
		global_select_scroll_position(selectObj, index);
		return true;
	}
	return false;
}

function global_select_remove_all(selectObj) {
	while (selectObj.length > 0) {
		global_destroyObject(selectObj[0]);
	}
}

function global_add_css(css) {
	var strFile = css;
	if(document.createStyleSheet) {
		document.createStyleSheet(strFile);
	}
	else {
		var css = document.createElement('link'); 
		css.rel = 'stylesheet'; 
		css.href = strFile; 
		document.getElementsByTagName('head')[0].appendChild(css);
	}
}

function global_getXY(obj) {
	var x = document.body.offsetLeft;
	var y = document.body.offsetTop;
	while (obj != null && obj != document.body) {
		x += obj.offsetLeft;
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return new Array(x, y);
}

// IAB - 10/15/2009 - Used for Warranty Tabs - taddisplay.php

function disableAllTabs()
{
	var divs  = document.getElementsByTagName("div");
	var count = 0;

	for (j = 0; j < divs.length; j ++)
	{
		if (divs[j].className == "mainContainer")
		{
			count ++;
		}
	}

	for (i = 0; i < count; i ++)
	{
		document.getElementById("InfoHeader_" + i).className   = "largebutton";
		document.getElementById("InfoBody_" + i).style.display = "none";					
	}
}

function showTab(index)
{
	disableAllTabs();
	document.getElementById("InfoHeader_" + index).className   = "largebuttonx";
	document.getElementById("InfoBody_" + index).style.display = "block";		
}

// IAB - 10/15/2009 - Used for Warranty Tabs - taddisplay.php

// IAB - 01/26/2010 - Used for Showcase List

function submitform(myform)
{
	var target = document.getElementById(myform);
	target.submit();
}

// IAB - 01/26/2010 - Used for Showcase List

// IAB - 01/26/2010 - Used in class.display_pager_default.php
function zoomImageInMainImage(img, imageMain, imageMainEnLarge) {
	// Create and store the old image link
	newImage = new Image(); 
	newImage.src = document.getElementById('main_image').src;
	
	// Update with selected image
	document.getElementById('main_image').src = img.src;
	
	// Update the large image link with selected image link
	if(img.src == imageMain) {
		document.getElementById('itemDetails_detail_largeImageLink').href = imageMainEnLarge;
	}
	else {
		document.getElementById('itemDetails_detail_largeImageLink').href = img.src;
	}
	
	
	// Place the old image into the current image's place
	img.src = newImage.src;
}