//Regatta Global Javascript Functions

// General Website Functions

// 2010
var baseHref = "";
var menuImageArray = new Array(10);

	function clearText(elementId,textValue)
	{
		if(document.getElementById(elementId).value == textValue)
		{
			document.getElementById(elementId).value = "";
		}
	}

	function productSearch(fieldId)
	{
		if(elementExists(fieldId))
		{
			if(document.getElementById(fieldId).value != "")
			{
				document.location.href="product-search.asp?srchtrm=" + document.getElementById(fieldId).value;
			}
		}
	}

	function swapBrandListsContent(brandListId,elementId,intLoopCount,strItemLink)
	{
		for(i=0; i < intLoopCount; i++)
		{
			//document.getElementById("BrandListListPanel"+i).innerHTML="";
		}
		var arrItem = eval("arrBrandList"+brandListId+"["+elementId+"]");
		var arrItemList = arrItem.split(",");
		var strBrandListToDisplay = "";
		
		for(i= 0; i < arrItemList.length; i++)
		{
			strBrandListToDisplay += "<p><a href='"+strItemLink+"&amp;bnd="+arrItemList[i].replace(" ", "")+"'>"+arrItemList[i]+"<\/a><\/p>";
		}
		
		//document.getElementById("BrandListListPanel"+brandListId).innerHTML="<p>"+arrItem.replace(/,/g, "</p><p>")+"</p>";
//alert(strBrandListToDisplay);
//alert(document.getElementById("BrandListListPanel"+brandListId).innerHTML);
//alert("BrandListListPanel"+brandListId);

		var elementExists = document.getElementById("BrandListListPanel"+brandListId);
		if (elementExists != null)
		{
//alert("Found Element "+brandListId);
//document.getElementById("BrandListListPanel"+brandListId).parentNode.innerHTML = strBrandListToDisplay;
			document.getElementById("BrandListListPanel"+brandListId).innerHTML=strBrandListToDisplay;
		}

		//document.getElementById("BrandListListPanel"+brandListId).innerHTML=strBrandListToDisplay;
	}

	function toggleReviews(whichTab)
	{
		if(whichTab == "reviews")
		{
			swapImages('product_topbox','images/product_page/product_topbox2.jpg');
			document.getElementById("product_wrapper").className="hideMe";
			document.getElementById("product_reviews_wrapper").className="showMe";
			document.getElementById("product_header").className = "product"
		}
		
		if(whichTab == "product"){
			swapImages('product_topbox','images/product_page/product_topbox1.jpg');
			document.getElementById("product_wrapper").className="showMe";
			document.getElementById("product_reviews_wrapper").className="hideMe";
			document.getElementById("product_header").className = "review"
		}
		
	}

	function replace_html(el, html) {
		if( el ) {
					var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
					var newEl = document.createElement(oldEl.nodeName);
	
					// Preserve any properties we care about (id and class in this example)
					newEl.id = oldEl.id;
					newEl.className = oldEl.className;
	
					//set the new HTML and insert back into the DOM
					newEl.innerHTML = html;
					if(oldEl.parentNode)
						oldEl.parentNode.replaceChild(newEl, oldEl);
					else
					oldEl.innerHTML = html;
	
					//return a reference to the new element in case we need it
					return newEl;
		}
	}

function elementExists(elementId)
{
	var elementExists = document.getElementById(elementId);
		if (elementExists != null)
		{
			elementExists = true;
		}else{
			elementExists = false;	
		}
		return elementExists;
}

	//function showPanel(i,intLoopCount,strLanguageSuffix)
	function showPanel(whichPanel,intLoopCount,strLanguageSuffix,i)
	{
		if(elementExists("genderPanel_mens"+strLanguageSuffix)){document.getElementById("genderPanel_mens"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_womens"+strLanguageSuffix)){document.getElementById("genderPanel_womens"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_boys"+strLanguageSuffix)){document.getElementById("genderPanel_boys"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_girls"+strLanguageSuffix)){document.getElementById("genderPanel_girls"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_kids"+strLanguageSuffix)){document.getElementById("genderPanel_kids"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_footwear"+strLanguageSuffix)){document.getElementById("genderPanel_footwear"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_equipment"+strLanguageSuffix)){document.getElementById("genderPanel_equipment"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_stockists"+strLanguageSuffix)){document.getElementById("genderPanel_stockists"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_contact"+strLanguageSuffix)){document.getElementById("genderPanel_contact"+strLanguageSuffix).style.display="none";}
		var imgLocation, menuItem;
		for(n=0; n <= intLoopCount; n++)
		{
			// alert(n);
			//document.getElementById("genderPanel_"+n).style.display="none";
			imgLocation = baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'1'+strLanguageSuffix+'.jpg'
			//imgLocation = baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'1'+strLanguageSuffix+'.jpg'
			menuItem = 'menuItem'+n;
			swapImages(menuItem,imgLocation);
			//swapImages(imgLocation,imgLocation,i);
		}
		if(whichPanel.toLowerCase() != "stockists")
		{
			imgLocation = baseHref + 'images/navigation/locator1'+strLanguageSuffix+'.jpg'
			menuItem = 'menuItem'+(n+3);
			swapImages(menuItem,imgLocation);
		}
		
		document.getElementById("genderPanel_"+whichPanel+strLanguageSuffix).style.display="block";
		//imgLocation = baseHref + 'images/navigation/'+menuImageArray[i].toLowerCase().replace("equipment", "rucksacks")+'3'+strLanguageSuffix+'.jpg';
		imgLocation = baseHref + 'images/navigation/'+whichPanel.toLowerCase().replace("equipment", "rucksacks")+'3'+strLanguageSuffix+'.jpg';
		swapImages(i,imgLocation);

		//var closer = setTimeout("hidePanel("+i+")",10000);
		var closer = setTimeout("hidePanels('"+strLanguageSuffix+"')",10000);
	}
	
	function hidePanel(z,strLanguageSuffix)
	{
		document.getElementById("genderPanel_"+z).style.display="none";
		imgLocation = baseHref + 'images/navigation/'+menuImageArray[z].toLowerCase().replace("equipment", "rucksacks")+'1'+strLanguageSuffix+'.jpg'
		menuItem = 'menuItem'+n;
	}

	function hidePanels(strLanguageSuffix){
		if(elementExists("genderPanel_mens"+strLanguageSuffix)){document.getElementById("genderPanel_mens"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_womens"+strLanguageSuffix)){document.getElementById("genderPanel_womens"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_boys"+strLanguageSuffix)){document.getElementById("genderPanel_boys"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_girls"+strLanguageSuffix)){document.getElementById("genderPanel_girls"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_kids"+strLanguageSuffix)){document.getElementById("genderPanel_kids"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_footwear"+strLanguageSuffix)){document.getElementById("genderPanel_footwear"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_equipment"+strLanguageSuffix)){document.getElementById("genderPanel_equipment"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_stockists"+strLanguageSuffix)){document.getElementById("genderPanel_stockists"+strLanguageSuffix).style.display="none";}
		if(elementExists("genderPanel_contact"+strLanguageSuffix)){document.getElementById("genderPanel_contact"+strLanguageSuffix).style.display="none";}
		/*
		var imgLocation, menuItem;
		for(n=0; n <= menuImageArray.length; n++)
		{
			var elementExists = document.getElementById("genderPanel_"+n);
			if (elementExists != null)
			{
				document.getElementById("genderPanel_"+n).style.display="none";
				imgLocation = baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'1'+strLanguageSuffix+'.jpg'
				menuItem = 'menuItem'+n;
				swapImages(menuItem,imgLocation);
			}
		}
		*/
	}

	function submitForm(strFormId)
	{
		if(strFormName !="")
		{
			document.getElementById(strFormId).submit();
		}
	}
	function movePage(pageNum)
	{
		document.getElementById("page").value=pageNum;
		document.getElementById("product-search-results-form").submit();
	}

	
	function submitForm(strFormName)
	{
		if(strFormName !="")
		{
			//document.getElementById(strFormName).submit();
			eval("document.forms."+strFormName).submit();
		}
	}
	function movePage(pageNum,frmName)
	{
		document.getElementById("page").value=pageNum;
		document.getElementById(frmName).submit();
	}

	function filterSearch()
	{
		var FilterProduct = "";
		//FilterProduct = document.getElementsByName("FilterProduct").value;
		//document.location.href="product-search.asp?gdr=<%=strGender%>&cgi=<%=strCatGroupId%>&bnd=<%=strBrand%>&page=1&FilterProduct=" + FilterProduct;
		
		//setCookie('menuState',stateToFromStr('someID'));
		
		document.forms.frmProductFilter.submit();
	}
	
//--------------------------------------------------------------------------------------------//

function pageRelocateTo(goToPage)
{
	if(goToPage != ""){
		document.location.href = goToPage;	
	}	
}

//--Check for valid Email Address
function checkemailaddress(inputbox){

	var teststring 
	teststring = inputbox.toString()

	if(inputbox == ""){
		return 1002
	}

	if(teststring.length <= 6){
		return 1002
	}

	var illegalchrs = new Array("*","£","$","!")
	var counter
	
	for(counter=0;counter<=illegalchrs.length;counter++){
		if(teststring.indexOf(illegalchrs[counter]) != -1){
			return 1002
		}
	}

	var atpositionback = teststring.lastIndexOf("@")
	var dotpositionback = teststring.lastIndexOf(".")
	var atpositionfront = teststring.indexOf("@")

	if(atpositionback == -1){
		return 1002
	}

	if(dotpositionback == -1){
		return 1002
	}

	if(atpositionfront != atpositionback){
		return 1002
	}

	if(atpositionback > dotpositionback){
		return 1002
	}

	return 0
}

/*Image PreLoader*/
	function loadImages(imageArray)
	{
		var p=imageArray.length;
		var preLoad = new Array();
		for (i=0; i<p; i++)
		{
			preLoad[i] = new Image();
			preLoad[i].src = imageArray[i];
		}
	}
	
/*IMAGE SWAP*/
	function swapImages(elementId,imageSource)
	{

		var elementExists = document.getElementById(elementId);
		if (elementExists != null)
		{
			document.getElementById(elementId).src = imageSource;
		}
	}

/*show / hide layer*/
	function showHideContent(divid)
	{

		if(document.getElementById(divid).style.display == '')
		{
			document.getElementById(divid).style.display = 'none';
		}else{
			document.getElementById(divid).style.display = '';
		}

	}

/*Relocate*/
	function relocate(url)
	{
		if(url !="")
		{
			document.location.href = url;
		}
	}
/*SET FOCUS*/
	function setFocus(elementId)
	{
		var elementExists = document.getElementById(elementId);
		if (elementExists != null)
		{
				document.getElementById(elementId).focus();
		}
	}
    
/*VALIDATORS*/
	function checkForm(fieldString)
	{ 
			
		if(fieldString != "")
		{
			var dottedLine = "---------------------------------------\n";
			var alertMessage = dottedLine;
			alertMessage += " Please complete the following information\n";
			alertMessage += dottedLine;
			var originalAlert = alertMessage;
			var fieldArray = fieldString.split("^");
			var firstFieldToFocus = "";
			for(f = 0; f < fieldArray.length; f++)
			{
				if(document.getElementById(fieldArray[f]).value == "" || document.getElementById(fieldArray[f]).value == fieldArray[f])
				{
					alertMessage += "\n ** " + fieldArray[f].replace("_", " ");
					if(firstFieldToFocus == "")
					{
						firstFieldToFocus = fieldArray[f];
					}
				}
			}
			
			if(alertMessage != originalAlert)
			{
				alertMessage += "\n\n" + dottedLine;
				alert(alertMessage);
				setFocus(firstFieldToFocus);
				return false;
			}
			
		}else{
			return false;
		}
	}

// Cascading Navigation Menu
//--------------------------------------------------------------------------------------------//

// Get Browser Width
function getViewportWidth () {
    var viewportWidth;
    if (typeof window.innerWidth != 'undefined'){
        viewportWidth = window.innerWidth
    }else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){
        viewportWidth = document.documentElement.clientWidth
    }else{
        viewportWidth = document.getElementsByTagName('body')[0].clientWidth
    }
	return viewportWidth;
}

//----------------------------------------
// TEMPORARY TESTING
// Navigation Drop-Downs 
function showProductClasses1 () {
	menuLeft = Math.round((getViewportWidth()/2)-280);
	menuLeft = menuLeft + 105;
	x = document.getElementById("products_home1");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("product_classes1");	
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideProductClasses1 () {
	x = document.getElementById("products_home1");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("product_classes1");
	x.style.visibility = 'hidden';			
}

function showCommunityPages1 () {
	menuLeft = Math.round((getViewportWidth()/2)+220);
	menuLeft = menuLeft + 34;
	x = document.getElementById("community_home1");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("community_pages1");	
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideCommunityPages1 () {
	x = document.getElementById("community_home1");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("community_pages1");
	x.style.visibility = 'hidden';			
}


function showProductRanges1 (pClass) {
	x = document.getElementById(pClass + "_home1");
	x.style.color = "#FFFFFF";		
    x.style.backgroundColor = "#73c2ec";	
	x = document.getElementById(pClass + "_ranges1");	
	x.style.visibility = 'visible';	
}

function hideProductRanges1 (pClass) {
	x = document.getElementById(pClass + "_home1");
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "";		
	x = document.getElementById(pClass + "_ranges1");	
	x.style.visibility = 'hidden';			
}

function showProductTypes1 (pClass, pRange) {
	x = document.getElementById(pClass + "_" + pRange + "_home1");
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "#73c2ec";	
	x = document.getElementById(pClass + "_" + pRange +  "_types1");	
	x.style.visibility = 'visible';		
	
}

function hideProductType1s1 (pClass, pRange) {	
	x = document.getElementById(pClass + "_" + pRange + "_home1");	
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "";	
	x = document.getElementById(pClass + "_" + pRange +  "_types1");	
	x.style.visibility = 'hidden';	
}
//----------------------------------------
var strLanguage = '<%=session("strLanguage")%>';
// Navigation Drop-Downs 
function showProductClasses () {
	menuLeft = 0;
	menuLeft = Math.round((getViewportWidth()/2)-280);
	
	if(strLanguage == "ESP"){
		menuLeft = menuLeft + 400;
		}else{
			menuLeft = menuLeft + 105;
			}
	x = document.getElementById("products_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("product_classes");	
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideProductClasses () {
	x = document.getElementById("products_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("product_classes");
	x.style.visibility = 'hidden';			
}

function showCommunityPages () {
	menuLeft = 0;
	menuLeft = Math.round((getViewportWidth()/2)+220);
	menuLeft = menuLeft + 34;
	x = document.getElementById("community_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("community_pages");	
	x.style.left = "0px";
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideCommunityPages () {
	x = document.getElementById("community_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("community_pages");
	x.style.visibility = 'hidden';			
}

function showContactPages () {
	menuLeft = 0;
	menuLeft = Math.round((getViewportWidth()/2)+320);
	menuLeft = menuLeft + 41;
	x = document.getElementById("contact_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("contact_pages");	
	x.style.left = "0px";
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideContactPages () {
	x = document.getElementById("contact_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("contact_pages");
	x.style.visibility = 'hidden';			
}

function showStockistPages () {
	menuLeft = 0;
	menuLeft = Math.round((getViewportWidth()/2) -108);
	menuLeft = menuLeft + 41;
	x = document.getElementById("stockists_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "#73c2ec";
	x = document.getElementById("stockists_pages");	
	x.style.left = "0px";
	x.style.left = menuLeft + "px";
	x.style.visibility = 'visible';	
}

function hideStockistPages () {
	x = document.getElementById("stockists_home");
	x.style.color = "#666666";
	x.style.backgroundColor = "";	
    x = document.getElementById("stockists_pages");
	x.style.visibility = 'hidden';			
}


function showProductRanges (pClass) {
	x = document.getElementById(pClass + "_home");
	x.style.color = "#FFFFFF";		
    x.style.backgroundColor = "#73c2ec";	
	x = document.getElementById(pClass + "_ranges");	
	x.style.visibility = 'visible';	
}

function hideProductRanges (pClass) {
	x = document.getElementById(pClass + "_home");
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "";		
	x = document.getElementById(pClass + "_ranges");	
	x.style.visibility = 'hidden';			
}

function showProductTypes (pClass, pRange) {
	x = document.getElementById(pClass + "_" + pRange + "_home");
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "#73c2ec";	
	x = document.getElementById(pClass + "_" + pRange +  "_types");	
	x.style.visibility = 'visible';		
	
}

function hideProductTypes (pClass, pRange) {	
	x = document.getElementById(pClass + "_" + pRange + "_home");	
	x.style.color = "#FFFFFF";	
	x.style.backgroundColor = "";	
	x = document.getElementById(pClass + "_" + pRange +  "_types");	
	x.style.visibility = 'hidden';	
}

// Landing Pages Image Montage Roll-overs
//--------------------------------------------------------------------------------------------//

function tileHoverOver (tileID) {
//	x = document.getElementById("tile_" + tileID + "_back");	
//	x.className = "tile_back_1";
//	x = document.getElementById("tile_" + tileID + "_img");	
//	x.className = "tile_img_1";	
  	x = document.getElementById("tile_" + tileID + "_text");
	x.style.visibility = 'visible';		
}

function tileHoverBack (tileID) {
//	x = document.getElementById("tile_" + tileID + "_back");	
//	x.className = "tile_back_0";
//	x = document.getElementById("tile_" + tileID + "_img");	
//	x.className = "tile_img_0";		
  	x = document.getElementById("tile_" + tileID + "_text");
	x.style.visibility = 'hidden';			
}

//function tileHoverOver4Row()
//{
//	document.getElementById("tile_c2r1_4row").style.visibility = 'visible';
//}

//function tileHoverBack4Row()
//{
//	document.getElementById("tile_c2r1_4row").style.visibility = 'hidden';
//}

// Map rollovers
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
		
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
// Map rollovers



// Flag Roll-overs
//--------------------------------------------------------------------------------------------//

function flagOver (flagID) {
    document.getElementById(flagID).src = "../images/flags/" + flagID + "1.jpg";
}

function flagBack (flagID) {
	document.getElementById(flagID).src = "../images/flags/" + flagID + "2.jpg";			
}

//--------------------------------------------------------------------------------------------//

// Name of Code Search
function clearText (divid) {
    document.getElementById(divid).value = "";	
}

function SwopColour(ProductRef,Colour,ColourCode){
document.ProductDetail.MainPicture.src = ProductRef + "-" + ColourCode + "-d.jpg"
document.ProductDetail.CurrentColourCode.value = ColourCode
document.ProductDetail.CurrentColourName.value = Colour
}

var newWindow1 = null;
var newWindow2 = null;
var newWindow3 = null;
var newWindow5 = null;

function OpenWindow1(Item){
	URL = "product-zoom.asp?" + Item
   if(!newWindow1 || newWindow1.closed)	{
        newWindow1 = window.open(URL,"subwin1","height=680,width=530,toolbars=no,status=no,scrollbars=no");
        newWindow1.focus();
   }else{
        newWindow1.close();
        newWindow1 = window.open(URL,"subwin1","height=680,width=530,toolbars=no,status=no,scrollbars=no");
        newWindow1.focus();
   }
}

function OpenWindow2(Item){
	URL = "product-features.asp?" + Item
   if(!newWindow2 || newWindow2.closed)	{
        newWindow2 = window.open(URL,"subwin2","height=450,width=350,toolbars=no,status=no,scrollbars=no");
        newWindow2.focus();
   }else{
        newWindow2.close();
        newWindow2 = window.open(URL,"subwin2","height=450,width=350,toolbars=no,status=no,scrollbars=no");
        newWindow2.focus();
   }
}

function OpenWindow3(Item){
	URL = Item
   if(!newWindow3 || newWindow3.closed)	{
        newWindow3 = window.open(URL,"subwin3","height=700,width=700,toolbars=no,status=no,scrollbars=yes");
        newWindow3.focus();
   }else{
        newWindow3.close();
        newWindow3 = window.open(URL,"subwin3","height=700,width=700,toolbars=no,status=no,scrollbars=yes");
        newWindow3.focus();
   }
}

function OpenWindow5(Item){
	URL = Item
   if(!newWindow5 || newWindow5.closed)	{
        newWindow5 = window.open(URL,"subwin5","height=600,width=800,resizable=1,toolbars=yes,status=no,scrollbars=yes");
        newWindow5.focus();
   }else{
        newWindow5.close();
        newWindow5 = window.open(URL,"subwin5","height=600,width=800,resizable=1,toolbars=yes,status=no,scrollbars=yes");
        newWindow5.focus();
   }
}

function addtowishlist(ProductCode, ProductRefNo, ProductName){
	alert ("The " + ProductName + " in colour " + document.ProductDetail.CurrentColourName.value + " has been added to your Wishlist");
	document.location.href = "product-wishlist-add.asp?Code=" + ProductCode + "&ColourCode=" + document.ProductDetail.CurrentColourCode.value + "&ColourName=" +  document.ProductDetail.CurrentColourName.value + "&ProductRefNo=" + ProductRefNo + "&ProductName=" + ProductName;
}

/*DEFAULT PAGE ONLOAD*/

/*
var pageOnload = "<%=strOnload%>";

if (window.onload) {
	var func = window.onload;
	window.onload = function() {
		func();
		if(pageOnload != "")
		{
			eval(pageOnload);
		}
	}
} else {
	window.onload = function() {
		if(pageOnload != "")
		{
			eval(pageOnload);
		}
	};
}
*/

function Checkform1(){
	if (document.ENTRY.Surname.value== "" || document.ENTRY.Surname.value== " "){
	     alert ("<%=strErrorMessage015%>")
	     document.ENTRY.Surname.focus();
	     return false;
	}
	if (document.ENTRY.Address1.value== "" || document.ENTRY.Address1.value== " "){
	     alert ("<%=strErrorMessage022%>")
	     document.ENTRY.Address1.focus();
	     return false;
	}
	if (document.ENTRY.Postcode.value== "" || document.ENTRY.Postcode.value== " "){
	     alert ("<%=strErrorMessage023%>")
	     document.ENTRY.Postcode.focus();
	     return false;
	}
	if (document.ENTRY.Telephone.value== "" || document.ENTRY.Telephone.value== " "){
	     alert ("<%=strErrorMessage024%>")
	     document.ENTRY.Telephone.focus();
	     return false;
	}
	if (document.ENTRY.Email.value== "" || document.ENTRY.Email.value== " "){
	     alert ("<%=strErrorMessage017%>")
	     document.ENTRY.Email.focus();
	     return false;
	}
	if(checkemailaddress(document.ENTRY.Email.value)!=0){
		alert("<%=strErrorMessage021%>");
		document.ENTRY.Email.focus();
		return false;
	}
}

function CheckImageForm(){
	if (document.galleryupload.Forename.value== "" || document.galleryupload.Forename.value== " "){
	     alert ("<%= strErrorMessage014%>")
	     document.galleryupload.Forename.focus();
	     return false;
	}
	if (document.galleryupload.Surname.value== "" || document.galleryupload.Surname.value== " "){
	     alert ("<%= strErrorMessage015%>")
	     document.galleryupload.Surname.focus();
	     return false;
	}
	if (document.galleryupload.Town.value== "" || document.galleryupload.Town.value== " "){
	     alert ("<%= strErrorMessage016%>")
	     document.galleryupload.Town.focus();
	     return false;
	}
	if (document.galleryupload.Filename.value== "" || document.galleryupload.Filename.value== " "){
	     alert ("<%= strErrorMessage019%>")
	     document.galleryupload.Filename.focus();
	     return false;
	}
	if (document.galleryupload.Email.value== "" || document.galleryupload.Email.value== " "){
	     alert ("<%= strErrorMessage017%>")
	     document.galleryupload.Email.focus();
	     return false;
	}
	if(checkemailaddress(document.galleryupload.Email.value)!=0){
		alert("<%= strErrorMessage021%>");
		document.galleryupload.Email.focus();
		return false;
		}
	if (document.galleryupload.ConfirmEmail.value != document.galleryupload.Email.value){
	     alert ("<%= strErrorMessage018%>")
	     document.galleryupload.Email.focus();
	     return false;
	}
	if (document.galleryupload.Agree[0].checked){
		}else{
	     alert ("<%= strErrorMessage020%>")
	     return false;
	}
	if (document.galleryupload.Info[0].checked || document.galleryupload.Info[1].checked){
		return true;
	}else{
	     alert ("<%=strPrompt329 & ", " & strPrompt330%>")
	     return false;
	}
	alert ("<%= strPrompt444%>");
}



function BlankField(){
var DefaultValue = "<%=strPrompt400%>"
	if(document.RightHandSearch.ProductSearchName.value== DefaultValue){
		document.RightHandSearch.ProductSearchName.value = ""
		document.RightHandSearch.ProductSearchName.focus();
	}
}

function CheckSearchField(){
	if(document.RightHandSearch.ProductSearchName.value== ""){
		document.RightHandSearch.ProductSearchName.value = " "
	}
}	 

function ProductSearch(){
	Searchclass = document.TopSearch.SearchProduct.value;
	Searchtype = document.TopSearch.SearchType.value;
	document.location.href = "ProductTypeSpecific.asp?SearchType=" + Searchtype + "&Searchclass=" + Searchclass
}

function StockistCountyList(){
	document.location.href='stockist-county.asp?County=' + document.getElementById("county").value;
}

function SubmitImageForm(){
	document.galleryupload.submit();
}

function ChangeCategory(){
	document.ENTRY.Category.value = document.ENTRY.CategorySelect.value
	document.ENTRY.submit();
}

var newMapWindow = null;

function OpenMapWindow(postalcode){
	url = 'stockist-map-popup.asp?PostCode=' + postalcode

	if(!newMapWindow || newMapWindow.closed)	{
		newMapWindow = window.open(url, "mapwin", "height=380, width=355, toolbars=no, status=no, scrollbars=no, resizable=yes");
		newMapWindow.focus();
	}else{
		newMapWindow.close();
		newMapWindow = window.open(url, "mapwin", "height=380, width=355, toolbars=no, status=no, scrollbars=no, resizable=yes");
		newMapWindow.focus();
	}
}

function checkHeadSearch(){

	//alert("Hello: " + document.head_search.button1.value);
	//alert(document.head_search.go1.value);
	return false;
	
		
}

    function StockistPostcode(){
		var postcodeValue = document.getElementById("postcode").value;
	    if (postcodeValue == "" || postcodeValue == " " || postcodeValue == "Enter your postcode"){
		    alert ("Please enter your Postcode for this search")
		    document.getElementById("postcode").focus();
		    return false
		}else{
			document.getElementById("stockistInputForm").action = "regatta-store-locator-by-postcode.asp?"; //Postcode=" + postcodeValue;
			//document.location.href='regatta-store-locator-by-postcode.asp?Postcode=' + postcodeValue;
	    }	
    }

	function StockistCountyList(){
		document.location.href='regatta-store-locator-by-county.asp?County=' + document.getElementById("county").value;
	}

/*--------------------------------------------------------------------
ONLOAD EVENTS
--------------------------------------------------------------------*/

	//onpreload
	var strImages = "";
/*
strImages += baseHref + 'images/navigation/home.jpg,';
	strImages += baseHref + 'images/navigation/home2.jpg,';
	strImages += baseHref + 'images/navigation/home3.jpg,';
	strImages += baseHref + 'images/navigation/mens.jpg,';
	strImages += baseHref + 'images/navigation/mens2.jpg,';
	strImages += baseHref + 'images/navigation/mens3.jpg,';
	strImages += baseHref + 'images/navigation/womens.jpg,';
	strImages += baseHref + 'images/navigation/womens2.jpg,';
	strImages += baseHref + 'images/navigation/womens3.jpg,';
	strImages += baseHref + 'images/navigation/kids.jpg,';
	strImages += baseHref + 'images/navigation/kids2.jpg,';
	strImages += baseHref + 'images/navigation/kids3.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3.jpg,';
	strImages += baseHref + 'images/navigation/locator1.jpg,';
	strImages += baseHref + 'images/navigation/locator2.jpg,';
	strImages += baseHref + 'images/navigation/locator3.jpg';

	strImages += baseHref + 'images/navigation/home_d.jpg,';
	strImages += baseHref + 'images/navigation/home2_d.jpg,';
	strImages += baseHref + 'images/navigation/home3_d.jpg,';
	strImages += baseHref + 'images/navigation/mens_d.jpg,';
	strImages += baseHref + 'images/navigation/mens2_d.jpg,';
	strImages += baseHref + 'images/navigation/mens3_d.jpg,';
	strImages += baseHref + 'images/navigation/womens_d.jpg,';
	strImages += baseHref + 'images/navigation/womens2_d.jpg,';
	strImages += baseHref + 'images/navigation/womens3_d.jpg,';
	strImages += baseHref + 'images/navigation/kids_d.jpg,';
	strImages += baseHref + 'images/navigation/kids2_d.jpg,';
	strImages += baseHref + 'images/navigation/kids3_d.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1_d.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2_d.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3_d.jpg,';
	strImages += baseHref + 'images/navigation/locator1_d.jpg,';
	strImages += baseHref + 'images/navigation/locator2_d.jpg,';
	strImages += baseHref + 'images/navigation/locator3_d.jpg';
	
	strImages += baseHref + 'images/navigation/home_es.jpg,';
	strImages += baseHref + 'images/navigation/home2_es.jpg,';
	strImages += baseHref + 'images/navigation/home3_es.jpg,';
	strImages += baseHref + 'images/navigation/mens_es.jpg,';
	strImages += baseHref + 'images/navigation/mens2_es.jpg,';
	strImages += baseHref + 'images/navigation/mens3_es.jpg,';
	strImages += baseHref + 'images/navigation/womens_es.jpg,';
	strImages += baseHref + 'images/navigation/womens2_es.jpg,';
	strImages += baseHref + 'images/navigation/womens3_es.jpg,';
	strImages += baseHref + 'images/navigation/kids_es.jpg,';
	strImages += baseHref + 'images/navigation/kids2_es.jpg,';
	strImages += baseHref + 'images/navigation/kids3_es.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1_es.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2_es.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3_es.jpg,';
	strImages += baseHref + 'images/navigation/locator1_es.jpg,';
	strImages += baseHref + 'images/navigation/locator2_es.jpg,';
	strImages += baseHref + 'images/navigation/locator3_es.jpg';
	
	strImages += baseHref + 'images/navigation/home_fr.jpg,';
	strImages += baseHref + 'images/navigation/home2_fr.jpg,';
	strImages += baseHref + 'images/navigation/home3_fr.jpg,';
	strImages += baseHref + 'images/navigation/mens_fr.jpg,';
	strImages += baseHref + 'images/navigation/mens2_fr.jpg,';
	strImages += baseHref + 'images/navigation/mens3_fr.jpg,';
	strImages += baseHref + 'images/navigation/womens_fr.jpg,';
	strImages += baseHref + 'images/navigation/womens2_fr.jpg,';
	strImages += baseHref + 'images/navigation/womens3_fr.jpg,';
	strImages += baseHref + 'images/navigation/kids_fr.jpg,';
	strImages += baseHref + 'images/navigation/kids2_fr.jpg,';
	strImages += baseHref + 'images/navigation/kids3_fr.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1_fr.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2_fr.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3_fr.jpg,';
	strImages += baseHref + 'images/navigation/locator1_fr.jpg,';
	strImages += baseHref + 'images/navigation/locator2_fr.jpg,';
	strImages += baseHref + 'images/navigation/locator3_fr.jpg';
	
	strImages += baseHref + 'images/navigation/home_nl.jpg,';
	strImages += baseHref + 'images/navigation/home2_nl.jpg,';
	strImages += baseHref + 'images/navigation/home3_nl.jpg,';
	strImages += baseHref + 'images/navigation/mens_nl.jpg,';
	strImages += baseHref + 'images/navigation/mens2_nl.jpg,';
	strImages += baseHref + 'images/navigation/mens3_nl.jpg,';
	strImages += baseHref + 'images/navigation/womens_nl.jpg,';
	strImages += baseHref + 'images/navigation/womens2_nl.jpg,';
	strImages += baseHref + 'images/navigation/womens3_nl.jpg,';
	strImages += baseHref + 'images/navigation/kids_nl.jpg,';
	strImages += baseHref + 'images/navigation/kids2_nl.jpg,';
	strImages += baseHref + 'images/navigation/kids3_nl.jpg,';
	strImages += baseHref + 'images/navigation/getintouch1_nl.jpg,';
	strImages += baseHref + 'images/navigation/getintouch2_nl.jpg,';
	strImages += baseHref + 'images/navigation/getintouch3_nl.jpg,';
	strImages += baseHref + 'images/navigation/locator1_nl.jpg,';
	strImages += baseHref + 'images/navigation/locator2_nl.jpg,';
	strImages += baseHref + 'images/navigation/locator3_nl.jpg';
*/	
	menuImageArray = strImages.split(",");

	for(n=0; n < menuImageArray.length; n++)
		{
			if(menuImageArray[n] != undefined)
			{
				strImages += baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'1.jpg,';
				strImages += baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'2.jpg,';
				strImages += baseHref + 'images/navigation/'+menuImageArray[n].toLowerCase().replace("equipment", "rucksacks")+'3.jpg';
				if(n<17){strImages +=","};
			}
		}
	loadImages(strImages);
	
//window.onload=function(){
/*
	compactMenu('someID',true,'&plusmn; Product');
	//stateToFromStr('someID',retrieveCookie('menuState'));
				
	compactMenu('someID2',true,'&plusmn; Range');
	//stateToFromStr('someID2',retrieveCookie('menuState'));
	
	compactMenu('someID3',true,'&plusmn; Price');
	//stateToFromStr('someID2',retrieveCookie('menuState'));
	
	compactMenu('someID4',true,'&plusmn; Colour');
	//stateToFromStr('someID2',retrieveCookie('menuState'));
	
	compactMenu('someID5',true,'&plusmn; Material');
	//stateToFromStr('someID2',retrieveCookie('menuState'));
*/
//}

function ChangePostcodeSelection(){
if (document.stockistInputForm.Country != document.stockistInputForm.CurrentCountry){
     if (document.stockistInputForm.CurrentCountry.value == 'Osterreich'){
        var elSel = document.getElementById('postcode');
        elSel.options[9]=new Option("Postleitzahlenbereich 0...", "0")

       // var elOptNew = document.createElement('option');
       // elOptNew.text = 'Postleitzahlenbereich 0...';
       // elOptNew.value = '9';
       // elSel.add(elOptNew);
        document.stockistInputForm.CurrentCountry.value = 'Deutschland';
    }else{
       var elSel = document.getElementById('postcode');
       elSel.remove(9);
       document.stockistInputForm.CurrentCountry.value = 'Osterreich';
    }
 }
 }