jQuery.noConflict();
jQuery(document).ready(function($){
	Cufon.set('fontFamily', 'capture').replace('h1',{hover: true})('h2',{hover: true})('h3',{hover: true})('h4',{hover: true});
//	Cufon.replace('h1, h2, h3, h4', { fontFamily: 'capture' });

	$('a[class="video_popup"]').each(function() {
		var $dialog = $('<div></div>');
		var $popupUrl = $(this).attr("href");
		$(this).bind('click', function() {
			layer_title = $(this).attr("title");
			dialogOptions = {
				width: 644,
				position:["center",66],
				modal: true,
				bgiframe: true,
				title: layer_title,
				closeText: "Close window",
				autoOpen: false,
				resizable: true,
				draggable: false,
				open: function(){
					Cufon.replace('.ui-dialog-title', {fontFamily: 'capture'});
					$dialog.load($popupUrl);
				},
				close: function(ev, ui) {
					$(this).remove();
				}
			};
			$dialog.dialog(dialogOptions)
			$dialog.dialog('open');
			return false;
		});
	});

	if ($('#backhome').length > 0) {
		$("#backhome").hover(
			function () {
				$(this).attr('src','/img/btn_terugnaaroverzicht_f2.png')
			},
			function () {
				$(this).attr('src','/img/btn_terugnaaroverzicht.png')
			}
		);
	}

	if ($('#back_to_home').length > 0) {
		$("#back_to_home").hover(
			function () {
				$(this).attr('src','/img/terug_naar_home_f.png')
			},
			function () {
				$(this).attr('src','/img/terug_naar_home.png')
			}
		);
	}
	if ($('#dagwinnaars').length > 0) {
		$("#dagwinnaars").hover(
			function () {
				$(this).attr('src','/img/bekijk_dagwinnaars_f.png')
			},
			function () {
				$(this).attr('src','/img/bekijk_dagwinnaars.png')
			}
		);
	}

	if ($('.backlink img').length > 0) {
		$(".backlink img").hover(
			function () {
				$(this).attr('src','/img/vorige_f2.png')
			},
			function () {
				$(this).attr('src','/img/vorige.png')
			}
		);
	}

	if ($('#footer div.float-right img').length > 0) {
		$("#footer div.float-right img").hover(
			function () {
				$(this).attr('src','/img/persbericht_f.png')
			},
			function () {
				$(this).attr('src','/img/persbericht.png')
			}
		);
	}

	
	$('#backhome').hover
	
	
	if ($('#cycle_shuffle').length > 0) {
		$('#cycle_shuffle').cycle({ 
			fx: 'scrollLeft', 
			easing: 'easeOutBounce', 
			delay: -5000,
			timeout: 0,
			pager: '#nav'
		});
	}
	
	$('.backimage1').bind('click', function(evt) {
		$('#cycle_shuffle').cycle('prev');
	});
	$('.backimage2').bind('click', function(evt) {
		$('#cycle_shuffle').cycle('prev');
		$('#cycle_shuffle').cycle('prev');
	});
	$('.backimage3').bind('click', function(evt) {
		$('#cycle_shuffle').cycle('prev');
		$('#cycle_shuffle').cycle('prev');
		$('#cycle_shuffle').cycle('prev');
	});
	$('.backimage4').bind('click', function(evt) {
		$('#cycle_shuffle').cycle('prev');
		$('#cycle_shuffle').cycle('prev');
		$('#cycle_shuffle').cycle('prev');
		$('#cycle_shuffle').cycle('prev');
	});
	
	$('.answer1').bind('click',function(evt) {
		$('#q1_a').val($(this).attr('id'));
		$('#cycle_shuffle').cycle('next');
	});
	$('#q2').bind('click',function(evt) {
		if ($('#q2_a').val()) {
			$('#cycle_shuffle').cycle('next');
		}
	});
	$('.answer3').bind('click',function(evt) {
		$('#q3_a').val($(this).attr('id'));
		$('#cycle_shuffle').cycle('next');
	});
	$('.answer4').bind('click',function(evt) {
		$('#q4_a').val($(this).attr('id'));
		$('#cycle_shuffle').cycle('next');
	});
	$('#q5').bind('click',function(evt) {
		if ($('#q5_a').val()) {
			$('#wktest').submit();
		}
	});
	$('#still_1 .overlay_text').transform({rotate: 3});
	if ($.browser.msie) {
		$('#still_1 .overlay_text').css('top','156px');
		$('#still_1 .overlay_text').css('left','40px');
	} else {
		$('#still_1 .overlay_text').css('top','164px');
		$('#still_1 .overlay_text').css('left','40px');
	}

	$('#still_2 .overlay_text').transform({rotate: -3});

	if ($.browser.msie) {
		$('#still_2 .overlay_text').css('top','153px');
		$('#still_2 .overlay_text').css('left','40px');
	} else {
		$('#still_2 .overlay_text').css('top','164px');
		$('#still_2 .overlay_text').css('left','40px');
	}

	$('#still_3 .overlay_text').transform({rotate: -1});

	if ($.browser.msie) {
		$('#still_3 .overlay_text').css('top','173px');
		$('#still_3 .overlay_text').css('left','24px');
	} else {
		$('#still_3 .overlay_text').css('top','178px');
		$('#still_3 .overlay_text').css('left','24px');
	}

	$('#still_4 .overlay_text').transform({rotate: -1});

	if ($.browser.msie) {
		$('#still_4 .overlay_text').css('top','171px');
		$('#still_4 .overlay_text').css('left','24px');
	} else {
		$('#still_4 .overlay_text').css('top','176px');
		$('#still_4 .overlay_text').css('left','24px');
	}

	$('#still_5 .overlay_text').transform({rotate: 2});

	if ($.browser.msie) {
		$('#still_5 .overlay_text').css('top','163px');
		$('#still_5 .overlay_text').css('left','40px');
	} else {
		$('#still_5 .overlay_text').css('top','168px');
		$('#still_5 .overlay_text').css('left','40px');
	}

	$('#still_6 .overlay_text').transform({rotate: -2});

	if ($.browser.msie) {
		$('#still_6 .overlay_text').css('top','162px');
		$('#still_6 .overlay_text').css('left','32px');
	} else {
		$('#still_6 .overlay_text').css('top','172px');
		$('#still_6 .overlay_text').css('left','32px');
	}

//	$('#still_7 .overlay_text').transform({rotate: -5});

	if ($.browser.msie) {
		$('#still_7 .overlay_text').css('top','166px');
		$('#still_7 .overlay_text').css('left','24px');
	} else {
		$('#still_7 .overlay_text').css('top','176px');
		$('#still_7 .overlay_text').css('left','24px');
	}

	$('#still_8 .overlay_text').transform({rotate: -5});

	if ($.browser.msie) {
		$('#still_8 .overlay_text').css('top','157px');
		$('#still_8 .overlay_text').css('left','49px');
	} else {
		$('#still_8 .overlay_text').css('top','167px');
		$('#still_8 .overlay_text').css('left','49px');
	}

	
	$("#still_1 .overlay_input").bind('keyup', function(event) {
		var overlayText = $(this).val(); 
		$("#still_1 .overlay_text").html(overlayText);
		Cufon.set('fontFamily', 'capture').replace('#still_1 .overlay_text', {textTransform: 'uppercase' });
	});
	$("#still_2 .overlay_input").bind('keyup', function(event) {
		var overlayText = $(this).val(); 
		$("#still_2 .overlay_text").html(overlayText);
		Cufon.set('fontFamily', 'capture').replace('#still_2 .overlay_text', {textTransform: 'uppercase' });
	});
	$("#still_3 .overlay_input").bind('keyup', function(event) {
		var overlayText = $(this).val(); 
		$("#still_3 .overlay_text").html(overlayText);
		Cufon.set('fontFamily', 'capture').replace('#still_3 .overlay_text', {textTransform: 'uppercase' });
	});
	$("#still_4 .overlay_input").bind('keyup', function(event) {
		var overlayText = $(this).val(); 
		$("#still_4 .overlay_text").html(overlayText);
		Cufon.set('fontFamily', 'capture').replace('#still_4 .overlay_text', {textTransform: 'uppercase' });
	});
	$("#still_5 .overlay_input").bind('keyup', function(event) {
		var overlayText = $(this).val(); 
		$("#still_5 .overlay_text").html(overlayText);
		Cufon.set('fontFamily', 'capture').replace('#still_5 .overlay_text', {textTransform: 'uppercase' });
	});
	$("#still_6 .overlay_input").bind('keyup', function(event) {
		var overlayText = $(this).val(); 
		$("#still_6 .overlay_text").html(overlayText);
		Cufon.set('fontFamily', 'capture').replace('#still_6 .overlay_text', {textTransform: 'uppercase' });
	});
	$("#still_7 .overlay_input").bind('keyup', function(event) {
		var overlayText = $(this).val(); 
		$("#still_7 .overlay_text").html(overlayText);
		Cufon.set('fontFamily', 'capture').replace('#still_7 .overlay_text', {textTransform: 'uppercase' });
	});
	$("#still_8 .overlay_input").bind('keyup', function(event) {
		var overlayText = $(this).val(); 
		$("#still_8 .overlay_text").html(overlayText);
		Cufon.set('fontFamily', 'capture').replace('#still_8 .overlay_text', {textTransform: 'uppercase' });
	});

	$('#captioncompetitionform').submit(function() {
		if ($('#still_1 .overlay_input').val().length == 0) { alert ('Vul aub een tekst in bij het eerste beeld.'); $('#still_1 .overlay_input').focus(); return false;} 
		if ($('#still_2 .overlay_input').val().length == 0) { alert ('Vul aub een tekst in bij het tweede beeld.'); $('#still_2 .overlay_input').focus(); return false;} 
		if ($('#still_3 .overlay_input').val().length == 0) { alert ('Vul aub een tekst in bij het derde beeld.'); $('#still_3 .overlay_input').focus(); return false;} 
		if ($('#still_4 .overlay_input').val().length == 0) { alert ('Vul aub een tekst in bij het vierde beeld.'); $('#still_4 .overlay_input').focus(); return false;} 
		if ($('#still_5 .overlay_input').val().length == 0) { alert ('Vul aub een tekst in bij het vijfde beeld.'); $('#still_5 .overlay_input').focus(); return false;} 
		if ($('#still_6 .overlay_input').val().length == 0) { alert ('Vul aub een tekst in bij het zesde beeld.'); $('#still_6 .overlay_input').focus(); return false;} 
		if ($('#still_7 .overlay_input').val().length == 0) { alert ('Vul aub een tekst in bij het zevende beeld.'); $('#still_7 .overlay_input').focus(); return false;} 
		if ($('#still_8 .overlay_input').val().length == 0) { alert ('Vul aub een tekst in bij het achste beeld.'); $('#still_8 .overlay_input').focus(); return false;} 

		if ($('#titel').val().length == 0) { alert ('Vul aub een titel in voor je filmpje.'); $('#titel').focus(); return false;} 
		if ($('#naam').val().length == 0) { alert ('Vul aub je naam in.'); $('#naam').focus(); return false;} 
		if ($('#email').val().length == 0) { alert ('Vul aub je email adres in.'); $('#email').focus(); return false;} 
		return true;
	});	
	

});
