function open_piva(doc){

    var win_dim = {
	'w':window.innerWidth,
	'h':window.innerHeight
    }
    var dim = {
	'w':369,
	'h':232
    };
    window.open(doc,'','status=no,toolbar=no,height='+dim['h']+',width='+dim['w']+',left='+((win_dim['w']-dim['w'])/2)+',top='+(win_dim['h']-dim['h'])/2);
}



jQuery(document).ready(function(){






    hs.showCredits = false;
    hs.graphicsDir = '/assets/frontend/js/highslide/graphics/';
    hs.outlineType = 'rounded-white';


    jQuery(document).pngFix();
    jQuery('a').bind('focus',function(){
	this.blur();
    });


    var param = {}

    var jqffm = {
	
	animateduration: {
	    over: 200,
	    out: 50
	}, //duration of slide in/ out animation, in milliseconds

	build:function(menuid, par){
	    jQuery(document).ready(function($){
		$('#'+menuid).children('ul:eq(0)').css('position','relative')
		var $mainmenu=$("#"+menuid+">#menuistverticale-middle>ul");
		var $headers=$mainmenu.find("ul").parent().parent().parent();
		$headers.each(function(i){
		    var $curobj=$(this);
		    $curobj.bind('mouseenter',
			function(e){
			    var $targetul=$(this).children(".submenu:eq(0)")
			    
			    
			    $targetul.find('>.submenu-middle').css('height',(($(this).children(".submenu ul li a:eq(0)").outerHeight()+15)*$(this).find('>.submenu>.submenu-middle>ul>li').size())-10+"px");
			    if ($targetul.queue().length<=1){
				$targetul.css({
				    left:"0px",
				    top:(($(this).parent().children('li').index(this)+1)*20)-20+"px"
				    }).fadeIn(jqffm.animateduration.over)
			    }

			})
		    $curobj.bind('mouseleave',
			function(e){
			    var $targetul=$(this).children(".submenu:eq(0)")
			    $targetul.fadeOut(jqffm.animateduration.out)
			}
			)
		});//each
		$mainmenu.find(".submenu").css({
		    display:'none',
		    visibility:'visible'
		})
	    });//ready
	}//buildmenu

    }//jqffm


    jqffm.build("menuistverticale",param);


    jQuery('#exceltable tr:first td').css('font-weight','bold');


    jQuery('.switchimage').bind('click', function(){

	var rela = jQuery(this).attr('rel');

	jQuery('#main-photo a').css('display','none');
	jQuery('#main-photo #'+rela).css('display','block');


    });


    jQuery('#main-photo a:first').css('display','block');



    // rassegna stampa
    jQuery('#filtrarassegna').bind('click', function(){


	jQuery('#container-articoli').show();
	jQuery('#dettaglio-articolo').html('&nbsp;');
	jQuery('#dettaglio-articolo').show();

	var anno = jQuery('#timechange').val();
	var testata = jQuery('#testata').val();

	jQuery.post('http://www.camon.it/prints/get_thumb/', {
	    anno: anno,
	    testata: testata
	},

	function(data){
	    jQuery('#container-rassegna').html(data);

	});

	return false;



    });

    // scateno il primo click
    jQuery('#filtrarassegna').click();



/*
var active;
if(jQuery('#menuist a.active').length > 0)
	active = jQuery('#menuist a.active');
else
	active = jQuery('#menuist a:first');
jQuery('#menuist-chk').css('top',(parseInt(jQuery('#menuist').offset().top)-parseInt(jQuery('#menuist-chk').css('height')))+'px');
jQuery("#menuist-chk").css('left',(parseInt(active.offset().left)+((parseInt(active.innerWidth())-parseInt(jQuery('#menuist-chk').css('width')))/2))+'px');
jQuery('#menuist ul li a').bind('mouseover',function(){
	jQuery("#menuist-chk").animate({left:(parseInt(jQuery(this).offset().left)+((parseInt(jQuery(this).innerWidth())-parseInt(jQuery('#menuist-chk').css('width')))/2))+'px'},'normal');
});
*/

if(jQuery('#adv').length > 0){

var adv_cookie = 'CAMON_ADV_COOKIE_'+jQuery('#adv').attr('rel');

if(jQuery.cookie(adv_cookie)==null){
    jQuery('#adv').show(800);
}

jQuery('#adv .close').click(
	function(){
		jQuery('#adv').slideUp(200);
	}
);

jQuery('.showhide').click(
	function(){

		if(jQuery(this).attr('checked')){
			jQuery.cookie(adv_cookie,2,{expires:7});
		}
		else{
			//jQuery.cookie(adv_cookie,30,{expires:1});
			jQuery.cookie(adv_cookie,null);
		}
	}
);

}


});


function slideRassegna(el,limit){
  
    var anno = jQuery('#timechange').val();
    var testata = jQuery('#testata').val();

    jQuery.post('http://www.camon.it/prints/get_thumb/', {
	anno: anno,
	testata: testata,
	limit: limit
    },

    function(data){
	jQuery('#container-rassegna').html(data);
    });

    return false;

}



function slideDetails(el,id){

    jQuery.post('http://www.camon.it/prints/get_article/', {
	id: id
    },

    function(data){

	jQuery('#container-articoli').hide();
	jQuery('#dettaglio-articolo').html(data);
	jQuery('#dettaglio-articolo').show(data);


    });

    return false;

}



function slideBackToList(){


    jQuery('#container-articoli').show();
    jQuery('#dettaglio-articolo').html('&nbsp;');
    jQuery('#dettaglio-articolo').show();

    return false;

}

