/***********************************************************************
* 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;
	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="170" 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="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="170" border="0" cellspacing="2" cellpadding="1">';
	returnString+='  <tr>';
	returnString+='    <td colspan="3" class="leftnav">&nbsp;</td>';
	returnString+='  </tr>';
	returnString+='  <tr>';
	returnString+='    <td width="5"><img src="pixel.gif" width="1" height="1"></td>';
	//START 'Home' link modification [author: Peblaco - http://www.peblaco.co.uk/ | revision: 1 | date: 16/02/2007]
	//This code does not need to be modified, to change the appearance, apply styles to the class selector 'home' in actinic.css
	returnString+='    <td colspan="2" class="leftnav"><a href="'+HomeLink+'" class="leftnav">Home</a></td>';
	returnString+='  </tr>';

if(Section != null) {
		for (var i = 1; i <= Section.length; i++) { 
			//START 'New Additions' link modification [author: Chris Willmott for Peblaco - http://www.peblaco.co.uk/ | revision: 4 | date: 17/02/2007]
			//This code does not need to be modified, to change the appearance, apply styles to the class selector 'new_additions' in actinic.css
			if(Section[i].sName=='New Additions'){
				returnString+='  <tr>';
				returnString+='    <td width="5"><img src="pixel.gif" width="1" height="1"></td>';
				returnString+='    <td colspan="2" width="165" align="left" valign="middle" class="leftnav"><a class="leftnav" href="'+Section[i].sURL+'">'+Section[i].sName+'</a>&nbsp;</td>';
				returnString+='  </tr>';
			} else {
				returnString+='  <tr>';
				returnString+='    <td width="5"><img src="pixel.gif" width="1" height="1"></td>';
				returnString+='    <td width="5" align="left" valign="top"><a href="'+Section[i].sURL+'"><img src="bullet_arrow.gif" width="3" height="10" border="0"></a></td>';
				returnString+='    <td width="160" align="left" valign="middle" class="leftnav"><a href="'+Section[i].sURL+'">'+Section[i].sName+'</a>&nbsp;</td>';
				returnString+='  </tr>';
			}
			//END 'new additions' modification
		}
	}

	returnString+='  <tr>';
	returnString+='    <td colspan="3" class="leftnav">&nbsp;</td>';
	returnString+='  </tr>';
	returnString+='  <tr>';
	returnString+='    <td colspan="3" class="leftnav">&nbsp;</td>';
	returnString+='  </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="170" 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="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="pixel.gif" width="1" height="1"></td>';
			returnString+='    <td width="5" align="left" valign="top"><a href="'+Section.pChild[i].sURL+'"><img src="bullet_arrow.gif" width="3" height="10" border="0"></a></td>';
			returnString+='    <td width="160" 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="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="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="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) {
	return GetTopNav(pSectionArray, HomeLink);
	/*
	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 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;
	return ReturnString;
}