<!--

function init() {
	getSearchTerms();
}

var newWindow = null;
window.onload = init;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function getCost() {
	if (getItemCount() > 0) {
		var Cost = getCookie("BasketCost");
		if (Cost) {
			return unescape('Basket value: ' + formatCurrency(Cost));
		}
	} else {
		return unescape('');
	}
}

function displayItemCount() {
	var Items = getCookie("BasketItemCount");
	if (Items > 0) {
		return unescape('Items in Basket: ' + Items);
	} else {
		return unescape('');
	}
}

function getItemCount() {
	var Items = getCookie("BasketItemCount");
	if (Items > 0) {
		return unescape(Items);
	} else {
		return (0);
	}
}

function getSearchTerms() {
	var Terms = getCookie("SearchTerms");
	if (Terms) {
	    if (document.getElementById) {
	        var SearchBox = document.getElementById('text');
	        if (SearchBox != null) {
	            SearchBox.value = Terms;
	        } else {
	            alert('Search box is null');
	        }
	    } else {
	        alert('getElementById is not supported');
	    }
	} else {
	    return (0);
	}
}

function getCookie(Name) {
 var search = Name + "="
 if (document.cookie.length > 0) {
	offset = document.cookie.indexOf(search)
	if (offset != -1) { 
		offset += search.length
		end = document.cookie.indexOf(";", offset) 
		if (end == -1)end = document.cookie.length
		return unescape(document.cookie.substring(offset, end))
	}
	else return 0
 }
 else return 0
}

function formatCurrency(num) {
	strPrefix = '&#163;';
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + strPrefix + num + '.' + cents);
}

function InsertCopyright() {
	var mydate=new Date();
	var year=mydate.getFullYear();

	document.write('Copyright &copy; ' + year);
}

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}


//-->
