function siteSearchOnClick(searchField)
{
	try
	{
		if (searchField.value == searchField.title)
		{
			searchField.value = '';
		}
		else if (searchField.value == '')
		{
			searchField.value = searchField.title;
		}
	}
	catch (exc) { }
}

		
function setCartInfo(count, amount)
{
	var cartSummary = document.getElementById('shop');
	if (cartSummary)
	{
		var text = cartSummary.innerHTML;
		text = text.replace(/\([0-9]+\)/gi, '(' + count + ')');
		cartSummary.innerHTML = text;
	}
}

function sendToFriend(referPageURL, referPageTitle)
{
	var popupURL = "/goto/sendToFriend/?referPageURL=" + escape(referPageURL) + "&referPageTitle=" + escape(referPageTitle);
	
//	window.open(popupURL, "SMSendToFriend", "height=590,width=670,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
	popup(popupURL, 'SMSendToFriend', 670, 590, 'yes');
}

/* Popup functions */
function popup(url, title, width, height, scroll) 
{
	var s = 'menubar=no,toolbar=no,location=no,resizable=yes,status=yes'
	s += ',scrollbars=' + scroll
	s += ',width=' + width + ',height=' + height;
	s += ',top=' + (screen.availHeight - height) / 2 + ',left=' + (screen.availWidth - width) / 2;

	//close existing window
	if (navigator.newwindow) navigator.newwindow.close();
	
	//save new window object in navigator object and activate
	navigator.newwindow = self.open(url, title, s);
	navigator.newwindow.focus();
	
	return false;
}


function popupEmail(btn)
{
	//Change target and action of form to popup in a new window
	
	//Save details
	var oldTarget = btn.form.target;
	var oldAction = btn.form.action;

	//New details
	var target = 'popupEmail';
	var action = '/site/page.cfm?s=ecardpreview&t=shopCart&preview=1';

	btn.form.target = target;
	btn.form.action = action;

	//Popup
	if (popup) popup('', target, 670, 550, 'yes');
	
	//Submit form
	btn.form.submit();
	
	//Reset changed values
	btn.form.target = oldTarget;
	btn.form.action = oldAction;
	
	return false;
}

function closeWindow() 
{
	window.close();
	if (window.opener)
		if (!window.opener.closed)
			window.opener.focus();
}

function addPopupEvents() 
{
	document.onkeydown = KeyDown;
}

function KeyDown(e) {
	if (e) {
			if (e.which == 27) closeWindow(); //Netscape & Mozilla
	}
	else if (event && event.keyCode == 27) closeWindow(); //IE
}

