/***********************************************************************
* getCartItem		-	Gets the Actinic Cart Value & No of Items
*
* Input: nIndex	-	Cart item index to retrieve
*							1 = TOTAL_VALUE
*							3 = CART_COUNT
*
* Returns:				Requested cart item or 0 (zero) if not found
*
************************************************************************/

function getCartItem(nIndex) {
	var act_cart= getCookie("CART_CONTENT")
	var sTemp =(act_cart != null) ? sTemp=act_cart.split("\t"):0;
	if(nIndex==1)
		return (sTemp.length > 0) ? sTemp[nIndex] : "$0.00";

	return (sTemp.length > 0) ? sTemp[nIndex] : 0;
}
	
/***********************************************************************
*
* win	- calls up the WUP window
*
* Input: 				nothing
*
* Returns:				nothing
*
************************************************************************/

function win()
	{
	var sMsg = window.open("paycash1.htm","","height = 507, width = 400, left = 378, top = 40");
	}

/***********************************************************************
*
* GotoAnchor - JS for jumping to an anchor - some user agents don't handle
*					anchors correctly if BASE HREF is present
*
* Input: 				sAnchor
*
* Returns:				nothing
*
************************************************************************/

function GotoAnchor(sAnchor) {
	window.location.hash = sAnchor;
}

function NavigationList(pItem, HomeLink) {
	var strIDs = '<table width="150" border="0" cellspacing="5" cellpadding="0">';
	strIDs += '<tr><td align="left" class="leftnav"><img src="pixel.gif" width="1" height="1"></td></tr>';
	if(pItem != null) {
		for (var i = 1; i <= pItem.length; i++) { 
			strIDs += '<tr><td align="left" class="leftnav">&nbsp;<img src="'+ HomeLink +'/acatalog/bullet_wheels.gif" width="12" height="13" align="absmiddle">';
			strIDs += '&nbsp;<a href="' + pItem[i].sURL + '">'+ pItem[i].sName + '</a></td></tr>';
		}
	} else {
		strIDs += '<tr><td class="leftnav">no categories</td></tr>';
	}
	strIDs += '</table>';
	return strIDs
}


function GetTopNavDropDown(ar)
{
	var strIDs = '<select name="Category" class="FormSelect" id="Category">';
	var sel = " SELECTED";
	strIDs += '<OPTION ' + sel + ' VALUE="">Entire Store &nbsp;&nbsp;</OPTION>';
	for (var i=1;i<=ar.length;i++) {
		if (ar[i].sURL !=null) {
			strIDs += '<OPTION VALUE="' + ar[i].sURL + '&ACTINIC_REFERRER=' + escape(location.href) + '&NOCLEARFRAMES=1">' + ar[i].sName + '</OPTION>';
		}
	}
	strIDs+='</select>';
	return strIDs;
}

function GetTopNav(Section, HomeLink) {
	var returnString= '';

	returnString='<table width="200" border="0" cellspacing="3" cellpadding="0">';
	returnString+='  <tr>';
	returnString+='    <td colspan="2" class="leftnav"><strong>[GEAR]</strong></td>';
	returnString+='  </tr>';
	returnString+='  <tr><td colspan="2"><img src="pixel.gif" width="5" height="5"></td></tr>';

	if(Section != null) {
		for (var i = 1; i <= Section.length; i++) { 
			returnString+='  <tr>';
			returnString+='    <td width="15" align="right" valign="bottom" class="Fixed"><a href="'+Section[i].sURL+'"><img src="'+HomeLink+'/acatalog/bullet_grid.gif" width="7" height="10" border="0"></a></td>';
			returnString+='    <td width="176" class="leftnav"><a href="'+Section[i].sURL+'">'+Section[i].sName+'</a></td>';
			returnString+='  </tr>';
		}
	}

	returnString+='  <tr><td colspan="2"><img src="pixel.gif" width="2" height="20"></td></tr>';
	returnString+='</table>';

	return returnString;
}

function GetSection(pSectionArray, pSectionId) {
	if(!pSectionArray)
		return null;

	var i=1;
	var returnArray=null;
	while(i <= pSectionArray.length) {
		if(pSectionArray[i].nSectionId==pSectionId)
			return pSectionArray[i];

		returnArray=GetSection(pSectionArray[i].pChild, pSectionId);
		if(returnArray!=null)
			return returnArray;
		i++;
  }
	return null;
}

function GetParentSection(pSectionArray, pSectionId) {
	if(!pSectionArray)
		return false;

	var i=1;
	var returnArray=false;
	while(i <= pSectionArray.length) {
		if(pSectionArray[i].nSectionId==pSectionId)
			return true;
		returnArray=GetParentSection(pSectionArray[i].pChild, pSectionId);
		if(returnArray==true)
			return pSectionArray[i];
		else if(returnArray!=false) 
			return returnArray;
		i++;
  }
	return false;
}

function GetSubNav(pSectionArray, HomeLink) {
	var returnString='';
	if(typeof(document.forms[1].SID) != 'object')
		return returnString;
		
	var SectionId = document.forms[1].SID.value;
	if(SectionId==null) 
		return returnString;

	var Section = GetSection(pSectionArray, SectionId);
	if(Section == null)
		return returnString;

	returnString='<table width="150" border="0" cellspacing="2" cellpadding="0">';
	returnString+='  <tr>';
	returnString+='    <td colspan="3" class="leftnav">&nbsp;</td>';
	returnString+='  </tr>';
	returnString+='  <tr>';
	returnString+='    <td width="5"><img src="'+HomeLink+'/acatalog/pixel.gif" width="1" height="1"></td>';
	returnString+='    <td colspan="2" class="leftnav"><strong>'+Section.sName+'</strong></td>';
	returnString+='  </tr>';

	if(Section.pChild && Section.pChild.length > 0) {
		for(var i=1; i<=Section.pChild.length; i++) {
			returnString+='  <tr>';
			returnString+='    <td width="5"><img src="'+HomeLink+'/acatalog/pixel.gif" width="1" height="1"></td>';
			returnString+='    <td width="5" align="left" valign="top"><a href="'+Section.pChild[i].sURL+'"><img src="'+HomeLink+'/acatalog/bullet_grid.gif" width="3" height="10" border="0"></a></td>';
			returnString+='    <td width="140" align="left" valign="middle" class="leftnav"><a href="'+Section.pChild[i].sURL+'">'+Section.pChild[i].sName+'</a>&nbsp;</td>';
			returnString+='  </tr>';
		}
	}
	returnString+='  <tr>';
	returnString+='    <td colspan="3" class="leftnav">&nbsp;</td>';
	returnString+='  </tr>';

	var ParentSection = GetParentSection(pSectionArray, SectionId);
	if((ParentSection != false) && (ParentSection != true)) {
		if(ParentSection.pChild) {
			var j=1;
			while(j<=ParentSection.pChild.length) {
				if(ParentSection.pChild[j].nSectionId!=SectionId) {
					returnString+='  <tr>';
					returnString+='    <td width="5" align="right" valign="top" class="leftnav"><img src="'+HomeLink+'/acatalog/pixel.gif" width="1" height="1"></td>';
					returnString+='    <td colspan="2" class="leftnav"><strong><a href="'+ParentSection.pChild[j].sURL+'">'+ParentSection.pChild[j].sName+'</a></strong></td>';
					returnString+='  </tr>';
				}
				j++;
			}
		}
		returnString+='  <tr>';
		returnString+='    <td colspan="3" class="leftnav">&nbsp;</td>';
		returnString+='  </tr>';
		returnString+='  <tr>';
		returnString+='    <td width="5" align="right" valign="top" class="leftnav"><img src="'+HomeLink+'/acatalog/pixel.gif" width="1" height="1"></td>';
		returnString+='    <td colspan="2" class="leftnav"><a href="'+ParentSection.sURL+'">up level</a></td>';
		returnString+='  </tr>';
	} else {
		returnString+='  <tr>';
		returnString+='    <td width="5" align="right" valign="top" class="leftnav"><img src="'+HomeLink+'/acatalog/pixel.gif" width="1" height="1"></td>';
		returnString+='    <td colspan="2" class="leftnav"><a href="'+HomeLink+'">up level</a></td>';
		returnString+='  </tr>';

	}
	returnString+='  <tr>';
	returnString+='    <td colspan="3" class="leftnav">&nbsp;</td>';
	returnString+='  </tr>';
	returnString+='</table>';

	return returnString;
}

function GetLeftNav(pSectionArray, HomeLink) {
	var returnString = '';
	if(pSectionArray != null) {
		for (var i = 1; i <= pSectionArray.length; i++) { 
			returnString+='<a href="'+pSectionArray[i].sURL+'">'+pSectionArray[i].sName+'</a><br>';
		}
	}

	return returnString;
	/*
	if(typeof(document.forms[1]) != 'object')
		return GetTopNav(pSectionArray, HomeLink);
		
	if(typeof(document.forms[1].SID) != 'object') {
		return GetTopNav(pSectionArray, HomeLink);
	}	else {
		return GetSubNav(pSectionArray, HomeLink);
	}
	*/
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function launchCenter(url, name, width, height, scrollbar) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;

  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    var xc = (aw - width);
    var yc = (ah - height);
    var xc = (aw - width)/2;
    var yc = (ah - height)/2;
 
    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
    str += ",hotkeys=0,menubar=0,resizable=0,scrollbars=" + scrollbar + ",status=0";
 }
  return window.open(url, name, str);
}

function FixImageURI(Features) {
	var ReturnString = '';
	var Position = Features.indexOf("<IMG SRC=");
	while(Position >=0) {
		ReturnString += Features.substring(0,Position+10);
		ReturnString += ImageLink;
		Features = Features.substring(Position+10, Features.length);
		Position = Features.indexOf("<IMG SRC=");
	}
	ReturnString += Features;

	Features = ReturnString;
	ReturnString = '';
	
	Position = Features.indexOf("<img src=");
	while(Position >=0) {
		ReturnString += Features.substring(0,Position+10);
		ReturnString += ImageLink;
		Features = Features.substring(Position+10, Features.length);
		Position = Features.indexOf("<img src=");
	}
	ReturnString += Features;	
	
	return ReturnString;
}