$(document).ready(function(){
	
	/* -------------- JQuery carusel -------------- */
	
	/* Activate JQuery Carusel */
    jQuery('#logo_slider ul').jcarousel();

	/* For vertical align images in jQuery carusel */
	$('#logo_slider a img:first-child').each(function(){
		$(this).parent().css('height',$(this).height());
		$(this).parent().css('width',$(this).width());
		$(this).parent().css('margin-top',(70 - $(this).height())/2);
	});
	/* -------------- End JQuery carusel -------------- */
	
	/* For hide/show search value */
	$('#search input').focus(function(){
		if(this.value == 'Search...' ) this.value='';
	}).focusout(function(){
		if(this.value == '') this.value='Search...';
	});
	
	/* Reset for last elements */
	$('#home_boxes .box:last').css('margin','0');
	$('.bottom_menu_nav li:last,.header_top_line .subnav ul li:last').addClass('last');
	
	/* Testemonials always at bottom */
	$('.blockquote').css('margin-top',$('.content_container').height() - $('#sidebar ul').height() - $('.blockquote').height() - 32);
		
	/* Print link */
	$('#print_link').click(function(event){
		event.stopPropagation();
			window.print();
		return false;
	});
	
	/* For last footer widget */
	$('.footer_content > ul > li:last').css('margin','0 0 10px 30px');
	
	/* Hover for JQuery carusel arrows */
	$('.jcarousel-prev-horizontal,.jcarousel-next-horizontal').hover(function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});
	
	/* For vertical align image at home boxes */
	$('.avatar img').each(function(){
		$(this).css('margin-top',(92-$(this).height())/2);
	});	
	
	/* -------------- Main Navigation menu -------------- */
	
	/* Inner arrow if has sub-menu */
	$('#bottom_header_nav ul > li').each(function(){
		if($(this).find('ul').hasClass('sub-menu'))
		{
			$(this).children('a').html($(this).children('a').text()+''+$('.hidden_arrow').html());	
		}
	});
	
	/* Open sub menu */
	$('#bottom_header_nav ul:first-child > li').hover(function(){
		$(this).addClass('active');
	},function(){
		$(this).removeClass('active');
	});
	
	/* Hack for IE 7 */
    $('.sub-menu').each(function(){
		$(this).find('li a').width($(this).width() - 31);
	});

		/* -------------- Header slider -------------- */
	var image_width = 851;
	var i = 0;
	$('#splash nav ul li a').each(function(){
		$(this).addClass('numer_'+i);
		i++;
	});
	
	var max_width = i * image_width;
	$('.images ul').css('width',max_width)

	$('#splash nav ul li:first').addClass('active');

	$('#splash nav ul li a').click(function(event){
		event.stopPropagation();
			$('#splash nav ul li').removeClass('active');
			$(this).parent().addClass('active');
			var count_rotate = $(this).attr('class').split('numer_')[1] * image_width;
			$('.images ul').animate({
				left: -count_rotate
			},500);
		return false;
	});
	
});

	
