  // function to print window
  function printWindow()
  {
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
  }

  // function to search cookie for current pet and size
  function inCookie(cookie_content_array, choice, petsize)
  {
   var found_flag = false;
   var choice_petclass_size_arr = [];
   for(i=0; i<cookie_content_array.length; i++)
   {
    choice_petclass_size_arr = cookie_content_array[i].split("$");
    if(choice == choice_petclass_size_arr[0] && petsize == choice_petclass_size_arr[1])
    {
     found_flag = true;
    }
   }
   return found_flag;
  }

  // param choice - the pet the user chose by clicking the checkbox
  function setCookie(choice, petsize)
  {
   var choices = readCookieValues();
   var choicesarr = choices.split("~");

   if(inCookie(choicesarr, choice, petsize))
   {
    unsetCookie(choice, petsize);
    return false;
   }

   choice = choice + "$" + petsize;
   if(choices)
   {
    choice = choices + "~" + choice;
   }

   var the_date = new Date("February 14, 2015");
   var the_cookie_date = the_date.toGMTString();
   var the_cookie = "webkinz_catalogue=" + escape(choice);

   the_cookie = the_cookie + ";expires=" + the_cookie_date;
   document.cookie = the_cookie;
  }

  // param choice - the pet the user chose by unclicking the checkbox
  function unsetCookie(choice, petsize)
  {
   var choices = readCookieValues();
   var choicesarr = choices.split("~");
   var newchoice = "";
   cnt = 0;

   var chneedle = choice + "$" + petsize;
   // sometimes unset gets called when set should be called due to page not being refreshed
   // and user checking and unchecking the boxes
   if(!inCookie(choicesarr, choice, petsize))
   {
    setCookie(choice, petsize);
    return false;
   }

   for(i=0; i<choicesarr.length; i++)
   {
    // choice to not include
    var choice_sz_arr = choicesarr[i].split("$");
    if(choice != choice_sz_arr[0] || petsize != choice_sz_arr[1])
    {
     if(cnt > 0)
     {
      newchoice = newchoice + "~" + choice_sz_arr[0] + "$" + choice_sz_arr[1];
     }
     else
     {
      newchoice = choice_sz_arr[0] + "$" + choice_sz_arr[1];
     }
     cnt++;
    }
   }

   var the_date = new Date("February 14, 2015");
   var the_cookie_date = the_date.toGMTString();
   var the_cookie = "webkinz_catalogue=" + escape(newchoice);

   the_cookie = the_cookie + ";expires=" + the_cookie_date;
   document.cookie = the_cookie;
  }

  function readCookie()
  {
   var cookiename = "webkinz_catalogue";
   var cookiestring=""+document.cookie;
   var index1=cookiestring.indexOf(cookiename);
   if (index1==-1 || cookiename=="") return "";
   var index2=cookiestring.indexOf(';',index1);
   if (index2==-1) index2=cookiestring.length;
   alert( unescape(cookiestring.substring(index1+cookiename.length+1,index2)) );
  }

  function readCookieValues()
  {
   var cookiename = "webkinz_catalogue";
   var cookiestring=""+document.cookie;
   var index1=cookiestring.indexOf(cookiename);
   if (index1==-1 || cookiename=="") return "";
   var index2=cookiestring.indexOf(';',index1);
   if (index2==-1) index2=cookiestring.length;
   return( unescape(cookiestring.substring(index1+cookiename.length+1,index2)) );
  }
  wishlistCookie = readCookieValues();

  function redirectHamsters()
  {
   window.location = "index_hamster.html";
  }
  function redirectWishList()
  {
   window.location = "wishlist.html";
  }
  function redirectWebkinz()
  {
   window.location = "index.html";
  }
  function redirectLilkinz()
  {
   window.location = "index_lil.html";
  }
  function redirectAccessories()
  {
   window.location = "index_acc.html";
  }

   function redirectStoreLocator()
  {
   window.location = "product_lines.html";
  }


    //---dynamic image loading by Denis

  var image = new Array('images/btn_wish_list_on.gif', 'images/store_locator_over.gif','images/btn_web_coll_on.gif', 'images/btn_web_lil_coll_on.gif', 'images/wishlist/btn_print_on.gif', 'images/btn_accessories_on.gif');

  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_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=image;

    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_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];}
	}

	//---end of dynamic image loading.
/*

  Rollimage = new Array()

  Rollimage[0]= new Image(170,59)
  Rollimage[0].src = "images/btn_wish_list_off.gif"
  Rollimage[1] = new Image(170,59)
  Rollimage[1].src = "images/btn_wish_list_on.gif"

  Rollimage[2]= new Image(170,59)
  Rollimage[2].src = "images/btn_web_coll_off.gif"
  Rollimage[3] = new Image(170,59)
  Rollimage[3].src = "images/btn_web_coll_on.gif"

  Rollimage[4]= new Image(170,59)
  Rollimage[4].src = "images/btn_web_lil_coll_off.gif"
  Rollimage[5] = new Image(170,59)
  Rollimage[5].src = "images/btn_web_lil_coll_on.gif"

  Rollimage[6]= new Image(170,59)
  Rollimage[6].src = "images/wishlist/btn_print_off.gif"
  Rollimage[7] = new Image(170,59)
  Rollimage[7].src = "images/wishlist/btn_print_on.gif"

  Rollimage[8]= new Image(170,59)
  Rollimage[8].src = "images/btn_accessories_off.gif"
  Rollimage[9] = new Image(170,59)
  Rollimage[9].src = "images/btn_accessories_on.gif"

   function SwapOut(image)
  {
    if(image == 1)
     document.wishlist.src = Rollimage[1].src;
    else if(image == 2)
     document.webkinz.src = Rollimage[3].src;
    else if(image == 3)
     document.lilkinz.src = Rollimage[5].src;
    else if(image == 4)
     document.print.src = Rollimage[7].src;
    else if(image == 5)
     document.accessories.src = Rollimage[9].src;
    return true;
  }

  function SwapBack(image)
  {
    if(image == 1)
     document.wishlist.src = Rollimage[0].src;
    else if(image == 2)
     document.webkinz.src = Rollimage[2].src;
    else if(image == 3)
     document.lilkinz.src = Rollimage[4].src;
    else if(image == 4)
     document.print.src = Rollimage[6].src;
    else if(image == 5)
     document.accessories.src = Rollimage[8].src;

    return true;
  }
  */
