<!--
//------------------------------------------------------------
//------------------- Config ---------------------------------
//------------------------------------------------------------
/*
var currentDomain = document.domain;
if (currentDomain=="localhost") {

	var secureCheckout = 'http://localhost:2500/duckanddive/nas/checkout.asp?bs=';
	
}else{

	var secureCheckout = "https://www.verysecuresites.net/duckanddive/nas/checkout.asp?bs=";
}

function domainInfo(){alert(currentDomain);}
*/

var checkoutURL = '/store/placeOrder.asp?';

//------------------------------------------------------------
//------------------- general --------------------------------
//------------------------------------------------------------
function showPopup( url, w, h, offsetX, offsetY, rsze, scr ){
	var winLeft = (screen.width / 2) - (w/2);
	var winTop = (screen.height / 2) - (h/2);
	winLeft += offsetX;winTop += offsetY;
	var newWin;newWin = "";
	if(!newWin  || newWin.closed){
		newWin = eval('window.open(url,"newWin","resizable='+rsze+',scrollbars='+scr+',status=no,left='+winLeft+',top='+winTop+',Width='+w+'px,Height='+h+'px")');
		newWin.focus();
		newWin.resizeTo(w,h);
		newWin.moveTo(winLeft,winTop);
	}	
}

function converter(){showPopup( '/store/converter.asp', 480, 520, 200, -150,0,0 );}
function showPriceList(){showPopup( '/store/downloads/tradePriceList.asp', 680, 520,0,0,1,1 );}
function showMailingListWin(){showPopup( '/store/mailingList.asp',470,450, 0, 0,0,0);}


function showAIF( url, w, h, offsetX, offsetY, rsze, scr ){
	var winLeft = (screen.width / 2) - (w/2);
	var winTop = (screen.height / 2) - (h/2);
	winLeft += offsetX;winTop += offsetY;
	var aifWin;aifWin = "";
	if(!aifWin  || aifWin.closed){
		aifWin = eval('window.open(url,"aifWin","resizable='+rsze+',scrollbars='+scr+',status=no,left='+winLeft+',top='+winTop+',Width='+w+'px,Height='+h+'px")');
		aifWin.focus();
		
	}	
}
function aif(id){showAIF('/store/downloads/aif.asp?id='+id, 680, 520,0,0,1,1 );}
//function cookieInfo(){showPopup( '/store/cookies.asp', 450, 500, 0, 0,0,1 );}
//function sizeChartCustom(itemID,obj,page){showPopup( '/store/sizeChartCustom.asp?itemID='+itemID+'&objRef='+obj+"&page="+page, 700, 500, -150, -100,0,1 );}
//function sizeChartStandard(){showPopup( '/store/sizeChartStandard.asp?', 700, 500, -150, -100,0,1 );}
//function requestDetails(){showPopup( '/store/request_my_details.asp', 450, 400, -20, -20,0,0 );}

//------------------------------------------------------------------------
//----------------- STORE -------
//------------------------------------------------------------------------

function tradePriceList(){showPopup( '/store/tradePriceList.asp', 600, 480, 0, 0,0,1 );}

function confirmAddToBskt(){
	/**/
	strAppVersion = navigator.appVersion;
	w=350;h=130;url="basket_confirmation.html";
	var winLeft = (screen.width / 2) - (w/2);var winTop = (screen.height / 2) - (h/2);
	var confirmBsktWin;confirmBsktWin = "";
	if(!confirmBsktWin  || confirmBsktWin.closed){
		
		//confirmBsktWin = eval('window.open(url,"confirmBsktWin","resizable=1,scrollbars=0,status=no,left='+winLeft+',top='+winTop+',Width='+w+'px,Height='+h+'px")');
		//confirmBsktWin.focus();
	   /* if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
	    {
	     winstyle = "dialogWidth="+w+"px; dialogHeight:"+h+"px; center:yes";
	      window.showModelessDialog(url,null,winstyle);
		  confirmBsktWin.focus();
	    }
	    else
	    {*/
	      confirmBsktWin = eval('window.open(url,"confirmBsktWin","resizable=0,scrollbars=0,status=no,left='+winLeft+',top='+winTop+',Width='+w+'px,Height='+h+'px")');
		  confirmBsktWin.focus();
	    //}
		
	}	
	
}

function checkForm(obj){
     //-- Check that they have entered  a quantity
     if (!obj.quantity.value){
          obj.quantity.value=prompt("You forgot to include a Quantity for this item. Please enter one below.","");
          if (obj.quantity.value=="null"){
               obj.quantity.value="";
          }
          return false;
        
     }
	 //-- check that the quantity is a number and convert to an integer
	 IntValue = obj.quantity.value;
		IntValue = parseInt(IntValue);
		if (isNaN(IntValue)) {   
			alert("Please enter a valid number value for the required quantity.\n\nThank you.");
			obj.quantity.value="";
			return false;
		}
	 //-- check the quantity is not zero
	 if(IntValue==0){
	 	alert("Please enter a valid number value for the required quantity.\n\nThank you.");
		return false;
	 }
	 
		//-- close the Cart Window
		theWin = window.cartWin;
        //if(!theWin || theWin.closed){ }else{theWin.close();}
		if(theWin){theWin.close();}
		return true;
		
}

function checkBasketForm(){
	theForm = document.forms["frmBasket"];
	for(i=0;i<theForm.length;i++){
		if(theForm.elements[i].type =="text"){
			//-- returns, "quanti", "priceE", "priceT", "allTot"
			if(theForm.elements[i].name.substring(0,6)=="quanti"){
				var quan = theForm.elements[i].value;
				if(isNaN(quan)){
					msg="Please enter a valid number value for the required quantity of all items."
					msg+="\n\nSetting an items quantity to '0' will remove that item."
					msg+="\n\nThank you."
					alert(msg);
					return false;
				}

			}
		}
	}
}

function viewPopupBsktNo(){
alert("Please login to be able to view Basket (registered Customers only).\n\nThank you.");
}
function viewPopupBskt(){
	/**/
	var winWidth = 600;
	var winHeight = 500;
	var winLeft = (screen.width / 2) - (winWidth/2) +100;
	var winTop = (screen.height / 2) - (winHeight/2) -100;
	var url = '/store/basket_popup.asp';
	var HelpWin
	cartWin = ""
	
	if (!cartWin  || cartWin.closed){
		cartWin = eval('window.open(url,"cartWin","resizable=no,scrollbars=yes,status=no,left='+winLeft+',top='+winTop+',Width='+winWidth+'px,Height='+winHeight+'px");')
		cartWin.focus();
	}
	
}

function checkOut(){
	//-- check we have items before allowing checkout
	/*
	obj = document.forms["frmBasket"].elements['allTotal'];
	if(obj.value=="£0.00 total"){
		alert("yes");
	}else{alert("no");alert(obj.value);}*/

	//-- no customer ID/Not logged in
	//if(cid==""){ alert("Please Login to be able to place your order");return false;}
	
	//-- check we have a basket ID
	/*if(bsktID!=""||bsktID!=null){
		//var url=secureCheckout+bsktID+"&cid="+cid; checkout
		if(cid!=""){ //-- we have a customer ID, so we can place order
			var url=checkout+bsktID+"&cid="+cid;
			opener.location.href=url;
			shutDown();
		}else{ //-- no customer ID
			alert("Please Login to be able to place your order");
		}
	}*/
	opener.location.href=checkoutURL;
	shutDown();

}

function DeleteMe(theElement){
	obj = document.forms["frmBasket"].elements[theElement];
	obj.value=0;
	checkBsktQuantity(obj);
}

function promptUpdate(obj){
	obj.elements['submit'].className="bskButtonPrompt";
}

function checkBsktQuantity(obj){
		if(obj.value==0){
			//-- change style
			obj.className="bskEmptyTextBox";
			//reCalculate();
			document.forms["frmBasket"].elements['submit'].className="bskButtonPrompt";
			obj.focus();
		}else{
			obj.className="textBox1";
			//reCalculate();
			document.forms["frmBasket"].elements['submit'].className="bskButtonPrompt";
			obj.focus();
		}
}

function removeFocus(obj){
	//alert(toString(obj)+" hasfocus")
	obj.blur();
}

function reCalculate(){
	theForm = document.forms["frmBasket"];
	var allTot=0;
	for(i=0;i<theForm.length;i++){
		if(theForm.elements[i].type =="text"){
			//-- returns, "quanti", "priceE", "priceT", "allTot"
			if(theForm.elements[i].name.substring(0,6)=="quanti"){
				var quan = theForm.elements[i].value;if(isNaN(quan)){return false};quan = eval(quan*1);
				var priceEa = theForm.elements[i+1].value;priceEa = priceEa.substring(3);priceEa = parseFloat(priceEa);
				var priceTot = theForm.elements[i+2].value;priceTot = priceTot.substring(1);priceTot = parseFloat(priceTot);
				//-- adjust priceTot
				priceTot = (quan * priceEa);
				var allTot = allTot + priceTot;
				
				theForm.elements[i].value = quan;
				theForm.elements[i+1].value = "@ "+ GetCurrency(priceEa,"£") + " ea";
				theForm.elements[i+2].value = GetCurrency(priceTot,"£");
				theForm.elements['allTotal'].value = GetCurrency(allTot,"£");
				//alert(quan +" x "+ priceEa +" = "+ priceTot)
			}
		}
	}
}

function GetCurrency(amount,poundSign){
	tmpCurr = poundSign + amount  /**/
	hasPeriod = tmpCurr.indexOf(".")
	if(hasPeriod==-1){
		tmpCurr = tmpCurr +".00"
	}else{
		zerosAfterPeriod = tmpCurr.substring(hasPeriod)
		if(zerosAfterPeriod.length==3){
			tmpCurr = tmpCurr
		}else{
			tmpCurr = tmpCurr +"0"
		}
	}

	return tmpCurr;
}


function shutDown(){
	close('self');
}



//-->
