//MIKARE CMS
//public javascript functions
//Kristo Vaher - kristo@waher.net, kristo.vaher@mikare.net

$(document).ready(function(){
	$('#compatibility').css('display','none');
	// alert($('#cookieok').attr('value'));
	if($('#cookieok').attr('value')==0){
		 $.ajax({
		   type: "GET",
		   url: 'compatibility.php',
		   data: "act=compatibility",
		   success: function(msg){
				// alert('ok');
				//
		   }
		 });
	}
//    $("#top10").jCarouselLite({
//		auto: 6,
//		speed: 2501,
//		easing: "linear",
//		marginadjuster: 0,
//		visible: 5
//    });
     $("#top10").jCarouselLite({
        btnNext: ".top10right",
        btnPrev: ".top10left",
		speed: 1000,
		easing: "easeOutExpo",
		marginadjuster: 0,
		visible: 4
    });
    $("#weekoffer").jCarouselLite({
        btnNext: ".weekoffernext",
        btnPrev: ".weekofferprev",
		easing: "easeOutExpo",
		marginadjuster: 0,
		visible: 2,
		speed: 1000
    });
    $("#bigbanner").jCarouselLite({
        btnNext: ".bignext",
        btnPrev: ".bigprev",
		easing: "easeOutExpo",
		marginadjuster: 0,
		visible: 1,
		speed: 0
    });
    $("#poems").jCarouselLite({
                auto: 12000,
                easing: "easeOutSine",
		vertical: true,
		speed: 2000,
                visible: 1,
                circular: true,
                scroll: 1,
                marginadjuster: 0
    });
	var lang=$("#lang").attr("value");
	var langnode=$("#langnode").attr("value");
	var ajaxurl='libraries/ajax.php?lang='+lang;
	$("[type=button]").click(function(){
		document.location.href=$("#"+$(this).attr('linked')).attr('href');
	});

	$('[pollvote]').livequery("click", function(e){
		var poll=$(this).attr("poll");
		var votefor=$(this).attr("votefor");
		$("#pollbox").fadeOut("normal");
		$("#pollbox").load(ajaxurl+"&act=pollsubmit&poll="+poll+"&votefor="+votefor,{},function(msg){
			if(msg!=''){
				$("#pollbox").css('display','none');
				$("#pollbox").fadeIn("normal");
			}
		});
	});
	$("[type=addtocart]").livequery("click", function(e){
		var productid=$(this).attr("productid");
		var thiselement=$(this);
		 $.ajax({
		   type: "GET",
		   url: ajaxurl,
		   data: "act=addtocart&productid="+productid+"&type="+lang+"&langnode="+langnode,
		   success: function(msg){
				if(msg=='error'){
					alert('This product is not active!');
				} else {
					//alert(msg);
					setTimeout('document.location.href="'+msg+'";',500);
				}
		   }
		 });
		e.preventDefault();
	});
	var thiselement;
	$("[moveonclick]").click(function(){
		//$(this).css("margin-left","3px");
	});
	$("[moveonclick2]").click(function(){
		//$(this).css("margin-top","3px");
	});
	$("#confirmorder").livequery("click", function(e){
		var continueto=$(this).attr("continue");
		$.post(ajaxurl+"&act=confirmorder", {}, function(data){ document.location.href=continueto; });
	});
	$("[type=showthumb]").hover(
		function(){
			var slot=$(this).attr("showthumb");
			$("#"+slot).fadeIn(200);
		},
		function(){
			var slot=$(this).attr("showthumb");
			$("#"+slot).fadeOut(200);
		}
	);
	$("#submitordertransport").livequery("click", function(e){
		if(checkAndMarkTransportFields()==true){
			var continueto=$(this).attr("continue");
			var order_name=$("#order_name").attr('value');
			var order_email=$("#order_email").attr('value');
			var order_company=$("#order_company").attr('value');
			var order_phone=$("#order_phone").attr('value');
			var order_delivery_house=$("#order_delivery_house").attr('value');
			var order_delivery_town=$("#order_delivery_town").attr('value');
			var order_delivery_state=$("#order_delivery_state").attr('value');
			var order_delivery_country=$("#order_delivery_country").attr('value');
			var order_delivery_postcode=$("#changetransporttype").val();
			var order_billing_house=$("#order_billing_house").attr('value');
			var order_billing_town=$("#order_billing_town").attr('value');
			var order_billing_state=$("#order_billing_state").attr('value');
			if($("#order_private_business_business").attr('checked')){
				var privatebusiness='business';
			} else {
				var privatebusiness='private';
			}
			var order_private_business=privatebusiness;
			var order_billing_country=$("#order_billing_country").attr('value');
			var order_billing_postcode=$("#order_billing_postcode").attr('value');
			var order_comments=$("#order_comments").attr('value');
                        var order_poem = '';
                        if ($('#order_poem').length != 0) {order_poem=$("#order_poem").attr('value')} 
			$.post(ajaxurl+"&act=ordertransport", { order_name: order_name , 
								order_email: order_email, 
								order_company: order_company, 
								order_phone: order_phone, 
								order_delivery_house: order_delivery_house, 
								order_delivery_town: order_delivery_town, 
								order_delivery_state: order_delivery_state, 
								order_private_business: order_private_business, 
								order_delivery_country: order_delivery_country, 
								order_delivery_postcode: order_delivery_postcode, 
								order_billing_house: order_billing_house, 
								order_billing_town: order_billing_town, 
								order_billing_state: order_billing_state, 
								order_comments: order_comments,
                                                                order_poem: order_poem,
								order_billing_country: order_billing_country, 
								order_billing_postcode: order_billing_postcode },  function(data){
									document.location.href=continueto;
								});
		}
	});
	$("[type=infobox]").hover(
		function(){
			var thiselement=$(this);
			var target=$(this).attr("target");
			var offset=thiselement.offset();
			$("#"+target).css("left",offset.left);
			$("#"+target).css("top",(offset.top+20));
			$("#"+target).toggle("fast");
		},
		function(){
			var thiselement=$(this);
			var target=$(this).attr("target");
			$("#"+target).toggle("fast");
		}
	);
	$("#cartconfirm").livequery("click", function(e){
		e.preventDefault();
		var values='';
		for(i=1;$("#quantity_"+i).length>0;i++){
			values=values+"&q"+$("#quantity_"+i).attr("tag")+"="+$("#quantity_"+i).attr("value");
		}
		 $.ajax({
		   type: "GET",
		   url: ajaxurl,
		   data: "act=updatequantities&type="+lang+"&langnode="+langnode+values,
		   success: function(msg){
				document.location.href=document.location.href;
		   }
		 });
	});
	$("#cartform").submit(function(e){
		e.preventDefault();
		var values='';
		for(i=1;$("#quantity_"+i).length>0;i++){
			values=values+"&q"+$("#quantity_"+i).attr("tag")+"="+$("#quantity_"+i).attr("value");
		}
		 $.ajax({
		   type: "GET",
		   url: ajaxurl,
		   data: "act=updatequantities&type="+lang+"&langnode="+langnode+values,
		   success: function(msg){
				document.location.href=$("#nextstep").attr("value");
		   }
		 });
		return false;
	});
	$("#accountediting").submit(function(){
		if($("#new_password").attr("value")==$("#new_password_again").attr("value")){
			if($("#cansubmit").attr("value")==0){
				var pass=$("#currentpassword").attr("value");
				 $.ajax({
				   type: "GET",
				   url: ajaxurl,
				   data: "act=checkpassword&password="+encodeURIComponent(pass)+"&langnode="+langnode,
				   success: function(msg){
						if(msg=='correct'){
							$("#cansubmit").attr("value","1");
							document.accountediting.submit();
						} else {
							$('#currentpassword').css("background-color","#ef8989");
							alert(msg);
							return false;
						}
				   }
				 });
				return false;
			} else {
				return true;
			}
		} else {
			$('#new_password').css("background-color","#ef8989");
			$('#new_password_again').css("background-color","#ef8989");
			return false;
		}
	});
	$("#registersubmitting").submit(function(){
		if($("#cansubmit").attr("value")==0){
			var valid=1;
			//testing email validity
			var filter=/^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,4})$/;
			if(filter.test($('#register_email').attr("value"))!=true || $('#register_email').attr("value")==''){
				valid=0;
				$('#register_email').css("background-color","#ef8989");
			}
			//testing password matching
			if($('#register_password').attr("value")=='' || $('#register_password').attr("value")!=$('#register_passwordagain').attr("value")){
				valid=0;
				$('#register_password').css("background-color","#ef8989");
				$('#register_passwordagain').css("background-color","#ef8989");
			}
			//testing if name field is not empty
			if($('#register_name').attr("value")==''){
				valid=0;
				$('#register_name').css("background-color","#ef8989");
			}
			//testing if name field is not empty
			if($('#register_username').attr("value")==''){
				valid=0;
				$('#register_username').css("background-color","#ef8989");
			}
			if(valid==1){
				var checkuser=$("#register_password").attr("value");
				var checkemail=$("#register_email").attr("value");
				 $.ajax({
				   type: "GET",
				   url: ajaxurl,
				   data: "act=checkuseremail&user="+encodeURIComponent(checkuser)+"&email="+encodeURIComponent(checkemail)+"&langnode="+langnode,
				   success: function(msg){
						if(msg=='correct'){
							$("#cansubmit").attr("value","1");
							document.registersubmitting.submit();
						} else {
							var messagefield=msg.split(":::");
							if(messagefield[0]=='username'){
								$('#'+messagefield[0]).css("background-color","#ef8989");
								alert(messagefield[1]);
							} else {
								$('#'+messagefield[0]).css("background-color","#ef8989");
								alert(messagefield[1]);
							}
							return false;
						}
				   }
				 });
			}
			return false;
		} else {
			return true;
		}
	});
	$("#newsletterformsubmit").submit(function(){
		var filter=/^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,4})$/;
		if(filter.test($('#newsletter_join_email').attr("value"))==true){
			return true;
			
		} else {
			$('#newsletter_join_email').css("background-color","#ef8989");
			return false;
		}
	});
	$("[type=deletecart]").livequery("click", function(e){
		var item=$(this).attr("item");
		 $.ajax({
		   type: "GET",
		   url: ajaxurl,
		   data: "act=deletecart&item="+item+"&type="+lang+"&langnode="+langnode,
		   success: function(msg){
				$("#cartrow_"+item).fadeOut("normal",function(){
					document.location.href=document.location.href;
				});
		   }
		 });
		e.preventDefault();
	});
	$("#changetransportmethod").livequery("change", function(e){
		var transport=$(this).attr("value");
		 $.ajax({
		   type: "GET",
		   url: ajaxurl,
		   data: "act=changetransport&transport="+transport+"&lang="+lang+"&langnode="+langnode,
		   success: function(msg){
				document.location.href=document.location.href;
		   }
		 });
	});
	$("#changetransporttype").livequery("change", function(e){
		var transport=$(this).attr("value");  
		 $.ajax({
		   type: "GET",
		   url: ajaxurl,
		   data: "act=changetransport&transport="+transport+"&lang="+lang+"&langnode="+langnode,
		   success: function(msg){
                           if ($('form[name="register-submitting"]')[0] == undefined)
				document.location.href=document.location.href;
		   }
		 });
	});
	$("#changepayment").livequery("change", function(e){
		var payment=$(this).attr("value");
		 $.ajax({
		   type: "GET",
		   url: ajaxurl,
		   data: "act=changepayment&payment="+payment+"&lang="+lang+"&langnode="+langnode,
		   success: function(msg){
				//document.location.href=document.location.href;
		   }
		 });
	});
	$("[type=categorycompare]").livequery("click", function(e){
		var element=$(this).attr("element");
		var category=$(this).attr("category");
		var actualtotal=$("#actualtotal").attr("value");
		$("#banner").css('display','none');
		$("#overlay").css('display','');
		$("embed").css('display','none');
		if (actualtotal && actualtotal>0){
			var comparethese='';
			for(var i=1;i<=actualtotal;i++){
				if($("#productcompare_"+i).attr("checked")==true){
					comparethese+=($("#productcompare_"+i).attr("value"))+':';
				}
			}
			$("#overlay_content").load(ajaxurl+"&act=compare&element="+element+"&category="+category+"&comparethese="+comparethese,{},function(msg){
				if(msg!=''){
					$("#overlay_content").css('display','none');
					$("#overlay_content").fadeIn("slow");
				}
			});
		} else {
			$("#overlay_content").load(ajaxurl+"&act=compare&element="+element+"&category="+category,{},function(msg){
				if(msg!=''){
					$("#overlay_content").css('display','none');
					$("#overlay_content").fadeIn("slow");
				}
			});
		}
		e.preventDefault();
	});
	$("[type=productcomments]").livequery("click", function(e){
		var productid=$(this).attr("productid");
		$("#banner").css('display','none');
		$("#overlay").css('display','');
		$("embed").css('display','none');
		$("#overlay_content").load(ajaxurl+"&act=productcomments&productid="+productid,{},function(msg){
			if(msg!=''){
				$("#overlay_content").css('display','none');
				$("#overlay_content").fadeIn("slow");
			}
		});
		e.preventDefault();
	});
	$("[type=viewlarge]").livequery("click", function(e){
		var winheight=$(window).height();
		var picturename=$(this).attr("picturename");
		var filenames=$("#filenamearray").attr("value");
		$("#banner").css('display','none');
		$("#overlay").css('display','');
		$("embed").css('display','none');
		$("#overlay_content").load(ajaxurl+"&act=viewlarge&picturename="+picturename+"&winheight="+winheight,{filenames:filenames},function(msg){
			if(msg!=''){
				$("#overlay_content").css('display','none');
				$("#overlay_content").fadeIn("slow");
			}
		});
		e.preventDefault();
	});
	$("[type=prevnextimage]").livequery("click", function(e){
		var winheight=$(window).height();
		var picturename=$(this).attr("picturename");
		var filenames=$("#filenamearray").attr("value");
		$("#overlay_content").load(ajaxurl+"&act=viewlarge&picturename="+picturename+"&winheight="+winheight,{filenames:filenames},function(msg){
			if(msg!=''){
				// $("#overlay_content").css('display','none');
				// $("#overlay_content").fadeIn("fast");
			}
		});
		e.preventDefault();
	});
	$(".closearrow").click(function(){
		//$("body").css('overflow','auto');
		$("#overlay").css('display','none');
		$("embed").css('display','');
		$("#banner").css('display','');
		$("#overlay_content").html('<img src="design/loading.gif"/>');
	});
	$(".productpic_thumb").click(function(){
		var file=$(this).attr("file");
		$("#product_picture_slot").fadeTo("fast",0.01,function(){
			$("#product_picture_slot").attr("picturename",file);
			$("#product_picture_slot").attr("src","uploads/pictures/medium/"+file);
			$("#product_picture_slot").fadeTo("normal",1);
		});
	});
	$(".purple_inactive_left[object='description']").attr("class","purple_active_left");
	$(".purple_inactive_content[object='description']").attr("class","purple_active_content");
	$(".purple_inactive_right[object='description']").attr("class","purple_active_right");
	$("#databox").html($("#hidden_description").html());
	$(".purple_inactive_content").livequery("click",function(e){
		$(".purple_active_left").attr("class","purple_inactive_left");
		$(".purple_active_content").attr("class","purple_inactive_content");
		$(".purple_active_right").attr("class","purple_inactive_right");
		var activate=$(this).attr("to");
		$(".purple_inactive_left[object="+activate+"]").attr("class","purple_active_left");
		$(".purple_inactive_content[object="+activate+"]").attr("class","purple_active_content");
		$(".purple_inactive_right[object="+activate+"]").attr("class","purple_active_right");
		$("#databox").fadeTo("fast",0.01,function(){
			$("#databox").html($("#hidden_"+activate).html());
			$("#databox").fadeTo("fast",1);
		});
	});
	$(".hidefromcomparison").livequery("click", function(e){
		var hook=$(this).attr("clicked");
		$("td[hook="+hook+"]").hide("fast");
	});
	$("[type=recentlyviewed]").livequery("click", function(e){
		var from=$(this).attr("from");
		var type=$("#type-value").attr("value");
		$("#recentlyviewedbox").html('<img src="design/loading.gif" style="margin:20px;margin-left:60px;"/>');
		$("#recentlyviewedbox").load(ajaxurl+"&act=recentlyviewed",{from:from,type:type},function(msg){
			if(msg!=''){
				$("#recentlyviewedbox").css('display','none');
				$("#recentlyviewedbox").fadeIn("fast");
			}
		});
	});
	$("[type=favoriteslist]").livequery("click", function(e){
		var from=$(this).attr("from");
		var type=$("#type-value").attr("value");
		$("#favoritesbox").html('<img src="design/loading.gif" style="margin:20px;margin-left:60px;"/>');
		$("#favoritesbox").load(ajaxurl+"&act=favoriteslist",{from:from,type:type},function(msg){
			if(msg!=''){
				$("#favoritesbox").css('display','none');
				$("#favoritesbox").fadeIn("fast");
			}
		});
	});
	$("[type=removefavorite]").livequery("click", function(e){
		var from=$(this).attr("from");
		var remove=$(this).attr("removeid");
		var type=$("#type-value").attr("value");
		$("#favoritesbox").html('<img src="design/loading.gif" style="margin:20px;margin-left:60px;"/>');
		$("#favoritesbox").load(ajaxurl+"&act=favoriteslist",{from:from,type:type,remove:remove},function(msg){
			if(msg!=''){
				$("#favoritesbox").css('display','none');
				$("#favoritesbox").fadeIn("fast");
			}
		});
	});
	$("#righthandboxtype").change(function(){
		var current=$(this).attr("value");
		 $.ajax({
		   type: "GET",
		   url: ajaxurl,
		   data: "act=righthandtype&righthandtype="+current,
		   success: function(msg){
				if(current=='recentlyviewedbox'){
					$("#recentlyviewed-title").html($("#"+current).attr("titleline"));
					$("#favoritesbox").fadeOut("fast");
					$("#recentlyviewedbox").fadeIn("fast");
				}
				if(current=='favoritesbox'){
					$("#recentlyviewed-title").html($("#"+current).attr("titleline"));
					$("#recentlyviewedbox").fadeOut("fast");
					$("#favoritesbox").fadeIn("fast");
				}
		   }
		 });
	});
	$("#product_note_form").submit(function(e){
		var status=$("#func_check").attr("value");
		if(status==1){
			$("#righthandboxtype").attr("value","favoritesbox");
			$("#recentlyviewedbox").fadeOut("fast");
			$("#favoritesbox").fadeOut("fast");
			var from=0;
			var type=$("#type-value").attr("value");
			var SB=$("#SB-data").attr("value");
			var productid=$("#product_note_id").attr("value");
			var notetext=$("#product_note").attr("value");
			$("#favoritesbox").html('<img src="design/loading.gif" style="margin:20px;margin-left:60px;"/>');
			$("#favoritesbox").load(ajaxurl+"&act=favoriteslist",{from:from,type:type,productid:productid,notetext:notetext},function(msg){
				if(msg!=''){
					$("#favoritesbox").css('display','none');
					$("#recentlyviewed-title").html($("#favoritesbox").attr("titleline"));
					$("#favoritesbox").fadeIn("fast");
				}
			});
		} else {
			//alert($("#favorites_translation").attr("value"));
			document.location.href=$("#notregistered").attr("value");
		}
		e.preventDefault();
	});
	$("#comment-submitting").livequery("submit", function(e){
		var status=$("#func_check").attr("value");
		if(status==1){
			var commentname=$("#comment_name").attr("value");
			var commentmail=$("#comment_email").attr("value");
			var commentmessage=$("#comment_message").attr("value");
			var productid=$("#productid").attr("value");
			var errormessage=$("#errormessage").attr("value");
			if(commentname=='' || commentmessage==''){
				alert(errormessage);
			} else {
				$("#banner").css('display','none');
				$("#overlay").css('display','');
				$("embed").css('display','none');
				$("#overlay_content").load(ajaxurl+"&act=productcomments&productid="+productid,{commentname:commentname,commentmail:commentmail,commentmessage:commentmessage},function(msg){
					if(msg!=''){
						$("#overlay_content").css('display','none');
						$("#overlay_content").fadeIn("slow");
					}
				});
			}
		} else {
			//alert($("#comment_translation").attr("value"));
			document.location.href=$("#notregistered").attr("value");
		}
		e.preventDefault();
	});
	$("[type=productinquiry]").livequery("click", function(e){
		var productid=$(this).attr("productid");
		$("#banner").css('display','none');
		$("#overlay").css('display','');
		$("embed").css('display','none');
		$("#overlay_content").load(ajaxurl+"&act=productinquiry&productid="+productid,{},function(msg){
			if(msg!=''){
				$("#overlay_content").css('display','none');
				$("#overlay_content").fadeIn("slow");
			}
		});
		e.preventDefault();
	});
	$("#productinquiry-submitting").livequery("submit", function(e){
		var productid=$("#productid").attr("value");
		var inquiry_url=$("#urlnodes").attr("value");
		var inquiry_name=$("#inquiry_name").attr("value");
		var inquiry_officialname=$("#inquiry_officialname").attr("value");
		var inquiry_email=$("#inquiry_email").attr("value");
		var inquiry_address=$("#inquiry_address").attr("value");
		var inquiry_phone=$("#inquiry_phone").attr("value");
		var inquiry_fax=$("#inquiry_fax").attr("value");
		var inquiry_contactby_email=$("#inquiry_contactby_email").attr("checked");
		var inquiry_contactby_address=$("#inquiry_contactby_address").attr("checked");
		var inquiry_contactby_phone=$("#inquiry_contactby_phone").attr("checked");
		var inquiry_contactby_fax=$("#inquiry_contactby_fax").attr("checked");
		var inquiry_content=$("#inquiry_content").attr("value");
		var errormessage=$("#errormessage").attr("value");
		if(inquiry_name=='' || inquiry_content==''){
			alert(errormessage);
		} else {
			$("#banner").css('display','none');
			$("#overlay").css('display','');
			$("embed").css('display','none');
			$("#overlay_content").load(ajaxurl+"&act=inquirysubmitting&productid="+productid,{inquiry_content:inquiry_content,inquiry_url:inquiry_url,inquiry_contactby_fax:inquiry_contactby_fax,inquiry_contactby_phone:inquiry_contactby_phone,inquiry_contactby_address:inquiry_contactby_address,inquiry_contactby_email:inquiry_contactby_email,inquiry_fax:inquiry_fax,inquiry_phone:inquiry_phone,inquiry_address:inquiry_address,inquiry_name:inquiry_name,inquiry_officialname:inquiry_officialname,inquiry_email:inquiry_email},function(msg){
				if(msg!=''){
					$("#overlay_content").css('display','none');
					$("#overlay_content").fadeIn("slow");
					setTimeout("$(\"#overlay\").css(\'display\',\'none\');$(\"embed\").css(\'display\',\'\');$(\"#banner\").css(\'display\',\'\');$(\"#overlay_content\").html(\'<img src=\"design/loading.gif\"/>\');", 2000);
				}
			});
		}
		e.preventDefault();
	});
});

jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

// Credits: Robert Penners easing equations (http://www.robertpenner.com/easing/).
jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};

function checkAndMarkTransportFields(){
	var valid=1;
	if($('#order_name').attr("value")==''){
		valid=0;
		$('#order_name').css("background-color","#ef8989");
	}
	if($('#order_phone').attr("value")==''){
		valid=0;
		$('#order_phone').css("background-color","#ef8989");
	}
	if($('#order_email').attr("value")==''){
		valid=0;
		$('#order_email').css("background-color","#ef8989");
	} else {
		var filter=/^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,4})$/;
		if(filter.test($.trim($('#order_email').attr("value")))!=true){
			valid=0;
			$('#order_email').css("background-color","#ef8989");
		}
	}
	if($('#order_delivery_house').attr("value")==''){
		valid=0;
		$('#order_delivery_house').css("background-color","#ef8989");
	}
	if($('#order_delivery_town').attr("value")==''){
		valid=0;
		$('#order_delivery_town').css("background-color","#ef8989");
	}
	if($('#order_delivery_state').attr("value")==''){
		valid=0;
		$('#order_delivery_state').css("background-color","#ef8989");
	}
	if($('#order_delivery_postcode').attr("value")==''){
		valid=0;
		$('#order_delivery_postcode').css("background-color","#ef8989");
	}
	if(valid==1){
		return true;
	} else {
		return false;
	}
}
