	var cDressurl = window.location.toString();
	var cDressarr = cDressurl.split('/');
	var cDress = cDressarr[cDressarr.length-1];
function set_cookie ( name, value )
{
    var cookie_string = name + "=" + escape ( value );
    var current_date = new Date;
    var exp_y = current_date.getFullYear ( ) + 1;
    var exp_m = current_date.getMonth ( );
    var exp_d = current_date.getDate ( );
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString() + "; path=/";
    document.cookie = cookie_string;
//	display_list();
}
function delete_cookie ( cookie_name )
{
  var addWish = document.getElementById("addToWishListLink");
  var addedToWishes = document.getElementById("addedToWishList");
  var showWishes =  document.getElementById("showWishListLink");
  var remWish = document.getElementById("removeWishListLink");
  var cookie_date = new Date ( );  // current date & time

  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString() + "; path=/;"; 
//  clear_display();

  if (remWish) remWish.style.display = "none";
  if (addWish) addWish.style.display = "block";
  if (addedToWishes) addedToWishes.style.display = "none";
  if (showWishes) showWishes.style.display = "none";

}
function get_cookie ( cookie_name )
{ 
	var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
	if ( results )
		return ( unescape ( results[1] ) );
	else
		return null;
}
function remove_from_wishlist ( cookie_name, item )
{
	  var new_cookie = "";
	  var wishcookie = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
	  var arrwishes = unescape(wishcookie[1]).split(",");

	for (i=0;i<arrwishes.length;i++){
		if (arrwishes[i]==item){
			arrwishes.splice(i,1); // remove the matching item
			new_cookie = arrwishes.toString();	
		  	delete_cookie ( cookie_name );
		  	set_cookie (cookie_name, new_cookie );
		}
	}

	var addWish = document.getElementById("addToWishListLink");
	var addedToWishes = document.getElementById("addedToWishList");
	var showWishes =  document.getElementById("showWishListLink");
	var remWish = document.getElementById("removeWishListLink");
	var myList = document.getElementById("myWishListLink");
	var topList = document.getElementById("headerWishListLink");
				
	var arr_count = cookie_count(cookie_name);		

	if (addWish) addWish.style.display = "block";
	if (addedToWishes) addedToWishes.style.display = "none";
	if (showWishes) showWishes.style.display = "none";
	if (remWish) remWish.style.display = "none";
	if (myList){
		if (arr_count == 0){myList.innerHTML = "My Wishlist";}
		else{myList.innerHTML = "My Wishlist (" + arr_count + ")";}
	}
	if (topList){
		if (arr_count == 0){topList.innerHTML = "My Wishlist";}
		else{topList.innerHTML = "My Wishlist (" + arr_count + ")";}
	}
//  display_list();
}

function update_wishlist ( cookie_name, value )
{
	var addWish = document.getElementById("addToWishListLink");
	var addedToWishes = document.getElementById("addedToWishList");
	var showWishes =  document.getElementById("showWishListLink");
	var remWish = document.getElementById("removeWishListLink");
	var myList = document.getElementById("myWishListLink");
	var topList = document.getElementById("headerWishListLink");

	if (get_cookie(cookie_name)==null) {
		set_cookie (cookie_name,value);
	} else {
	  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
	  var dupres = unescape(results).indexOf(value) ;
	  if (dupres ==-1) {
	  	delete_cookie ( cookie_name );
	  	set_cookie (cookie_name, unescape ( results[1] ) + "," + value);
	  }
	}
	
	var arr_count = cookie_count(cookie_name);

//	var wishcookie = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
//	var arrwishes = unescape(wishcookie[1]).split(",");

	if (addWish) addWish.style.display = "none";
	if (addedToWishes) addedToWishes.style.display = "block";
	if (showWishes) showWishes.style.display = "block";
	if (remWish) remWish.style.display = "block";
	if (myList){
		if (arr_count == 0){myList.innerHTML = "My Wishlist";}
		else{myList.innerHTML = "My Wishlist (" + arr_count + ")";}
	}
	if (topList){
		if (arr_count == 0){topList.innerHTML = "My Wishlist";}
		else{topList.innerHTML = "My Wishlist (" + arr_count + ")";}
	}

//  display_list();
}

function update_cookie ( cookie_name, value )
{
	if (get_cookie(cookie_name)==null) {
		set_cookie (cookie_name,value);
	} else {
	  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
	  var dupres = unescape(results).indexOf(value) ;
	  if (dupres ==-1) {
	  	delete_cookie ( cookie_name );
	  	set_cookie (cookie_name, unescape ( results[1] ) + "," + value);
	  }
	}
//  display_list();
}
function clear_display() {
	document.getElementById("WishList").innerHTML = "";
	document.getElementById("WishList").style.background = "#FFFFFF";
	document.getElementById("WishListBox").style.background = "#FFFFFF";
}
function display_list() {
	clear_display();
	var x = get_cookie ( "PGWISHLIST" );
	if (x != null) {
		var temp = x.split(',');
		for (var loop = 0; loop <temp.length; loop++)
		{
			document.getElementById("WishList").innerHTML = document.getElementById("WishList").innerHTML + "<font size=-1><strong> - <a href=" + temp[loop] + " style=text-decoration:none;font-family:arial>" + temp[loop] + "</strong></font><br>" ;
		}
		document.getElementById("WishList").innerHTML = document.getElementById("WishList").innerHTML + "<a href='/myfavorites' style=text-decoration:none;><br><strong>VIEW ALL</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=javascript:onClick=delete_cookie('PGWISHLIST'); style=text-decoration:none;><strong>CLEAR</strong></a>" ;
		document.getElementById("WishList").style.background = "#CCEEFF";
		document.getElementById("WishListBox").style.background = "#CCEEFF";
	}
}
