
function addTitleMap(serv_name){
	
	var KeyServices, ancH2;
	ancH2 = serv_name.substr(1);
	ancH2 = "tit_"+ancH2;
	//alert(ancH2);
	//KeyServices = jQuery(anc).siblings("h2:"+anc+"").text();
	//KeyServices = $("h2").siblings(""+anc+"").text();
	KeyServices = jQuery("#"+ancH2+"").text();
	//alert(KeyServices);
	//jQuery(this).attr('title', KeyServices);
	jQuery("area[rel=" + serv_name + "]").attr('title', KeyServices);
	jQuery("area[rel=" + serv_name + "]").attr('alt', KeyServices);
	//jQuery("area[rel=" + serv_name + "]").simpletooltip();
}

function scrollWin(anc){  
	target = jQuery(anc);
	
	//alert(anc);
	jQuery('#colonna_nascosta div').animate({  
		scrollTop: target.offset().top-151
	}, 1000);  
} 

function morph(id_to_scroll){
	jQuery("#colonna_nascosta").fadeIn(2000);
	jQuery(".jScrollPaneContainer").hide();
	jQuery("#services img.full").animate({'height':'84px','width':'246px','opacity':'0'},2000,function(){jQuery("#img_full").hide()});
	//jQuery("#services img.half").css({'height':'84px','width':'246px'});
	jQuery("#img_half").show();
	// jQuery("img.half").fadeIn(3000,scrollWin(id_to_scroll));
	jQuery("img.half").fadeIn(3000);
}

function Popup(data) 
{
    var mywindow = window.open("", "mydiv", "height=400,width=600,scrollbars=yes");
    mywindow.document.write('<html><head><title>my div</title>');
    /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
    mywindow.document.write('</head><body >');
    mywindow.document.write('<style type="text/css">');
    mywindow.document.write('a{color: #DF0022; font-weight: bold; background-color:#FFFFFF; text-decoration:none}');
    mywindow.document.write('body {background-color: #FFFFFF;color: #064C79;font-family: verdana,tahoma,sans-serif;font-size: 11px;font-style: normal;font-weight: 400;line-height: 16px;margin: 0;padding: 0;}');
    mywindow.document.write('li {margin-top: 15px; list-style-type:none;}');
    mywindow.document.write('</style >');
    mywindow.document.write(data);
    mywindow.document.write('</body></html>');
    mywindow.document.close();
    mywindow.print();
    return true;
}


function seleziona (ruolo){
	if (contatore == 0) {
	    //document.getElementById(ruolo).className = 'correnteprofili';
	    jQuery(jQuery("#"+ruolo+" a").attr("className","correnteprofili"));
	    contatore = contatore+1
	    //alert (contatore);
	    ruolo_selezionato = ruolo;
	}
	else {
	    //document.getElementById(ruolo_selezionato).className = 'wrap-menu-profili';
	    //document.getElementById(ruolo_selezionato).className = '';
	    //document.getElementById(ruolo).className = 'correnteprofili';
		
		jQuery(jQuery("#"+ruolo+" a").attr("className","correnteprofili"));
		jQuery(jQuery("#"+ruolo_selezionato+" a").attr("className",""));
		
	    //alert(jQuery("#"+ruolo).attr("className"));
	    
	    ruolo_selezionato = ruolo;
	    //alert("ruolo selezionato: "+ruolo_selezionato)
	}
}

jQuery(document).ready(function() {		
		if(window.CheckUrl) {
			//alert("chiamo il checkurl");
			CheckUrl();
		}
		else{
			//alert("checkur non presente	");
		}
		//jQuery('.editable').inlineCKEditor({ submitUrl: 'process.php', fieldIdPrefix: 'content_' });
		jQuery('.scrollable').jScrollPane({scrollbarWidth: '12', showArrows: true, animateStep: 2, animateTo: true, animateInterval: 1000});
		jQuery('.scrollablePersone').jScrollPane({scrollbarWidth: '12', showArrows: true, animateStep: 2, animateTo: true, animateInterval: 1000});
		
		//jQuery('#sitenav > ul > li.selected').next().show();
		jQuery('#sitenav > ul > li.selected > ul').show();
		jQuery('#sitenav > ul > li > ul > li.selected').parent().show();
		jQuery('#sitenav > ul > li > ul > li.selected ul').show();
		jQuery('#sitenav > ul > li > ul > li > ul > li.selected').parent().parent().parent().show();
		jQuery('#sitenav > ul > li > ul > li > ul > li.selected').parent().show();
		jQuery('#testi_fade').cycle({sync: 0});	
		jQuery('.news_idee img.left').hover(
				function(){
					jQuery('#copertina_big').fadeIn('slow');
				},
				function(){
					jQuery('#copertina_big').animate({width: '200px', height:'283px', left:'50px', top:'-35px', opacity:'0.8'},500, function(){jQuery(this).removeAttr("style")});
				}
		);
		
		
		/*jQuery('.pdf').click(function(event){
			var pdflink = jQuery(this).attr("href");
			var mainwrapper = jQuery('.main').attr("id");
			var pdfObj = new PDFObject({ url: pdflink }).embed(mainwrapper);
			if(pdfObj) event.preventDefault();
		});
		*/
		

		
		
	    jQuery(".markermenu li").mouseleave(function(){
	    	if(jQuery(this).attr("class")!="correnteprofili"){
	    		//alert("lascio un link generico");
	    		jQuery(this).css({"background-image":"none"} );
	    	}
	    	else{
	    		//alert("lascio il profilo corrente");
	    		
	    	}
	    });

	    /*
	    jQuery("#img_full").click(
	    		function(){
	    			jQuery("#colonna_nascosta").fadeIn(2000);
	    			jQuery("#services img.full").animate({'height':'84px','width':'246px','opacity':0},2000,function(){jQuery("#services a").hide()});
	    			jQuery("#services img.half").css({'height':'84px','width':'246px'});
	    			jQuery("#services img.half").fadeIn(3000);
	    });
	    */
	    
	    jQuery("#img_full area").click(function(){
	    	idToScroll = jQuery(this).attr("rel");
	    	//alert(idToScroll);
	    	morph(idToScroll);
	    });
	    
	    jQuery("#img_half area").click(function(){
	    	idToScroll = jQuery(this).attr("rel");
	    	//alert(idToScroll);
	    	morph(idToScroll);
	    });
	    
	    
	    
	    jQuery(".tre_colonne_new #colonna_nascosta .back").click(
	    		function(){
	    			jQuery("#colonna_nascosta").fadeOut(2000);
	    			jQuery(".jScrollPaneContainer").show();
	    			jQuery("#img_full").show();
	    			jQuery("#services img.full").animate({'height':'199px','width':'246px','opacity':1},2000);    			
		});
	    
	    jQuery("#services li").click(function() {  
	    	  scrollWin("#service_"+jQuery(this).attr("id"));  
	    });  
	    
	    jQuery("a.print").click(function(){
	    	data = jQuery("#"+jQuery(this).attr("rel")).html();
	    	Popup("<style>.print{visibility: hidden; }</style>"+data);
	    });
	    
	   
	    		
	    		
	    
	    
	    //jQuery(".with-tooltip").simpletooltip();
	    
	    
	    jQuery('#accordion .redBold').click(function() {
		$(this).next('.des-case-study').toggle();
		return false;
	    }).next().hide();
	    
	   

	});
