function open_window(link,w,h) //opens new window
{
	var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
	newWin = window.open(link,'newWin',win);
	newWin.focus();
}

function confirmDelete() //unsubscription confirmation
{
	temp = window.confirm('{/literal}{$smarty.const.QUESTION_UNSUBSCRIBE}{literal}');
	if (temp) //delete
	{
		window.location="index.php?killuser=yes";
	}
}

function validate_custinfo() //validate customer information
{
	if (document.custinfo_form.first_name.value=="" || document.custinfo_form.last_name.value=="")
	{
		alert("{/literal}{$smarty.const.ERROR_INPUT_NAME}{literal}");
		return false;
	}
	if (document.custinfo_form.email.value=="" || !isValidEmail(document.custinfo_form.email.value))
	{
		alert("{/literal}Please input a valid email address{literal}");
		return false;
	}
	if (document.custinfo_form.city.value=="")
	{
		alert("{/literal}{$smarty.const.ERROR_INPUT_CITY}{literal}");
		return false;
	}
	if (document.custinfo_form.state.value=="")
	{
		alert("{/literal}{$smarty.const.ERROR_INPUT_STATE}{literal}");
		return false;
	}
	if (document.custinfo_form.zip.value=="")
	{
		alert("{/literal}{$smarty.const.ERROR_INPUT_ZIP}{literal}");
		return false;
	}
	if (document.custinfo_form.country.value=="")
	{
		alert("{/literal}{$smarty.const.ERROR_INPUT_COUNTRY}{literal}");
		return false;
	}

	return true;
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); 
}