function getMap(){
	mypage = "map_large.html";
	myname = "map";
	w = "640";
	h = "550";
	popUp(mypage, myname, w, h);
}

function popUp(mypage, myname, w, h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,scrollbars=no,resize=no,location=no';
	window.open(mypage,myname,settings);
}

function priceInquiry(){
	var temp = false;	
	var key = document.processor;
        if(key.first_name.value == ''){
                alert('First Name cannot be blank.');
                key.first_name.focus();
        }else if(key.last_name.value == ''){
                alert('Last Name cannot be blank.');
                key.last_name.focus();
        }else if(key.address1.value == ''){
                alert('Address 1 cannot be blank.');
                key.address1.focus();
        }else if(key.city.value == ''){
                alert('City cannot be blank.');
                key.city.focus();
        }else if(key.state.value == ''){
                alert('State cannot be blank.');
                key.state.focus();
        }else if(key.zip_code.value == ''){
                alert('Zip Code cannot be blank.');
                key.zip_code.focus();
        }else if(key.telephone.value == ''){
                alert('Telephone cannot be blank.');
                key.telephone.focus();
        }else if(key.email.value == ''){
                alert('E-Mail cannot be blank.');
                key.email.focus();
        }else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(key.email.value))){
				alert("Invalid E-mail Address! Please re-enter.")
                key.email.focus();
        }else{
		temp = true;
		key.submit();
	}
	return temp;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function Navigate(page){
  var frm = document.navigate;
  if (page == 'update_user'){
     if(validateField() == true)
        document.signupForm.submit();
  }else if(page == "submit_order"){
	document.cart.page.value = "submit_order";
	document.cart.submit();
  }else if(page == "EmptyCart"){
	if (confirm("Are you sure you want to empty your cart?")){
     		frm.special.value = "EMPTY|";
     		frm.page.value = "view_cart";
     		frm.submit();
	}
   }else if(page == "sign_out"){
	if(confirm("Are you sure you want to signout?")){
	   frm.special.value = 'SIGNOUT|';
	   frm.submit();
	}
  }else{
     	frm.page.value = page;
     	frm.submit();
  }
}

function signIn(){
  var email = document.signin.email.value;
  var pass  = document.signin.pass.value;
  if(email == ''){
	alert('You must enter your email address to continue!');
	document.signin.email.focus();
  }else if(pass == ''){
	alert('You must enter your password to continue!');
	document.signin.pass.focus();
  }else
	document.signin.submit();
}
function forgotPassword(){
  var frm = document.navigate;
  var email = document.signin.email2.value;
  if(email == ''){
	alert('You must enter your email address to continue!');
	document.signin.email.focus();
  }else{
	frm.special.value = "SENDPASS|"+email;
	frm.page.value = "sign_in";
	frm.submit();
  }
}
function getProdCat(cat){
	document.navigate.cat.value = cat;
	Navigate("products");	
}

function getProdInfo(prod){
	document.navigate.item_id.value = prod;
	Navigate("listing");	
}

function RemoveItem(item){
	if (confirm("Are you sure you want to remove this item?")){
	   document.navigate.special.value = 'REMOVE|'+item;
	   document.navigate.submit();
	}
}

function validateField(){
        var valid = false;
        var key = document.signupForm;
       if(key.fname.value == ''){
                alert('First Name cannot be blank.');
                key.fname.focus();
        }else if(key.lname.value == ''){
                alert('Last Name cannot be blank.');
                key.lname.focus();
	}else if(key.fname.value == key.lname.value){
                alert('First Name and Last Name fields cannot be identical. Please review and re-submit.');
                key.fname.focus();		
        }else if(key.email.value == ''){
                alert('E-Mail cannot be blank.');
                key.email.focus();
	}else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(key.email.value))){
		alert("Invalid E-mail Address! Please re-enter.")
                key.email.focus();
        }else if(key.password.value == ''){
                alert('Password cannot be blank.');
                key.password.focus();
        }else if(key.confirm.value != key.password.value){
                alert('Passwords do not match.');
                key.password.focus();
        }else if(key.city.value == ''){
                alert('City cannot be blank.');
                key.city.focus();
        }else if(key.state.value == ''){
                alert('State cannot be blank.');
                key.state.focus();
        }else if(key.zip.value == ''){
                alert('Zip Code cannot be blank.');
                key.zip.focus();
	//}else if(key.zip.value != parseFloat(key.zip.value)){
    //           alert('The Zip Code you entered contains letters or non-numeric characters. Please ensure the zip code field only contains numbers and re-submit.');
    //          key.fname.focus();		
        }else{
                valid = true;
        }
        return valid;
}
function checkOut(){
	document.cart.update_item.value = 1;
	document.cart.page.value = 'check_out';
	document.cart.submit();
}
function submitOrder(){
	
document.cart.update_item.value = 1;
	document.cart.page.value = 'submit_order';
	document.cart.submit();
}
function continueShopping(){
	document.cart.update_item.value = 1;
	document.cart.page.value = 'product';
	document.cart.submit();
}
function payment(){
	document.cart.page.value = 'payment';
	document.cart.submit();
}

function updateCart(){
        var cart = document.cart;
        cart.update_item.value = 1;
        cart.submit();
}

function Notes(){
	var notes = document.cart.notes.value;
	mypage = "notes.html?notes="+notes;
	myname = "notes";
	w = "375";
	h = "200";
	popUp(mypage, myname, w, h);
}
function popUp(mypage, myname, w, h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,scrollbars=no,resize=no,location=no';
	window.open(mypage,myname,settings);

}

function saveNotes(){
	var cart = window.opener.document.cart;
	cart.notes.value = document.weborder.notes.value;
	cart.update_item.value = 1;
	cart.submit();
	self.close();	
}

function numbersOnly(key, dec){
  var isNS4 = (navigator.appName=="Netscape")?1:0;
  if(!isNS4)
  {
	if(key.keyCode < 48 || key.keyCode > 57){ 
	  if(!dec || key.keyCode != 46){ 
	  	key.returnValue = false;
  	  }
  	}
  }
  else
  {
	if(key.which < 48 || key.which > 57){ 
	  if(!dec || key.which != 46){ 
	  	returnfalse;
  	  }
  	}
  }
}
