$(document).ready(function(){
	
	// TOP MENU
	$('#top .menu li a').click(function(){
		if ($(this).html() == 'Talk to us') {
			$('.bubble').fadeIn("fast");
			return false;
		}
	});
	$('.bubble-close').click(function(){
		$('#top .bubble').hide();
	});
	
	$('#top .menu li img').parent().mouseover(function(){
		$(this).css('background', 'none');
	});
	
	// 	
    $('.products').click(function(){
        var ele = $(this).parent().find('.submenu');
        if (ele.is(':visible')) {
        	ele.hide();
        	$(this).removeClass('hover');
        } else {
        	ele.show();
        	$(this).addClass('hover')
        }
    });

	$('#wrapper').click(function(event){
		$('.menu a').removeClass('hover');
		$('.submenu').hide();
	});
	
	if(typeof(isInEditMode) == 'undefined') {
		$('.themes .theme').click(function(){
			window.location = $(this).find('a').attr('href');
		});
	} else {
	
		$('#preview_large').show().appendTo('body').css('margin', '10px 10px 10px 10px').css('float', 'left');
		$('#thumb_1').show().appendTo('body').css('margin', '10px').css('float', 'left');
		$('#thumb_2').show().appendTo('body').css('margin', '10px').css('float', 'left');
		$('#thumb_3').show().appendTo('body').css('margin', '10px').css('float', 'left');
		
			
	}
	
	
	// Features
	$(window).resize(function(){
		$('#features .feature:nth-child(3n)').addClass('lastOfRow');
		if ($(window).width() > 1200) {
			$('.pricing .plan:nth-child(4n)').addClass('lastOfRow');
		} else {
			$('.pricing .plan:nth-child(4n)').removeClass('lastOfRow');
		}
	});
	
	$(window).resize();
	
	
	// Video
	var enableVideo = true;
	
	$('#videoTour .youtube').click(function(){
		if (enableVideo) {
			$(this).parent().parent().html('<object width="624" height="375"><param name="movie" value="' + $(this).attr('href') + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + $(this).parent().attr('href') + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="624" height="375"></embed></object>');
			enableVideo = false;
			$(this).parent().css('outline', 0);
		}
		
		return false;
	});
	
	// Email
	var emailDefault = $('.emailLabel').html();
	if(typeof(isInEditMode) == 'undefined') {
	  	$('.emailLabel').hide();
	}
	$('#iduydt-iduydt').val(emailDefault).focus(function() {
		if ($(this).val() == emailDefault) {
			$(this).val('');
		}
	}).blur(function(){
		if ($(this).val() == '') {
			$(this).val(emailDefault);
		}
	});
	
	// Theme preview
	$('.sfButton').each(function(){
		if ($(this).attr('href') == 'skapa-en-webbsida/pure-blog') {
			$(this).parent().parent().find('img').addClass('border');
		}
	});
	

});
