/**
 * @author Onbeperkt Media
 */
//	::::::::::::::::::::::::: start Add javascript specific stylesheet / sifr replacement script :
$('<script type="text/javascript" src="include/inc_js/lib/jquery.lightbox-0.5.min.js"></script>').appendTo($('head')[0]);
$('<link rel="stylesheet" href="css/js-enabled.css" type="text/css" />').appendTo($('head')[0]);
//	::::::::::::::::::::::::: end Add javascript specific stylesheet / sifr replacement script */


 $(document).ready(function(){
	if ($("a[rel='nofollow']").length > 0) 
	{
		$("a[rel='nofollow']").click(function()
			{ window.open($(this).attr('href')); return false;	}
		);
	}
	

	/* initialize Fn Functions */
	$('input[type="submit"]').hover(
		function(){
			$(this).addClass('hover');			
		},
		function(){
			$(this).removeClass('hover');
		}
	);
	FnToggleInputDefaultVal.init();
	FnFormSubmit.init();
	FnLightBox.init();
	
	if ($('.video-block').length > 0 ) {
				
				$('.video-block img').wrap('<div id="video-container"></div>');
								
				// passing variables and functions based on active page:
				var videoFileName = $('.video-block img').attr('title');
				var imageFileName = 'still-'+videoFileName.split('.')[0] + '.png';
				
				var flashvars = {
					file: '../../media/movies/'+videoFileName,
					image: 'media/images/'+imageFileName
				};
				var params = {
					allowfullscreen: true,
					allowscriptaccess:"always",
					wmode: "transparent"
				};			
				var attributes = {
					id:"videoPlayer",  
	                name:"videoPlayer"
				};			
							
				// load swfobject:
				swfobject.embedSWF("include/inc_swf/jw-videoplayer.swf", "video-container", "394", "242", "9.0.115", false, flashvars, params, attributes);	
				
			}
	

});

// start Function Toggle Input Default Value
FnToggleInputDefaultVal = {
	init:function(){
		$('input:text').each(function(){
			$(this).addClass("no-focus");

			if (!$(this).hasClass('hold-value')) { // exceptions
				var initValue;
				if ($(this).val()!='') {
					initValue = $(this).val();	
				} else {
					var label = $(this).parent().find('label').html();
					initValue = label;
					$(this).val(initValue);
				}
				
				$(this).focus(function(){
					$(this).removeClass("no-focus");
					if($(this).val() == initValue) $(this).val('');
				})
				$(this).blur(function(){
					if ($(this).val() == "") $(this).addClass("no-focus");	// set class no-focus only if value is cleared
					if($(this).val() == '') $(this).val(initValue);
				})
			}
		})
	}
}
// end Function Toggle Input Default Value


FnFormSubmit = {
	init: function() {
		
		if ($('form').length > 0 ) {
			
			$('form').each(function(){
				$(this).submit(function(){
					$(this).find('input:text').each(function(){
						var initValue = $(this).parent().find('label').html();

						if ($(this).val() == initValue) {
							$(this).val('');
							//return false;
						}
						
					});
				});
			});
			
		}
		
	}
}

FnLightBox = {
	
	init: function()
	{
		if ($('.gallery').length > 0 ) 
		{
			//initialize lightbox triggers
			$('.gallery a').lightBox(
			{

				imageLoading: 'images/lightbox/lightbox-ico-loading.gif',
				imageBtnClose: 'images/lightbox/lightbox-btn-close.gif',
				imageBtnPrev: 'images/lightbox/lightbox-btn-prev.gif',
				imageBtnNext: 'images/lightbox/lightbox-btn-next.gif',
				txtImage: 'Foto',
				txtOf: 'van'
			});
		}
	}
}


