/***********************************************************************
*
* 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
*
************************************************************************/

//CART_CONTENT = Cookie name
//1 = TOTAL_VALUE
//3 = CART_COUNT

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   - None
* Returns - None
************************************************************************/

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;
	}

/***********************************************************************
*
* ftnShowHide - JS for expanding and contracting a navigtation item
*				anchors correctly if BASE HREF is present
*
* Input: 				obj - the id of the object we wish to expand/contract
*
* Returns:				nothing
*
************************************************************************/
function ftnShowHide(obj) {
				if (document.getElementById(obj).style.display == "block") {
					document.getElementById(obj).style.display = "none";
				} else {
					document.getElementById(obj).style.display = "block";
				}
			}
			
			
function ftnBuildNavigation(ar) {
	
				intSID = "";	
	
				if(document.getElementById("SID")){
					intSID = document.getElementById("SID").value;
				};
				
								
				strIDs = "";
				
				for (var i=0; i < ar.length; i++) {
				
					if (ar[i+1].pChild) {
					
					//if the array section id matches the current section id, set display to "block", otherwise display is "none"
					this.displayStyle = 'none';
					this.strNavClass = "heading";
					this.strSubNavClass	=	"subHeading";
					this.intProductSectionId = ar[i+1].nSectionId;
					(this.intProductSectionId==intSID)?this.displayStyle = 'block':this.displayStyle = 'none';
					this.intSubSectionLength = ar[i+1].pChild.length;
					
					//loop through the subsections, determine whether to set the display to 'block' or not.
					for (var j=1; j <= this.intSubSectionLength; j++) {
						
						this.intChildSid = ar[i+1].pChild[j].nSectionId;
						//if the subsection id is the same as the pages section id (intSID) then set display to block
						if(this.intChildSid==intSID || this.intProductSectionId==intSID){
							this.displayStyle = 'block';
							
							//comment the line above in to make the headings change colour when section is active (being browsed)
							this.strNavClass = "headingDown";
							//break, we know we have to set the display to block so there is no more to be done
							break;
						}
						
						//if the subsection contains a subsection, then we must be dealing with a products array
						if(ar[i+1].pChild[j].pChild){
							//loop through the products array (the sub-sub-section array)
							for (var k=1; k <= ar[i+1].pChild[j].pChild.length; k++){
								this.intProductSid = ar[i+1].pChild[j].pChild[k].nSectionId;
								//if the product section id is the same as the pages section id (intSID) then set display to block
								if(this.intProductSid==intSID){
									this.displayStyle = 'block';
									//comment the line above in to make the headings change colour when section is active (being browsed)
									this.strNavClass = "headingDown";
									//and set j to the higest value to end the loop, since the job has been done
									j = intSubSectionLength;
									//break, we know we have to set the display to block so there is no more to be done
									break;
								}
							}
						}
						
						
					}	
					
						strIDs += "<div class=\"" + this.strNavClass + "\"><a href=\"javascript:void(0);\" onclick=\"ftnShowHide(" + ar[i+1].nSectionId + ");\" >" + ar[i+1].sName + "__</a></div>"
						strIDs += "<div id=\"" + ar[i+1].nSectionId + "\" style=\"display:" + this.displayStyle + ";\">"
							for (var j=1; j <= ar[i+1].pChild.length; j++) {
									this.strURL		=	ar[i+1].pChild[j].sURL;
									this.strName	=	ar[i+1].pChild[j].sName + "__";
									this.intChildSid = ar[i+1].pChild[j].nSectionId;
									(this.intChildSid==intSID)?this.strSubNavClass	=	"subHeadingDown":this.strSubNavClass	=	"subHeading";
										if(ar[i+1].pChild[j].pChild){
											for (var k=1; k <= ar[i+1].pChild[j].pChild.length; k++){
												this.intProductSid = ar[i+1].pChild[j].pChild[k].nSectionId;
												if(this.intProductSid==intSID){
													this.strSubNavClass	=	"subHeadingDown";
													break;
												}
											}
										}
									
									//this.strName	 = this.strName	.replace(/ /g,"&nbsp;");
									strIDs += "<div class=\"" + this.strSubNavClass + "\" ><a href=\"" + this.strURL + "\" >" + this.strName + "</a></div>";
									
								
							}
						strIDs += "</div>";

						
					}
				}
				
				
				var d = document.getElementById("productsBox");
				 d.innerHTML = strIDs
			}