function getCookie(NameOfCookie)
{
if (document.cookie.length > 0) 
	{              
		begin = document.cookie.indexOf(NameOfCookie+"=");       
			if (begin != -1) 
				{           
					begin += NameOfCookie.length+1;       
					end = document.cookie.indexOf(";", begin);
						if (end == -1) end = document.cookie.length;
				        return unescape(document.cookie.substring(begin, end));
				} 
	}
return null;
}

function setCookie(NameOfCookie, value, expiredays) 
{
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() +  (expiredays * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + 
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function DoTheCookieStuff()
{
	var iMyWidth, iMyHeight, visited
	visited = null //getCookie('visited')
	if (visited==null) 
		{
			//setCookie based on how many hours you want this to last. Passed value will
			//be multiplied by 3600 (the number of seconds in an hour).
			setCookie('visited','yes',1)
			iMyWidth = (window.screen.width/2) - (125 + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
			iMyHeight = (window.screen.height/2) - (145 + 50); //half the screen height minus half the new window height (plus title and status bars).
			//var win2 = window.open("/vibe_popup.html","Vibe_popup","height=243,width=307,resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
			//var win2 = window.open("jenna_popup.html","Jenna_popup","height=243,width=307,resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
			//loadpopunder();
			//win2.focus();
		}
}

//Pop-under window- By JavaScript Kit
//Credit notice must stay intact for use
//Visit http://javascriptkit.com for this script
var win2
//specify page to pop-under
//var popunder="/catalogrequest-under.asp"
//var popunder="/AEGold-under.asp"
var popunderID = parseInt(Math.random() * 2500) + 1; 
var popunderurl="/pop_under.asp?sid="
var popunder = popunderurl + popunderID

//specify popunder window features
//set 1 to enable a particular feature, 0 to disable
if (isEven(popunderID)) {
	var winfeatures="width=300,height=300,scrollbars=0,resizable=0,toolbar=0,location=0,menubar=0,status=0,directories=0"

}
else {
	var winfeatures="width=584,height=306,scrollbars=0,resizable=0,toolbar=0,location=0,menubar=0,status=0,directories=0"
}


//Pop-under only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause popunder to load every time page is loaded
var once_per_session=1

///No editing beyond here required/////

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function loadornot(){
	if (get_cookie('popunder')==''){
		loadpopunder()
		document.cookie="popunder=yes"
	}
}

function loadpopunder(){
	win2=window.open(popunder,"popunder",winfeatures)
	
	if (win2) 
	{
		win2.blur()
		window.focus()
	}
}

// by rayson 04/26/04
function isinframe()  
{
if (self != top)
   {
    //alert('In a frame');
    top.location = self.location;
    }
else
	{
    //alert('Not in a frame');
    }
}

function StartHomePage()
{
	//DoTheCookieStuff();
  
	MM_preloadImages('/images/l_menu/l_mn_new_products_on.gif','/images/l_menu/l_mn_video_on.gif','/images/l_menu/l_mn_dvd_on.gif','/images/l_menu/l_mn_vibrators_on.gif','/images/l_menu/l_mn_sex_toys_on.gif','/images/l_menu/l_mn_slip_sensations_on.gif','/images/l_menu/l_mn_playwear_on.gif','/images/l_menu/l_mn_novelties_on.gif','/images/l_menu/l_mn_condoms_on.gif','/images/l_menu/l_mn_clearance_on.gif','/images/l_menu/l_mn_shop_guide_on.gif','/images/r_menu_hm/r_mn_hm_contact_us_on.gif','/images/r_menu_hm/r_mn_hm_cust_reg_on.gif','/images/r_menu_hm/r_mn_hm_request_cat_on.gif','/images/r_menu_hm/r_mn_hm_specialty_on.gif','/images/r_menu_hm/r_mn_hm_comp_info_on.gif','/images/r_menu_hm/r_mn_hm_cust_serv_on.gif','/images/r_menu_hm/r_mn_hm_contact_us_on.gif','/images/r_menu_hm/r_mn_hm_cust_reg_on.gif','/images/r_menu_hm/r_mn_hm_request_cat_on.gif','/images/r_menu_hm/r_mn_hm_specialty_on.gif','/images/r_menu_hm/r_mn_hm_comp_info_on.gif','/images/r_menu_hm/r_mn_hm_cust_serv_on.gif');

//	if (once_per_session==0)
//	loadpopunder()
//	else
//	loadornot()
}

// 17 June 2004 - HG
function LoadHomePagePopUnder(ShowPopUnder)
{
	
	DoTheCookieStuff();
	//alert(ShowPopUnder)
	if (ShowPopUnder == '1') return;
		if (once_per_session==0)
			loadpopunder();
		else
			loadornot();
}

// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See:  http://www.msc.cornell.edu/~houle/JavaScript/randomizer.html

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};

function isEven(x) { return (x%2)?false:true; }
function isOdd(x) { return !isEven(x); }


function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
 //  alert('length:' + buttonGroup.length);
   if (buttonGroup.length != 0) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
//		 alert(i + ': ' + buttonGroup[i].checked);
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function


