$(document).ready(function () {
	
	$('#smenu2 li:last a').css('color','#003366');
	
$(":text").each(function () {
	
	if ( $(this).attr("title") ) {
		$(this).val($(this).attr("title"));
	}
	$(this).focus(function () {
		
		if ($(this).val() === $(this).attr("title")) {
			$(this).val("");
		}
	}).blur(function () {
		if ($(this).val() === "") {
			$(this).val($(this).attr("title"));
		}
	});

});

	$("#printCoupon").click(function() {
			 //$("#coupon").printElement();
			 $("#coupon").printElement({printMode:'popup'});


         });


    $('#notificationDiv').effect("highlight", {color:'#D3ECF5'}, 5000);


	$("a[rel^='photoBox']").prettyPhoto( {theme: 'light_square' });	/* light_rounded / dark_rounded / light_square / dark_square */	
			if(window.outerWidth){
				$("#loader").width(window.outerWidth); /* window.outerWidth;*/
				$("#loader").height(window.outerHeight); /* window.outerHeight;*/
			}else{
				$("#loader").width(document.body.clientWidth); /* window.outerWidth;*/
				$("#loader").height(document.body.clientHeight); /* window.outerHeight;*/
			}
	
	// + Print button + //
	$(".print").click(function(){
		window.print() ;
		return false;
	});
	
	
	/*$("#smenu1 li a").click(function(){
		
		var href = $(this).attr("href");
		//var lang = $(this).attr("lang");
		var lang = 'en';
		
		if (  this.href.indexOf("yachting-matters") != -1  ){
		
			if($('#inlineBox:hidden').length == 1){ //als de inlineBox hidden is
				$.ajax({
					url: "/"+ lang +"/yachting-matters/inline/",
					global: false,
					type: "GET",
					data: 'ajax',
					dataType: "html",
					success: function(data){
						$("#inlineBox").show();
						$("#inlineBox").html(data);
					}
				});
				
			}else{
				$("#inlineBox").hide();
			}
			
			return false;
			
		}
	
		
		
		
	});*/
	
	
	
	
	
	
	// - Print button - //
	// + Make boxes clickable + //
	$(".clickbox").each(function () {
		$(this).click(function(){
			
			var href = $(this).find("a.readmore").attr("href");
			
			if (href){
				var target = $(this).find("a.readmore").attr("target");
				
				if (target == "_blank"){
					window.open(href);
					//parent.location.href = href;
				} else {
					document.location = href;
				}
			}
		});
		$(this).hover(function() { 
			$(this).addClass('active');   
		  }, function() {   
			$(this).removeClass('active');
		});
	});
	// - Make boxes clickable - //
  
	// + Set language effect + //
	$("#languages").hide();
		  
	$("#languageClick").click(function () {
		
        $("#languages").slideToggle("normal");
     return false;
	});
	// - Set language effect -//
	
	// CONFIRM: asked to confirm before leaving to href url
	$(".jConfirm").click(function(event) {  
		event.preventDefault();  // prevent the anchor tag from sending the user off to the link   
		var url = this.href; 
		var title = this.title;
		var yousure = confirm(title);
		
		if (yousure == true) {
			document.location = url;
		} else {
			// Do nothing
		}		
	
	});
	$('.jHighlight').mouseover(function(event) {

		$(this).addClass('highlight');

	}).mouseout(function(event) {

		$(this).removeClass('highlight');

	});

	imagePreview();
	
	$('.box ul').accordion(); // Set accordion effect
	$('.test ul').accordion(); // Set accordion effect
	
	/*$('#eyecatcher').cycle({ 
    	fx:      'fade', 
		timeout:  5000 
	});*/
	
	$(function() {
			$('#show').find('img').each(function(){
				this.style.display = 'block';
			});
			if(document.getElementById('eyecatcher')){
				document.getElementById('eyecatcher').style.display = 'block';
				$('#show').cycle({
					fx:     'fade',
					timeout: 7000,
					pager:  '#nav',
					pagerEvent: 'mouseover',
					pauseOnPagerHover: '1',
					pagerAnchorBuilder: function(idx, slide) {
						// return sel string for existing anchor
						return '#nav li:eq(' + (idx) + ') a';
					}
					
				});
			}
	});
		
	$('#rssBlock').cycle({ 
    	fx:      	'fade', 
		timeout:	3600000
	});
	
	$('.ad_banners').cycle();
	
	// POPUP: launches url in a new resizale popup window 
	$(".jPopup").click(function(event) {  
		event.preventDefault();  // prevent the anchor tag from sending the user off to the link   

		var url 	= this.href;
		var title 	= this.title;
		var regex 	= /\|[0-9]+\|[0-9]+\|$/;
		var day 	= new Date();
		var id 		= day.getTime();

		if (title.match(regex)) {
			// get dimensions
			var dimensions = String(regex.exec(title));
			var dimensionsArr = dimensions.split("|");
			
			// use user defined dimensions, not resizable
			eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + dimensionsArr[1] + ",height=" + dimensionsArr[2] + ",left = 100,top = 100');");
		} else {
			// use standard dimensions, keep resizable
			eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=800,height=600,left = 100,top =100');");
		}	
	
	});	


//loadScript();

});

function loadpage(){
	
	alert('test');
	}
	
function resetZoek(){
	$('#mainContent').load('/en/search-result/reset/');
}
function zoek(page){
	$("#mainContent").html('<div class="loader"><img src="/Directberth/assets/common/loading2.gif" /></div>')
	
	keyword 		= $('#keyword').val();
	countrycode 	= $('#country').val();
	city		 	= $('#city').val();
	draught 		= $('#draught').val();
	lengte 			= $('#length').val();
	beam 			= $('#beam').val();
	purpose			= $('#purpose').val();
	
	$("#mainContent").load("/"+language+"/search-result/", {
		keyword		: keyword,
		country		: countrycode,
		city		: city,
		draught		: draught,
		length		: lengte,
		beam		: beam,
		purpose		: purpose,
		page		: page
	});
}
