//DETECT NS4 and ask them to upgrade!!

function showNS4Message(){
	
	var NS4 = (document.layers) ? true : false;

	if (NS4) 
	{ 
		GotoHere="/ns4.asp";

		if (IsPopupBlocker(GotoHere)) {
			var upgrade = window.confirm("Welcome to ASOS. We have detected that you are using Netscape Navigator 4.\n Unfortunatley this browser does not support the functionality of this site. \nYou can still search our Store by using the Store Directory link located in the Useful Information box on the left of the page. If you wish to have the full experience of this site and many others please upgrade your browser.\nDo you wish to be taken to the Netscape site to upgrade your browser?");
			if (upgrade) window.location="http://channels.netscape.com/ns/browsers/default.jsp";
		}
	}
}

function IsPopupBlocker(GotoHere) {
	var newwin;
	var NewWidth = 400;
	var NewHeight = 300;
	var NewLeft = (screen.width - NewWidth) / 2;
	var NewTop = (screen.height - NewHeight) / 2;
	
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	newwin = window.open(GotoHere,'newwindow','height=' + NewHeight + ',width=' + NewWidth +', top=' + NewTop + ', left=' + NewLeft + ', status=no');
	
	if (newwin==null || typeof(newwin)=="undefined") {
			return true;
		} else {
			if(javascript_version > 1.0)
			{
				//delay a bit here because IE4 encounters errors
				//when trying to focus a recently opened window
				setTimeout('newwin.focus();',250);
			}
			return false;
	}				
}

//End NS4 DETECTION

function switchlayer(lname, hgt, img) {
 if (document.getElementById) {
  if(document.getElementById(lname).style.display == '') {
   img.src="/images/forum_plus.gif"
   document.getElementById(lname).style.display = 'none'
  } else {
   img.src="/images/forum_minus.gif"
   document.getElementById(lname).style.display = ''
  }
 }
}

function orderby(height,width) {
	NewLeft = (screen.width - 545) / 2;
	NewTop = (screen.height - 450) / 2;
	window.open("OrderByPhone.asp","sizing","status=no,scrollbars=no,resizable=no,width="+width+",height="+height+",top="+ NewTop +",left=" + NewLeft);
}

function returns(page) {
	NewLeft = (screen.width - (screen.width * 0.65)) / 2;
	NewTop = (screen.height - (screen.height * 0.85)) / 2;
	location.href = "/retref.asp"
	//window.open("/retref.asp","SmallWin","status=no,scrollbars=yes,resizable=no,width=638,height=480,top="+ NewTop +",left=" + NewLeft);
}

function SmallWin(page) {
	NewLeft = (screen.width - 630) / 2;
	NewTop = (screen.height - 470) / 2;
	window.open(page+".asp","DelivCharge","status=no,scrollbars=yes,resizable=no,width=630,height=470,top="+ NewTop +",left=" + NewLeft);
}

function SmallWin1(page) {
	NewLeft = (screen.width - 630) / 2;
	NewTop = (screen.height - 470) / 2;
	window.open(""+page+".asp","DelivCharge","status=no,scrollbars=yes,resizable=no,width=630,height=570,top="+ NewTop +",left=" + NewLeft);
}

function Whinge(page) {
	NewLeft = (screen.width - 630) / 2;
	NewTop = (screen.height - 470) / 2;
	window.open(""+page+".asp","DelivCharge","status=no,scrollbars=yes,resizable=no,width=630,height=500,top="+ NewTop +",left=" + NewLeft);
}

function CurrConv(Convert) {
	iLeft=(screen.availWidth / 2) - 200
	iTop=(screen.availHeight / 2) - 150;
	window.open("Curr.asp?id=" + Convert, '', 'left='+iLeft+',top='+iTop+',width=340,height=240,scrolling=no,scrollbars=no');
}

function ChangeCurr(newval) {
  document.changecurrency.curr.value = newval
  document.changecurrency.submit()
}
function gohelpdesk() {
  location.href = "helpdesk.asp"
}

function newsletter() {
	var CanSubmit = false;
	validate();
	if (CanSubmit) {
		document.newsletter.submit();
	}
}

function validate(){

	if (document.newsletter.email.value.indexOf(' ') != -1){
	alert('Please enter a full email address')
	document.newsletter.email.focus();
	CanSubmit = false;
	return CanSubmit;
	}

	if (document.newsletter.email.value.indexOf('@') == -1){
	alert('Please enter a full email address')
	document.newsletter.email.focus();
	CanSubmit = false;
	return CanSubmit;
	}
     
	if (document.newsletter.email.value.lastIndexOf('.') == -1){
	alert('Please enter a full email address')
	document.newsletter.email.focus();
	CanSubmit = false;
	return CanSubmit;
	}
		
	CanSubmit = true;
		
	if (CanSubmit) {
	document.newsletter.submit();
	}
	
	return CanSubmit;
	
}

function BuyItem(shop) {
	x = ""
  if (document.options.opttype.value=="rb") {
    var undef
		field = document.options.sku
		if (field.length!=undef) {
			for (i=0; i < field.length; i++) {
			  if(field[i].checked) {
			    x = field[i].value
				}
			}
		} else {
		  if (document.options.sku.checked) {
		    x = document.options.sku.value
		  }
		}
	} else {
	  x = document.options.sku.value
	}
	
  if (x=="") {
    alert("Please select from the available size and colour options")
  } else {
		PopWinHeight = screen.availHeight - 10;
		if (PopWinHeight > 600) {
			PopWinHeight = 625
		}
		NewLeft = (screen.width - 545) / 2;
		NewTop = (screen.height - PopWinHeight) / 2;
		location.href="xt_add_item.asp?a=Buy&ShopperID=" + shop + "&sku=" + x//, "basket", "status=no,scrollbars=yes,resizable=no,width=545,height=" +  PopWinHeight +",top="+ NewTop +",left=" + NewLeft);
	}
}

function resetimg(id) {
  DisplayVariant = id
}

function SwitchCol(oSKU, nSKU) {
  x = eval("document.images['" + oSKU + "255255']")
  ns = "http://www.asos.com/images/prods/" + nSKU + "/image1l.jpg" 
  //alert(ns)
	x.src = ns
	DisplayVariant = nSKU
}

function christmas() {
	NewLeft = (screen.width - 545) / 2;
	NewTop = (screen.height - 450) / 2;
	window.open("christmasdelivery.asp","sizing","status=no,scrollbars=no,resizable=no,width=580,height=270,top="+ NewTop +",left=" + NewLeft);
}

function ShowSizing(html) {
	NewLeft = (screen.width - 545) / 2;
	NewTop = (screen.height - 450) / 2;
	window.open("sizing"+html+".asp","sizing","status=no,scrollbars=yes,resizable=no,width=545,height=285,top="+ NewTop +",left=" + NewLeft);
}

function zoomwin(myval,width,height) {
	strhref= myval;
	myWin = window.open(strhref,"",'toolbar=no,scrollbars=no,width='+width+',height='+height+',screenx=0,screeny=0');
}

function ProdWin(img, dv) {
NewLeft = (screen.width - 545) / 2;
NewTop = (screen.height - PopWinHeight) / 2;
GotoHere="/ProdWin.asp?sku=" + dv + "&img="+img;
BasketWin=open(GotoHere,"basket","status=no,scrollbars=yes,resizable=no,width=545,height=" + PopWinHeight + ",top="+ NewTop +",left=" + NewLeft);
}

function ShowCVV() {
  window.open("credit.htm", "_cvv", "left=10, top=10, width=670, height=550")
}

function popUp(url)
{
sealWin=window.open(url,"win",'toolbar=0,location=1,directories=0, status=1,menubar=1,scrollbars=1,resizable=1,WIDTH=500,height=450');
self.name = "mainWin"; 
}

function switchcard(id) {
  location.href="billing.asp?mscsid=<%= shopperID%>&cctype=" + id + "#card"
}

function checkdiscode() {
  if (document.discode.voucher.value!="") {
    document.discode.submit()
  }
}

function ChangeCtry() {
  document.frmBilling.state.value="ctry"
  document.frmBilling.action="billing.asp"
  document.frmBilling.submit()

}

//Menu generator
//Kevin Lewis

function doNuhn() 
{
	//Do nothing...
	window.status='';
}

function changeDisplay( elementId, setTo ) {

    if( document.getElementById ) {
        //DOM
        var theElement = document.getElementById( elementId );
    } else {
        if( document.all ) {
            //Proprietary DOM
            var theElement = document.all[ elementId ];
        } else {
            //Create an object to prevent errors further on
            var theElement = new Object();
        }
    }
    if( !theElement ) {
        /* The page has not loaded or the browser claims to support
        document.getElementById or document.all but cannot actually
        use either */
        return;
    }
    //Reference the style ...
    if( theElement.style ) { theElement = theElement.style; }
    if( typeof( theElement.display ) == 'undefined' &&
    !( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) {
      //The browser does not allow us to change the display style
      //Alert something sensible (not what I have here ...)
      window.alert( 'Your browser does not support this' );
      return;
    }
    //Change the display style
    theElement.display = setTo;
}

function changeMenu(sGender, iNum){

	if (sGender == "F")
	{
		sMenu = "woman" + 'Menu' + iNum
	}else if (sGender == "M"){
		sMenu = "man" + 'Menu' + iNum
	}else{
		sMenu = "gift" + 'Menu' + iNum
	}
	//sMenu = ((sGender == 'F') ? "woman" : "man") + 'Menu' + iNum; //Row ID
	
	if (sGender == "F")
	{
		sArrow = "woman" + 'Arrow' + iNum; //Arrow image ID
	}else if (sGender == "M"){
		sArrow = "man" + 'Arrow' + iNum; //Arrow image ID
	}else{
		sArrow = "gift" + 'Arrow' + iNum; //Arrow image ID
	}
	//sArrow = ((sGender == 'F') ? "woman" : "man") + 'Arrow' + iNum; //Arrow image ID
	
	if (vMenu == sMenu){
		hideMenu(sMenu, sArrow, sGender) //Hide existing menu
	}else{
		if (vMenu != "") //Hide previous Menu
		{ 
			hideMenu(vMenu, vArrow, sGender);
		}
		showMenu(sMenu, sArrow, sGender); //Show menu
	}
}

function hideMenu(sMenu, sArrow, sGender){
	
	changeDisplay( sMenu, 'none' );
	
	vGender = (vGender == "") ? sGender : vGender;
	
	if (vGender == "F")
	{
		sColour = "pink"
	}else if (vGender == "M"){
		sColour = "blue"
	}else{
		sColour = "orange"
	}
	
	//sColour = ((vGender == "F") ? "pink" : "blue"); //Colour of arrow image ID
	document.getElementById(sArrow).src = "images/arrow_" + sColour + "_right.gif";
	
	vMenu = "";
	vArrow = "";
	vGender = "";
}

function showMenu(sMenu, sArrow, sGender){

	changeDisplay( sMenu, 'block' );
	
	if (sGender == "F")
	{
		sColour = "pink"
	}else if (sGender == "M"){
		sColour = "blue"
	}else{
		sColour = "orange"
	}
	//sColour = ((sGender == 'F') ? "pink" : "blue"); //Colour of arrow image ID
	document.getElementById(sArrow).src = "images/arrow_" + sColour + "_down.gif";
	
	vMenu = sMenu;
	vArrow = sArrow;
	vGender = sGender;
}

//End Menu code


//Start Newsletter Code

function bskNewsletter() {
	var CanSubmit = false;
	validateBskN();
	if (CanSubmit) {
		document.frmNewsletter.submit();
		}
	}

function validateBskN(gender){

	if (document.frmNewsletter.email.value.indexOf(' ') != -1){
	alert('Please enter a full email address')
	document.frmNewsletter.email.focus();
	CanSubmit = false;
	return CanSubmit;
	}

	if (document.frmNewsletter.email.value.indexOf('@') == -1){
	alert('Please enter a full email address')
	document.frmNewsletter.email.focus();
	CanSubmit = false;
	return CanSubmit;
	}

	if (document.frmNewsletter.email.value.lastIndexOf('.') == -1){
	alert('Please enter a full email address')
	document.frmNewsletter.email.focus();
	CanSubmit = false;
	return CanSubmit;
	}

	CanSubmit = true;

	if (CanSubmit) {
	document.frmNewsletter.gender.value=gender;
	document.frmNewsletter.submit();
}

return CanSubmit;

}

//End Newsletter Code