//Gestione PNG con JS
//Attivazione CufOn
//OnFocus input

$(function(){
    Cufon.replace(".title-princ, .title, .value, .subtitle, .watch-showreel a strong, ul.faq-list li .count, .contact-us a strong, a.start strong", {
        fontFamily: 'DIN',
        hover : true
    });
    Cufon.replace("#navigations ul li a, .project-slider .project-name, .small-title, #subnav-container ul li a", {
        fontFamily: 'Franklin Gothic Medium',
        hover : true
    });
    $(".delme").focus(function(){
        if ($(this).is('input')) {
            var orival = $(this).val();
            $(this).val("");
        }else{
            var orival = $(this).html();
            $(this).html("");
        }

        $(this).blur(function(){
            if($(this).is('input')){
                if ($(this).val() != "" && $(this).val() != orival) {
                    $(this).removeClass('delme').unbind('blur').unbind('focus');
                }else{
                    $(this).val(orival);
                }
            }else{
                if ($(this).html() != "" && $(this).html() != orival) {
                    $(this).removeClass('delme').unbind('blur').unbind('focus');
                }else if ($.browser.safari && $(this).val() != "" && $(this).val() != orival) {
                    $(this).removeClass('delme').unbind('blur').unbind('focus');
                }else{
                    $(this).html(orival);
                }
            }

        });
    });
    function setSliderHelper(){
        var portw = $('body').width();
        if(portw > 1590){
            var diff = (portw - 1590) / 2;
            $('.left-bg-repeat, .right-bg-repeat').width(Math.round(diff));
        }else{
            $('.left-bg-repeat, .right-bg-repeat').width(0);
        }
    }
    setSliderHelper();
    $(window).resize(function(){
        setSliderHelper();
    });
	
    var leftPart  = Math.round( 960+( ($('body').width()-960)/2  ) );
    var tmp = leftPart/600;
    tmp =  600 - (leftPart - 600*Math.floor(tmp));
    $(".slider ul").css('left', -(tmp+20));	
    var theCallback = function(){
        var html = $(".slider-current-active-element").next().find('.info-container').html();
        $(".project-slider .info-container").html(html);
        Cufon.replace(".project-slider .project-name", {
            fontFamily: 'Franklin Gothic Medium',
            hover : true
        });
    };
    $(".slider").configurableSlider({
        slideCallback : theCallback, 
        startPos : -(tmp+20),
        infiniteMode : true, 
        speed : 400, 
        easing : 'swing', 
        naviContainer : '.slider-navi'
    });
/*$.wdbox.settings.window_title = "";
	$(".urlInBox").urlInBox({createCallback : function(){
		$(".wdbox .wdbox_interaction").html("<a class = 'closeLink'>chiudi</a>");
	}});
	$(".form-project .resInBox").resInBox({createCallback : function(res){
		if(res == 'allOK'){
			$(".wdbox .wdbox_content_body").html("Please wait...");
			$(".wdbox .wdbox_interaction").html("");
			$('.form-project .resInBox').append('<input name="quote_sync" type="hidden"/>').die('submit').submit();
		}else{
			$(".wdbox .wdbox_interaction").html("<a class = 'closeLink'>chiudi</a>");
		}
	}});
	$(".send-mail .resInBox").resInBox({createCallback : function(res){
		$(".wdbox .wdbox_interaction").html("<a class = 'closeLink'>chiudi</a>");
	}});
	$(".notice div").slideDown(1200);
	
	$(".services-list ul a").click(function(){
		var rel = $(this).attr('rel');
		$(".services .images li."+rel+", .services .text li."+rel).addClass('visible').siblings().removeClass('visible');
		return false;
	});
	*/
	
});
function attachThis(){
    var filename = $('input[type=file]').val().replace(/^.*\\/, '')
    $(".fileHolder").html(filename);
}
