$(document).ready(function() {
	var tekstballon = $('#tekstballon_area'),
	    //tekstballonSlogan = tekstballon.attr("value"),
	    tekstballonSlogan = 'Plaats hier uw leukste tekstballon. De origineelste wint!',
	    message = $('#bc_message');
	
	message.keyup(function(e){
		tekstballon.attr('value',message.attr('value'));
	});
	tekstballon.keyup(function(e){
		message.attr('value',tekstballon.attr('value'));
	});
	
	if(tekstballon.attr("value") === tekstballonSlogan) {
    	// only on the first click in this field remove the placeholder value
        tekstballon.one("click" , function() {
    	    tekstballon.attr('value', '');
    	});
	}
	
    if(message.attr("value") === tekstballonSlogan) {
    	// only on the first click in this field remove the placeholder value
    	message.one("click" , function() {
    	    message.attr('value', '');
    	});
    }
	
	
	//console.log(message.attr('value'));
	
	// convert rel="external" to blank-page-links
	$(function(){$('a[href][rel*=external]').each(function(i){this.target = "_blank";});}); 

	// superfish menu
	$('.sf-menu').superfish();
	
	// remove border form the nav item next to the active one
	$(".sf-menu li.active").next("li").addClass("next");
	
	// Hide subscribe to newsletter
	$('a.subscribe-link').toggle(function(e) {
/* 		$('.subscribe-body').slideDown('500').insertAfter($('a.subscribe-link').parent()); */
			$('.subscribe-body').slideDown('500');
		e.preventDefault(); }, function(e) {
			$('.subscribe-body').slideUp('500');
		}
		);
		
	/* Webshop computer hover */	
	if ($('#goto_webshop_computer').html() != null) {
		$('#goto_webshop_computer').hover(function() {
			$(this).find('img').attr('src', '/images/layout/webshop_computer_white_hover2.gif');
		}, function() {
			$(this).find('img').attr('src', '/images/layout/webshop_computer_white2.gif');
		});
	}
	/* Webshop kantoor hover */
	if ($('#goto_webshop_kantoor').html() != null) {
		$('#goto_webshop_kantoor').hover(function() {
			$(this).find('img').attr('src', '/images/layout/webshop_kantoor_white_hover2.gif');
		}, function() {
			$(this).find('img').attr('src', '/images/layout/webshop_kantoor_white2.gif');
		});
	}
	/* Webshop computer fr hover */
	if ($('#goto_webshop_computer-fr').html() != null) {
		$('#goto_webshop_computer-fr').hover(function() {
			$(this).find('img').attr('src', '/images/layout/e-store-ordinateurs-hover.gif');
		}, function() {
			$(this).find('img').attr('src', '/images/layout/e-store-ordinateurs.gif');
		});
	}
	/* Webshop kantoor hover */
	if ($('#goto_webshop_kantoor-fr').html() != null) {
		$('#goto_webshop_kantoor-fr').hover(function() {
			$(this).find('img').attr('src', '/images/layout/e-store-bureau-hover.gif');
		}, function() {
			$(this).find('img').attr('src', '/images/layout/e-store-bureau.gif');
		});
	}
	
	if ($('#status-herstelling').html() != null) {
		$('#status-herstelling').bind('submit', function(e) {
			if (! validateHerstellingForm()) {
				e.preventDefault();
				return;
			}
			$('#ajax-loader').show();
			var data = $('#status-herstelling').serialize();
			$.ajax({
			   type: "POST",
			   url: "/app/ajax/checkStatus.php",
			   data: data,
			   success: function(res) {
					$('#status-info').html(res).show('500');
					$('#ajax-loader').hide();
				 }
			 });
			e.preventDefault();
		});
	}	
	
	// Split menu
	$("div.nav-1 li a:contains('Buitenkansjes')").parent().css('clear', 'left');
	
	// Hover: show ico
	$('#col-right .item-shop').hover(function() {
		$(this).find('.to-shop').show();
	}, function() {
		$(this).find('.to-shop').hide();
	});
	
	// Click: to shop
	$('#col-right .item-shop').click(function(e) {
		window.location.replace($(this).find('a').attr('href'));
		e.preventDefault();
	});
	
	$('.schedule-alt-container').hide();
	$('.gallery-img-select').click(function(e) {
		$('.gallery-item li').removeClass('selected');
		$(this).parent().parent().parent().find('.target').attr('src', $(this).attr('href'));
		$(this).parent().addClass('selected');
		e.preventDefault();
	});
	$(function(){$('a[href][rel*=external]').each(function(i){this.target = "_blank";});});
	$('#search-criterium').attr('autocomplete', 'off');
	$('#search-criterium').KeywordDropDown();
	$('#footer ul:first li:last').css('border-right', 'none');
	$('.jcarousel').jcarousel({scroll: 1, auto: 5});
	$('.fancybox').fancybox();
	$('#col-right .item-news-wrapper').bind('click', function(e) {
		window.location.replace($(this).find('.read_more').attr('href'));
		e.preventDefault();
	});
	$('#col-right .item-news-wrapper').hover(function() {
		$(this).addClass('item-news-wrapper-hover');
	}, function() {
		$(this).removeClass('item-news-wrapper-hover');
	});
	$('.mediaflash_hide').css('display', 'none');
	$('#header-banners').cycle({
		fx :'turnDown',
		timeout: 15000,
		height: 90,
		before: function(curr, next, opts) {
        var $next = $(next), src = $next.attr('src');
        $next.attr('src', src);
    }
		
		
		
	});
});
$(window).load(function() {
	$('.gallery-item').cycle({
		fx :'fade',
		timeout: 2000,
		pager: '#cycle-pager'
	});
});

/* ------------------- [ SMM ] ------------------- */
var smm_key 	 = '8DE6B9746965CF4DCC6E5E5DF49A8C1CBFB9BEEDA231B5961536C2334D29889B';
		smm_key 	+= '-524A6A57EEAE3C94548E8716E43AE26506DDC684669DB9D9D7AED7A25C8279DA';
		smm_key 	+= '-4EA0C6C6DB8F2730102C750175A6D42F2ECADBE26309DC869DFDA23E1016B46B';
		smm_key 	+= '-77B173D66767833E134EE77FA8530720A19C48CA6F85A2943ADDBAB2B8286EAF';
		smm_key 	+= '-A54978A967B9F38649035B54E636D2A5B0AD9766E31F834200E49B0924E33445';
		smm_key 	+= '-9333D69CC92442C064067900D0FEE7D59E14199334CDEAED63AA39119E0A1A79';
		smm_key 	+= '-8737DB3CB8DCC4331A4591A85FF9CD483156AE2D570209CEB6B2639C4C859BE8';
		smm_key 	+= '-C98D33C6FDE7910D7D7CD01373ED7B7367051FD34F1F1AE027FDBDC22A3C809E';
		smm_key 	+= '-2730B85C5DBB3A76B14A702DAB909E745031573D15122740019F0AC6F6C10D57';
		smm_key 	+= '-034ECBEE4CFF51C6068CE92B7FA79E898B1E7C8F970913B59C6986C92C89F75F';
		smm_key 	+= '-BFE59023469718337863099F813738FB3963361CABE880D387C1D15E30FBF3EC';
		smm_key 	+= '-CD6ABFCE063C1DA040917C0247722F56A6172EC89EF2ABF4D4EBEE50805DCBDB';
		smm_key		+= '9775C43E2502431C2A79DEB4BE41B36D49A51997963C0781C315F078D5B1068E';
		smm_key		+= 'AC7A8AB25FB5B937617E24F61A72B98D023A5A4146D0192F89536183A0F9B9FD';

				
var smm_succes = 'U bent ingeschreven!';
var smm_error = 'fout bij het verzenden';
var smm_output_id = 'smm_output_id';
var smm_submit_text = 'inschrijven';
var smm_email_standard_value = 'e-mail';
var smm_email_invalid = 'email ongeldig';
var smm_g = '105';

function validateHerstellingForm() {
	var subm = true;
	var errors = "";
	$('#status-info').css('border', '1px solid #aaa');

	if ($('#klantnr').val() == '') {
		$('#klantnr').css('border', '1px solid #C31111');
		$('#status-info').css('border', '1px solid #C31111');
		if (SI_CMS.locale.lang == 'nl') {
			errors += "<p>Klantennummer is een verplicht veld.</p>";
		} else {
			errors += "<p>Veuillez indiquer votre numéro de client.</p>";
		}
		subm = false;
	} else {
		$('#klantnr').css('border', '1px solid #aaa');
	}
	if ($('#herstelbonnr').val() == '') {
		$('#herstelbonnr').css('border', '1px solid #C31111');
		$('#status-info').css('border', '1px solid #C31111');
		if (SI_CMS.locale.lang == 'nl') {
			errors += "<p>Herstelbon is een verplicht veld.</p>";
		} else {
			errors += "<p>Veuillez indiquer le numéro de votre bon de réparation.</p>";
		}
		subm = false;
	} else {
		$('#herstelbonnr').css('border', '1px solid #aaa');
	}
	if (subm == false) {
		errors = '<div class="error">' + errors + '</div>';
		$('#status-info').html(errors).show(500);
	}
	return subm;
	
	
	
	
}






