/**************************************************************************************
================================ swfobject.js ==================================
***************************************************************************************/
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.getAttribute("redirectUrl");this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;


/**************************************************************************************
====================================== plugins.js =====================================
***************************************************************************************/
/**
 * set default folder where images are stored
 */
var imagesFolder = "/cs/Satellite?ssbinary=true&blobcol=urldata&blobtable=MungoBlobs&blobkey=filevalue&blobwhere=";
var AJAXProductArray = new Array();	// * used to store data once retrieved * //
var AJAXImageArray = new Array();
var cid;
var carouselUrl;
var doubleProducts = false;
var tripleProducts = false;
var selectedProductCode;
/**
 * Generic initialisation function. Discovers the selected navitem and leaves it open whilst closing all the others
 */
function init() {
	var MenuID = $("#LeftNav > div.TopLevel.Selected").attr("id");
	bannerInit();
	menuLoaderInit();
	navInit(MenuID); 
	initLocationSelector();
	productFinderInit();
}


function carouselSingleInit() {
        $(function () {
            $('#tabcontainer > ul').tabs(); //init tabs	
        });
	// This is to display main image according to the click on thumb images
	
	$('.thumb').click(function(event) {
    		event.preventDefault();
		$(function(){  			
  			$('.product').attr("style","display: none");         
		});				
		var SmallElementId =  $(this).attr("id");               
		var LargeElementId = $('div#' + SmallElementId).attr("id");			
		$("#" + LargeElementId).attr("style","display:");
	});
               
	$(window).load(function () {				
		$(document).pngFix(); //init PNG IE6 fix	
		runCarousel('#carousel_ul', '#left_scroll_small', '#right_scroll_small', 750, 1); //init carousel 1carousel 2
           
		(function () {
			//var maxHeight = Math.max($('#wrapper1').height(), $('#wrapper2').height(), $('#wrapper3').height(), 393);	
			//var maxHeight = Math.max($('#wrapper1').height(), $('#wrapper2').height(), w3Height , 393);

			var w1Height = $('#wrapper1-top').height() + $('#wrapper1-mid .product').height() + $('#wrapper1-bottom').height();		
			var w3Height = $('#wrapper3-top').height() + $('#wrapper3-mid').height() + $('#wrapper3-bottom .a').height() + $('#wrapper3-lowermid').height() ;
			
			var maxHeight = Math.max(w1Height, $('#wrapper2').height(), w3Height , 413);
			var w1FixedHeight = $('#wrapper1-top').height() + $('#wrapper1-bottom').height() ;
			var w3FixedHeight = $('#wrapper3-top').height() + $('#wrapper3-bottom .a').height() + $('#wrapper3-lowermid').height() ;
       
			// This is adjust font size of product name according to the available height
			if ($('#wrapper1-top #product-title h3').height() <= 60){
				$('#wrapper1-top #product-title h3').css('font-size', '16px');
			} else if (($('#wrapper1-top #product-title h3').height() > 60) && ($('#wrapper1-top #product-title h3').height() <= 100)){			
				$('#wrapper1-top #product-title h3').css('font-size', '12px');	
			} else {
				$('#wrapper1-top #product-title h3').css('font-size', '11px');	
			}
		
			if (w1Height == maxHeight){
				maxHeight = maxHeight + 20;
			}
		 
			if ($.browser.msie && $.browser.version < 7) {                	
                    		// fix IE 6 strange height behaviour
                 		w1FixedHeight -= 4; 			        
              	}
			// This is to display thumb images	
			$('.thumb').show();

                	$('#wrapper1-mid').height((maxHeight - w1FixedHeight) + 'px');
                	$('#wrapper3-mid').height((maxHeight - w3FixedHeight) + 'px');
                	$('#wrapper2').height(maxHeight + 'px');
                	var w2InnerHeight = $('#wrapper2 .inner-wrapper').height();

			if ($.browser.msie && $.browser.version < 7) {                	
                    		// fix IE 6 strange height behaviour
                 		maxHeight += 4; 			        
              	}
                	if (w2InnerHeight < maxHeight) {
                    		$('#wrapper2 .inner-wrapper').css('marginTop', (maxHeight - w2InnerHeight - 3) + 'px');
                	}								
                	$('.b ul#carousel_ul li').css('float', 'left');
            	})();
	});
}

function carouselMultipleInit(){	
	$(function() {
		  $('#tabcontainer > ul').tabs(); //init tabs
	});
	// This is to display main image according to the click on thumb images
	
	$('.thumb').click(function(event) {
    		event.preventDefault();
		$(function(){  			
  			$('.product').attr("style","display: none");         
		});				
		var SmallElementId =  $(this).attr("id");               
		var LargeElementId = $('div#' + SmallElementId).attr("id");			
		$("#" + LargeElementId).attr("style","display:");
	});

	$(window).load(function() {			
		$(document).pngFix(); //init PNG IE6 fix
		runCarousel('#carousel_ul','#left_scroll','#right_scroll',1500, 4); //init carousel 1
		runCarousel('#carousel_ul2','#left_scroll2','#right_scroll2',1500, 4); //init carousel 2
					
		(function(){
			//var maxHeight = Math.max($('#wrapper1').height(), $('#wrapper2').height(), $('#wrapper3').height(), 393);
			//var maxHeight = Math.max(w1Height , $('#wrapper2').height(), $('#wrapper3').height(), 413);
			
			var w1Height = $('#wrapper1-top').height() + $('#wrapper1-mid .product').height() + $('#wrapper1-bottom').height();				
			var w3Height = $('#wrapper3-top').height() + $('#wrapper3-mid').height() + $('#wrapper3-bottom').height() +  $('#wrapper3-lowermid').height() ;
			var maxHeight = Math.max(w1Height, $('#wrapper2').height(), w3Height, 413);

			var w1FixedHeight = $('#wrapper1-top').height() + $('#wrapper1-bottom').height();
			var w3FixedHeight = $('#wrapper3-top').height() + $('#wrapper3-bottom').height() + $('#wrapper3-lowermid').height();

			// This is adjust font size of product name according to the available height
			if ($('#wrapper1-top #product-title h3').height() <= 60){
				$('#wrapper1-top #product-title h3').css('font-size', '16px');
			} else if (($('#wrapper1-top #product-title h3').height() > 60) && ($('#wrapper1-top #product-title h3').height() <= 100)){			
				$('#wrapper1-top #product-title h3').css('font-size', '12px');	
			} else {
				$('#wrapper1-top #product-title h3').css('font-size', '11px');	
			}
				
			if (w1Height == maxHeight){
				maxHeight = maxHeight + 20;					
			}
				
			if ($.browser.msie && $.browser.version < 7) {
			    // fix IE 6 strange height behaviour
			  	w1FixedHeight -= 4;									     
			}

			// This is to display thumb images				
			$('.thumb').show();

			$('#wrapper1-mid').height((maxHeight-w1FixedHeight) + 'px');
			$('#wrapper3-mid').height((maxHeight-w3FixedHeight) + 'px');
			$('#wrapper2').height(maxHeight + 'px');
			var w2InnerHeight = $('#wrapper2 .inner-wrapper').height();
			if ($.browser.msie && $.browser.version < 7) {                	
             			// fix IE 6 strange height behaviour
             			maxHeight += 4; 			        
             		}
			if (w2InnerHeight < maxHeight) {					
				$('#wrapper2 .inner-wrapper').css('marginTop', (maxHeight - w2InnerHeight - 3) + 'px');
			}
		})();
	});
}

function downloadsInit() {
	downloadsTabsInit();
}

function forBusinessInit() {
	forBusinessTabsInit();
}

function forHomeInit() {

}

function inTheWorldInit() {
	var RightMenuID = $("#RightNav > div.TopLevel.Selected").attr("id"); 
	navInit(RightMenuID); 
	DisplayContryInfo();
}

function productDescriptionInit() {
	productCarouselInit();
}

function productRangeInit() {

}

function whereToBuyInit() {
	var supplierarray = [];
	if(navigator.userAgent.toLowerCase().indexOf("msie") != -1) { isIE = true; } else { isIE = false; }
	whereToBuyInit();
}

function productFinderInit() {
	/*
	if (!(!$("#txtProductFinder").length)) {
		$.get("/cs/Satellite?pagename=DLCommon/Product/ProductFinder", function(data){
			var oProductFinder = new AutoSuggestControl( document.getElementById("txtProductFinder"), new ProductSuggestions( eval(data) ) );	
		});
	}
	*/
}

function DisplayContryInfo(){
	$("li[class^='Single']").children('a').click(function(event) {	
		$(".ExtendedInfo.visible").removeClass('ExtendedInfo visible').addClass('ExtendedInfo hidden');
		var ContryInfo = $(this).next('ul').attr('id');   
   		if ($("#"+ContryInfo).attr('style') == "display: block;"){
			$("#"+ContryInfo).css("display", "none");
			$("#"+ContryInfo).addClass('ExtendedInfo hidden');
   		}
   		else{
			$("#"+ContryInfo).css("display", "block");
			$("#"+ContryInfo).addClass('ExtendedInfo visible');
   		}	
	});
}

/**
 * changes selected tab and banner image for Where To Buy page only
 * @param - tabs : number of tabs
 * @param - tabID : ID of tab div clicked
 * @param - tabColour : colour of tab stroke
 * @param - page : page name (home, business, both)
 */
 /**
 * changes selected tab and banner image for business landing page
 * @param - tabID : ID of tab div clicked
 * @param - tabColour : colour of tab stroke
 */
function ProdDesctabChange(tabs,tabID,tabColour)
{
	// Change container background
	document.getElementById("ProductDescTabs").className = tabs + "_" + tabID.toLowerCase() + "_" + tabColour + " " + tabs ;

	// change all tabs to NOT selected
	if (tabs.toLowerCase() == 'sixtabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
		document.getElementById("Tab5").className = "Tab Middle";
		document.getElementById("Tab6").className = "Tab Middle";
	}  
	else if (tabs.toLowerCase() == 'fivetabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
		document.getElementById("Tab5").className = "Tab Middle";
	}      
	else if (tabs.toLowerCase() == 'fourtabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
	}
	else if (tabs.toLowerCase() == 'threetabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
	}
	else if (tabs.toLowerCase() == 'twotabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle"; 
	}
	else{
		document.getElementById("Tab1").className = "Tab Left";
	}
	// find which tab has been clicked
	var positionClickedTab = tabID.replace("Tab","");

	// change under gradient image
	//document.getElementById("ProductDescGradient").src = imagesFolder + "downloads_undergrad_" + tabs + "_tab" + positionClickedTab.toLowerCase() + "_" + tabColour + ".gif";
	document.getElementById("ProductDescGradientContainer").className = "gradient_" + tabs + "_" + tabID.toLowerCase() + "_" + tabColour;

	// change tab background
	document.getElementById(tabID).className=document.getElementById(tabID).className + " Selected";         

	//change selected banner to visible
	var clickedTabContentId = "Tab" + positionClickedTab + "Content";
	varShowContent = document.getElementById(clickedTabContentId).innerHTML;
	document.getElementById("ProductDescContent").innerHTML=varShowContent;
} 

function wheretobuytabChange(tabs,tabID,tabColour,page){
	var page = page.toLowerCase();
	// Change container background
	document.getElementById("DownloadsTabs").className = tabs + "_" + tabID.toLowerCase() + "_" + tabColour + " " + tabs ;
	// change all tabs to NOT selected
	if (tabs.toLowerCase() == 'sixtabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
		document.getElementById("Tab5").className = "Tab Middle";
		document.getElementById("Tab6").className = "Tab Middle";
	}
	else if (tabs.toLowerCase() == 'fivetabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
		document.getElementById("Tab5").className = "Tab Middle";
	}        
	else if (tabs.toLowerCase() == 'fourtabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
	}
	else if (tabs.toLowerCase() == 'threetabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
	}
	else if (tabs.toLowerCase() == 'twotabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle"; 
	}
	else{
		document.getElementById("Tab1").className = "Tab Left";
	}

	// find which tab has been clicked
	var positionClickedTab = tabID.replace("Tab","");
	// change under gradient image
	//document.getElementById("DownloadsGradient").src = imagesFolder + "downloads_undergrad_" + tabs + "_tab" + positionClickedTab.toLowerCase() + "_" + tabColour + ".gif";
	document.getElementById("DownloadsGradientContainer").className = "gradient_" + tabs + "_" + tabID.toLowerCase() + "_" + tabColour;
	// change tab background
	document.getElementById(tabID).className=document.getElementById(tabID).className + " Selected";
	// Empty the ProductsResults div
	document.getElementById("WTB_Results").innerHTML = '';
	// Fetch HTML for the Search box (if available)
	makeHttpRequest('snippet_wheretobuy.asp?createtabs=false&createsearch=true&page=' + page + '&id='+positionClickedTab, 'CreateWTBSearch', false);
	//Fetch page content
	if (positionClickedTab == '3'){
		makeHttpRequest('snippet_wheretobuy.asp?createtabs=false&createsearch=false&page=' + page + '&id='+positionClickedTab, 'CreateWTBContent3Cols', false);
	}
	else{
		makeHttpRequest('snippet_wheretobuy.asp?createtabs=false&createsearch=false&page=' + page + '&id='+positionClickedTab, 'CreateWTBContent2Cols', false);
	}
}

function wheretobuypageChange(tabs,tabID,tabColour,page){
	document.getElementById("Home").className = "blue";
	document.getElementById("Business").className = "red";
	document.getElementById("Both").className = "black";
	document.getElementById(page).className += " Current";
	var page = page.toLowerCase();
	// change all tabs to NOT selected
	if (tabs.toLowerCase() == 'sixtabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
		document.getElementById("Tab5").className = "Tab Middle";
		document.getElementById("Tab6").className = "Tab Middle";
	}
	else if (tabs.toLowerCase() == 'fivetabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
		document.getElementById("Tab5").className = "Tab Middle";
	}        
	else if (tabs.toLowerCase() == 'fourtabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
		document.getElementById("Tab4").className = "Tab Middle";
	}
	else if (tabs.toLowerCase() == 'threetabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle";
		document.getElementById("Tab3").className = "Tab Middle";
	}
	else if (tabs.toLowerCase() == 'twotabs'){
		document.getElementById("Tab1").className = "Tab Left";
		document.getElementById("Tab2").className = "Tab Middle"; 
	}
	else{
		document.getElementById("Tab1").className = "Tab Left";
	}
	// change under gradient image
	document.getElementById("DownloadsGradientContainer").className = "gradient_" + tabs + "_tab1_" + tabColour;
	// Change container background
	document.getElementById("DownloadsTabs").className = tabs + "_tab1_" + tabColour + " " + tabs ;
	// change tab background
	document.getElementById('Tab1').className += " Selected";	
	makeHttpRequest('snippet_wheretobuy.asp?createtabs=true&page=' + page, 'CreateWTBTabs', false);
	makeHttpRequest('snippet_wheretobuy.asp?createtabs=false&createsearch=true&page=' + page + '&id=1', 'CreateWTBSearch', false);
	makeHttpRequest('snippet_wheretobuy.asp?createtabs=false&createsearch=false&page=' + page + '&id=1', 'CreateWTBContent2Cols', false);
}

function menuLoaderInit(){
	var MainDivName = 'MainBodyArea';
	$("a[id^='leftnavitem']").click(function(event) {
		event.preventDefault();
		var product = $(this).attr("id").replace("leftnavitem_","");

		displayProgressImage(MainDivName,'progress1.gif');
		makeHttpRequest('snippet_products.asp?productid='+product, 'GetPageDetails', false);

		$(this).addClass("Selected");
		$("a[id!=" + $(this).attr("id") + "][id^='leftnavitem']").removeClass("Selected");
		// TODO : add the mainstyle functionality
	});
}

/**
 * description of function
 * @param - divName : name of div to fill with progress image HTML code
 * @param - imgName : filename of progress image to use
 */
function displayProgressImage(divName /*string*/, imgName /*string*/){
	var d = document.getElementById(divName);
    	if(!d){return;}
	d.innerHTML = '<div class="MainBodyShort" style="height:300px;text-align:center;padding-top:50px;"><img src="' + imagesFolder + imgName + '"/></div>';
}

/**
 * description of function
 * @param - divName : name of div to fill with progress image HTML code
 * @param - imgName : filename of progress image to use
 */
function displayCarouselProgressImage(divName /*string*/, imgName /*string*/){
	var d = document.getElementById(divName);
	if (!d){return;}
	d.innerHTML = '<div style="text-align:center;"><img src="' + imagesFolder + imgName + '"/></div>';
}

/**
 * pauses script
 * @param - millis : amount of milliseconds to pause for
 */
function pausecomp(millis /*integer*/){
	var date = new Date();
	var curDate = null;
	do { curDate = new Date(); }
	while(curDate-date < millis);
}

/**
 * Populate the product details on the product description page
 * @param - pTitle : Title of product
 * @param - pCode : Product code
 */
function populateProductInformation(pCode /*string*/){
	makeHttpRequest('snippet_products.asp?productcode='+pCode, 'PopulateFullProductDetails', false);
}

/**
 * populate the carousel product data (showing progress image whilst getting data)
 */
function populateCarouselData(){
	// * show progress image * //
	//displayCarouselProgressImage('CarouselArea','progress1.gif');
	// * Do request (and replace progress image) * //
	//makeHttpRequest('http://localhost/snippet_products.asp?carousel=on', 'CreateProductObjects', false)
	//CreateProductObjects(eval(carouselData));
}

/** TEMPLATE - DO NOT DELETE ***
 * description of function
 * @param - param1 : param1 description
 */  
 /* */
function initLocationSelector(){
	// Add an 'enhanced' class to this element so that it renders as the popup when js is enabled
	$("#LocationsList").each(function(i){
		$(this).hide();
		$(this).addClass("enhanced");	
	});  
}
/** 
 * Reworking of the showPanel so that the visibility is set correctly
 */
function showPanel(panelID,linkID){
	$("div#"+panelID).toggle();
	if($("a#"+linkID).hasClass("ArrowLeft")){
		$("a#"+linkID).attr("class","ArrowDown");	
	} else{
		$("a#"+linkID).attr("class","ArrowLeft");
	}
	// Hides Panel when clicking anywhere else
	$("#MainContent, #TopBar, #FooterLinks").click(function() {
		$("div#"+panelID).hide();
		$("a#"+linkID).attr("class","ArrowLeft");
	});
}

function bannerInit(){
	var HomeSectionDivider = $("#MainBannerImage1").attr("style");	
	var BusinessSectionDivider = $("#MainBannerImage2").attr("style");	
		
	if (HomeSectionDivider == "display: none;"){
		$("#HomeDivider").css("background","transparent");
		$("#BusinessDivider").css("background","#87161c");			
	}
	if (BusinessSectionDivider == "display: none;"){	
		$("#BusinessDivider").css("background","transparent");
		$("#HomeDivider").css("background","#0087be");		
	}
	
	//$("#BusinessDivider").css("background","transparent");
	$("#LeftNavForHome").mouseover(function() {
		$("#HomeDivider").css("background","#0087be");
		$("#BusinessDivider").css("background","transparent");
		$("#MainBannerImage1").show();
		$("#MainBannerImage2").hide();	  
	});

	$("#LeftNavForBusiness").mouseover(function() {
		$("#HomeDivider").css("background","transparent");
		$("#BusinessDivider").css("background","#87161c");
		$("#MainBannerImage2").show();
		$("#MainBannerImage1").hide();
	});
}

/**
* Function to setup the visibility of both the left and right nav when we have js enabled
*/
function navInit(MenuID){
	var ParentMenuID = $('div[id='+MenuID+']').parent().attr("id");
	var navButtonColour;
	// Parse the starting colour of the button
	if (!(!$("#"+MenuID+"Operator").length)) {
		navButtonColour = $('a[id='+MenuID+'Operator] > img').attr("src").replace(imagesFolder, "").replace("leftnav_minus_","").replace(".gif","");
	} else{
		navButtonColor = "black";
	}

	// Setup events for toggling nav
	$('div[id='+ParentMenuID+'] > div.TopLevel > div > a').each(function(i) {
		var thisMenu = $(this).parent().parent().next("div.SubLevel").attr("id");
		$(this).bind("click", {MenuID: thisMenu, sectionColour: navButtonColour}, toggleNav);
	});

	// Setup all the other menus so that only the selected menu stays open
	$('div[id='+ParentMenuID+'] > div.TopLevel[id!=' + MenuID + '] > div > a.TopLevelOperator,div[id='+ParentMenuID+'] > div.TopLevel[id!=' + MenuID + '] + div.SubLevel').each(function(i) {
		if ($(this).hasClass("TopLevelOperator")) {
			// TopLevel
			$(this).find("img").attr({ src: imagesFolder+ "leftnav_plus_"+navButtonColour+".gif",title: "+",alt: "+"});
		} else {
			// Sublevel
			$(this).hide();
		}
	});
	// Make sure that all the country nav items are closed at the start
	$("ul.ExtendedInfo").each(function(j) {
		$(this).hide();
		$(this).prev("a").bind("click", {LinkID: $(this).prev("a").attr("id") }, toggleExtendInfo);
	}); 
}

/**
* Toggles the visibility of items in both left and right-hand navigation
*/
function toggleNav(event){
	if (event.data){ 
		var MenuID = event.data.MenuID;
		var sectionColour = event.data.sectionColour;
		var ParentMenuID = $('div#'+MenuID).parent().attr("id");
		var menu = $('div#' + MenuID);
		var menuImg = menu.prev().find("img");

		menu.toggle();

		if (menuImg.attr("alt") == "+"){
			menuImg.attr({ src: imagesFolder + "leftnav_minus_"+ sectionColour +".gif",title: "-",alt: "-"});
		} else{
			menuImg.attr({ src: imagesFolder + "leftnav_plus_"+ sectionColour +".gif",title: "+",alt: "+"});
		}
		
		var allOtherMenus = $('div#' + ParentMenuID + ' > div.SubLevel[id!=' + MenuID + ']');
		var allOtherMenuImgs = allOtherMenus.prev().find("img");
		
		allOtherMenus.each(function(i){
			$(this).hide();
			$(this).find("ul.ExtendedInfo").each(function(j){
				$(this).hide();
			});
		});
		
		allOtherMenuImgs.each(function(i){
			$(this).attr({ src: imagesFolder + "leftnav_plus_"+ sectionColour +".gif",title: "+",alt: "+"});	
		});
	}
}
/**
* Toggles the visibility of the extended info items in rh-navigation
*/
function toggleExtendInfo(event){
	var LinkID = event.data.LinkID;	
	$('a#' + LinkID + '+ul').toggle();

	$('a#' + LinkID).parent().parent().find('li > a[id!= '+ LinkID + '] + ul').each(function(k) {
		$(this).hide();
	});
}

/**
* Initialises tabs for downloads page
*/
function downloadsTabsInit(){
	// Give all of our tab content containers and Id by which we can identify them
	$("div.DownloadsContent").each(function(f) {
		$(this).attr("id","DownloadsContentTab"+(f+1));
	});	
	// When we initialise - we make sure that all of the tabs except the first are hidden
	// TODO: With cookies we could allow different tabs to be focussed after a refresh
	$("div.DownloadsContent:not(:first)").each(function(f) {
		$(this).hide();
	});
	// Prepend the Tabs container to our BasicContent container
	$("div.BasicContent").prepend("<div id=\"DownloadsTabs\" class=\"fourtabs_tab1_black fourtabs\"></div>");	
	// Create the tabs themselves by wrapping the h2s in a tab div and then injecting a link to attach a click function
	$("div.BasicContent > h2").each(function(e){
		$(this).wrapInner('<a href="javascript:void(0)"></a>').click(function(i){			
			// Make the current tab 'Selected'
			$("div#Tab"+(e+1)).addClass("Selected");
			// Make all the other tabs not 'Selected'
			$('div#DownloadsTabs > div[id!=Tab'+(e+1)+']').removeClass("Selected");

			// Update the downloads tab class to reflect the current tab position WTF??
			$('div#DownloadsTabs').attr("class","fourtabs_tab" + (e+1) + "_black fourtabs");
			// Update the gradient container class to reflect the current tab position WTF??
			$('div#DownloadsGradientContainer').attr("class","gradient_fourtabs_tab" + (e+1) + "_black");

			// Change the content pane
			$('div[class="DownloadsContent"][id!=DownloadsContentTab'+(e+1)+']').hide();
			$('div#DownloadsContentTab'+(e+1)).show();	
		});		
		// We're initialising this for the first time here so make the first tab selected and give it a class of Left
		// All other Tabs get a class of Middle
		if (e == 0) {
			$(this).wrap("<div class=\"Tab Left Selected\" id=\"Tab" + (e+1) + "\"></div>");
		} else {
			$(this).wrap("<div class=\"Tab Middle\" id=\"Tab" + (e+1) + "\"></div>");
		}
	});
	
	// Append each of our newly created Tabs to the DownloadsTabs container
	$("div.BasicContent > div.Tab").each(function(e){
		$("div#DownloadsTabs").append($(this));
	});
	
	// Add the GradientContainer after the DownloadsTabs container
	$("div#DownloadsTabs").after("<div id=\"DownloadsGradientContainer\" class=\"gradient_fourtabs_tab1_black\"></div><br clear=\"all\"/>");

	// Tab2 is special as it has js enhanced functionality 
	// So we setup Tab2, by making an ajax call (here using instead the temp vars tabID2Data and tabID2)
	$.get("snippet_downloads.asp?createtabs=false&getdata=true&id=2", function(data){
		// Create a product array using product data
		productarray = eval(data);
		$.get("snippet_downloads.asp?createtabs=false&id=2", function(data){
			// The following should exist in a call back from the AJAX call
			$('div#DownloadsContentTab2').html(data);
			// Add DownloadsTotalFound div and DownloadsImagesResults div to Tab2
			$("div#DownloadsContentTab2").append('<div id="DownloadsTotalFound">Total Products Found:<span id="NoProductsFound">0</span></div>');
			$("div#DownloadsContentTab2").append('<div id="DownloadsImagesResults"/>');
			// Filter the results for the first time
			filter_results(iResults);
		});
	});
}

function forBusinessTabsInit(){	
	// When we initialise - we make sure that all of the tabs except the first are hidden
	// TODO: With cookies we could allow different tabs to be focussed after a refresh
	/*
	// This will not work with IE8
	$("div.BannerImage:not(:first)").each(function(f) {		
		$(this).hide();	
	});
	*/
	
	$('div.BannerImage:not(:first)').each(function(f) {
		if ($(this).attr('id')!= 'BannerImage1'){
			$(this).hide();
		}				
	});

	$("div.HeaderPanel").attr("class", "BasicContent BasicContentDownloads");
	$("div.BasicContent").prepend("<div id=\"DownloadsTabs\" class=\"threetabs_tab1_red_long threetabs_long\"></div>");
	$("h1").each(function(e){
		// We're initialising this for the first time here so make the first tab selected and give it a class of Left
		// All other Tabs get a class of Middle
		$(this).mouseover(function(i){
			$("div#Tab"+(e+1)).addClass("Selected");
			// Make all the other tabs not 'Selected'
			$('div#DownloadsTabs > div[id!=Tab'+(e+1)+']').removeClass("Selected");
			// Update the downloads tab class to reflect the current tab position WTF??
			$('div#DownloadsTabs').attr("class","threetabs_tab" + (e+1) + "_red_long threetabs_long");
			// Update the gradient container class to reflect the current tab position WTF??
			$('div#DownloadsGradientContainer').attr("class","gradient_threetabs_tab" + (e+1) + "_red_long");

			// Change the content pane
			$('div[class=BannerImage][id!=BannerImage'+(e+1)+']').hide();
			$('div#BannerImage'+(e+1)).show();	
		});

		if (e == 0){
			$(this).wrap("<div class=\"Tab Left Selected\" id=\"Tab" + (e+1) + "\"></div>");
		} else{
			$(this).wrap("<div class=\"Tab Middle\" id=\"Tab" + (e+1) + "\"></div>");
		}
	});
	$("div.Tab").each(function(e){
		$("div#DownloadsTabs").append($(this));
	});
	$("div#DownloadsTabs").after("<div id=\"DownloadsGradientContainer\" class=\"gradient_threetabs_tab1_red_long\"></div><br clear=\"all\"/>");	
	$("div.MainBodyHalf").append($("div.BannerImage, div#BottomPanelHalf"));
}

/**
 * initialises the product carousel
 */
function productCarouselInit(){
	$("#CarouselArea").each(function(i){
		displayCarouselProgressImage('CarouselArea','progress1.gif');
		// * Call the serverside code that returns the product data * //
		$.get(carouselUrl, function(data){		  
			// Create the product array from returned data
			AJAXProductArray = eval(data);
			// Jumping through some hoops here => our main item in the carousel is actually the third item in our array so
			// We pop two items off the end of the array and unshift them onto the front
			AJAXProductArray.unshift(AJAXProductArray.pop());
			AJAXProductArray.unshift(AJAXProductArray.pop());

			// Then dependant on our selectedProductIndex we shift items of the front of the array and push them onto the end
			for ( var i=0, len=selectedProductIndex; i<len; ++i ){
				AJAXProductArray.push(AJAXProductArray.shift());		   
			}
			// * Create products image array * //
			if ( AJAXProductArray.length == 2 || AJAXProductArray.length == 3 |  AJAXProductArray.length == 4 ){				
				var updatedArray = new Array();
				if ( AJAXProductArray.length == 2){
					updatedArray = AJAXProductArray.concat(AJAXProductArray).concat(AJAXProductArray);
					tripleProducts = true;
				} else{
					updatedArray = AJAXProductArray.concat(AJAXProductArray);
					doubleProducts = true;
				}
				AJAXProductArray = updatedArray;
			} 
			for ( var i=0, len=AJAXProductArray.length; i<len; ++i ){
				// * Create the element and assign ID * //
				var tmp = document.createElement("IMG");
				tmp.id = 'productImage' + i;
				tmp.name = 'productImage' + i;
				// * Get the image details for the code * //
				tmp.src = AJAXProductArray[i][1];
				tmp.alt = 'Image for [' + AJAXProductArray[i][0] + ']';
				tmp.title = 'Image for [' + AJAXProductArray[i][0] + ']';
				// * Add default class then determine if we need to add another * //
				tmp.className = 'block';  
				if (i == 2){tmp.className = 'block mainblock';}
				if (i == 0 || i > 3){tmp.className = 'block hiddenblock';}			
				if (i == 0 && len==1){tmp.className = 'block mainblock single';}
				// * assign current index to created IMG element      
				AJAXImageArray[i] = tmp;
				// * Set the last item * //
				lastIdx = i;
				lastItem = tmp;
			}

			var productCounter = selectedProductIndex;
			if (doubleProducts == false && tripleProducts == false ){
				var productTotal = AJAXImageArray.length;
			} else{
				if (doubleProducts == true ) {
					var productTotal = AJAXImageArray.length/2;
				} else{
					var productTotal = AJAXImageArray.length/3;
				}
			}

			// * Clear the progress image * //
			document.getElementById('CarouselArea').innerHTML = '';
			// * Populate carousel DIV with image data * //
			for ( var i=0, len=AJAXProductArray.length; i<len; ++i ){
				document.getElementById('CarouselArea').appendChild(AJAXImageArray[i]);
			}

			$("#Tab1Content").show();
			$("#ProductDescContent > div[id!=Tab1Content]").hide();
			// * Attach next and previous function to appropriate a tags * //
			$("#linkprevious").bind("click",aPrevClick);
			$("#linknext").bind("click",aNextClick);
			// * Supress the default click behaviour (ie don't follow the link) * //
			$("#linkprevious, #linknext").bind("click", function(event){
				event.preventDefault();
			});		
			// Populate selected product
			loadProductData(selectedProductCode);	
		});
	});	
}

function whereToBuyInit(){
}

function productFamilyInit(){	
	var masterCheckboxArray = [];
	// Remove the filter button
	$("#FilterSubmit").hide();
	prodfamilystart();
}
/**************************************************************************************
================================ HTTPHander.js ==================================
***************************************************************************************/
/*  
	FUNCTION
	makeHttpRequest
	DESCRIPTION
	Create an appropriate HTTP Request and runs the specified function on the result. 
	PARAMETERS
	url - url of web file to access for result
	callback_function - local JavaScript function to apply to result of 'url' above
	return_xml - boolean flag determining if result is XML or not
*/
function makeHttpRequest(url, callback_function, return_xml){
	var http_request = false;
	var i; 
	var activex_ids = ['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];

   	if (window.XMLHttpRequest){
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if(http_request.overrideMimeType){
			http_request.overrideMimeType('text/xml');
		}
		} else if (window.ActiveXObject){ 
			for (i = 0; i < activex_ids.length; i++){ 
				try { 
					http_request = new ActiveXObject(activex_ids[i]); 
				} catch (e) {} 
			} 
		}

		if (!http_request) {
			//Don't need to tell user, just don't do AJAX - left in comment for dev clarity.
			//alert('Browser doesn\'t support AJAX.');
			return false;
		}

		// Now we run our designated function with the data returned
		http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				if (return_xml) {
					eval(callback_function + '(http_request.responseXML)');
				} else {
					eval(callback_function + '(http_request.responseText)');
				}
			} else {
				// Don't tell the user - left in comment for dev clarity.
				//alert('There was a problem with the request.(Code: ' + http_request.status + ')');
			}
		}
	}
	http_request.open('GET', url, true);
	http_request.send(null);   
}

/**************************************************************************************
================================ autosuggest.js ==================================
***************************************************************************************/
/*
	FUNCTION
	AutoSuggestControl
	DESCRIPTION
	Creates the autosuggest textbox control from a normal textbox control.
	PARAMETERS
	oTextbox - HTMLInputElement
	oProvider - SuggestionProvider
	NOTES
*/
function AutoSuggestControl(oTextbox , oProvider, layername){    
	/**
	* The currently selected suggestions.
	* @scope private
	*/   
	this.cur /*:int*/ = -1;
	/**
	* The dropdown list layer.
	* @scope private
	*/
	this.layer = null;
	this.layername = layername;
	/**
	* Suggestion provider for the autosuggest feature.
	* @scope private.
	*/
	this.provider /*:SuggestionProvider*/ = oProvider;
	/**
	* The textbox to capture.
	* @scope private
	*/
	this.textbox /*:HTMLInputElement*/ = oTextbox;
	//initialize the control
	this.init();
}

/**
 * Autosuggests one or more suggestions for what the user has typed.
 * If no suggestions are passed in, then no autosuggest occurs.
 * @scope private
 * @param aSuggestions An array of suggestion strings.
 * @param bTypeAhead If the control should provide a type ahead suggestion.
 */
AutoSuggestControl.prototype.autosuggest = function (aSuggestions){    
	//make sure there's at least one suggestion
	if (aSuggestions.length > 0){       
		this.showSuggestions(aSuggestions);
	} else{
		this.hideSuggestions();
	}
};

/**
 * Creates the dropdown layer to display multiple suggestions.
 * @scope private
 */
AutoSuggestControl.prototype.createDropDown = function (){
	var oThis = this;
	//create the layer and assign styles
	//this.layer = document.createElement("div");
	// this.layer = document.getElementById("hiddenPFLayer");
	this.layer = document.getElementById(this.layername);
	this.layer.className = "suggestions";
	this.layer.style.visibility = "hidden";
	this.layer.style.width = this.textbox.offsetWidth;
	//when the user clicks on the a suggestion, get the text (innerHTML)
	//and place it into a textbox
	this.layer.onmousedown = 
	this.layer.onmouseup = 
	this.layer.onmouseover = function (oEvent){
		oEvent = oEvent || window.event;
		oTarget = oEvent.target || oEvent.srcElement;

		if (oEvent.type == "mousedown"){
			oThis.textbox.value = oTarget.firstChild.nodeValue;
			oThis.hideSuggestions();
		} else if (oEvent.type == "mouseover"){
			oThis.highlightSuggestion(oTarget);
		} else{
			oThis.textbox.focus();
		}
	};  
	if (1 == 2){document.body.appendChild(this.layer);}
};

/**
 * Gets the left coordinate of the textbox.
 * @scope private
 * @return The left coordinate of the textbox in pixels.
 */
AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
	var oNode = this.textbox;
	var iLeft = 0;
	while(oNode.tagName != "BODY") {
		iLeft += oNode.offsetLeft;
		oNode = oNode.offsetParent;        
	}
	return iLeft;
};

/**
 * Gets the top coordinate of the textbox.
 * @scope private
 * @return The top coordinate of the textbox in pixels.
 */
AutoSuggestControl.prototype.getTop = function () /*:int*/ {
	var oNode = this.textbox;
	var iTop = 0;

	while(oNode.tagName != "BODY") {
		iTop += oNode.offsetTop;
		oNode = oNode.offsetParent;
	}
	return iTop;
};

/**
 * Handles three keydown events.
 * @scope private
 * @param oEvent The event object for the keydown event.
 */
AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/){
	switch(oEvent.keyCode){
		case 38: //up arrow
		this.previousSuggestion();
		break;
		case 40: //down arrow 
		this.nextSuggestion();
		break;
		case 13: //enter
		this.hideSuggestions();
		break;
	}
};

/**
 * Handles keyup events.
 * @scope private
 * @param oEvent The event object for the keyup event.
 */
AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
	var iKeyCode = oEvent.keyCode;
	//for backspace (8) and delete (46), shows suggestions without typeahead
	if (iKeyCode == 8 || iKeyCode == 46) {
		this.provider.requestSuggestions(this, false);
		//make sure not to interfere with non-character keys
	} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
		//ignore
	} else {
		//request suggestions from the suggestion provider with typeahead
		this.provider.requestSuggestions(this, true);
	}
};

/**
 * Hides the suggestion dropdown.
 * @scope private
 */
AutoSuggestControl.prototype.hideSuggestions = function (){
	this.layer.style.visibility = "hidden";
};

/**
 * Highlights the given node in the suggestions dropdown.
 * @scope private
 * @param oSuggestionNode The node representing a suggestion in the dropdown.
 */
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode){    
	for (var i=0; i < this.layer.childNodes.length; i++) {
		var oNode = this.layer.childNodes[i];
		if (oNode == oSuggestionNode) {
			oNode.className = "current";
		} else if (oNode.className == "current") {
			oNode.className = "";
		}
	}
};

/**
 * Initializes the textbox with event handlers for
 * auto suggest functionality.
 * @scope private
 */
AutoSuggestControl.prototype.init = function (){
	//save a reference to this object
	var oThis = this;
	//assign the onkeyup event handler
	this.textbox.onkeyup = function (oEvent){
		//check for the proper location of the event object
		if (!oEvent) {
			oEvent = window.event;
		} 
		//call the handleKeyUp() method with the event object
		oThis.handleKeyUp(oEvent);
	};
    
	//assign onkeydown event handler
	this.textbox.onkeydown = function (oEvent) {
		//check for the proper location of the event object
		if (!oEvent) {
			oEvent = window.event;
		}
		//call the handleKeyDown() method with the event object
		oThis.handleKeyDown(oEvent);
	};

	//assign onblur event handler (hides suggestions)    
	this.textbox.onblur = function () {
		oThis.hideSuggestions();
	};

	//create the suggestions dropdown
	this.createDropDown();
};

/**
 * Highlights the next suggestion in the dropdown and
 * places the suggestion into the textbox.
 * @scope private
 */
AutoSuggestControl.prototype.nextSuggestion = function () {
	var cSuggestionNodes = this.layer.childNodes;

	if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
		var oNode = cSuggestionNodes[++this.cur];
		this.highlightSuggestion(oNode);
		this.textbox.value = oNode.firstChild.nodeValue; 
	}
};

/**
 * Highlights the previous suggestion in the dropdown and
 * places the suggestion into the textbox.
 * @scope private
 */
AutoSuggestControl.prototype.previousSuggestion = function () {
	var cSuggestionNodes = this.layer.childNodes;
	if (cSuggestionNodes.length > 0 && this.cur > 0) {
		var oNode = cSuggestionNodes[--this.cur];
		this.highlightSuggestion(oNode);
		this.textbox.value = oNode.firstChild.nodeValue;   
	}
};

/**
 * Selects a range of text in the textbox.
 * @scope public
 * @param iStart The start index (base 0) of the selection.
 * @param iLength The number of characters to select.
 */
AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {
	//use text ranges for Internet Explorer
	if (this.textbox.createTextRange) {
		var oRange = this.textbox.createTextRange(); 
		oRange.moveStart("character", iStart); 
		oRange.moveEnd("character", iLength - this.textbox.value.length);      
		oRange.select();
        
		//use setSelectionRange() for Mozilla
	} else if (this.textbox.setSelectionRange) {
		this.textbox.setSelectionRange(iStart, iLength);
	}  
	//set focus back to the textbox
	this.textbox.focus();      
}; 

/**
 * Builds the suggestion layer contents, moves it into position,
 * and displays the layer.
 * @scope private
 * @param aSuggestions An array of suggestions for the control.
 */
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
	var oDiv = null;
	this.layer.innerHTML = "";  //clear contents of the layer

	for (var i=0; i < aSuggestions.length; i++) {
		oDiv = document.createElement("div");
		oDiv.appendChild(document.createTextNode(aSuggestions[i]));
		this.layer.appendChild(oDiv);
	}
	this.layer.style.left = this.getLeft() + "px";
	this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
	this.layer.style.visibility = "visible";
};

/* SUGGESTION CODE */
/**
 * Populate the autosuggest control with suggestions. 
 * @scope protected
 * @param pSuggestions (Array) : suggestion data elements.
 */
 function ProductSuggestions(pSuggestions) {
	//this.products = ["DIR-655", "DIR-350", "DIR-100", "DLX-655","DLX-355", "DLX-350", "DLX-100"];
	this.products = pSuggestions;  
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
ProductSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/) {
	var aSuggestions = [];
	var sTextboxValue = oAutoSuggestControl.textbox.value;
	if (sTextboxValue.length > 0){
		// If there are no products defined (for any reason) then don't error, just don't show anything
		if (!this.products){return;}
		//search for matching products
		for (var i=0; i < this.products.length; i++) {		
			var s1 = this.products[i].toLowerCase();

			if (s1.indexOf(sTextboxValue.toLowerCase()) >= 0) {
				aSuggestions.push(this.products[i]);
			} 
		}
	}
	//provide suggestions to the control
	oAutoSuggestControl.autosuggest(aSuggestions);
};

/**************************************************************************************
================================ wheretobuyfilter.js ==================================
***************************************************************************************/
/***
* Submit the form 
*/
function wheretobuy_filter_results(){
	var form = document.getElementById('whereToBuySearch');
	var elements = form.elements;
	var resetValue = false;
	for (var elem, i = 0; ( elem = elements[i] ); i++) {
		if (resetValue) {
			elem.value = '*';
		}
		if (elem.type == 'select-one' && elem.name.indexOf('pack:WhereToBuy') == 0 && elem.value == "*") {
			resetValue = true;
		}
	}
	form.submit();
}
