//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

//Start Add To Basket
function BuyItem(shop) {
	x = ""
  if (document.options.opttype.value=="rb") {
    var undef
		field = document.options.InvItems
		if (field.length!=undef) {
			for (i=0; i < field.length; i++) {
			  if(field[i].checked) {
			    x = field[i].value
				}
			}
		} else {
		  if (document.options.InvItems.checked) {
		    x = document.options.InvItems.value
		  }
		}
	} else {
	  x = document.options.InvItems.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
	}
}
//End Add To Basket

//Start Menu Code
var vMenu = "";
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 changeDrop(fID,spec_status,feature_status,sys_status,acc_status){

  if(fID=='over')
  {
		  if(spec_status =='t'){		  
		  	document.getElementById('tab_class1').className='overview_onpage';
		  }
		  if(feature_status =='t'){
		  		document.getElementById('tab_class2').className='tech';
		  }
		  if(sys_status =='t'){
		  		document.getElementById('tab_class3').className='delivery_info';
		  }
		  if(acc_status =='t'){
		  		document.getElementById('tab_class4').className='accessories';
		  }
	   
  }
  if(fID=='tech')
  {
	 
		 if(spec_status =='t'){		  
			document.getElementById('tab_class1').className='overview';
		  }
		   if(feature_status =='t'){
		  		document.getElementById('tab_class2').className='tech_onpage';
		  }
	   	if(sys_status =='t'){
		  		document.getElementById('tab_class3').className='delivery_info';
		  }
	   	 if(acc_status =='t'){
		  		document.getElementById('tab_class4').className='accessories';
		  }
	 
  }
  if(fID=='a3')
  {
	 
	  	 if(spec_status =='t'){		  
			document.getElementById('tab_class1').className='overview';
		  }
	 	 if(feature_status =='t'){
		  		document.getElementById('tab_class2').className='tech';
		  }
		  if(sys_status =='t'){
		  		document.getElementById('tab_class3').className='delivery_info_onpage';
		  }
	   	 if(acc_status =='t'){
		  		document.getElementById('tab_class4').className='accessories';
		  }
	 
  }
  if(fID=='a4')
  {
	 
	  	 if(spec_status =='t'){		  
			document.getElementById('tab_class1').className='overview';
		  }
	   if(feature_status =='t'){
		  		document.getElementById('tab_class2').className='tech';
		  }
	   	if(sys_status =='t'){
		  		document.getElementById('tab_class3').className='delivery_info';
		  }
		 if(acc_status =='t'){
		  		document.getElementById('tab_class4').className='accessories_onpage';
		  }
	 
  }
	  
  sMenu = fID
    
  if (vMenu == sMenu){
    MenuHide(sMenu) //Hide existing menu
  }else{
    if (vMenu != "") //Hide previous Menu
    {
      MenuHide(vMenu);
    }
    MenuShow(sMenu); //Show menu
  }
}

function MenuHide(sMenu) {
  changeDisplay(sMenu, "none")
  vMenu = "";
}

function MenuShow(sMenu) {
  changeDisplay(sMenu, "block")
  vMenu = sMenu
}

//End Menu code

//IFrame Reload code
function getDocHeight(doc) {
var docHt = 0, sh, oh;
if (doc.height) docHt = doc.height;
else if (doc.body) {
	if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
	if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
	if (sh && oh) docHt = Math.max(sh, oh);
}
return docHt;
}

function setIframeHeight(iframeName) {
var iframeWin = window.frames[iframeName];
var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
if ( iframeEl && iframeWin ) {
	iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
	var docHt = getDocHeight(iframeWin.document);
	// need to add to height to be sure it will all show
	if (docHt) iframeEl.style.height = docHt + 30 + "px";
}
}

function loadIframe(iframeName, url) {
if ( window.frames[iframeName] ) {
	window.frames[iframeName].location = url;   
	return false;
}
else return true;
}
//End IFrame Reload code

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

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

//New Window PopUp
var mywindow;
function spawnwindow(url, name, attributes)
{
	mywindow=window.open(url,name,attributes);
	if (window.focus) {mywindow.focus()}
}
//End

var testemail
function checkemail(emailtotest){
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(emailtotest))
	testemail=true;
else{
	testemail=false;
}
return (testemail);
}

