	/**
 	*	NETVLIES.NL JAVASCRIPTS
 	*	Author:	Sebastiaan Smid, Netvlies
 	*	Author: Stephan van Opstal, Netvlies 	 	
 	*
 	*	Dependencies: 
 	*	- jQuery v 1.2.2
 	*	- jQuery.lightbox 0.4
 	*/	

	$(document).ready(function()
	{
		$("#search input[value!=][type=text]").focus(function () { 
			if(!$(this).attr("startvalue")) {  
				$(this).attr("startvalue", $(this).val());
			} 
			if($(this).val() == $(this).attr("startvalue")) {
				$(this).val('');	
			}
		}).blur(function () { 
			if($(this).val() == '') {
				$(this).val($(this).attr("startvalue"));
			}
		});
	
		// PNGflt
		if (window.alphaPNG) {
			alphaPNG();
		}
		
		// Contact form
		$('#checkcontact').click(
			function() {
				var ster = '';
				if (this.checked == true) {
					ster = '*';
				}
				$('#tel_verplicht').html(ster);
			}
		);
		
		// Flash bedrijfsfilm	
		$('#flash_bedrijfsfilm').ready(
			function() {
				
				// Taal bepalen
				switch ($('#flash_bedrijfsfilm').attr('lang')) {
					case 'de':
						video_src = '/swf/bedrijfsfilm_de.swf';
						video_width = 400;
						video_height = 300;
					break;
					default:
						video_src = '/swf/bedrijfsfilm.swf';
						video_width = 450;
						video_height = 253;
				}
				
				// Video starten
				$('#flash_bedrijfsfilm').flash(
					{
						src: video_src,
						width: video_width,
						height: video_height 
					}
					,{ version: 7 }
				);	
				
			}
		);	
		
		Cufon.replace('#product-switch a');
// 		Cufon.replace('#ex-rental-selector h2 a');
		
		if($('#product-switch').length > 0) { 
			$('#product-switch a.rent').click( function() { 
				$('#product-switch a').removeClass('selected');
				$(this).addClass('selected');
				$('#ex-rental-selector').hide();
				$('#product-selector').show();
				Cufon.replace('#product-switch a');
			});
			$('#product-switch a.exrent').click( function() { 
				$('#product-switch a').removeClass('selected');
				$(this).addClass('selected');
				$('#product-selector').hide();
				$('#ex-rental-selector').show();
				Cufon.replace('#product-switch a');
				Cufon.replace('#ex-rental-selector h2 a');
			});
		}


		// Print script
		if(window.print && document.getElementById('btn-print')) { 
			$('#btn-print').css({display: "inline"});
			$('#btn-print').click(
				function() { 
					window.print();
				}
			);
		}
		
		//Verberg sub
		$('#product-info-sbmt').css({display: "none"});
		
		
		
		// Vergroot product foto
		
		var imageUrl = [$('#product-vsl').attr('src'), $('#product-vsl-zoom').attr('href')];
		var imageSize = [$('#product-vsl').width(), $('#product-vsl').height()];
		var imageLoaded = false;
		var imageSizeZoom;
		
		$('#product-vsl-zoom').toggle(function() 
		{
			$(this).addClass('load');
			
			if (imageLoaded) {
				$('#product-info').fadeOut(function() {
					$('#product-vsl').attr('src', imageUrl[1]).animate({ width: imageSizeZoom[0], height: imageSizeZoom[1] }, function() {
						$('#product-vsl-zoom').html('Sluit vergroting').removeClass('load').addClass('close');
					});
				});
			} else {
				pic = new Image();
				pic.src = imageUrl[1];
				pic.onload = function()
				{
					imageLoaded = true;
					imageSizeZoom = [this.width, this.height];
					
					$('#product-info').fadeOut(function() {
						$('#product-vsl').attr('src', imageUrl[1]).animate({ width: imageSizeZoom[0], height: imageSizeZoom[1] }, function() {
							$('#product-vsl-zoom').html('Sluit vergroting').removeClass('load').addClass('close');
						});
					});
				}
			}
		},function() {
		
			$('#product-vsl').animate({ width: imageSize[0], height: imageSize[1] }, function() {
				$(this).attr('src', imageUrl[0]);
				$('#product-info').fadeIn();
				$('#product-vsl-zoom').html('Bekijk vergroting').removeClass('close');
			});
		});

	});
