// JavaScript Document

	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=="")
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		if (document.custinfo_form.country.value=="")
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_COUNTRY}{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.city.value=="")
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_CITY}{literal}");
			return false;
		}


		return true;
	}

function show(target1,target2){
	clr();
	document.getElementById(target1).className = 'show';
	document.getElementById(target2).className = 'selected';
}
function clr(){
	var button_values = new Array('about','products','gallery','services','showroom','faq','contact');
	var menu_values = new Array('prodmenu','servicesmenu','tst','tst','tst','tst','tst');
	for (i=0;i<7;i++){
	document.getElementById(menu_values[i]).className = 'hide';
	document.getElementById(button_values[i]).className = '';
	}
}



function check_limit(val){
	var x = val.value;
	x = parseInt(x);
	//alert(x);
	//if(val == "a"){ var x = document.getElementById("id").value;  } 	
	//else{  	var x = document.getElementById("the_id").value; }  
	var y = document.getElementById("num_rows");  
	var limit = parseInt(y.value);
	if(x > limit){  alert("Value is too high!"); val.value = limit; }	 
	if(x < 1){  alert("Value is too low!"); val.value = 1;}
	//alert(limit)
} 

function check_limit_a(val){
	var x = val.value;
	x = parseInt(x);
	//alert(x);
	//if(val == "a"){ var x = document.getElementById("id").value;  } 	
	//else{  	var x = document.getElementById("the_id").value; }  
	var y = document.getElementById("num_rows");  
	var limit = parseInt(y.value);
	if(x > limit){  alert("Value is too high!"); limit = limit + 1; val.value = limit; }	 
	if(x < 1){  alert("Value is too low!"); val.value = 1;}
	//alert(limit)
	
} 



function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }