$(function() {
		   
	$('.js_mainPhotoTrigger').click(function(e){
		 e.preventDefault();
		 e.stopPropagation();
		$('#lightbox a:first').trigger('click'); 
			 
		 
	});
	
	$('#lightbox a').lightBox();
	$('#additionalPhotos a').lightBox();

    /**
     * Handle the default video/images display 
     *
     * Author: waldemarm
     */  
     
     /** check if we have cookie - if not then default set to images **/
     if(readCookie('profile_default_display')==null){
        createCookie('profile_default_display','images');
     }
     
    $('.js_turnOnVideo').click(function(e){
        e.preventDefault();
        e.stopPropagation();                                        
        createCookie('profile_default_display','video');
        document.location.href = document.location.href;
    });
    
    $('.js_turnOnImages').click(function(e){
        e.preventDefault();
        e.stopPropagation();
        createCookie('profile_default_display','images');
        document.location.href = document.location.href;        
    }); 

});

function loadLightBox()
{
	$('#lightbox a:first').each(function() {
		$(this).click();
	});
}

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);

}



function createCookie(name,value,days) {

if (days) {

var date = new Date();

date.setTime(date.getTime()+(days*24*60*60*1000));

var expires = "; expires="+date.toGMTString();

}

else var expires = "";

document.cookie = name+"="+value+expires+"; path=/";

}



function readCookie(name) {

var nameEQ = name + "=";

var ca = document.cookie.split(';');

for(var i=0;i < ca.length;i++) {

var c = ca[i];

while (c.charAt(0)==' ') c = c.substring(1,c.length);

if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

}

return null;

}



function eraseCookie(name) {

createCookie(name,"",-1);

}


