$(document).ready(function() {
	$("body").keyword({
		trigger: "kontakt",
		url: "vektorv2/kontakt"
	});
	$("#second-menu-placeholder").live("mouseleave", menu_leave);
	$(".case-small").live("mouseenter mouseleave", case_overlay);
	$(".blog-comment").live("click", blog_comment);
	$(".autoclear").live("focusin focusout", autoclear);
	$("#toggle-menu").live("click", toggle_menu);
	$("#scroll-prev, #scroll-next").live("click", scroll_me);
	$("input, textarea").live("focus blur", handle_active_input);
	
	$("#call-me-send").live("click", phonenumber_validation);
	
	//external plugin calls
	$("a.fancy").fancybox();
	$('textarea').elastic();
	
	handle_js_validation();
	append_loading_icon();
	setup_case_slide();
	setup_index_vertical_scroll();
	init_cycle();
	index_slide_resize();
	group_picture();

  $('.clear').each(function() {
    $(this)
      .data('default', $(this).val())
      .addClass('inactive')
      .focus(function() {
        $(this).removeClass('inactive');
        if($(this).val() == $(this).data('default') || '') {
          $(this).val('');
        }
      })
      .blur(function() {
        var default_val = $(this).data('default');
        if($(this).val() == '') {
          $(this).addClass('inactive');
          $(this).val($(this).data('default'));
        }
      });
  });

// Kundcase
	if($(".project-picture").size() > 0){
		
		var count = $(".project-picture").size();
		
		for(i=1; i<=count; i++){
			$("#project-"+i).cycle({
				fx:    'fade', 
				speed:  1000,
				timeout: 0, 
				pager:  '#nav-'+i 
			});
		}
	}
// end fade in content
// end new js			
// contact first page
	$(".phone").live("hover click", function (event) {
		event.preventDefault();
		if(event.type === "click"){
			return false;
		}
		var id;
		id =$(this).attr("id").replace("phone_", "");
		
		if($(this).hasClass("active-phone")) {
			$(this).removeClass("active-phone");
			$("#phonecontact_"+id).hide();
		}
		else {
			$(this).addClass("active-phone");
			$("#emailcontact_"+id).hide();
			$("#email_"+id).removeClass("active-email");
			$("#phonecontact_"+id).show();
		}
	});
	
	$(".email").live("hover", function (event) {
		event.preventDefault();
		var id;
		id = $(this).attr("id").replace("email_", "");
		if($(this).hasClass("active-email")) {
			$(this).removeClass("active-email");
			$("#emailcontact_"+id).hide();
		}
		else {
			$(this).addClass("active-email");
			$("#phonecontact_"+id).hide();
			$("#phone_"+id).removeClass("active-phone");
			$("#emailcontact_"+id).show();
		}
	});
// end contact first page
/* Red button hover */
$('.red-button').hover(function(){
	$(this).addClass('hover');
},function(){
	$(this).removeClass('hover');
});
/* Red button hover End */
/* Clickable block Start */
$('.block').click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
});
/* Clickable block End */
/* Project thumb hover */
$('.project').hover(function(){
	$who = $(this).find('.boxed-title');
	$($who).addClass('hover');
	if (!$(this).hasClass('animated')) {
		$($who).dequeue().stop().animate({ left: "-100px" },200);
	}
}, function() {
	$($who).removeClass('hover');
    $($who).addClass('animated').animate({ left: "65px" }, 200, function() {
		$(this).removeClass('animated').dequeue();
	});
});
/* Project thumb hover end */
}); // end doc ready



//Cufon
Cufon.replace('#access a,h1,h2,h3,h4,h5,h6,.clarendon,.red-button span,#menu-huvudmeny-1 a',{
			  fontFamily: 'clare-h',
			  hover: true
});
Cufon.replace('h5 span,.box-topic span',{fontFamily: 'clare-l'});
