window.onload=function(){
	if(MagnaCartShopCat)
	{	var liObj = GetObject(MagnaCartShopCat);
		if(liObj){liObj.className='BtnOn';}
	}
}
function AlterClass(thisAction,thisObj,thisNewClass,thisOldClass)
{	
  switch (thisAction){
    case 'swap':
     thisObj.className = !AlterClass('check',thisObj,thisNewClass) ? thisObj.className.replace(thisOldClass,thisNewClass) : thisObj.className.replace(thisNewClass,thisOldClass);
    break;
    case 'add':
      if(!AlterClass('check',thisObj,thisNewClass)){thisObj.className+=thisObj.className?' '+thisNewClass:thisNewClass;}
    break;
    case 'remove':
      var rep=thisObj.className.match(' '+thisNewClass)?' '+thisNewClass:thisNewClass;
     thisObj.className=thisObj.className.replace(rep,'');
    break;
    case 'check':
      return new RegExp('\\b'+thisNewClass+'\\b').test(thisObj.className)
    break;
  }
}


//	Convert object name string or object reference into a valid object reference
function GetObject(ThisRef)
{
	if (typeof ThisRef != "string")
	{	return ThisRef	}
	if(document.getElementById)
	{	if(document.getElementById(ThisRef)){return document.getElementById(ThisRef)}}
	else if(document.all)
	{	if(document.all[ThisRef]){return document.all[ThisRef]}}
	else if(document.ids)
	{	if(document.ids[ThisRef]){return document.ids[ThisRef]}}
	else if(document.layers)
	{	if(document.layers[ThisRef]){return document.layers[ThisRef]}}
	
	return false;
}

function ChangeButton(ThisName,ThisColor,IndexNum)
{	ThisObject = GetObject(ThisName);
	if(ThisObject){ThisObject.style.backgroundColor = ThisColor}
}

function ChangeBackground(ThisName,ThisColor,IndexNum)
{	
	ThisObject = GetObject(ThisName);
	if(ThisObject){ThisObject.style.backgroundColor = ThisColor}
}

function ChangeClass(ThisName,ThisClass)
{	
	ThisObject = GetObject(ThisName);
	if(ThisObject){ThisObject.className = ThisClass}
}

function OpenWindow(WindowHREF,Width,Height,Name,ScreenX,ScreenY,LocationBar,ToolBar)
	{	if (Name == null || Name == ""){Name="DataWindow"} 
		if (WindowHREF == null || WindowHREF == ""){WindowHREF='""'} 
		if (Width != null && Width != "")
		{	Width=",Width="+(Width+50)}
		if (Height != null || Height != "")
		{	Height=",Height="+(Height+100)}
		if (ScreenX == null || ScreenX == ""){ScreenX = ""} else{ScreenX=",ScreenX="+ScreenX+",left="+ScreenX}
		if (ScreenY == null || ScreenY == ""){ScreenY = ""} else{ScreenY=",ScreenY="+ScreenY+",top="+ScreenY}
		if (LocationBar == null || LocationBar == ""){LocationBar = ""} else{LocationBar=",Location=yes"}
		if (ToolBar == null || ToolBar == ""){ToolBar = ""} else{ToolBar=",ToolBar=yes"}
		
		Options = Width+Height+ScreenX+ScreenY+LocationBar+ToolBar;
		Options += ',menubar,status,scrollbars,resizable,titlebar';
		DataWindow = window.open("",Name,Options);
		if (DataWindow.opener == null){DataWindow.opener = self};
		DataWindow.location = WindowHREF;
		DataWindow.focus();
	};
	
// GLOBAL FUNCTION TO VIEW LARGE FORMAT PRODUCT IMAGE
function MakeImageWindow(ImageLink,ImageName,ImageWidth,ImageHeight)
	{	ImageWidth = ImageWidth * 1 + 20;
		ImageHeight = ImageHeight * 1 + 20;
		WindowSpecs = "resizable,ScreenX=50,Screeny=50,left=50,top=50,width=" + ImageWidth + ",height=" + ImageHeight;
		if(window.ImageWindow){window.ImageWindow.close()};
		ImageWindow = window.open("","ImageWindow",WindowSpecs);
		if (ImageWindow.opener == null){ImageWindow.opener = self};
		NewContent = '<html><head><title>' + ImageName + '</title></head>';
		NewContent += '<BODY bgcolor="#ffffff" >';
		NewContent += '<center><IMG src="' + ImageLink + '" >';
		NewContent += '</body></html>';
		ImageWindow.document.open();
		ImageWindow.document.write(NewContent);
		ImageWindow.document.close();
		ImageWindow.focus();
	};
	

// This function goes through the options for the given
// drop down box and removes them in preparation for
// a new set of values
function emptyList( box ) {
	// Set each option to null thus removing it
	while ( box.options.length ) box.options[0] = null;
}

// This function assigns new drop down options to the given
// drop down box from the list of lists specified
function fillList( box, arr ) {
	// arr[0] holds the display text
	// arr[1] are the values
	for ( i = 0; i < arr[0].length; i++ )
	{	// Create a new drop down option with the
		// display text and value from arr
		option = new Option( arr[0][i], arr[1][i] );
		box.options[box.length] = option;	// Add to the end of the existing options
	}
	box.selectedIndex=0;	// Preselect option 0
}

// This function performs a drop down list option change by first
// emptying the existing option list and then assigning a new set
function changeList( box )
{	// Isolate the appropriate list by using the value of the currently selected option
	list = SearchParams[box.options[box.selectedIndex].value];
	emptyList( box.form.SearchField );	// Next empty the slave list
	fillList( box.form.SearchField, list );	// Then assign the new list values
}
function HideDivs(DivList)
{	var DivId = DivList;
	DivAry=DivList.split(",");
	for ( i = 0; i < DivAry.length; i++ )
	{	DivId = DivAry[i];
		if(document.all && document.all.style)
		{	if(document.all[DivId]){document.all[DivId].style.visibility = "hidden"}}
		else if(document.getElementById)
		{	if(document.getElementById(DivId)){document.getElementById(DivId).style.visibility = "hidden"}}
		else if(document.ids)
		{	if(document.ids[DivId]){document.ids[DivId].display = "none"}}
		else if(document.layers)
		{	if(document.layers[DivId]){document.layers[DivId].visibility = "hidden"}}
	}
}

function ShowDivs(DivList)
{	var DivAry = new Array();
	DivAry=DivList.split(",");
	for ( i = 0; i < DivAry.length; i++ )
	{	DivId = DivAry[i];
		if(document.all && document.all.style)
		{	if(document.all[DivId]){document.all[DivId].style.visibility = "visible"}}
		else if(document.getElementById)
		{	if(document.getElementById(DivId)){document.getElementById(DivId).style.visibility = "visible"}}
		else if(document.ids)
		{	if(document.ids[DivId]){document.ids[DivId].display = "inline"}}
		else if(document.layers)
		{	if(document.layers[DivId]){document.layers[DivId].visibility = "display"}}
	}
}

function HideLayer(LayerName)
{	
	if (document.layers)
	{	document.LayerName.visibility = 'hidden'	}
	else
	{	document.all.LayerName.style.visibility = 'hidden'   }
}

function TextAreaTab()
{	if(window.event)
	{	var e = window.event; 
		if (e.keyCode == 9)
		{	e.srcElement.value = e.srcElement.value + "\t"; 
			e.srcElement.focus() 
			return false; 
		} 
		return true; 
	}
	return false;
}

function TrackCount(fieldObj,maxChars,fieldID)
{ // use: onKeyUp="TrackCount(this, 100,'countdown')" You have <span id="countdown" style="font-weight: bold">100</span> remaining characters
  var diff = maxChars - fieldObj.value.length;

  // Need to check & enforce limit here also in case user pastes data
  if (diff < 0)
  {
    fieldObj.value = fieldObj.value.substring(0,maxChars);
    diff = maxChars - fieldObj.value.length;
  }

  if( fieldID != null )
  {
    var element = document.getElementById(fieldID)
    if( element != null )
    {
        element.innerHTML=diff;
    }
  }

}

function setCookie(name, value, expires, path, domain, secure) {
/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function fixDate(date) {
// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function InfoBubble(targetId,PosTop,PosLeft,PosRight,PosBottom,reloadSeconds) {
targetDivObj = GetObject(targetId);
//targetDivObj.style.position = 'absolute';
if(typeof(PosRight) != 'undefined' && PosRight != ''){targetDivObj.style.right = PosRight+"px";}
if(typeof(PosBottom) != 'undefined' && PosBottom != ''){targetDivObj.style.bottom = PosBottom+"px";}
if(typeof(PosLeft) != 'undefined' && PosLeft != ''){targetDivObj.style.left = PosLeft+"px";}
if(typeof(PosTop) != 'undefined' && PosTop != ''){targetDivObj.style.top = PosTop+"px";}
targetDivObj.style.display == "block" ? targetDivObj.style.display = "none" : targetDivObj.style.display = "block";
if(reloadSeconds){var xtemp = setTimeout(function(){InfoBubble(targetId,PosTop,PosLeft,PosRight,PosBottom)},reloadSeconds);}
}

function CheckSearchForm(thisForm)
{	if(thisForm.Keywords.value=='' || thisForm.Keywords.value=='Enter Search Here')
	{	InfoBubble('GlobalSearchAlert',0,0,'','',5000);
		return false;
	}
		return true;
}

function BuildList(thisArray,thisTitle,thisEnvelope)
{	if(thisArray)
	{	var x;
		var listData = '';
		if(!thisEnvelope || thisEnvelope == "open"){listData = "<ul>";}
		if(thisTitle){ listData = listData + '<li>'+thisTitle+'</li>';}
		for(x in thisArray)
		{	var Values = thisArray[x].split("===");
			var thisId = Values[2] ? ' id="'+Values[2]+'"' : '';
			var thisScript = MagnaCartScript;
			if(Values[3]){thisScript = thisScript.replace("http://", "https://")} //secure
			if(Values[1].indexOf('http://') >= 0){	thisScript = Values[1];}
			else{	thisScript = thisScript+Values[1];}
			listData = listData + '<li'+thisId+'><a href="'+thisScript+'">'+Values[0]+'</a></li>';
		}
		if(!thisEnvelope || thisEnvelope == "close"){listData = listData + "</ul>";}
		return listData;
	}
	return '';
}

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
// Globals

// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 115;
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

