function rand( min, max ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Leslie Hoare
    // *     example 1: rand(1, 1);
    // *     returns 1: 1

    if( max ) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    } else {
        return Math.floor(Math.random() * (min + 1));

    }
}

function doClear(theText) {
	if( theText.value == theText.defaultValue) {
		theText.value="";
			theText.style.color="#000";
	}
}


function navigation_init(obj) {
	url = window.location.href;
	
var si=document.getElementById('sidebarnav');	
var li=document.getElementById('left_img');
var ca=document.getElementById('content_area');
var debug=document.getElementById('debug');
si.style.display = 'none';


if( url.search(/ShoppingCart\.asp/) > -1 ) {
  var discounttext= document.getElementById('discounttext');
  
  if( discounttext ) {
    discounttext.innerHTML = "<img src='/v/vspfiles/templates/xmas2008/images/OctoberWomanSmallLogo.gif' width='26' height='34'/>10% merchandise discount<br/>10% additional donation to OctoberWoman for breast cancer research";
  }
}

if( url.search(/debug=1/) > -1 ) {
  debug.style.display = 'block';
debug.innerHTML = "current url is " + url;
}

if( url.search(/\/$|\/\?|p-.+?_a|\/Default.+?asp|\/login\.asp|\/help\.asp|\/aboutus\.asp|\/myaccount\.asp/) > -1)      {    
	if( url.search(/\/$|\/\?|\/Default.+?asp/) > -1 ) { li.style.display = 'none';} 
          else if( url.search(/p-AboutUs_a/) > -1 ) li.style.display = 'none'; 
else if( url.search(/p-Collections_a/) > -1 ) li.style.display = 'none'; 
            else {
              if( url.search(/\/p-ContactUs_a/) > -1 ) li.className = "contactus_img";
	        else if( url.search(/\/myaccount.asp/) > -1 ) li.className = "myaccount_img";
	          else if( url.search(/\/help.asp/) > -1 ) li.className = "help_img";
                    else if( url.search(/\/login.asp/) > -1 ) li.className = "login_img"; 
                      else if( url.search(/p-Stores_a/) > -1 ) li.className = "stores_img";  
                        else if( url.search(/p-Praises_a/) > -1 ) li.className = "praises_img";   
	                  else if( url.search(/p-Press_a/) > -1 ) li.className = "press_img";  
              li.style.display = 'block';  
	      if( ca ) {
	        ca.style.width='600px';
	      }
            }
  } else {
    if( url.search(/u-.+?/) > -1 ) {
      li.style.display = 'none'; 
      var top_nav=document.getElementById('top_nav');
      top_nav.style.display = 'none';
    } else {
      if( li ) {
       li.style.display = 'none'; 
      }
      si.style.display = 'block';
      si.style.width = '173px';
    }
  }

}


function cart_init() {
    var sc=document.getElementById('display_cart_summary');
	
if( sc ) {

var htmltxt = '<a href="/myaccount.asp">My Account</a> | <a href="/help_answer.asp?ID=11#131">Return Policy</a> |  <a href="/help_answer.asp?ID=17#150">Email Sign Up</a> | <a href="/help.asp">Customer Service</a>';
     var tmpsc = "";
	  var count = sc.innerHTML.replace(/.+Your shopping cart contains (.+?) item.+/, "$1");
	  if( isNaN(count) ) {

		tmpsc = sc.innerHTML.replace(/\(.+?\)/, htmltxt);          }
	else {
tmpsc = sc.innerHTML.replace(/\(Your shopping cart contains .+? item.+?<a/, "<a");
    tmpsc = tmpsc.replace( /View My Cart/, count + " <img src=\"/v/vspfiles/templates/xmas2008/images/shopping_bag.gif\" border=0/> Shopping Bag");
            tmpsc = tmpsc.replace( /(<\/a\>)/, "$1 |" + htmltxt);
	
        }
       sc.innerHTML = tmpsc;
       }
}

	function show_object(id) {
		document.getElementById(id).style.visibility="visible";
	}
	function hide_object(id) {
		document.getElementById(id).style.visibility="hidden";

	}
        function highlight_text(id) {
		document.getElementById(id).style.color="#333";
	}
	function unhighlight_text(id) {
		document.getElementById(id).style.color="#fff";
	}

var PopupWindow;

function Popup(strUrl, strTarget)
  {
  var windowWidth, windowHeight, windowLeft, windowTop;

 
   if(typeof window.screenX == "number" && typeof window.innerWidth == "number")
  {
  windowLeft = window.screenX + window.innerWidth * .16;
  windowTop = window.screenY + window.innerHeight * .16;
  }
  else if(typeof window.screenTop == "number" && typeof document.documentElement.offsetHeight == "number")
  {
  windowLeft = window.screenLeft + document.documentElement.offsetWidth * .16;
  windowTop = window.screenTop - 50;
  }
  else
  {  
    windowLeft = 60;
    windowTop = 40;
  }; 
  windowWidth = 780;
  windowHeight = 575;



  /* The above code is just to define reasonable sizes and initial positions to the popup to be. */

  if (PopupWindow== null || PopupWindow.closed)
  {
  window.name = "adea_parent";

     PopupWindow= window.open(strUrl, strTarget, "top=" + windowTop + ",left=" + windowLeft + ",width=" + windowWidth + ",height=" + windowHeight + ",location,resizable,scrollbars,status");
PopupWindow.focus();
  }
  else
  {
  PopupWindow.focus();
  };

  }
