// JavaScript Document
function open_pic(opener)
	{
	popUp2 = window.open("content/pic_pop.php?id="+opener,"Gift_Form","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=500,height=450, left=0, top=0")

popUp2.focus()
	}
function validForm(passform)
	{
		
		if(passform.what_item.value == "")
				{
				alert("You need to an item description")
				passform.what_item.focus()
				return false
				}
		if(passform.how_much.value == "")
				{
				alert("You need to a payment amount")
				passform.how_much.focus()
				return false
				}
		
		else
				{
				sText = passform.how_much.value;
				var ValidChars = "0123456789.";
   				var IsNumber=true;
   				var Char;

						for (i = 0; i < sText.length && IsNumber == true; i++) 
      						{ 
      							Char = sText.charAt(i); 
      							if (ValidChars.indexOf(Char) == -1) 
         							{
         								IsNumber = false;
         								alert("You need to enter a number")
										passform.how_much.value = ""
										passform.how_much.focus()
										return false
         							}
      						}
				}
		
		if(passform.contact_email.value == "")
				{
				alert("You need to enter your email address. We will never give this to anyone and use it to contact you if there is a problem with the payment")
				passform.contact_email.focus()
				return false
				}
		else
				{
					var x = passform.contact_email.value;
					var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
							if (filter.test(x)) 
									{
										//document.paypal_form.submit();
										return true
									}
							else 
									{
										alert('Enter a valid email address. We will never give this out to anybody');
										passform.contact_email.value="";
										passform.contact_email.focus();
										return false
									}
				}
		
	}
	
function checkOut(passform)
	{
		if(passform.x_first_name.value == "")
				{
				alert("You need to enter your first name")
				passform.x_first_name.focus()
				return false
				}
		if(passform.x_last_name.value == "")
				{
				alert("You need to enter your last name")
				passform.x_last_name.focus()
				return false
				}
		if(passform.x_address.value == "")
				{
				alert("You need to enter your address")
				passform.x_address.focus()
				return false
				}
		if(passform.x_city.value == "")
				{
				alert("You need to enter your city")
				passform.x_city.focus()
				return false
				}
				
		if(passform.x_state.value == "")
				{
				alert("You need to enter your state")
				passform.x_state.focus()
				return false
				}
				
		if(passform.x_zip.value == "")
				{
				alert("You need to enter your zip")
				passform.x_zip.focus()
				return false
				}
				
		if(passform.x_phone.value == "")
				{
				alert("You need to enter a phone number")
				passform.x_phone.focus()
				return false
				}
				
		if(passform.x_email.value == "")
				{
				alert("You need to enter an email address")
				passform.x_email.focus()
				return false
				}
		else
				{
					var x = passform.x_email.value;
					var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
							if (filter.test(x)) 
									{
										//document.paypal_form.submit();
										return true
									}
							else 
									{
										alert('Enter a valid email address. We will never give this out to anybody');
										passform.x_email.value="";
										passform.x_email.focus();
										return false
									}
				}
	}
	
function switchNav(former)
	{
		var num = former.value
		if(num != 'choose')
		{
		window.location="?page=select&mode=cat&cat_num="+num
		}
	}
	
function switchLabel(former)
	{
		var num = former.value
		if(num != 'choose')
		{
		window.location="?page=select&mode=label&cat_num="+num
		}
	}
	

function send_paypal()
	{
		document.paypal_form.submit();
	}
	
function validNumber(passform)
		{
			if(passform.quantity.value == "")
				{
				alert("You need to enter a quantity")
				passform.quantity.focus()
				return false
				}
			else
				{
				sText = passform.quantity.value;
					var ValidChars = "0123456789.";
   				var IsNumber=true;
   				var Char;

						for (i = 0; i < sText.length && IsNumber == true; i++) 
      				{ 
      					Char = sText.charAt(i); 
      							if (ValidChars.indexOf(Char) == -1) 
         							{
         								IsNumber = false;
         								alert("You need to enter a number");
         								passform.quantity.value = "";
         								passform.quantity.focus();
         							}
      				}
						
						if(IsNumber == false)
							{
								return false;
							}
						else
							{
								
								return true
								
							}
				}
		}	