jQuery.noConflict();
jQuery(document).ready(function(){    
    jQuery("body").append('<div id="chi_siamo" style="position:absolute; z-index:999;"></div>');
    jQuery("body").append('<div id="cosa_facciamo" style="position:absolute; z-index:999;"></div>');
    jQuery("body").append('<div id="progetto" style="position:absolute; z-index:888;"></div>');
    jQuery("body").append('<div id="referenze" style="position:absolute; z-index:888;"></div>');
    jQuery("body").prepend('<div id="areaClienti" style="z-index:999999;"></div>');
    jQuery("body").prepend('<div id="areaFlickr" style="z-index:999999;"></div>');
    jQuery("#areaFlickr").dialog({
        bgiframe: true,
        autoOpen: false,
        width: 900,
        height: 580,
        closeOnEscape: false,
        modal: true,
        resizable: false,
        draggable: false
    });
    jQuery("#areaClienti").dialog({
        bgiframe: true,
        autoOpen: false,
        width: 900,
        height: 580,
        closeOnEscape: false,
        modal: true,
        resizable: false,
        draggable: false
    });
	
	jQuery("#fullscreen").css("opacity", 0);

	function showChisiamo(){
		jQuery("#cosa_facciamo").fadeOut('slow');
		jQuery("#chi_siamo").load("html/chi_siamo.htm?nocache=" + new Date().getTime());
		var coordinate=jQuery("#imgChi").offset();
		jQuery("#chi_siamo").css("top", (coordinate.top + 45));
		jQuery("#chi_siamo").css("left", (coordinate.left - 110));
		//jQuery("#chi_siamo").animate({opacity: 0.8}, 600).css("display", "block");
		jQuery("#chi_siamo").fadeIn('slow').animate({opacity: 0.9}, 100);
	}
	// Toogle profileview
	//jQuery("#imgChi").click(function(e){
	//	e.preventDefault();
	//	showChisiamo();
	//});

	function closeChisiamo(){
		jQuery("#chi_siamo").delay(200).fadeOut('slow');
	}

	function showCosafacciamo(){
		jQuery("#chi_siamo").fadeOut('slow');
		jQuery("#cosa_facciamo").load("html/cosa_facciamo.htm?nocache=" + new Date().getTime());
		var coordCosa=jQuery("#imgCosa").offset();
		jQuery("#cosa_facciamo").css("top", (coordCosa.top + 45));
		jQuery("#cosa_facciamo").css("left", (coordCosa.left - 70));
		//jQuery("#cosa_facciamo").animate({opacity: 0.8}, 600).css("display", "block");
		jQuery("#cosa_facciamo").fadeIn('slow').animate({opacity: 0.9}, 100);
	}
	// Toogle profileview
	//jQuery("#imgCosa").click(function(e){
	//	e.preventDefault();
	//	showCosafacciamo();
	//});

	function closeCosafacciamo(){
		jQuery("#cosa_facciamo").delay(200).fadeOut('slow');
	}

});

function showReferenze(){
	jQuery("#fullscreen").css("display", "block").animate({opacity: 0.5}, 200);
	var coordPage=jQuery("#divNotizie").offset();
	//alert(jQuery("#progetto").html());
	jQuery("#referenze").css("top", coordPage.top + 800);
	jQuery("#referenze").css("left", (coordPage.left));
	jQuery("#referenze").load("referenze.aspx?nocache=" + new Date().getTime(),'',function(){
		jQuery("#referenze").fadeIn('slow').animate({top: coordPage.top}, 2000);
		// gallery progetto
		jQuery("#loopedSliderPr").loopedSlider({
		    container: '.containerPr',
		    slides: '.slidesPr',
		    pagination: 'paginationPr',
			autoStart: 0,
			slidespeed: 600,
			fadespeed: 600,
			containerClick: false,
			autoHeight: true
		});
	});
}

function showReferenzeOld(){
	jQuery("#fullscreen").css("display", "block").animate({opacity: 0.5}, 200);
	var coordPage=jQuery("#divNotizie").offset();
	//alert(jQuery("#progetto").html());
	jQuery("#referenze").css("top", coordPage.top + 800);
	jQuery("#referenze").css("left", (coordPage.left));
	jQuery("#referenze").load("referenzeold.aspx?nocache=" + new Date().getTime(),'',function(){
		jQuery("#referenze").fadeIn('slow').animate({top: coordPage.top}, 2000);
		// gallery progetto
		jQuery("#loopedSliderPr").loopedSlider({
		    container: '.containerPr',
		    slides: '.slidesPr',
		    pagination: 'paginationPr',
			autoStart: 0,
			slidespeed: 600,
			fadespeed: 600,
			containerClick: false,
			autoHeight: true
		});
	});
}

function closeReferenze(){
	jQuery("#fullscreen").delay(200).fadeOut('slow');
	jQuery("#referenze").delay(200).fadeOut('slow');
}

function showProgetto(idP){
	jQuery("#fullscreen").css("display", "block").animate({opacity: 0.5}, 200);
	var coordPage=jQuery("#divNotizie").offset();
	//alert(jQuery("#progetto").html());
	jQuery("#progetto").css("top", coordPage.top + 800);
	jQuery("#progetto").css("left", (coordPage.left));
	jQuery("#progetto").delay(500).load("progetto.aspx?idPr=" + idP + "&nocache=" + new Date().getTime(),'',function(){
		jQuery("#progetto").fadeIn('slow').animate({top: coordPage.top}, 2000);
		window.setTimeout('loopedSliderPrFunc()',2000);
	});
}

function loopedSliderPrFunc(){
	// gallery progetto
	jQuery("#loopedSliderPr").delay(2000).loopedSlider({
	    container: '.containerPr',
	    slides: '.slidesPr',
	    pagination: 'paginationPr',
		autoStart: 0,
		slidespeed: 600,
		fadespeed: 600,
		containerClick: false,
		autoHeight: true
	});
}

function closeProgetto(){
	jQuery("#fullscreen").delay(200).fadeOut('slow');
	jQuery("#progetto").delay(200).fadeOut('slow');
}

function areaCLIENTI(){
    jQuery("#areaClienti").load("areaClienti.aspx?nocache=" + new Date().getTime(),'',function(){
        jQuery("#areaClienti").dialog('open');
	jQuery("#areaClienti").css("z-index", "999999");
    });
}

function areaFLICKR(){
    jQuery("#areaFlickr").load("areaFlickr.aspx?nocache=" + new Date().getTime(),'',function(){
        jQuery("#areaFlickr").dialog('open');
	jQuery("#areaFlickr").css("z-index", "999999");
    });
}

function chiudiAreaClienti(url){
    window.setTimeout('window.location = \'' + url + '\'',2000);
}

function chiudiAreaFlickr(url){
    window.setTimeout('window.location = \'' + url + '\'',2000);
}
