function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + '=' + escape(value) +
	((expires) ? '; expires=' + expires : '') +
	((path) ? '; path=' + path : '') +
	((domain) ? '; domain=' + domain : '') +
	((secure) ? '; secure' : '');
}

function getCookie(name) {
var cookie = ' ' + document.cookie;
var search = ' ' + name + '=';
var setStr = null;
var offset = 0;
var end = 0;
if (cookie.length > 0) {
 offset = cookie.indexOf(search);
 if (offset != -1) {
  offset += search.length;
  end = cookie.indexOf(';', offset)
  if (end == -1) {
   end = cookie.length;
  }
  setStr = unescape(cookie.substring(offset, end));
  }
 }
 return(setStr);
}

function BookmarkPage(location,title,type)
{
	window.external.addFavorite(location,title);
	window.location="bookmark-report.php"
		+"?location="+encodeURIComponent(location)
		+"&title="+encodeURIComponent(title)
		+"&type="+encodeURIComponent(type)
		+"&referer="+encodeURIComponent(window.location)
	;
}

function BookmarkThisPage()
{
	BookmarkPage(window.location,document.title,"current page");
}

function BookmarkLastPage()
{
	BookmarkPage(window.OpenerLocation,window.OpenerTitle,"last visited page");
}

function BookmarkHomePage()
{
	BookmarkPage("http://www.appliancebargains.co.uk/","Appliance Bargains","homepage");
}

function BookmarkPopunder()
{
	//alert(getCookie('bookmark_block')+':'+getCookie('bookmark_allow'));
	// if (!window.navigator.cookieEnabled) return;
	if (getCookie('bookmark_block') && !getCookie('bookmark_allow')) return;
	var expires=(new Date((new Date()).getTime()+1000*60*60*24*30)).toGMTString();
	setCookie('bookmark_block',1,expires); // for month
	setCookie('bookmark_allow',1); // for session
	//var pop=window.open('close.php','bookmark_close','toolbar=0,location=0,width=500,height=470');
	window.focus();
	pop.OpenerTitle=String(document.title);
	pop.OpenerLocation=String(window.location);
	//alert(document.cookie);
}
