// JavaScript Document

jQuery(function(){
	/**
	 * Handle the default video/images display 
	 *
	 * Author: waldemarm
	 */	 
	 
	 /** check if we have cookie - if not then default set to images **/
	 if(_getCookie('profile_default_display')==null){
	 	_setCookie('profile_default_display','images');
	 }
	 
	$('.js_turnOnVideo').click(function(e){
		e.preventDefault();
		e.stopPropagation();										
		_setCookie('profile_default_display','video');
//		document.location.href = document.location.href;
		document.location.href = $(this).attr('href');
	});
	
	$('.js_turnOnImages').click(function(e){
		e.preventDefault();
		e.stopPropagation();
		_setCookie('profile_default_display','images');
//		document.location.href = document.location.href;
		document.location.href = $(this).attr('href');
	});	
	
});

/**
 * Function which set cookie with name, value and lifetime passed as the function parameter 
 * @param 'cookieLifetime' in default is set to 365 days
 *
 * Author: waldemar.matlosz
 */
function _setCookie(cookieName, cookieValue, cookieLifetime){
		if(isNaN(cookieLifetime)){
			cookieLifetime = 365;
		}
		$.cookie(cookieName, cookieValue, {path: '/', expires: cookieLifetime });
}

/**
 * Function which set cookie value of the selected cookie
 * @param 'cookieName' 
 *
 * Author: waldemar.matlosz
 */
function _getCookie(cookieName){
		return $.cookie(cookieName);
}

