var menu = "#mhome";

$(document).ready(function() {

	foto("A.foto");
	foto("A.foto");
	foto("IMG.foto");

	$(menu).addClass("act");
	
	if ($(".fullpage").html()==null) $("#main").append("<div id='main-corner'>&nbsp;</div>");
	
	$("#sidebar SELECT").each(function (i) {
		$(this).css('width','140px');
	});
		
	$("FORM.niceform").each(function (i) {
		$(this).jqTransform({imgPath:'/include/jquery/jqtransformplugin/img/'});
	});
	
	$(".item IMG").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/item_thumb_bg.png");
 	});
	
	$(".news IMG").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/news_thumb_bg.png");
 	});
	
	$(".festival IMG").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/festival_thumb_bg.png");
 	});
	
	/*$(".professionisti IMG").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/news_thumb_bg.png");
 	});*/
	
	$(".industry IMG").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/professionisti_thumb_bg.png");
 	});
	
	$(".location IMG").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/location_thumb_bg.png");
 	});
	
	$("IMG.thumb").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/dettaglio_thumb_bg.png");
 	});
	
	$("IMG.video").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/dettaglio_video_bg.png");
 	});
	
	$("IMG.locandina").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/new/dettaglio_film_bg.png");
 	});
	
	$("IMG.focus").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/focus_bg.png");
 	});
	$("DIV.banner IMG").each(function (i) {
		var thsrc = "url(" + $(this).attr("src") + ")";
        $(this).css("background-image",thsrc);
		$(this).attr("src","/img/banner_bg.png");
 	});
});

function maxLength(obj,max){
  if (max > 0 && obj.value.length >= max) obj.value = (obj.value).slice(0,max);
}

function foto(selector){
	$(selector).lightBox({fixedNavigation:true,imageLoading:'/include/jquery/images/lightbox-ico-loading.gif',imageBtnPrev:'/include/jquery/images/lightbox-btn-prev.gif',imageBtnNext:'/include/jquery/images/lightbox-btn-next.gif',imageBtnClose:'/shim.gif',imageBlank:'/include/jquery/images/lightbox-blank.gif'});
}

function gallery(selector,_size,_count) {
	$(document).ready(function() {
		$("#browsable").scrollable({size:_size}).navigator();
		if (_count<=_size) {
			$(".navi").hide();
			$(".prevPage").hide();
			$(".nextPage").hide();
		}
	});
	
}

function niceform(selector) {
	$(selector).jqTransform({imgPath:'/include/jquery/jqtransformplugin/img/'});	
}
