$(document).ready(function(){
	$('#contact-container').css({'display' : 'none'});
	$('.main-link').css({backgroundPosition: "0 70px"}).mouseover(function(){$(this).stop().animate({backgroundPosition:"(0 -1)"},{duration:150})
	})
	.mouseleave(function(){
		$(this).stop().animate(
		{backgroundPosition:"(0 70px)"}, 
		{duration:150})
	})
	// Contact Form fnc
	function Contact(){
	$('#loader').html('<img src="loaders/loader.gif" width="16" height="16" />');
	$.getJSON('controlers/captcha-gen.php?hashcap=true', function(data){
	   $('#loader').html('');
	   var dataCaptcha = data.captcha,
	   	   dataHashcap = data.hashcap;
    	 $('#capstring').html(dataCaptcha);
		 $('#captcha-hash').val(dataHashcap);
   },"json");
}
	//Toggle Button
	$('.contact').click(function(){Contact();$('#contact-container').toggle(200);});
	//Refresh Button
	$('#capt-refresh').click(function(){Contact();});
	//Send Button & fnc
	$('#captcha').keyup(function(){
		$.post('email/mail.php?scr='+$('#captcha').val()+'&hs='+$('#captcha-hash').val(), function(r){
		if((r) == 0){
			$('#c-message').html('Please retype numbers');
		return false;
		}
		if((r) == 1){
			$('#c-message').html('');
			$('#send').show();
		}
			});
	});
	$('#send').click(function(){
	$.post('email/mail.php?email='+$('#email').val()+'&comment='+$('#comment').val(), function(r){
		if((r) == 100){
			$('#c-message').html('Provide Email');
		return false;
		}
		if((r) == 101){
			$('#c-message').html('Invalid email format');
		return false;
		}
		if((r) == 102){
			$('#c-message').html('please comment');
		return false;
		}
		if((r) == 103){
			$('#c-wrap').fadeOut(100);
			$('#c-complete').fadeIn(300).html('&radic; Your message was sent');
		}
		});
		Contact();
	});
});
