// JavaScript Document menu.js



$(document).ready(function() {

//menu
	
	$('.menu').hover(function () {
		clearTimeout($.data(this, 'timer'));
		$('li', this).stop(true, true).slideDown(200);
	}, function () {
	
		$.data(this, 'timer', setTimeout($.proxy(
		function() {
			$('li', this).stop(true, true).slideUp(200);
		}, 
		this), 200)
		);
	});
	
//marketing bullshit bingo

    runIt();

//carousel

    $('#badges').jcarousel();

//sidebar-menu

	$('#sidebar-menu a').stop().animate({'marginLeft':'-100px'},1000);

	$('#sidebar-menu > li').hover(
		function () {
		    $('a',$(this)).stop().animate({'marginLeft':'-10px'},200);
		},
		function () {
		    $('a',$(this)).stop().animate({'marginLeft':'-100px'},200);
		}
	);
	

// contact form	

	$('#contact-form').submit(function(event){
		
		event.preventDefault();
		
		var $form = $(this),
		url = $form.attr( 'action' ),
		cname = $('#contact-name').val(),
		cemail = $('#contact-email').val()

		if(checkName(cname)){
			if (checkMail(cemail)){
					//send mail
					$.post("php/mail.php", { 
						cname: cname, 
						cemail: cemail,
						comment: $('#comments').val(),
						code: $('#code').val()
					},
						function(response){
							if(response){
							$('#code-img').attr('src', 'php/imgval/code.php?id=' + ++ts +'&random=' + Math.floor(Math.random()*ts));
								if(response == 'email_sent'){
									$("div.content, div.citem").hide("slow");									
								}
								showNote(locale,response);

							}else{
								showNote(locale,'unknown_error');
							}
					});
			}else{
				showNote(locale,'email_error');
			}		
		}else{
			showNote(locale,'name_error');
		}
	});
});



	var content = ("#contact, #about, #news, #links");
	
	$(content).hide();
	
	$("nav a").click(function(e){
		e.preventDefault();
		$(content).hide();
		$($(this).attr("href")).slideToggle();
	});

