// <!-- Start Hiding the Script

// Make the new Date object and set it 30 days ahead:
var exp = new Date();     //set new date object
exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 30));     //set it 30 days ahead

// =================================================================================
function setCookie (name, value, expires) {
	document.cookie = name + "=" + escape(value) + "; " + ((expires == null) ? "" : "; expires=" + expires.toUTCString());
}
//toGMTString

// =================================================================================
function getCookie (name) {
  var results = document.cookie.match ( '(^|;) ?' + name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

// =================================================================================
function deleteCookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toUTCString();
}

// =================================================================================
function AddToMyList(value)	{

	var cc = getCookie('myList');

	if (cc == null)	{
		setCookie('myList', value, exp);
		alert('Added ' + value + ' as your 1st entry to My List!');
	}else	{
		if (cc.length==0)	{
			setCookie('myList', value, exp);
			alert('Added ' + value + ' as your 1st entry to My List!');
		}else{
			var ccSplit = cc.split(",");
			var ccFind = ccSplit.find(value);
			if (ccFind)	{
				alert(value + ' is already on My List at position ' + ccFind + '.');
			}else{
				setCookie('myList', cc + ',' + value, exp);
				alert('Added ' + value + ' to My List!');
			}
		}
	}
}

// =================================================================================
function DelFromMyList(value)	{
	var cc = getCookie('myList');
	var ccSplit = cc.split(",");
	var ccFind = ccSplit.find(value);
//	alert(value+"\n"+cc+"\n"+ccSplit+"\n"+ccFind);

	if (ccFind)	{
		ccSplit.splice(ccFind,1);
		setCookie('myList', ccSplit.join(), exp);
		alert('Removed ' + value + ' from My List!');
		window.location = "mylist.asp";
//		alert(value + ' is already on My List at position ' + ccFind + '.');
	}else{
//		setCookie('myList', cc + ',' + value, exp);
		alert(value + ' not found in My List!');
	}
}

// =================================================================================
function ClearMyList()	{
		var npreply=confirm('Clear My List?');
		if (npreply==true)
			{
				deleteCookie('myList');
				window.location = "mylist.asp";
			}
}

// =================================================================================

Array.prototype.find = function(searchStr) {
  var returnArray = false;
  for (i=0; i<this.length; i++) {
    if (typeof(searchStr) == 'function') {
      if (searchStr.test(this[i])) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    } else {
      if (this[i]===searchStr) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    }
  }
  return returnArray;
}

// =================================================================================
// =================================================================================
// =================================================================================
// Stop Hiding script -->
