
// scripts used for mobile phones direct

// show discounts
function showDiscounts(cid,whichLayer)
	{
	if (cid==2)
		{
		if (document.getElementById)
			{
			var style2 = document.getElementById(whichLayer).style;
			style2.display = "block";
			}
		else if (document.all)
			{
			var style2 = document.all[whichLayer].style;
			style2.display = "block";
			}
		else if (document.layers)
			{
			var style2 = document.layers[whichLayer].style;
			style2.display = "block";
			}
	}
	
	else
		{
		if (document.getElementById)
			{
			var style2 = document.getElementById(whichLayer).style;
			style2.display = "";
			}
		else if (document.all)
			{
			var style2 = document.all[whichLayer].style;
			style2.display = "";
			}
		else if (document.layers)
			{
			var style2 = document.layers[whichLayer].style;
			style2.display = "";
			}
		}
	}


// Add bookmark for both browser engines...
function addBookmark(title,url) 
	{
	if (window.sidebar) 
		{
		window.sidebar.addPanel(title, url,"");
		} 
	else if( document.all ) 
		{
		window.external.AddFavorite( url, title);
		}
	else if( window.opera && window.print ) 
		{
		return true;
		}
	}

	
// open the basket 
function checkoutBasketOpen () 
	{
  	var basketClosed = document.getElementById("basketClosed");
	var basketArea = document.getElementById("basketArea");
	var showExpandBasket = document.getElementById("showExpandBasket");
	
	// if there is no id=basketArea on this page break from the function and return
	if (!basketArea)
		{
		return false;
		}
	
	// if there is an id=basketClosed on the page use these setting to hide the basket
	if (basketClosed != null)
		{
		basketArea.style.display = 'none';
		showExpandBasket.style.display = 'block';
		}
	
	// if there is not an id=basketClosed on the page use these settings to show the basket
	else
		{
		basketArea.style.display = 'block';
		showExpandBasket.style.display = 'none';
		}
	}	


/* function to change the background image of table td if a checkbox is checked - pete b */
function historyBasketBg ( check, bgChange ) 
	{
  	// assign value 'checked' or 'not checked' to variable ifChecked from checkbox onclick
	var ifChecked = document.getElementById(check);
	// get the id of the row to change
	// get array of all tds within the id of the row to change
	var bgChange = document.getElementById(bgChange);
	var tds = bgChange.getElementsByTagName("td");
   	
	for (var j=0; j<tds.length; j++) 
		{
    	if ( ifChecked.checked == true )
  			{
			// when checked use blue bg for table row
			tds[j].style.background="url(/common/img/basket/tdBgBlue.gif) no-repeat left bottom";
			}
		else
  			{
			// when unchecked use normal bg for table row
			tds[j].style.background="url(/common/img/basket/tdBg.gif) no-repeat left bottom";
  			}
		
		// always set any bg in the first td to -2px position left out of sight
		tds[0].style.backgroundPosition="-2px bottom";
		}
	}


/* function to reset all checkboxes to unchecked - pete b */
function historyBasketClearCheck()
	{
	var basket = document.getElementById("basket");
	var checkBoxes = basket.getElementsByTagName("input");
	var tds = basket.getElementsByTagName("td");
	
	for ( var i=0; i<checkBoxes.length; i++ ) 
		{
		if ( checkBoxes.checked == true )
			{
			checkBoxes[i].checked = true;
			}
		else
			{
			checkBoxes[i].checked = false;
			}
		}
		
	for ( var j=0; j<tds.length; j++ )
		{
		tds[j].style.background="url(/common/img/basket/tdBg.gif) no-repeat left bottom";
 		
		if (tds[j].className == "basketQty" )
			{
			tds[j].style.backgroundPosition="-2px bottom";
			}
		}
	}


// faqs menu and reset menu

//declare the last var and set an initial state (to stop errors)
var last = '1';

/* function to get the link called a+which ie a1, a2 ... a10 (the answer that has just been anchored to) 
and change its class name from 'roundedBlue549px' to 'roundedBlue549px on' - to apply the ON state 'background-position:-55px or something' */

function activateTip(which)
	{
 	//remove any existing ON states by calling the toTheTop function below to set all anchors to have class name 'roundedBlue549px'
	//this is used incase another faq is selected from the menu without the 'back to top' link being clicked
 	toTheTop();
 		
	//apply the new ON style so the anchor now has the class name 'on'
	document.getElementById('a'+which).className="answerBgs on";
 		
	//set 'last' variable to whatever a1, a2... a10 anchor was given the ON state so we can change it back using the toTheTop function
	last = which;
	}


/* function to set any anchor with an ON state back to its normal state by resetting the the class name */
function toTheTop()
	{
	//reset the background image
	document.getElementById('a'+last).className="answerBgs";
	}


// hiding active content ie select boxes, from showing through a div placed above
function hideSelect()
	{
	if (document.all)
		{
		document.all.formselect.style.visibility="hidden";
		}
	}

function unhideSelect()
	{if (document.all)
		{
		document.all.formselect.style.visibility="visible";
		}
	}

//Add the formselect ID to your select box (or the form itself if you have multiple select boxes, as I did):
//<form action="reportpost.cfm" method="post" id="formselect">
//Invoke your script with a mouseover/mouseout:
//<a href="whatever.html" onmouseover="hideSelect()" onmouseout="unhideSelect()">Show or Hide Select</a>
//Works in IE. Not sure about other browsers/platforms but it's pretty simple so give it a try.

/*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(num,numelems,opennum,animate) {
    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'blind',{duration:0.001, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num,'blind',{duration:0.001, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num);
        }
    }
}

