function ViewWin(loc)
{
 
 //opens a new window for viewing img and sets the location for the window to an html document containing the images
 var w=window.open("","","toolbar=no,menubar=yes,location=no,scrollbars=no,resizable=no,directories=no,status=no,width=520,height=610","")
 w.location=loc
}


function ViewImg(img)
{
 
 //opens a new window for viewing img
 var w=window.open("","","toolbar=no,menubar=yes,location=no,scrollbars=no,resizable=no,directories=no,status=no,width=520,height=550","")
 w.document.write("<html><head><title>"+img+"</title></head><body>")
 w.document.write("<img src='"+img+"'><br>")
 w.document.write("<input type='button' value='Close' onclick='self.close()'>")
 w.document.write("</body></html>")
}


//Get QueryString 

function QueryString(key)
{
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++)
	{
		if (QueryString.keys[i]==key)
		{
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse()
{
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;		
		}
	}

}
//Parse Querystring set some variables
QueryString_Parse();
	var Store_Code = "002"
	var Agent_track = QueryString("AG")
	if (window.location.search.match("Screen")){
		var Screen = QueryString("Screen")
	}else{
		var Screen = "CTGY"
	}
	if (Screen == "SRCH"){
			var Screen = "SRCH"
	}else{
			var Screen = "CTGY"
	}
	
	if (window.location.search.match("Category_Code")){
		var Category_Code = QueryString("Category_Code")
	}else{
		var Category_Code = ""	
	}
	
//Get Cookie the reason it needs to write a cookie is so that it remebers which option it was on when you click on the next button
function getCookie (name) {
var dcookie = document.cookie; 
var cname = name + "=";
var clen = dcookie.length;
var cbegin = 0;
        while (cbegin < clen) {
        var vbegin = cbegin + cname.length;
                if (dcookie.substring(cbegin, vbegin) == cname) { 
                var vend = dcookie.indexOf (";", vbegin);
                        if (vend == -1) vend = clen;
                return unescape(dcookie.substring(vbegin, vend));
                }
        cbegin = dcookie.indexOf(" ", cbegin) + 1;
                if (cbegin == 0) break;
        }
return null;
}

function setCookie (name, value, expires) {
        if (!expires) expires = new Date();
		document.cookie = name + "=" + escape (value) + "; path=/";
//expires=" + expires.toGMTString() +  ";
}

function setCookieArray(name){
this.length = setCookieArray.arguments.length - 1;
        for (var i = 0; i < this.length; i++) {
        this[i + 1] = setCookieArray.arguments[i + 1]
        setCookie (name + i, this[i + 1], expdate);
        }        
}

function getCookieArray(name){
var i = 0;
        while (getCookie(name + i) != null) {
        this[i + 1] = getCookie(name + i);
        i++; this.length = i; 
        }
}

var expdate = new Date();
expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
	
	if (Screen == "SRCH"){
		var OptionCookieArray = new setCookieArray("OptionsCookies", "");
	}else{
		if (Category_Code > ""){ 
			var OptionCookieArray = new setCookieArray("OptionsCookies", Category_Code);
		}
	}
	if (Agent_track > ""){ 
	var AgentTrackCookie = new setCookieArray("Agent_track",Agent_track)
	}

	var AgentTrackCookie = new getCookieArray("Agent_track")
	var OptionCookieArray = new getCookieArray("OptionsCookies")
	var GetCheckoutCookie = new getCookieArray("CheckoutCookie")
	
	var CheckOutStatus = (GetCheckoutCookie[1])
	Category_Code = (OptionCookieArray[1])
	Agent_track = (AgentTrackCookie[1])

/*Special remove I-Step Club From Prevention Page*/
function prevIstepImg(){
	if (Category_Code > ""){
		if (Category_Code.match("prevwow")){
			document.write("");
		}else{
		document.write("<td valign=\"top\"><a href=\"http://www.istepclub.com\" target=\"_blank\"><img src=\"/images/head_is.gif\" alt=\"I Step Club\" width=\"134\" height=\"25\" border=\"0\"/></a></td>");
		}
	}else{
	document.write("<td valign=\"top\"><a href=\"http://www.istepclub.com\" target=\"_blank\"><img src=\"/images/head_is.gif\" alt=\"I Step Club\" width=\"134\" height=\"25\" border=\"0\"/></a></td>");
	}
}		

function prevIstepLink(){
	if (Category_Code > ""){
		if (Category_Code.match("prevwow")){
			document.write("");
		}else{
		document.write("<td valign=\"top\" class=\"bottomnav_pad\"><div class=\"bottomnav\"><a href=\"http://www.istepclub.com\" target=\"_blank\" class=\"bottomnav\">Get motivated and join our easy to use and affordable Online Walking Club! Log your walks and more!</a></div></td>");
		}
	}else{
	document.write("<td valign=\"top\" class=\"bottomnav_pad\"><div class=\"bottomnav\"><a href=\"http://www.istepclub.com\" target=\"_blank\" class=\"bottomnav\">Get motivated and join our easy to use and affordable Online Walking Club! Log your walks and more!</a></div></td>");
	}
}		

function rightnav(){
	if (Category_Code > ""){
		if (Category_Code.match("brand_rp_wm")){
			document.write("<a href=\"/store/merchant.mvc?Screen=CTGY&Store_Code=002&Category_Code=brand_rp_wm\"><img src=\"/images/side_rockportlogo.gif\" width=\"149\" height=\"99\" border=\"0\" /></a>");
		}else if(Category_Code.match("brand_hg")){
			document.write("<a href=\"/store/merchant.mvc?Screen=CTGY&Store_Code=002&Category_Code=brand_hg\"><img src=\"/images/side_highgear.gif\" width=\"149\" height=\"99\" border=\"0\" /></a>");
		}else{
			document.write("&nbsp;");	
			}
	}else{
	document.write("&nbsp;");	
	}
}		


//Rollovers on template.dwt
		function MM_preloadImages() { //v3.0
		 	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}

		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_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;
		}

		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_goToURL() { //v3.0
 			 var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
 			 for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
		}

		
//Popwindows Shoppers Resources	on rightnav in miva and in catagories/apparel pages
		function OpenWindowSize(url){
			window.open(url, "SizeGuide","width=873,height=350,toolbar=0,menubar=0,scrollbars=0,resizable=0,status=0,location=0,directories=0,left=5,top=5");
		}
		function OpenWindowFabric(url){
			window.open(url, "FabricGuide","width=580,height=600,toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,directories=0,left=5,top=5");
		}
		function OpenWindowAboutPedo(url){
			window.open(url, "Pedometers","width=800,height=500,toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,directories=0,left=5,top=5");
		}
		function OpenWindowAboutHeart(url){
			window.open(url, "Heartmonitor","width=490,height=500,toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,directories=0,left=5,top=5");
		}
		function OpenWindowSwiss(url){
			window.open(url, "Swiss","width=519,height=500,toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,directories=0,left=5,top=5");
		}
		function OpenWindowFootwearTips(url){
			window.open(url, "FootwearTips","width=490,height=500,toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,directories=0,left=5,top=5");
		}
		function OpenWindowFootwearGuide(url){
			window.open(url, "FootwearGuide","width=600,height=500,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=0,location=0,directories=0,left=5,top=5");
		}

//Standared Pop Window
		function OpenWindow(url){
			window.open(url, "newWindow","width=500,height=495,toolbar=0,menubar=0,scrollbars=0,resizable=0,status=0,location=0,directories=0,left=5,top=5");
		}

//Live Help Button on template.dwt
		function liveHelpBtn(){
			document.write('<A HREF="javascript:;" onclick="window.open(\'');
  			document.write('https://www.walkerswarehouse.com/cgi-bin/start.exe/apps/livehelp/index.html?');
  			document.write("','LHC_'+Math.floor(Math.random()*100000),");
  			document.write("'resizable,height=355,width=400');\"><img border=0 ");
			document.write('src="https://www.walkerswarehouse.com/cgi-bin/start.exe/apps/livehelp/img.html');
  			document.write('?r=' + Math.random() );
  			document.write('" width="145" height="23"></A>');	
		}

//Banner on template.dwt
		function topNavBanner(){
			var banner=new Array()
			banner[0]="<b class=\"smallyellow\">click here to:</b><br/><div class=\"topnav\"><a href=\"http://www.walkofftheweight.com\" target=\"blank\" class=\"topnav\">Walk Off the Weight!</a></div>"
			//banner[1]="Banner2"
			var pickBanner=Math.floor(Math.random()*(banner.length))
			document.write(banner[pickBanner])
		}
		
		
	if(CheckOutStatus == "invoice"){
		document.write("<meta http-equiv=\"refresh\" content=\"0;URL=/store/invoice.asp\" />");
	}
	
	
	function vipprice(currentprice){
		currentprice = Format(currentprice * .95,2);
		document.write ("<span class=\"alert\">VIP PRICE ONLY <b>$" + currentprice + "</b></span><br/><span class=\"bottomnav\"><a href=\"/store/merchant.mvc?Screen=PROD&Product_Code=WW-1025&Store_Code=002\"> Not A Vip Member <b>Click Here</b></a></span>");
	}
	
	function Format(total,decimals){
    	if ( decimals==undefined )
        decimals = 2;
	    var suffix = ""
     	for ( var i=0; i<decimals; i++ )
     	suffix += "0";
	    var num = "" + parseFloat(total);
	    if ( num == "NaN" )
        return num = "0." + suffix;
	    if ( num.indexOf(".") == -1 )
        return num += "."+suffix;
	    return (num+suffix).substring(0,num.indexOf(".")+decimals+1);
		}

		/*Add-to-favorites Script*/
		//configure the two variables below to match yoursite's own info
		var bookmarkurl="http://www.walkerswarehouse.com"
		var bookmarktitle="The Walker's Warehouse"
		function addbookmark(){
		if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
		}
		
	function checkme(){ //check for required fields
	if (document.productform.AttributeValue){if (document.productform.AttributeValue.value == "")
    {inf_attr.firstChild.nodeValue=(productform.attrprompt.value + " is required.");
    document.productform.AttributeValue.focus();return(false)}}}
	
	function checkme2(){ //check for required fields
	var attrv = document.productform.AttributeValue;
	if (attrv){if (attrv.value == "")
    {var msg = "Please Select A Value From The Dropdown List";
	alert(msg); 
    attrv.focus();return(false)}}}
		
		
	function checkmeintl(){ //check for required fields
	if (document.productform1.AttributeValue){if (document.productform1.AttributeValue.value == "")
    {inf_attr.firstChild.nodeValue=(productform1.attrprompt.value + " is required.");
    document.productform1.AttributeValue.focus();return(false)}}}
	
	
	function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
	}
	
	function ReturnToShopping(){
		if(Get_Cookie( "rtspc" )=="CAT" ){
			document.write("<a href=\"/store/Categories.asp?Category_Code=" + Get_Cookie("rtscc") + "\"><img src=\"/images/btn_returntoshopping.gif\" width=\"200\" height=\"26\"/></a>")
		} else{
			document.write("<a href=\"/store/product.asp?Product_Code=" + Get_Cookie("rtspc") + "&Category_Code=" + Get_Cookie("rtscc") + "\"><img src=\"/images/btn_returntoshopping.gif\" width=\"200\" height=\"26\"/></a>")
			}
		}
	
	/*Removes Frames From our Site*/
  	if (top.location == "http://www.walkerswarehouse.com/wwpop/"){
  	}else{
  	if (top.location != location) {top.location.href = document.location.href ;}
  	}
	