var addthis_config = {
	ui_language: "fr",			
     services_compact: 'email, facebook, twitter, more',
     services_expanded: 'email, facebook, twitter',          
     services_exclude: 'print'          
}	

//________global functions________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
$(document).ready(function(){ 
 	
	// #### enable superfish navigation menu
	$("#navigation_menu").superfish({		
		'delay':			'100',
		'animation':   	{ opacity	:'show', height:'none' },
		'speed':       	'slow',
		'dropShadows': 	'false',
		'autoArrows':  	'false'
	});		
	$('#navigation_menu').superfish().find("ul").bgIframe({opacity:false}); // add this bit for bgIframe support only

	// #### set tooltips
	$('label').each(function() {	
		if ($(this).attr("class")) {
			if ($(this).attr("class").length<=0)	
				if ($(this).attr("title").length>0) 
					$(this).addClass("label_help");
		}
	});
	
	$('a[title]').tooltip({ 'fade':250, 'showURL':false }); 	
	$('label[title]').tooltip({ 'fade':250, 'showURL':false }); 	
	
	// #### set prettycheckboxes
	$('input[type=checkbox], input[type=radio]').each(function() {
		if ($(this).attr("class")) {
			if ($(this).attr("class").indexOf("none")<0)
				$(this).prettyCheckboxes()
		}
	});
		
	// #### set textbox focus style
	$('input[type=text].textbox, textarea.textbox').focus(function() {
		$(this).addClass("textbox_focus");
	});
	// #### set textbox blur style
	$('input[type=text].textbox, textarea.textbox').blur(function() {
		$(this).removeClass("textbox_focus");
	});	
	
	// #### pictures lazyload fadein effects
	$("img").each(function() {
		if ($(this).attr("class")) {
			if ($(this).attr("class").indexOf("none")<0)
				$(this).lazyload({ 
					effect      : "fadeIn" 	
				});
		}
	});	
		
	if ($("#creations_list")) $('#creations_list').jScrollPane({showArrows: false});
	if ($("#creations_thumbs")) $('#creations_thumbs').jScrollPane({showArrows: false});
	
	if ($("#search")) {
		$("#search").keydown(function(evt) {
			if (evt.keyCode == "13")
				if ($("#f_search")) 
					$("#f_search").submit();
		});
	}
	if ($("#btn_search")) {
		$("#btn_search").click(function() {
			if ($("#f_search")) $("#f_search").submit();
		});
	}
	
	initialize_css3();
	
	resize_video_background();	
	
	$("#play_video_lightbox").click(function() {
		play_video_lightbox();
	});
	$("#close_video_lightbox_bottom, #close_video_lightbox_top").click(function() {
		close_video_lightbox();
	});
}); 

$(window).resize(function() {
	resize_video_background();
});

function resize_video_background() {
	if ($("#video_background")) {
		var d_height = $(document).height() + 100;		
		$("#video_background").css("height", d_height+"px");
	}	
}
function initialize_css3() {	
	if (window.PIE) {
		$('.css3, .btn, .btn_big, .selector, .paddle, .shadowed, .rounded').each(function() {
		  PIE.attach(this);
		});
	}	
}

function close_video_lightbox() {
	
	//swfobject.removeSWF("video_container");
	$("#video_lightbox").fadeOut("fast");	
	$("#video_background").fadeOut("fast");	
}

function play_video_lightbox() {

	if ($("#video_lightbox").length<=0) return false;
	if ($("#video_container").length<=0) return false;

	$("#video_lightbox").fadeIn("fast");	
	$("#video_background").fadeIn("fast");	
	
	/*if ($("#video_background")) {
		$("#video_background").click(function() {
			document.location.href = "index.html";
		});
	}*/
	
	var flashvars = {
     	'file': '/uploads/files/video_elan.mp4',
    	     'skin': '/uploads/files/stormtrooper.zip',
    	     'autostart' : true
   	};
    
   	var params = {
     	'allowfullscreen':        'true',
      	'allowscriptaccess':      'always'
   	};
 
   	var attributes = {
     	'id':                     'video_container',
      	'name':                   'video_container'
   	};

   swfobject.embedSWF('player.swf', 'video_container', '800', '450', '9', 'false', flashvars, params, attributes);	
}
function check_search() {
	
	if ($("#search").length>0) {	
		var searched_value = $("#search").val();
		if (searched_value.length>0) return true;		
	}
	
	return false;
}


function setMenuScroll() {

}
function show_creations(v_idcreation_folder) {
	
	$("#creations_list ul li[name=creations]").removeClass();
	$("#creation_"+v_idcreation_folder).addClass("selected");
	fill_div("header_container", "clients_results.html?folder="+escape(v_idcreation_folder));
	
}

function show_creation(v_idcreation) {	
	//fill_div("creations_thumbs", "clients_results.html?idcreation="+escape(v_idcreation));	
	fill_div("header_container", "clients_results.html?idcreation="+escape(v_idcreation));	
}
