// JavaScript Document

//Get Browser Type IE or Netscape based
var ie = null
var nn = null
if(document.all){
	ie=true;
}else{
	nn=true;
}
//Missing Icon placeholder
var defaultImage = '/skin_default/templateimages/content/NoImageAvailable_sm.gif'


/*********************************************************************
'######################################################################
'#### PINDAR : KW : JQUERY CODE THAT CONTROLS:
'#### PINDAR : KW : Top Menu
'#### PINDAR : KW : Side Category Menu
'#### PINDAR : KW : Product Page Tabs
'######################################################################

/****************** PINDAR: KW: MAIN DROP DOWN MENU *****************/

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function PindarMenu_open()
{  PindarMenu_canceltimer();
   PindarMenu_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function PindarMenu_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function PindarMenu_timer()
{  closetimer = window.setTimeout(PindarMenu_close, timeout);}

function PindarMenu_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#PindarMenu > li').bind('mouseover', PindarMenu_open)
   $('#PindarMenu > li').bind('mouseout',  PindarMenu_timer)});

document.onclick = PindarMenu_close;

/***************** PINDAR: KW: END MAIN DROP DOWN MENU *************/

/***************** PINDAR: KW: START COLLAPSIBLE CATEGORY MENU ************/
	function initMenus() {
	
	/*
	'######################################################################
	'#### PINDAR : KW : Find out how many menu levels we need to hide
	'#### PINDAR : KW : Set as a Cookie in config.asp
	'#### PINDAR : KW : Loop through after reading the cookie to build up
	'#### PINDAR : KW : The number of UL levels to hide
	'#### PINDAR : KW : Also See what market type it is as the differing
	'#### PINDAR : KW : Number of sub-levels affects the way
	'######################################################################
	*/
	
	 TempLevelscookieExists = document.cookie.indexOf('HideMenuLevels');
	
     if (TempLevelscookieExists != -1) 		
		{	
			MenuLevels = readCookie("HideMenuLevels");
			//alert("TempLevels "+TempLevels);
			//var TempLevelsArray = TempLevels.split("=");
			//var MenuLevels = TempLevelsArray[1];
		}
	else
		{
			//var MenuLevels = 3;
			var MenuLevels = 3;
		}
	

	 TempMarketcookieExists = document.cookie.indexOf('MarketType');
	
     if (TempMarketcookieExists != -1) 		
		{	
			MarketType = readCookie("MarketType");
		//	alert("TempMarket "+TempMarket);
			//var TempMarketArray = TempMarket.split("=");
	   		//var MarketType = TempMarketArray[1];
		}
	else
		{
			var MarketType = "C";
		}
		
	MenuItemcookieExists = document.cookie.indexOf('PreviousMenuItem');
	
     if (MenuItemcookieExists != -1) 		
		{	
			PreviousMenuItem = readCookie("PreviousMenuItem");
			//var TempParent = TempMenuItemSettings.split("=");
			//var PreviousMenuItem = TempParent[1];
		}
	else
		{
			var PreviousMenuItem = 0;
		}

	
	var ListString = "";
	
	for (i=1;i<=MenuLevels;i++)
	{
		ListString = ListString +" ul";
	}
	

	
	
		
	//Set A Default Value for the parent Cat ID
		
	var ParentCatID = 0;

	/*
	'######################################################################
	'#### PINDAR : KW : Find Parent ID Of the current Menu Item
	'######################################################################
	*/
	$('ul.categorymenu'+ListString).hide();
	
	
	//'#### PINDAR : KW : Find out the parent ID so we can open the Menu at the appropriate Level
			var variable = "strParents";
			var ParentString = "";
			var query = window.location.search.substring(1); 
			
			var vars = query.split("&");
			  for (var i=0;i<vars.length;i++) 
			  {
				 var pair = vars[i].split("=");
					if (pair[0] == variable) 
					{
						 ParentString = pair[1];
					}
			   } 
			   
			  
			/*
	
			'#### PINDAR : KW : The following keeps the menu expanded
			'#### PINDAR : KW : According to the category you're on

			*/
				var mySplitResult = ParentString.split(",");
				
				var TotalParents = (mySplitResult.length)-1;

				
				for(ML = 2; ML <= TotalParents; ML ++)
					{
						ParentCatID = mySplitResult[ML];
						var selectedCat = $("#C_"+ParentCatID);
						
						var parentLink = $("#A_"+ParentCatID);

							
						$(selectedCat).slideToggle("medium");
						
						$(parentLink).toggleClass("expanded").toggleClass("collapsed")
						
					}
				
		
	//'#### PINDAR : KW : START Open Menu Code

	$('ul.categorymenu li a').click(
		function() {
			
			
				
		
			/*'#### PINDAR : KW : Write Out Current Parent Category and
			  '#### PINDAR : KW : Hide Menu/Market Type to a cookie
			  '#### PINDAR : KW : So that we can close the correct
			  '#### PINDAR : KW : Menu Item when opening another
			*/  

			//Create Cookies
			 createCookie('HideMenuLevels',MenuLevels, 1);
			 createCookie('MarketType',MarketType, 1);
			 createCookie('PreviousMenuItem',ParentCatID, 1);
			
		
			/***************
			'#### PINDAR : KW : 	
			COMMENTED OUT AS Current ML site leaves the previously clicked items open
			
			Note: Code below not fully checked!
			
			*****************/
			//Hide Previously Opened Menu Item if we're now on a new item
			
		//	if(PreviousMenuItem=="0" || PreviousMenuItem == ParentCatID)
		//	{
				//Close all items as we're on the top anyway
		//		$('ul.categorymenu ' + ListString	).hide();
		//		var ItemToClose = $("#C_"+PreviousMenuItem);
		//		$(ItemToClose).slideToggle("medium");
		//		$(ItemToClose).hide();
		//		$(ItemToClose).toggleClass("expanded").toggleClass("collapsed");
	
		//	}
		//	else
		//	{
				//Close Specific Item
		//		var ItemToClose = $("#C_"+PreviousMenuItem);
		//		$(ItemToClose).slideToggle("medium");
		//		$(ItemToClose).hide();
		//		$(ItemToClose).toggleClass("collapsed");

		//	}	
			
			if($(this).hasClass('collapsed') || $(this).hasClass('expanded'))
			{
			$(this).toggleClass("expanded").toggleClass("collapsed").find("+ ul").slideToggle("medium");
			}
			else if($(this).hasClass('expanded'))
			{
			//alert("expanded");
			}
			else
			{
			$(this).find("+ ul").slideToggle("medium");
			}
		}

	);

	$('ul.purchmenu li a').click(
		/*function() {
			if($(this).hasClass('collapsed') || $(this).hasClass('expanded'))
			{
				$(this).toggleClass("expanded").toggleClass("collapsed").find("+ ul").slideToggle("medium");
			}
			else if($(this).hasClass('expanded'))
			{
			//alert("expanded");
			}
			else
			{
			$(this).find("+ ul").slideToggle("medium");
			}
		}*/
		
		function() {
			$("a[id^='BillTo']").removeClass("expandedpurchmenu").addClass("collapsed");
			
			//hide the contacts if they show
			$('#ContactMenuHeaderDiv').slideUp('medium');
			$("ul[id$='Contact']").slideUp('medium');
			$("ul[id$='Contact']").removeClass("expandedpurchmenu").addClass("collapsed")

			//hide the shiptos if they show
			$('#ShipToMenuHeaderDiv').slideUp('medium');
			$("ul[id$='ShipTo']").slideUp('medium');
			$("ul[id$='ShipTo']").removeClass("expandedpurchmenu").addClass("collapsed")
			

			//show the shiptos for the selected bill to
			$('#ShipToMenuHeaderDiv').slideDown('medium');
			$('#' + $(this).attr("id") + "ShipTo").slideToggle('medium');
			$(this).addClass("expandedpurchmenu").removeClass("collapsed")
			
			//scroll to the appropriate part of the screen.
			$('html, body').animate({scrollTop: $('#ShipToMenuHeaderDiv').offset().top}, 1000);
		}
	);

	$('ul.purchmenushipto li a').click(
		function() {
			$("a[id^='BillTo'][id*='ShipTo']").removeClass("expandedpurchmenu").addClass("collapsed");
			
			//hide the contacts if they show
			$('#ContactMenuHeaderDiv').slideUp('medium');
			$("ul[id$='Contact']").slideUp('medium');
			$("ul[id$='Contact']").removeClass("expandedpurchmenu").addClass("collapsed")
			
			//show the contacts for the selected shipto 
			$('#ContactMenuHeaderDiv').slideDown('medium');
			$('#' + $(this).attr("id") + "Contact").slideDown('medium');
			$(this).addClass("expandedpurchmenu").removeClass("collapsed");
			
			//scroll to the appropriate position
			$('html, body').animate({scrollTop: $('#ContactMenuHeaderDiv').offset().top}, 1000);
		}
	);	
	
	$('ul.purchmenu li a').mouseover(
		function() {
			$(this).css("color","#D8781A");
		}
	);	
	
	$('ul.purchmenu li a').mouseout(
		function() {
			$(this).css("color","black");
		}
	);
	
	$('ul.purchmenushipto li a').mouseover(
		function() {
			$(this).css("color","#D8781A");
		}
	);	
	
	$('ul.purchmenushipto li a').mouseout(
		function() {
			$(this).css("color","black");
		}
	);
	
	$('ul.purchmenushiptocontact li a').mouseover(
		function() {
			$(this).css("color","#D8781A");
		}
	);	
	
	$('ul.purchmenushiptocontact li a').mouseout(
		function() {
			$(this).css("color","black");
		}
	);
	
	$('ul.purchmenushiptocontact li a').click(
		function() {
			$('#AddNewAddress').hide();
			$('#AddNewAddressHeader').hide();
			$('html, body').animate({scrollTop: $('#MainPageContainer').offset().top}, 1000);
		}
	);	

	$('#showPrintQuote').click(
		function() {
			$('#printQuote').slideToggle('medium');
		}
	);	
}

	
$(document).ready(function() {initMenus();});


/***************** PINDAR: KW: END COLLAPSIBLE CATEGORY MENU **************/


/**************** PINDAR: KW: Product page tabs ***********************/

/*****END TABS ***/

var timeoutId = 0
var blnBannerInit = true;
//Used to determine in banner is hidden
var blnElemHidden = false;
//Used for fade out
var opacity
if(ie){
	opacity=100
}else{
	opacity=1	
}
var bannerCount = 0;
var aryBanners = new Array();



function loadCatalogue(aryProducts){
	var i = 0
	for(i=0;i<aryProducts.length;i++){
		//Product Id
		var pId = aryProducts[i][0];
		//Product Name
		var pName = aryProducts[i][1];
		//Product Image - Hero Products use the Product Id
		var pImage = aryProducts[i][2]+(aryProducts[i][2]==''?'':'/')+aryProducts[i][0];
		//Product Description - Not used
		var pDescription = aryProducts[i][3]
		//check image value is not empty
		var d = new Date();
		var imgcache = d.getFullYear().toString()+d.getMonth().toString()+d.getDate().toString()+d.getHours().toString();
		var img = new Image()
		img.id = 'rotatingBannerImage'
		img.setAttribute('alt',pName)
		img.src='uploads/images_homepage_heros/'+pImage+'.jpg?' + escape(imgcache)
		//If the Image does not exist then show a default image.
		img.onerror = function(){
								this.src = defaultImage
						  }
		var bannerLink = document.createDocumentFragment()
		//Create the link to the product page
		var aLink = document.createElement('a')
		aLink.setAttribute("href","product.asp?P_ID="+pId)
		aLink.setAttribute("title",pName)
		//Insert the image to the link.
		aLink.appendChild(img)
		//add the Image and Text holders to the docFrag
		bannerLink.appendChild(aLink)
		//add the docFrag to the array
		aryBanners.push(bannerLink)
	}
}

function displayBanners(){
	var elem = document.getElementById('home_region1')
	if(elem==null){
		return false;
	}
	if(aryBanners.length==0){
		return false;	
	}
	
	if(blnElemHidden==true){
		showElem()
	}
	//Exit if there are no banners
	if(bannerCount==aryBanners.length){
		bannerCount = 0	
	}
	elem.innerHTML =''
	elem.appendChild(aryBanners[bannerCount].cloneNode(true))
	bannerCount++
	//Force the image to fit the size of the div set in the Stylesheet
	//Might need fixing for IE
	var img = document.getElementById('rotatingBannerImage')
	//If the image doesn't exist then use a default image.
	if(img!=null){		
		img.onerror = function(){
				this.src=defaultImage;
		}
	}

	if(img.width>elem.clientWidth){
			img.width=elem.clientWidth
	}
	//Time used to rotate the banner
	timeoutId = setTimeout("hideElem()",6500)
	
	return true;
}
function hideElem(){
		
	var elem = document.getElementById('home_region1')
	if(document.all){
		elem.style.filter = 'alpha(opacity='+opacity+')';	
	}else{
		elem.style.opacity=opacity	
	}
	if(parseFloat(opacity)>0){
		if(ie){
			opacity=opacity-10
			elem.style.filter = 'alpha(opacity=' + opacity + ')';
		}else{
			opacity=opacity-0.1
			elem.style.opacity = opacity;
		}
		setTimeout("hideElem()",75)
	}else{
		blnElemHidden = true
		displayBanners()
	}
	

	
}

function showElem(){
	var elem = document.getElementById('home_region1')
	if(document.all){
		elem.style.filter = 'alpha(opacity='+opacity+')';	
	}else{
		elem.style.opacity=opacity	
	}

	var theVal
	if(ie){
		theVal = 100
	}else{
		theVal=1
	}
		
	if(parseFloat(opacity)<theVal){
		if(document.all){
			opacity=opacity+10
			elem.style.filter = 'alpha(opacity=' + opacity + ')';
		}else{
			opacity=opacity+0.1
			elem.style.opacity = opacity;
		}
		setTimeout("showElem()",50);
	}else{
		blnElemHidden =false;	
	}
}

//Speed Order Update script
function processSpeedOrder(frm){

	if(document.getElementById('quickOrderError')!=null){
		document.getElementById('quickOrderError').innerHTML = ''	
	}
	var productCode = ''
	var quantity = 0
	//Issue with IE not getting form items that have been dynamically set
	if(frm.strCode==null){
		var els = document.getElementById('speedorder').getElementsByTagName('INPUT')
		for(i=0;i<els.length;i++){
			var el = els[i]
			if(el.name=='strCode'){
				productCode = el.value
			}
			if(el.name=='numQuant'){
				quantity = el.value	
			}
		}
		
	}else{
		productCode = frm.strCode.value
		quantity = frm.numQuant.value	
	}
		
	if(productCode==''||quantity==''){
		displaySpeedOrderMessage('You did not enter a product code or quantity')	
		return false;
	}
	if(isNaN(quantity)){
		displaySpeedOrderMessage('Please enter numerical values only');
		frm.numQuant.value = 1;
		frm.numQuant.focus();
		return false;
	}
	if(parseInt(quantity)<1){
		displaySpeedOrderMessage('Please enter a number greater than zero');
		frm.numQuant.value = 1;
		frm.numQuant.focus();
		return false;
	}
	var speedProcess = document.getElementById('SpeedProcess')
	var spinner = document.getElementById('spinner')

	//Set the spinner going to show work being done
	speedProcess.style.display='none';
	spinner.style.display='block';
	addToBasket(quantity,productCode);
	
	return false;
}
var globalIntQty = 0
function addToBasket(intQty,strCode){
	globalIntQty = intQty
	try{
		var request = new ajaxObject('/ajaxMethods/speedOrder.asp',processAddToBasket);
		request.update("code="+strCode+"&qty="+intQty,'POST');
	}catch(err){
		displaySpeedOrderMessage('There was an error: ' + err.message)	
	}
	var i =0
	var t = getErrorDisplay();
}
function removeFromBasket(versionId, optionsList){
	try{
		var request = new ajaxObject('/ajaxMethods/removeFromBasket.asp',processAddToBasket);
		request.update("vId="+versionId+"&strOptions="+optionsList,'POST');
	}catch(err){
		displaySpeedOrderMessage('There was an error: ' + err.message)	
	}	
}
function processAddToBasket(responseText, responseStatus){
	try{
		if(responseStatus!=200){
			displaySpeedOrderMessage(responseText);
			return false;
		}
		var rs = eval(responseText);
		if(rs==null){
			//There was an error serverside
			displaySpeedOrderMessage('There was an error, please try again')
			return false;
		}
		if(rs.RecordCount==0&&rs.MethodName=='addToBasket'){
			//There was an error
			if(rs.SearchTerm=='')
			{
				displaySpeedOrderMessage('There were no products with the code you specified')
			}
			else
			{
				displaySpeedOrderMessage(rs.SearchTerm+' has more options, <a href="search.asp?strKeywords='+rs.SearchTerm+'">click here<\/a> to search')
			}
			return false;
		}
		
		//Add prodsto table
		addProductToDOM(rs)
		//Update the basket Values
		basketUpdate()
	}catch(err){
		displaySpeedOrderMessage("Line Number:"+ 235 +"\n"+err.message)			
	}
}



function addProductToDOM(rs){
	//Manipulate the QuickOrder Table
	var quickOrderTable
	try{
		quickOrderTable = document.getElementById('frmSpeedOrder').getElementsByTagName('TABLE')[0]
		if(quickOrderTable==null){
			quickOrderTable =createSpeedOrderTable();	
		}
		//Clone the node for appending later
		var inputRow = quickOrderTable.rows[quickOrderTable.rows.length-1].cloneNode(true);
		//Remove existing product rows
		for(i=quickOrderTable.rows.length-1;i>0;i--){
			quickOrderTable.deleteRow(quickOrderTable.rows.length-1);
		}
	}catch(err){
		displayErrorMessage('Line: 256\n'+err.message)	
	}
	try{
		for(i=0;i<rs.RecordCount;i++){
			var displayRow = quickOrderTable.insertRow(quickOrderTable.rows.length);
		
			var cDescription = displayRow.insertCell(0);
			var cQty = displayRow.insertCell(1);
			var cDelete = displayRow.insertCell(2);
			
			cDescription.innerHTML = rs.Records[i].productName;
			cQty.innerHTML = rs.Records[i].itemCount;
			cDelete.innerHTML = "<img src='images/delete.gif' style='cursor:pointer' onclick=\"removeFromBasket('" + rs.Records[i].versionId +"','"+ rs.Records[i].optionsList +"');this.src='images/spinner.gif';\" />";
		}
	}catch(err){
		displaySpeedOrderMessage('Cannot delete tables')
	}
	try{
		var newInputRow = quickOrderTable.insertRow(quickOrderTable.rows.length);
		createInsertRow(newInputRow)
	}catch(err){
		displaySpeedOrderMessage('Line 295' + err.message)	
	}
}

function createInsertRow(r){
	var c0,c1,c2
	try{
		c0 = r.insertCell(0);
		c1 = r.insertCell(1);
		c2 = r.insertCell(2);
		if(c0!=null){
			c0.className='productcode';
		}
		if(c1!=null){
			c1.className='quantity';
		}
		//c1.class='quantity';
	}catch(err){
		displaySpeedOrderMessage('Error initializing the cells: ' +err.message);
	}
	
	
	
	try{
	
		var txtQty = document.createElement('input');
		var txtCode = document.createElement('input');
		var btnSubmit = document.createElement('input');
		var imgSpinner = document.createElement('img');
		if(txtQty!=null){
			txtQty.setAttribute('type','text');
			txtQty.setAttribute('name','numQuant');
		}
		if(txtCode!=null){
			
			txtCode.setAttribute('type','text');
			txtCode.setAttribute('name','strCode');
		}
		if(btnSubmit!=null){
			btnSubmit.setAttribute('type','image');
			btnSubmit.setAttribute('id','SpeedProcess');
			btnSubmit.setAttribute('style','display:block');
			btnSubmit.setAttribute('src','/skin_default/templateimages/content/add_button.gif');
			btnSubmit.setAttribute('value','');
		}
		if(imgSpinner!=null){
			imgSpinner.setAttribute('id','spinner');
			imgSpinner.setAttribute('style','display:none');
			imgSpinner.setAttribute('src','images/spinner.gif');
			imgSpinner.setAttribute('name','spinner');
		}
	}catch(err){
		displaySpeedOrderMessage('Error setting values: ' +err.message)	;
	}

	try{		
		c0.appendChild(txtCode);
		c1.appendChild(txtQty);
		c2.appendChild(btnSubmit);
		c2.appendChild(imgSpinner);
	}catch(err){
		displaySpeedOrderMessage('Error adding objects: ' +err.message)	;
	}
	
}

//Creates the table for displaying the items the customer has just added via speed Order
function createSpeedOrderTable(){
	var table = document.createElement('table');
	try{		
		table.id = 'speedOrderDisplay'
		table.setAttribute('cellspacing','0')
		table.setAttribute('cellpadding','0')
		table.setAttribute('border','0')
	
		var formParent = document.getElementById('frmSpeedOrder').parentNode
		formParent.insertBefore(table,document.getElementById('frmSpeedOrder'))
	}catch(err){
		displaySpeedOrderMessage('Cannot create table: ' +err.message)	;	
	}
	return table;
}

//Updates the vie of the basket

function basketUpdate(){
	if(location.pathname=='/basket.asp'){
		location.reload(true)
		return false;
	}
	try{
		
		var request = new ajaxObject('/ajaxMethods/updateBasket.asp');
		request.update("",'POST');
		request.callback = function(responseText,responseStatus){
								if(responseStatus!=200){
									displaySpeedOrderMessage('Error refreshing items: Status' + responseStatus)	
									return false;	
								}
								var docFrag = document.createDocumentFragment()
								docFrag.innerHTML = responseText
								var basketText = document.getElementById('basketInfo')
								if(basketText==null){
									//alert('I am empty');
									return false;
								}
								basketText.innerHTML = docFrag.innerHTML
								
							}			
	}catch(err){
		displaySpeedOrderMessage('There was an error: ' + err.message)	
	}
	
	resetQuickOrderButtons()
	
	return false;
}

function resetQuickOrderButtons(){
	var speedProcess = document.getElementById('SpeedProcess')
	var spinner = document.getElementById('spinner')
	try{
		if(speedProcess!=null){
			speedProcess.style.display='block';
			spinner.style.display='none';		
		}
	}catch(err){
		displaySpeedOrderMessage('Error resetting buttons: ' +err.message)	;	
	}
}

function displaySpeedOrderMessage(strMessage){
	try{
		var elem = getErrorDisplay();
		elem.innerHTML = strMessage;
	}catch(err){
		alert('Error\nLine Number: '+err.lineNumber+'\nMessage: '+err.message)	;
	}
	resetQuickOrderButtons()
}
function getErrorDisplay(){
	var elem = document.getElementById('quickOrderError')
	if(elem==null){
		elem = document.createElement('div')
		elem.id = 'quickOrderError'
		document.getElementById('frmSpeedOrder').appendChild(elem)
	}
	return elem
}


/*

'######################################################################
'#### PINDAR : KW : My Account Page - Show Delivery Address
'######################################################################

*/

function UpdateShipping(id, TheForm)
	{
		if (document.getElementById)
		{
			obj = document.getElementById(id);
				if (obj.style.display == "none")
					{	
						/*
						Empty out fields
						*/
						TheForm.C_ShippingCompany.value=TheForm.C_CardholderCompany.value;
						TheForm.C_ShippingStreetAddress.value=TheForm.C_CardholderStreetAddress.value;
						TheForm.C_ShippingStreetAddress2.value=TheForm.C_CardholderStreetAddress2.value;
						TheForm.C_ShippingTownCity.value=TheForm.C_CardholderTownCity.value;
						TheForm.C_ShippingCounty.value=TheForm.C_CardholderCounty.value;
						TheForm.C_ShippingPostCode.value=TheForm.C_CardholderPostCode.value;
						TheForm.C_ShippingCountry.value = TheForm.C_CardholderCountry.value;
					
						/* Open up the form */
						obj.style.display = "";
					} 
					else 
					{
						obj.style.display = "none";
					}
		}
	}
	
/*
'######################################################################
'#### PINDAR : KW : ShowProcessing(DIV ID)
'#### PINDAR : KW : Function to hide the submit button and show 
'#### PINDAR : KW : A "spinner" so the user knows something is 
'#### PINDAR : KW : Happening after clicking a button
'######################################################################
*/

function ShowProcessing(ButtonDiv, ProcessDiv, SpinningImage)
{

objToHide = document.getElementById(ButtonDiv);
objToHide.style.display = "none";
objToShow = document.getElementById(ProcessDiv);
objToShow.style.display = "";


/* 
'#### PINDAR : KW : Reset the spinner image source to the same grapic
'#### PINDAR : KW : IE stops animating GIFs when forms are submitted (!)
'#### PINDAR : KW : So reloading the source kicks the animation back in */

document.getElementById(SpinningImage).src = "/images/spinner.gif"
}

/*
'######################################################################
'#### PINDAR : KW : CheckShippingAccount(Form Name)
'#### PINDAR : KW : Checks to see if a user has selected the UPS/Fedex
'#### PINDAR : KW : Radio Button but not entered an account number
'#### PINDAR : KW : On Shipping Methods step of checkout
'#### PINDAR : KW : Or selected at least one shipping method
'######################################################################
*/

function CheckShippingAccount(TheForm)
{

var ErrorMsg = "";
var MethodSelected = 0;
var AccountPos = -1;

for( kt = 0; kt < TheForm.numShipMethod.length; kt++ )
	{
		if( TheForm.numShipMethod[kt].checked == true )
		{
			MethodSelected = 1;
		}	
		if( TheForm.numShipMethod[kt].value == "ACCOUNT" )
		{
			AccountPos = kt;
		}
	}
	
	if(TheForm.numShipMethod.value != undefined)
	{
		MethodSelected = 1;
	}
	
	if((AccountPos!=-1) && (TheForm.numShipMethod[AccountPos].checked) && (TheForm.C_FedexUpsAccount.value==''))
	{
		ErrorMsg = "<li>Please Enter Your FedEx or UPS Account Number<\/li>";	
	}

	
	if (MethodSelected == 0)
	{
		ErrorMsg = ErrorMsg + "<li>Please select your preferred shipping method from the options below<\/li>";
	}
		
	if(ErrorMsg!="")
	{
		document.getElementById('ErrorMessage').innerHTML = "<strong>The following problems occured:<\/strong><ol>"+ErrorMsg+"<\/ol>";
		document.getElementById('ErrorMessage').style.display = "";
		return false;	
	}
	else
	{
	 	ShowProcessing('FormSubmitProceed', 'ProcessingMsg', 'ShippingSpinner');
		return true;
	}

}

/*
'######################################################################
'#### PINDAR : KW : Check to see if we need to show the Facility
'#### PINDAR : KW : Form field in the checkout/account page
'######################################################################
*/

function CheckDestination(TheForm, BillingFieldDiv, ShippingFieldDiv)
{

	if(TheForm.C_DestinationType.value!='Facility')
	{
		document.getElementById(BillingFieldDiv).style.display = "none";
		document.getElementById(ShippingFieldDiv).style.display = "none";
	}
	else
	{
		document.getElementById(BillingFieldDiv).style.display = "";
		document.getElementById(ShippingFieldDiv).style.display = "";
	}
}

/*
'####################################################
'# ML : MW : Upcharges
'####################################################
*/
function LTLToggleLiftGateDiv()
{
	if (!$("#C_ReceivingDock").attr("checked"))
	{
		$("#ltlLiftGateDiv").show();
		$("#C_LTLLiftGate").attr('checked', true);
	}
	else
	{
		$("#C_LTLLiftGate").attr('checked', false);
		$("#C_LTLInsideDelivery").attr('checked', false);
		$("#ltlLiftGateDiv").hide();
	}
	LTLToggleInsideDeliveryDiv();
}

function LTLToggleInsideDeliveryDiv()
{
	if ($("#C_LTLLiftGate").attr("checked"))
	{
		$("#ltlInsideDeliveryDiv").show();
	}
	else
	{
		$("#C_LTLInsideDelivery").attr('checked', false);
		$("#ltlInsideDeliveryDiv").hide();
	}
}

/*

		<script language="javascript">
          function EnableDisableDIV() {
              if ($("#chkShowPersonal").attr("checked")) {
                  $("#dvPersonal").show();
              } else {
              $("#dvPersonal").hide();
              }  

			function HelloWorld()
			{
				alert("HelloWorld");
			}
          }          

      </script>
	  */
