$(document).ready(function(){
	
	$('#slider').nivoSlider({
		effect:'random',
		slices:15,
		animSpeed:600,
		pauseTime:4000,
		startSlide:0,
		directionNav:false,
		pauseOnHover:true
	});
	
	$('.nivo-controlNav').css({
		'width': parseInt(($('.nivo-controlNav a').length)*15)+parseInt(($('.nivo-controlNav a').length)*5)+'px',
		'left': parseInt($('#slider').width()/2)-parseInt(($('.nivo-controlNav a').length)*15)+parseInt(($('.nivo-controlNav a').length)*5)+'px'
	});
	
	$(function(){ 
		$("#ticker-back ul").liScroll({travelocity: 0.10}); 
	}); 
		
	
	$('#sidebar > ul > li > ul li:last-child').css({
		'border-bottom':'none'  
	});
	
	if($('#big-blue').length > 0){
		var the_height = parseInt($('#header').height())+parseInt($('#big-blue').height())+parseInt($('#main').height())+parseInt($('#footer').height());
	}else
	{
		var the_height = parseInt($('#header').height())+parseInt($('.big-blue-inner').height())+parseInt($('#main').height())+parseInt($('#footer').height())
	}
	if(the_height < $(window).height())
	{	
			var second_height = $(window).height()-the_height;
			
			$('#main').css(
				'height', $('#main').height()+second_height-70+'px'
			);
		
	}
	
	/* Contact Form */
    
    $('#contact_form').submit(function(){
    
    	$('.loader').fadeIn("slow");
     	$('.contactError').fadeOut();
     	$('.contactFieldsError').fadeOut();
    
    	$.post(template_url+"/sendmail.php", $("#contact_form").serialize(),
   			function(data){
     			
     			$('.loader').fadeOut("slow");
     			
     			if(data.nameError === true){
     				$("#contactName").next().fadeIn("slow");
     			}else{
     				$("#contactName").next().fadeOut("slow");
     			}
     			
     			if(data.emailError === true){
     				$("#contactEmail").next().fadeIn("slow");
     			}else{
     				$("#contactEmail").next().fadeOut("slow");
     			}
     			
     			if(data.subjectError === true){
     				$("#contactSubject").next().fadeIn("slow");
     			}else{
     				$("#contactSubject").next().fadeOut("slow");
     			}
     			
     			if(data.messageError === true){
     				$("#contactMessage").next().fadeIn("slow");
     			}else{
     				$("#contactMessage").next().fadeOut("slow");
     			}
     			
     			if(data.formSuccess === true){
     				$("#contact_form").fadeOut("slow", function(){ $("#form_success").fadeIn("slow") });
     			}
     			
     			if(data.formSuccess === false){
     			
     				if(data.nameError === true || data.emailError === true || data.subjectError === true || data.messageError === true){
     				
     					$('.contactFieldsError').fadeIn("slow");
     				
     				}else{
     				
     					$('.contactError').fadeIn("slow");
     				
     				}
     			
     			}
     				
   			}, 
   		"json");
    	
    	return false;
    
    });
    
    /* Contact Form */
	

});//end of document ready
