

DD_belatedPNG.fix('div,ul,img,button');

function validate(email) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(email) == false)
		return false;
	else
		return true;
}

$(document).ready(function() {
	$("select#select_activity").change(function() {
		if ($("#pact").css("display") == 'none')
			$("#pact").show();
		else
			$("#pact").hide();
	});

	$("img#contact_img").click(function() {
		if ($("#contact").css("display") == 'none')
			$("#contact").show('slow');
		else
			$("#contact").hide('slow');
	});
	$("a#sendit").click(function() {
		name = $("#contact_form input#cname").val();
		email = $("#contact_form input#cemail").val();
		question = $("#contact_form textarea#cquestion").val();
		send=true;
		if(!validate(email)){
			send=false;
			$("#contact_form input#cemail").css({'border':'1px solid red','background-image':'url("../images/input_bgr.gif")'});
			$("#send_warn").html("You email is not correct!");
		}
		if(!question){
			send=false;
			$("#contact_form textarea#cquestion").css({'border':'1px solid red','background-image':'url("../images/textarr.gif")'});
			$("#send_warn").html($("#send_warn").html() + "<br />Question can't be empty!");
		}
		if (send){
		$.ajax( { type: "GET", url: "/scripts/ajaxcontact.php?name="+name+"&email="+email+"&question="+encodeURIComponent(question), async: false, success: function(xml) {
			if ($("booler", xml).text()>0){
				$("#contact_form").hide();
				$("#send_succ").html("Your question has been successfully sent");
				setTimeout(function(){
					$("#contact").hide('slow',function(){
						$("#contact_form").show();
					});
					$("#send_succ").html("");
				},4000);
				$("#send_warn").html("");
				$("#contact_form input#cemail").css({'border':'1px solid #cccccc','background-image':'url("../images/input_bg.gif")'});
				$("#contact_form textarea#cquestion").css({'border':'1px solid #cccccc','background-image':'url("../images/textar.gif")'});
				$("#contact_form input#cname").val("");
				$("#contact_form input#cemail").val("");
				$("#contact_form textarea#cquestion").val("");
			}
			
			}});
		}else{
			
		}
	});
	
	
	$('<div id="loader"><img src="images/loading.gif" alt="loading..." /></div>')
			.css({position: "relative", top: "1em", left: "25em"})
			.appendTo("body")
			.hide();
	$(this).ajaxStart(function() {
			$("#loader").show();
	}).ajaxStop(function() {
		   $("#loader").show();
	}).ajaxError(function(a, b, e) {
			throw e;
	});
	

});

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17866671-1']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
