function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

//zoom 

var bigWidth; //width of the zoom image 
var smallWidth; // width of zoomed image
var bigHeight; // height of the zoom image
var bigX = 0; // zoom image x position
var bigY = 0; // zooom image y position
var smallHeight;
var bigBoxWidth;
var bigBoxHeight;
var factorY;
var factorX;
var easing = 0.18;
var zoomInterval = 0; 
var mouseX = 0;
var mosueY = 0;
var sHeight;
var elements;
var scrollBorder;
var thumbsPos = new Array();
var thumbsPosDown = new Array();
var imgAmount;
var i = 0;
var g = 92*5;
var idc = 0;
var delay = 0;
var rollOverInetrval;
var hideInterval;
var str =  new String(window.location);
var zoomImageShown = false;
var nr;
var issueNumber;
var pageNumber;
var images;
var scrollHeight; 


function initProductPage()
{
	sHeight = 92;
	document.body.onmousemove=setMouseCoords;
	elements = countElements("thumbnails-mask","img");
	scrollHeight = sHeight * elements ; 
	//document.getElementById("thumbnails-loop").style.top = scrollHeight+'px';

	smallWidth = 230;
	smallHeight = 345;

	bigBoxWidth = document.getElementById('zoom-box').offsetWidth;
	bigBoxHeight = document.getElementById('zoom-box').offsetHeight;

	//document.getElementById('zoom-image').style.left = -450 + 'px';
	//document.getElementById('zoom-image').style.top = -800 + 'px';
	

	YAHOO.util.Event.addListener("up-arrow", "click", moveDown);
	YAHOO.util.Event.addListener("down-arrow", "click", moveUp);

	//zoom onload vars 
	var oUpArrow = document.getElementById("up-arrow");
	var oDownArrow = document.getElementById("down-arrow");

	countsImages ('thumbnails-mask');
	document.getElementById('medium-image').onclick=showBig;
	document.getElementById('large-image').onmouseover=clearIntrv;

	document.getElementById('large-image').onmouseout=hideBig;
	//document.getElementById('large-image').onclick=showBig;
	bigWidth = document.getElementById('zoom-image').offsetWidth ;
	bigHeight = document.getElementById('zoom-image').offsetHeight ;
	
	
	
 

}





function prevPage(){
	navigtionsetup();
  if(pageNumber>1){
     pageNumber--;
window.location="/Content/"+issueNumber+"/Issue&pageNo="+pageNumber+"";
}

}

function navigateToPage(nr){
navigtionsetup();
window.location = "/Content/"+issueNumber+"/Issue&pageNo="+nr+"";

}

function nextPage() {
navigtionsetup();

pageNumber++;
window.location= "/Content/"+issueNumber+"/Issue&pageNo="+pageNumber+"";


}

function navigtionsetup(){
 str =  new String(window.location);
 str = str.split("/");


 issueNumber = str[4];

if(str[5]!="Issue"){
 pageNumber = str[5].split("=");

pageNumber = pageNumber[1];
pageNumber = pageNumber.split("");
	

if(pageNumber[1]=="?"||pageNumber[1]==undefined){
	 pageNumber = pageNumber[0];
 }else{
	 
	 pageNumber = pageNumber[0]+""+pageNumber[1];
 }





}
}


function countsImages (element_id)
{
	images = document.getElementById(element_id).getElementsByTagName('img');

	imgAmount = (images.length -1);
	idcc = (images.length -1);
	//var images2 = document.getElementById('thumbnails-loop').getElementsByTagName('img');
	scrollBorder = (sHeight * 3 ) - (sHeight*images.length);

	for(var d=0;d<images.length;d++)
	{
		
		
		
		thumbsPos.push(sHeight*(d-1));
		
		thumbsPosDown.unshift(sHeight*(d-1));
		
		document.getElementById(images[d].id).style.top = thumbsPos[d]+'px';
		YAHOO.util.Event.addListener(images[d].id, "click", moveUp);
		//YAHOO.util.Event.addListener(images2[d].id, "click", moveUp);
		
		
		
		
	}
}





function setMouseCoords(e)
{
	var ie = document.all?true:false;
	if(!e)
	{
		   e = window.event;
	}
	if(e.pageX || e.pageY)
	{
		   mouseX = e.pageX;
		   mouseY = e.pageY;
		
	
	
	}
	else if(e.clientX || e.clientY)
	{		
	   mouseX = YAHOO.util.Event.getPageX(e); 
	   mouseY = YAHOO.util.Event.getPageY(e); 	
	}
}

//////////////COVER ROLLOVER FUNCTIONALITY //////////////////////////////Pawel

function imageOn(imageName){

	var imgSrcOff = new String(imageName.src);
	var imgSrcOn = imgSrcOff.replace(/inactive/gi, "active");
	var promoTxtOff = document.getElementById("promo-text").src;
	var promoTxtOn = promoTxtOff.replace(/off/gi, "on");
	var promoId = imageName.id;	
	var issueNbr = document.getElementById("promo-text").src;
		 issueNbr = issueNbr.split("/");
	promoId = promoId.slice(5);	
	imageName.src = imgSrcOn;
	document.getElementById("promo-text").src = "/images/issues/2008/"+issueNbr[6]+"/cover/promotext"+promoId+"_active.jpg";

}


function imageOff(imageName){

	var imgSrcOff = new String(imageName.src);
	var imgSrcOn = imgSrcOff.replace(/active/gi, "inactive");;
	var promoTxtOff = document.getElementById("promo-text").src;
	var promoTxtOn = promoTxtOff.replace(/active/gi, "inactive");
	var promoId = imageName.id;
	var issueNbr = document.getElementById("promo-text").src;
		//issueNbr = issueNbr.slice(49,53);
		issueNbr = issueNbr.split("/");
		
	
	
	promoId = promoId.slice(5);
	imageName.src = imgSrcOn;
	document.getElementById("promo-text").src = "/images/issues/2008/"+issueNbr[6]+"/cover/promotext_inactive.jpg";
}







////////////////////////////////////////////////////////////////////////



//show zoom image 
function showBig()
{
clearIntrv();	
//document.getElementById('sizing').style.visibility = 'hidden';
	document.getElementById('demo').style.visibility = 'hidden';
	document.getElementById('sizing').style.visibility = 'hidden';
	document.getElementById('designer').style.visibility = 'hidden';
	document.getElementById('zoom-image').style.visibility = 'visible';
	document.getElementById('zoom-box').style.visibility = 'visible';
	
	largeImageShown = true;

	zoomInterval = setInterval("animateBigImage()",20);
	
}


//////SIZING CHART TAB//////////////////////////////////////////////////////
function showtab(tabname)

    {

        var measuring_guide_tab = document.getElementById('measuring-guide');

        var size_conversion_tab = document.getElementById('size-conversion');

        var product_measurement_tab = document.getElementById('product-measurement');

 

        //Hide all tabs by default

        measuring_guide_tab.style.display = 'none';

        size_conversion_tab.style.display = 'none';

        product_measurement_tab.style.display = 'none';

 

        //Then show the selected one

        document.getElementById(tabname).style.display = 'block';

    }

 
function prepViewLargeImageLink(product_id, image_type, channel, cache_url)
{
    var fullsize_link = document.getElementById('full-size-image-link');
    fullsize_link.onclick = function()
    {
        launchPopUp('/' + channel + '/ViewFullSizeImage.ice?productID=' + product_id + '&imageType=' + image_type, 580,760);
    }
}

function loadBig(img,prodId,channel, cache_url) {

        prepViewLargeImageLink(prodId, img, channel, cache_url)
        document.getElementById("medium-image").src =  cache_url+"/images/products/"+prodId+"/" + img + "_l.jpg";
        loadZoomImage(img,prodId, cache_url);
 
    }


function loadZoomImage(img,prodId, cache_url){
		 
	    document.getElementById("zoom-image").src = cache_url+"/images/products/"+prodId+"/" + img + "_xl.jpg";
}




function clearIntrv(){
	clearTimeout(hideInterval);
		
}



function hideBig(){
	
	hideInterval = setTimeout("hideDelay()",250);
	
}






function hideDelay(){
	
	if(document.getElementById('zoom-image').style.visibility != 'hidden')
	{
		document.getElementById('demo').style.visibility = 'visible';
		document.getElementById('sizing').style.visibility = 'visible';
		document.getElementById('designer').style.visibility = 'visible';
		clearInterval (zoomInterval);	
		document.getElementById('zoom-image').style.visibility = 'hidden';
		document.getElementById('zoom-box').style.visibility = 'hidden';
			
	}

	
}







function hideBigBox()
{	
	document.getElementById('zoom-image').style.visibility = 'hidden';
}


//zoom function 
function animateBigImage()
{
	var xPos =  mouseX;
	var yPos =  mouseY;	
	var bigXPos = YAHOO.util.Dom.getX('zoom-image');
	var bigYPos = YAHOO.util.Dom.getY('zoom-image');

	var largeXOffset = YAHOO.util.Dom.getX('medium-image');
	var largeYOffset = YAHOO.util.Dom.getY('medium-image');

	//var bigXPos = document.getElementById('zoom-image').offsetLeft;
	//var bigYPos = document.getElementById('zoom-image').offsetTop;	

	factorX = (bigWidth- bigBoxWidth)/smallWidth;
	factorY = (bigHeight-bigBoxHeight)/smallHeight ;	

	var targetX = 0 - (factorX * (xPos-largeXOffset));
	var targetY = 0 - (factorY * (yPos-largeYOffset));		

	targetX = Math.round(targetX);
	targetY = Math.round(targetY);

	bigX +=  ((targetX-bigX)*easing); 
	bigY +=  ((targetY-bigY)*easing);	

	bigY = Math.round(bigY);
	bigX = Math.round(bigX);
	
	document.getElementById("zoom-image").style.left  = bigX + 'px';
	document.getElementById("zoom-image").style.top = bigY + 'px';
 	//var move = new YAHOO.util.Anim('bImg', {top: { to: bigY }, left:{to:bigX}}, 1 ,YAHOO.util.Easing.easeOut); 
}

//scroll fucntionality 

function countElements(container_id, tag)
{
	var container = document.getElementById(container_id);
	var elem_count = container.getElementsByTagName(tag).length;
	return elem_count;
}



 
 
function moveDown(e)
{		
	if(idc>0)
	{
		idc--;		
	}		
	else
	{
		idc=images.length-1;
	}	
	var tempPoss = thumbsPos.shift();
	thumbsPos.push(tempPoss);
		document.getElementById(images[idc].id).style.top = -92+'px';	
	
	for(var d=0;d<images.length;d++)
	{
	
			
				
		
		
			

		
	
				var moves = new YAHOO.util.Anim(images[d].id, {top: {to: thumbsPos[d]}} ,  0.6 ,YAHOO.util.Easing.easeOutStrong); 		
		moves.animate();
				
				
				
		
	}
	 

 }
 
 


 
 
//move thumbnails up 
function moveUp(e) 
{ 				
	if(document.getElementById(images[idc].id).offsetTop<92) 
	{		
		document.getElementById(images[idc].id).style.top = 368+'px';
	}
	if(idc<imgAmount)
	{						
		idc++;
	}
	else 
	{
		idc=0;
	}
		
	var tempPos = thumbsPos.pop();
	thumbsPos.unshift(tempPos);
	
	for(var d=0;d<images.length;d++)
	{	
		var move = new YAHOO.util.Anim(images[d].id, {top: {to: thumbsPos[d]}} ,  0.6 ,YAHOO.util.Easing.easeOutStrong); 		
		move.animate();	
	}
	
}





// ADDED BY ANDY FROM INLINE ON 8th FEB

function openSignUp()
{
	if (validateEmail())
	{
		var url = '/intl/Content.ice?page=Sign-Up-For-Fashion-News&pgForward=popup' + '&email=' + document.getElementById('email').value;
        open(url,'SignupForFashionNews','width=700,height=500');
        var tmp = open(url,'SignupForFashionNews','width=700,height=500');
		tmp.focus();
	}
	return false;
}

function clearDefault(el) 
{
	if (el.defaultValue==el.value) el.value = ""
}

function jsubmit()
{
	if (validate()) 
	{
		document.emailreg.submit();
	}
}

function validate()
{
	if(!isGoodEmail(document.emailreg.email.value))
	{
		alert("Please make sure that you\ninput a valid e-mail address");
		document.emailreg.email.focus()
		return false
	}
	return true;
}

function validateEmail() 
{
	if(!isGoodEmail(document.emailreg.email.value, false))
	{
		alert("Please make sure that you\ninput a valid e-mail address");
		document.emailreg.email.focus()
		return false
	}
	return true;
}

function isGoodEmail(emailStr, thankyouflag) 
{
	if (thankyouflag == null) 
	{
		thankyouflag=true;
	}
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\!\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var firstChars=validChars;
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom="(" + firstChars + validChars + "*" + ")";
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
	{
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	// See if "user" is valid
	if (user.match(userPat)==null) 
	{
		return false;
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) 
	{
		// this is an IP address
		for (var i=1;i<=4;i++) 
		{
			if(IPArray[i]>255) 
			{
				return false;
			}
		}
		return true;
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) 
	{
		return false;
	}
	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if(domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
	{
	   // the address must end in a two letter or three letter word.
	   return false
	}
	if (domArr[domArr.length-1].length==3 && len<2) 
	{
	   return false
	}

	// default behavior - keep existing uses continue to work
	if(thankyouflag) 
	{
	// Everything's valid:
	   window.open('Thank You', 'newFormWindow', 'width=340,height=260');
	}
	return true;
}
	
var rollover_state_re = /\/images\/issues.*(_on|_off)\.(gif|jpg)$/;

function rolloverimage_handler() 
{
	var ON = '_on';  var OFF = '_off'; var SUFFIX = '.';
	if (rollover_state_re.test(this.src)) 
	{
		this.src = this.src.replace(RegExp.$1 + SUFFIX, (RegExp.$1==ON?OFF:ON)  + SUFFIX);
	}
	/* else, by convention, do nothing */
}

function rolloverimage_setup()
{
	for(var i=0; i<document.images.length; i++) 
	{
		var img = document.images[i];
		if (rollover_state_re.test(img.src)) 
		{
			img.onmouseover = rolloverimage_handler;
			img.onmouseout = rolloverimage_handler;
		}
	}
}

function s(o,f) 
{	 
	eval ("document."+o+".src= "+f+".src;");
}


function csoon()
{
	window.open("http://www.net-a-porter.com/popups/comingsoon.html","csoon","width=340,height=110,scrollbars=auto");
}



function msg(a)
{
	if(a==1) 
	{
		window.open("http://www.net-a-porter.com/popups/comingsoon.html","csoon","width=340,height=110,scrollbars=auto");
	} 
	else 
	{
		window.open("http://www.net-a-porter.com/popups/soldout.html","soldout","width=340,height=260,scrollbars=auto,location=no");
	}
}

function stay()
{
}

///////////////////////////////////////////////////////////
//above are old functions kept for backwards compatibility.
//please add new global functions below. ta.
///////////////////////////////////////////////////////////
var dom,ns,ie;

if (document.getElementById) 
{
	dom = 1;
} 
else if (document.layers) 
{
	nn = 1;
} 
else if (document.all) 
{
	ie = 1;
}

function set_visible(div, value)
{
	var ref;
	if(dom == 1)
	{
		ref = document.getElementById(div).style;
	}
	else if(ie == 1)
	{
		ref = eval('document.all.div.style');
	}
	else if(nn == 1)
	{
		ref = eval('document.layers[div]');
	}
	ref.visibility = value;
}

function image_swap(layer, id, newpic) 
{
	if (dom || ie)
	{
		eval ("document."+id+".src = "+newpic+".src;");
	}
	else if (nn) 
	{
		eval("document.layers['" + layer + "'].document.images['" + id  +"'].src = " + newpic + ".src");  
	}
}

function switchClass(which,what)
{
	if (!document.layers) 
	{
		if (document.all) 
		{ 
			switchObj = eval('document.all.' + which + ''); 
		}
		else
		{
			switchObj = document.getElementById(''+which+''); 
		} 
		switchObj.className = what;
	}
}

// custom object
function product_info(designer,status) 
{
	this.designer = designer;
	this.status = status;
}

var product = new Array();

function clickOn(sku) 
{
	var _sku = '_'+sku;
	var status = product[_sku].status;
	if(!status || status == "none" ) 
	{
		ri(product[_sku].designer, sku);
	} 
	else if (status == 3) 
	{
		launchPopUp('/intl/Content.ice?page=Sold-Out&pgForward=popup',280,210);
//		window.open('/popups/soldout.html','soldout','left=100,top=100,width=340,height=110,scrollbars=auto');
	}
	else
	{// status == instock|prepay|soldout 
		window.location.href = "/product/" + sku;
	} 
}


var ri_subdir = "";
var Collection_ID = "";
function ri(designer,sku) 
{
	designer = designer.toLowerCase();
	var url = "/intl/Content.ice?page=RegisterInterest&pgForward=popup&designer=" + designer + "&sku=" + sku;
	if (sku == null) 
	{ 
		url = "/intl/Content.ice?page=RegisterInterest&pgForward=popup&designer=" + designer + "&sku=" + Collection_ID + "&collection=1";
	}
	if (ri_subdir != null && ri_subdir != "")
	{
		url += "&subdir="+ri_subdir;
	}
	window.open( url,'emailpopup', 'width=320,height=320,scrollbars=no');
}

function designerri(designer,sku) 
{
	designer = designer.toLowerCase();
	var url = "/intl/Content.ice?page=DesignerRegisterInterest&pgForward=popup&designer=" + designer;
	if (sku == null) 
	{ 
		url = "/intl/Content.ice?page=DesignerRegisterInterest&pgForward=popup&designer=" + designer;
	}
	if (ri_subdir != null && ri_subdir != "")
	{
		url += "&subdir="+ri_subdir;
	}
	window.open( url,'emailpopup', 'width=320,height=300,scrollbars=no');
}

// generate instock|soldout|prepay|(none) tags 
function show_instock_tags()
{
	var string="";
	for (var _id in product)
	{
		var sku = _id.replace(/_(\d+).*/,"$1");
		var id = _id.replace(/^_/,"");
		var instock_tag = product[_id].status;
		if(product[_id].status == 0 || product[_id].status == "" || product[_id].status == "none") 
		{
			continue;
		}

		switch (product[_id].status) 
		{
			case 1: instock_tag = "instock"; break;
			case 3: instock_tag = "soldout"; break;
			case 2: instock_tag = "prepay";  break;
		}
		string += "<div id=\"instock" +id+ "\">\n" +
                "<a href=\"javascript:clickOn("+sku+")\" onmouseover=\"switchClass('link"+id+"','black')\" onmouseout=\"switchClass('link"+id+"','a')\"><img src=\"/i/nav_elements/" +instock_tag+ ".gif\" border=0 alt=\"\"></a>\n" +
                "</div>\n";      
   }
   document.write(string);
}

if (top.tempo == null) top.tempo = new Object();

function save(id, val) 
{
	if (val!=null) top.tempo[id] = val;
}

function restore(id) 
{
	return (top.tempo[id]!=null)?top.tempo[id]:null;
}

function clear(id) 
{
	if (top.tempo[id]!=null) top.tempo[id] = null;
}

function launchPopUp(url,w,h) 
{
	eval( "window.open('"+url+"', 'NAP_pop','menubar=no,location=no,resizable=yes,scrollbars=yes,location=no,status=no,width="+w+",height="+h+"');" );
}
	
function launchPopUpNoScrolls(url,w,h) 
{
	eval( "window.open('"+url+"', 'NAP_pop','menubar=no,location=no,resizable=no,scrollbars=no,status=no,width="+w+",height="+h+"');" );
}

var newwindow;
function help(url)
{
	newwindow=window.open(url,'name','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=670,height=540');
	if (window.focus) {newwindow.focus()}
}
	

// function to handle mouse actions, added by AJ 30-10-2006   
function mouseAction(state, image)
{					
	rollOverDiv			= "div" + image.name;
	rollOverImageName	= image.name ;
	rollOverImage		= "";	
	if (state == "on")
	{	
		rollOverImage = image.name + "1";
	}
	else if(state == "off")
	{
		rollOverImage = image.name + "0";
	}	
	image_swap(rollOverDiv,rollOverImageName,rollOverImage);
}

var rollover_state_re = /\/images\/issues.*(_on|_off)\.(gif|jpg)$/;



function rolloverimage_handler() 
{
	var ON = '_on';  var OFF = '_off'; var SUFFIX = '.';
	
	
	if(rollover_state_re.test(this.src)) 
	{
		this.src = this.src.replace(RegExp.$1 + SUFFIX, (RegExp.$1==ON?OFF:ON)  + SUFFIX);
	
	}
	
	
	
	/* else, by convention, do nothing */
}

function rolloverimage_setup() 
{

	
	for(var i=0; i<document.images.length; i++) 
	{
		var img = document.images[i];
		if (rollover_state_re.test(img.src)) 
		{
			img.onmouseover = rolloverimage_handler;
			img.onmouseout = rolloverimage_handler;
		}
	}
}



// Flash Player Version Detection - Rev 1.5
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;
	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
	try 
	{
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} 
	catch (e) 
	{
	}
	if (!version)
	{
		try 
		{
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} 
		catch(e) 
		{
		}
	}

	if (!version)
	{
		try 
		{
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} 
		catch (e) 
		{
		}
	}

	if(!version)
	{
		try 
		{
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} 
		catch (e) 
		{
		}
	}

	if (!version)
	{
		try 
		{
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} 
		catch (e) 
		{
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer()
{
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) 
	{
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) 
		{
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) 
			{
				tempArrayMinor = descArray[3].split("r");
			} 
			else 
			{
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) 
	{
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) 
	{
		return false;
	} 
	else if (versionStr != 0) 
	{
		if(isIE && isWin && !isOpera) 
		{
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} 
		else 
		{
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) 
		{
			return true;
		} 
		else if (versionMajor == parseFloat(reqMajorVer)) 
		{
			if (versionMinor > parseFloat(reqMinorVer))
			{
				return true;
			}
			else if(versionMinor == parseFloat(reqMinorVer))
			{				
				if (versionRevision >= parseFloat(reqRevision))
				{
					return true;
				}
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function uncheckAll(){
	email_prefs.weekly_newsletter.checked = false ;
	email_prefs.sale_special.checked = false ;
	}

function toggleDisplay(id)
{
    var elem = document.getElementById(id);
    var disp = elem.style.display;
    if('none' != disp)
    {
        elem.style.display = 'none';
    }
    else
    {
        elem.style.display = 'block'
    }
}

function toggleArrowClass(src)
{
    var elem = document.getElementById(src);
    var elemclass = elem.getAttributeNode('class').value;
    //alert(elemclass);
    if('productnav-toggle-rightarrow' == elemclass)
    {
        elem.setAttribute('class','productnav-toggle-downarrow');
        elem.className = 'productnav-toggle-downarrow';
    }
    else if('productnav-toggle-downarrow' == elemclass)
    {
        elem.setAttribute('class','productnav-toggle-rightarrow');
        elem.className = 'productnav-toggle-rightarrow';
    }
}