$(document).ready(function(){
	
	// main navigation effects
	$('#navigation a.about').css('opacity','0.5');
	$('ul#navigation li').hover(function(){
		$(this).stop().animate({marginRight:6}, 250);
		}, function(){
			$(this).stop().animate({marginRight:0}, 250)
	});
	$('#navigation a.about').click(function(){
		$('#content').animate({'top':'0'},700);
		$('#navigation a').css('opacity','1');
		$(this).css('opacity','0.5');
	});
	$('#navigation a.services').click(function(){
		$('#content').animate({'top':'-590'},700);
		$('#navigation a').css('opacity','1');
		$(this).css('opacity','0.5');
	});
	$('#navigation a.portfolio').click(function(){
		$('#content').animate({'top':'-1205'},700);
		$('#navigation a').css('opacity','1');
		$(this).css('opacity','0.5');
	});
	$('#navigation a.tips').click(function(){
		$('#content').animate({'top':'-1830'},700);
		$('#navigation a').css('opacity','1');
		$(this).css('opacity','0.5');
	});
	$('#navigation a.contact').click(function(){
		$('#content').animate({'top':'-2450'},700);
		$('#navigation a').css('opacity','1');
		$(this).css('opacity','0.5');
	});
	
	// view all of my works button
	$('a#allworks').click(function(){
		$('#content').animate({'top':'-1205'},700);
		$('#navigation a.about').css('opacity','1');
		$('#navigation a.portfolio').css('opacity','0.5');
	});
	

	// logo click effect
	$(".avatar-link").click(function(){
		$('#content').animate({'top':'0'},700);
		$("#navigation a").css('opacity','1');		
		$('#navigation a.about').css('opacity','0.5');
	});
	
	// front-end developer. click effect
	$(".uibeercoffee-link").click(function(){
		$('#content').animate({'top':'-590'},700);
		$('#navigation a').css('opacity','1');
		$("#navigation a.services").css('opacity','0.5');
	});
	$('#twitter a').click(function(){
		$('#twits').animate({'left':'0px'},200);
		$(this).css('opacity','0.5');
	});
	$('#twits').click(function(){
		$('#twits').animate({'left':'-500px'},1500);
		$('#twitter a').css('opacity','1');
		
	});
	
	// fancy box settings
	$("a.fancy").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	$(".ajx").fancybox({ajax : {
 type : "POST",
 data : 'mydata=test'
 } }); 
	// scrollable - portfolio
	$("#scroller").scrollable({size: 1, clickable: false}).circular().navigator();
	$("#service").scrollable({size: 1, clickable: false}).circular().navigator();
	$("#tipsntricks").scrollable({size: 1, clickable: false}).circular().navigator();		
	// form submission 
	$('.contactForm').submit( function(){
		  //statements to validate the form	
		  var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		  var name = document.getElementById('name');
		  var email = document.getElementById('email');
		  var message = document.getElementById('message');
		  
		  if (!filter.test(email.value)) {
			  //$('.email-missing').show();
			  email.value = "You forgot to enter your e-mail.";
			  $(email).css("color", "red");
		  } else {}
		  if (document.cform.name.value == "") {
			  //$('.name-missing').show();
			  name.value = "Hey, what's your name?";
			  $(name).css("color", "red");
		  } else {}	
		  if (document.cform.message.value == "") {
			  //$('.message-missing').show();
			  message.value = "Don't you want to say something?";
			  $(message).css("color", "red");
		  } else {}		
		  if ((document.cform.name.value == "") || (!filter.test(email.value)) || (document.cform.message.value == "")){
			  $(name).css("color", "red");
			  return false;
		  } 
		  
		  if ((document.cform.name.value != "") && (filter.test(email.value)) && (document.cform.message.value != "")) {
			  //hide the form
			  $('.contactForm').hide();
		  	  $("#contact p").hide();
			  
			  //show the loading bar
			  $('.loader').append($('.bar'));
			  $('.bar').css({display:'block'});
		  
			  //send the ajax request
			  $.post('mail.php',{name:$('#name').val(),
								email:$('#email').val(),
								message:$('#message').val()},
		  
			  //return the data
			  function(data){
				//hide the graphic
				$('.bar').css({display:'none'});
				$('.loader').append(data);
				$('.loader').hide();
				$('.loader').fadeIn("slow");
			  });
			  
			  //stay on the page
			  return false;
		  } 
	});	
		
});

$(document).ready(function() {
	
	$('a.avatar-link').hover(function(){
		$('#avatar').fadeIn("fast");
	});
	$('a.avatar-link').mouseout(function(){
		$('#avatar').fadeOut("fast");
	});
	
	$('a.uibeercoffee-link').hover(function(){
		$('#uibeercoffee').fadeIn("fast");
	});
	$('a.uibeercoffee-link').mouseout(function(){
		$('#uibeercoffee').fadeOut("fast");
	});
	
	$('#kindwords ul').innerfade({
				animationtype: 'fade',
				speed: 950,
				timeout: 3900,
				type: 'random',
				containerheight: '55px'
	});

	
 // 	$.preloadCssImages();
	
	$(".projecthov").hover(function() {
		$(this).stop().animate({
			opacity: 0.6
		}, "slow");
	});
	
	$(".projecthov").mouseout(function() {
		$(this).stop().animate({
			opacity: 0.0
		}, "slow");
	});
	
});
