
function isEmail(elm) {
    if (elm.value.indexOf("@") == "-1" || elm.value.indexOf(".") == "-1" || elm.value == "")
    return true;
    else return false;
}

function checkData_contactus() {
  	if (document.form_contactus.name.value.length == 0) {
		alert("Please enter your Name. ");
		document.form_contactus.name.focus();
       return false;
	};
	
	if (isEmail(document.form_contactus.email) == true) {
       alert("Please enter a valid Email address.");
		document.form_contactus.email.focus();
       return false;
    };

	if (document.form_contactus.phone.value.length == 0) {
       alert("Please enter your Phone. ");
		document.form_contactus.phone.focus();
       return false;
	};
	
	if (document.form_contactus.topic.value.length == 0) {
       alert("Please select a Topic. ");
		document.form_contactus.topic.focus();
       return false;
	};
	
	if (document.form_contactus.comments.value.length == 0) {
       alert("Please write a Comment. ");
		//document.form_contactus.comment.focus();
       return false;
	};
	
	

	return true;
}

function checkData_winkSize() {
	if ((!document.orderform2.product_options450[0].checked &&
	!document.orderform2.product_options450[1].checked &&
	!document.orderform2.product_options450[2].checked) || document.getElementById("po448").options[document.getElementById("po448").selectedIndex].value == "" || document.getElementById("po449").options[document.getElementById("po449").selectedIndex].value == ""
) {
		// no radio button is selected
alert("You must choose a size, cupcake flavor and icing flavor before ordering.");
		return false;
	}
	return true;
}
       

	   function checkData_winkSize2() {
	if ((!document.orderform.product_options454[0].checked &&
	!document.orderform.product_options454[1].checked &&
	!document.orderform.product_options454[2].checked) || document.getElementById("po453").options[document.getElementById("po453").selectedIndex].value == "" 
) {
		// no radio button is selected
alert("You must choose a size and cupcake flavor before ordering.");
		return false;
	}
	return true;
}

	   

// popup boxes
$(document).ready(function(){
 		
    		$("#alert1").click(function(){
			
			if (checkData_winkSize()) {
			
			 $.ajax({
   type: "GET",
   url: "/store/cart.php",
   data: "mode=add&productid=17516&product_options[448]=" + document.getElementById("po448").options[document.getElementById("po448").selectedIndex].value + "&product_options[449]=" + document.getElementById("po449").options[document.getElementById("po449").selectedIndex].value + "&amount=" +  document.getElementById("product_avail_input").value +"&product_options[450]=" +  $('input[name=product_options450]:checked').val()  +"&cat=&page=",
   success: function(msg){
   if ($('input[name=product_options450]:checked').val() == "4162") {
   size = "Mini Wink";
   }
   if ($('input[name=product_options450]:checked').val() == "4163") {
   size = "Wink";
   
   }
   if ($('input[name=product_options450]:checked').val() == "4164") {
   size = "Jumbo Wink";
   
   }
   
    $("#pdname").replaceWith("<div id=pdname>" +  document.getElementById("product_avail_input").value + " " + size +  " Cupcakes<br>"  + document.getElementById("po448").options[document.getElementById("po448").selectedIndex].text + " cake with "  + document.getElementById("po449").options[document.getElementById("po449").selectedIndex].text + " icing </div>")    
   }
 });
 
    			$("#dim").fadeIn();			
			$('#msgbox').show('slow');}
    			return false;		
			});
			
			
			/*product alert*/
			$("#alert3").click(function(){
			
			ajax.widgets.add2cart(document.orderform)
			 $("#pdname").replaceWith("<div id=pdname>" +  $("title").html() + " </div>")    
    			$("#dim").fadeIn();			
			$('#msgbox').show('slow');
    			return false;				
			});
			
			
			
					$("#alert2").click(function(){
			
			
			if (checkData_winkSize2()) {
		
			 $.ajax({
   type: "GET",
   url: "/store/cart.php",
   data: "mode=add&productid=17521&product_options[453]=" + document.getElementById("po453").options[document.getElementById("po453").selectedIndex].value  + "&amount=" +  document.getElementById("product_avail").value +"&product_options[454]=" +  $('input[name=product_options454]:checked').val()  +"&cat=&page=",
   success: function(msg){
   if ($('input[name=product_options454]:checked').val() == "4184") {
   size = "Mini Wink";
   }
   if ($('input[name=product_options454]:checked').val() == "4185") {
   size = "Wink";
   
   }
   if ($('input[name=product_options454]:checked').val() == "4186") {
   size = "Jumbo Wink";
   
   }
   $("#pdname").replaceWith("<div id=pdname>" +  document.getElementById("product_avail").value +  " " + size + " Cupcakes<br>"  + document.getElementById("po453").options[document.getElementById("po453").selectedIndex].text + " icing </div>")
   }
 });
 
    			$("#dim").fadeIn();			
			$('#msgbox').show('slow');}
    			return false;
			
			
			});
	
    		
    		$(".close").click(function(){
    			$("#dim").fadeOut();
                        $('#msgbox').hide('slow');
    			return false;	
			});
			
		
		});

