var clones = 1;

//var video_source = '<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/7skC_nWAWes&amp;hl=en_GB&amp;fs=1&amp;autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/7skC_nWAWes&amp;hl=en_GB&amp;fs=1&amp;autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>';

//var video_thumb = '<img src="images/video_start_thumb.jpg" alt="Bekijk de video" />';

$(document).ready(function(){
	
	
	// video section
	// -------------------------------------
	//$("#the_video").hide();
	
	//$("a#videoControl").addClass("openVideo");
	
	//$("a.openVideo").click(function() {
	//	
	//	$(this).toggleClass("openVideo");
	//	
	//	$("#video").toggle("slow", 
	//		
	//		function(){
	//			
	//			$("#the_video").fadeIn("slow");
	//			
	//			var klas = $("a#videoControl").attr("class");
	//	
	//				if( klas =='openVideo' ) {
	//					
	//					$("a#videoControl img").attr("src","images/open_video.jpg");
	//					
	//				} else {
	//					
	//					$("a#videoControl img").attr("src","images/close_video.jpg");
	//					
	//				}
	//			
	//		}
	//	
	//	);
	//	
	//	return false;
	//	
	//});
	
	//$("#the_video img").click(
	//	function() {
	//		$("#the_video").html(video_source);
	//		return false;
	//	}
	//	
	//);
	
	
	// easy slider for news
	// -------------------------------------
	$("#featured").easySlider({
		auto: true,
		continuous: true
	});
	
	// beautytips tooltips
	// -------------------------------------
	$("span.bt").bt({
		
		showTip: function(box){
		    $(box).fadeIn(200);
		},
		hideTip: function(box, callback){
		  $(box).animate({opacity: 0}, 100, callback);
		},
		
		shrinkToFit: true,
		hoverIntentOpts: {
		  interval: 0,
		  timeout: 0
		},
		
		positions: 'top',
		spikeLength: 11,
		spikeGirth: 22,
		cornerRadius: 2,
		
		fill: 'rgba(0, 0, 0, .9)',
		
		shadow: true,
		shadowOffsetX: 0,
		shadowOffsetY: 0,
		shadowBlur: 8,
		shadowColor: 'rgba(0,0,0,.7)',
		shadowOverlap: false,
		noShadowOpts: {strokeStyle: '#FFF', strokeWidth: 3},
		
		strokeWidth: 3,
		strokeStyle: '#FFF',
		cssStyles: {color: '#FFF', fontSize: 10, fontWeight: 'bold'}
		
	});
	
	
	// clone deelnemers
	// -------------------------------------
	
	//$("#specs .spec").find("span.gnumb").attr("id", 'si0' );
	//$("#specs .spec").find(":input").each(function() {
	//	
	//	var new_id = jQuery(this).attr("name").replace('[', '_');
	//	new_id = new_id.replace(']', '');
	//	
	//	$(this).attr("rel", 'si0' );
	//	$(this).attr("id", new_id );
	//	
	//});
	
	//$("#deelnemers").change(function() {
	//	
	//	clones = $(this).val() - clones;
	//	var specs = $("#specs .spec").length;
	//	
	//	if (clones > 0)
	//	{
	//		for(i=1; i <= clones; i++ )
	//		{
	//			var clone = $("#spec").clone();
	//			
	//			$(clone).find("span.gnumb").text(specs+i);
	//			$(clone).find("span.gnumb").attr("id", 'si'+((specs+i)-1) );
	//			
	//			$(clone).find(":input").each(function() {
	//				
	//				var original_name = $(this).attr('name').replace('0', ((specs+i)-1) );
	//				
	//				$(this).attr( 'name', original_name ); // set new input "name"
	//				
	//				var new_id = original_name.replace('[', '_');
	//				new_id = new_id.replace(']', '');
	//				
	//				$(this).attr( 'id', new_id ); // set new input "id"
	//				
	//				$(this).attr( 'rel', 'si'+((specs+i)-1) ); // set new input "rel"
	//				
	//			});
	//			
	//			$(clone).find("label.error").remove();
	//			
	//				clone.insertBefore("#submit");
	//				
	//			}
	//		
	//		clones = $(this).val();	
	//	}
	//	
	//	else
	//	
	//	{
	//		for(i=clones; i < 0; i++ )
	//		{
	//			$("#specs .spec:last").remove();
	//		}
	//		
	//		clones = $(this).val();
	//	}
	//	
	//	
	//});
	
	
	
	// validate
	// -------------------------------------
	$("#aanmelden").validate({
		messages: {
			voorletter: "Voer voorletter(s) in a.u.b.",
			achternaam: "Voer achternaam in a.u.b.",
			telefoonnummer: "Voer telefoonnummer in a.u.b.",
			email: "Voer e-mailadres in a.u.b.",
			deelnemers: "Voer aantal deelnemers in a.u.b.",
			bedrijfsnaam: "Voer bedrijfsnaam in a.u.b.",
			functie: "Voer functie in a.u.b.",
			adres: "Voer adres in a.u.b.",
			postcode: "Voer postcode in a.u.b.",
			plaats: "Voer plaats in a.u.b."
		}

	});
	
	
	// trainingen list // open - close
	//--------------------------------------
	
	//$("#trainingen li:has(ul)").addClass("is_parent active"); // define parents
	//$("#trainingen li.is_parent ul").hide(); // hide sub elements
	
	//$("#trainingen li.is_parent a").click(
	//	function() {
	//		$(this).parent().find("ul:first").toggle("fast");
	//		$(this).parent().toggleClass("active");
	//	}
	//);
	
	// overlay
	//---------------------------------------
	$("body").append('<div id="vtl-overlay"></div>');
	$("#vtl-overlay").hide(); // hide the overlay container at pageload
	$("#vtl-overlay-window").hide();
	
	$(window).resize(function(){
	  	
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
		else {
			
			var winW = window.innerWidth;
	  		var winH = window.innerHeight;
	  	}
	  		
	  	$("#vtl-overlay").css({'height':winH,'width':winW});
		
	});
	//---------------------------------------
	$("a[rel=overlay]").click(function() {
		
		var target = jQuery(this).attr("href");
		$("#vtl-overlay").css({'height':'100%','background':'#000000','opacity':'0.8','-moz-opacity':'0.8','filter':'alpha(opacity=80)'}).fadeIn("slow");
		$("#vtl-overlay-window").fadeIn("slow").append('<span id="close-overlay">Close</span>');
		$("#close-overlay").css('display','block');
		
		$("#vtl-overlay,#close-overlay").click(closeOverlay);
		
		$("#vtl-overlay-content").jScrollPane({ scrollbarMargin: 0 });
		
		
	});
	
	//---------------------------------------
	// close overlay
	//---------------------------------------
	var closeOverlay = function(){
		$("#vtl-overlay-window").fadeOut("slow");
		$("#vtl-overlay").fadeOut("slow");
	};
	//---------------------------------------
	//$("#close-overlay").click(closeOverlay);
	
});

//function closeOverlay() {
//	$("#vtl-overlay-window").fadeOut("slow");
//	$("#vtl-overlay").fadeOut("slow");
//}


// copy user information
// -------------------------------------
function copyInfo(_id) {
	
	var num = jQuery(_id).attr("rel").replace('si', '');
	
	//var newValue = jQuery("#voorletter").val();
	//alert(newValue);
	
	if( jQuery(_id).val() == "1" ) {
	
		jQuery("#_voorletter_"+num).val( jQuery("#voorletter").val() );
		jQuery("#_tussenvoegsel_"+num).val( jQuery("#tussenvoegsel").val() );
		jQuery("#_achternaam_"+num).val( jQuery("#achternaam").val() );
	
	}
	else {
		
		jQuery("#_voorletter_"+num).val("");
		jQuery("#_tussenvoegsel_"+num).val("");
		jQuery("#_achternaam_"+num).val("");
		
	}
	
}
// -------------------------------------
