$(document).ready(function(){		
	$(".clkGallery").each(function(){
		ckPage =  location.href+',2';
		$(".clkGallery").click(function(){SetCookie('navGallery',''+ckPage+'','','/','tiscali.it','');});
	});
});	

// generic
var urlPage = document.location.href;
var get = location.search.slice(1);

function $f(id){
	return document.getElementById(id);
}

function makeToolbar(LEVEL1,LEVEL2){
	if(LEVEL1 == 'generico'){
		LEVEL1 = "cinema";	
	}
	else{
		LEVEL1 = LEVEL1;	
	}
	if(LEVEL1 == 'spettacoli'){
		$("li#"+LEVEL1+" > a:first-child").attr("class","tabActiveSpettacoli" );
	}
	else{
		$("li#"+LEVEL1+" > a:first-child").attr("class","tabActive" );	
	}
	$("li#"+LEVEL1+" > ul").css({'display':''});	
	$("ul > li#"+LEVEL2+" > a:first-child").attr("class","subActive" );	
}

// target blank
function target() { 
    for (var i=0; i<document.links.length; i++)
	{
       	if(document.links[i].className.indexOf('blank') != -1)document.links[i].target="_blank";
	} 
}
window.onload = target;

// social network
function addSocial(type,title){
	var socialType = new Array('del','ok','digg','gg','facebook');
	var socialLink = new Array(
		'http://del.icio.us/post?url='+escape(urlPage)+'&title='+title+'',
		'http://oknotizie.alice.it/post.html.php?url='+escape(urlPage)+'&title='+title+'&category=',
		'http://digg.com/submit?phase=2&url='+escape(urlPage)+'&title='+title+'',
		'http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk='+escape(urlPage)+'&title='+title+'',
		'http://www.facebook.com/sharer.php?u='+escape(urlPage)+'&t='+title+'');
	for (i in socialType){
		if(type == socialType[i])window.open(socialLink[i]);
	}
}

function switchTab(id,label,cont){
	i=0;
	while(i < 3){
		if(id==i){
			$f(label+i).className = 'btnOthActive';	
			//$f(cont+i).style.display = 'block';
			$('#'+cont+''+i).slideDown("normal");
			$('#fr_'+i).attr({src: "/v006/img/fr_giu.png"});
			$('#'+cont+''+i).focus();
		}
		else{
			if((id == 0)){
				if((i == 0) || (i == 2)) $f(label+i).className = 'btnInactiveL1';
				else $f(label+i).className = 'btnInactiveL0';
			}
			
			else if(id == 1){
				$f(label+i).className = 'btnInactiveL1';
			}
			
			else if(id == 2){
				if(i == 0) $f(label+i).className = 'btnInactiveL1';
				else $f(label+i).className = 'btnInactiveL2';	
			}
			else $f(label+i).className = 'btnInactiveL0';
			$('#fr_'+i).attr({src: "/v006/img/fr_su.png"});
			$f(cont+i).style.display = 'none';	
				
		}
		i++
	}

}

// send
function send(url, title){
var body = 'Ho trovato questo articolo su Tiscali Spettacoli e ho pensato ti potesse interessare.%0d%0a%0d%0a';
	body += 'Per vederlo vai a questo link:%0d%0a' + escape(url);
	var mail = 'mailto:?subject=Tiscali Spettacoli: ' + title + '&body=' + body;
    window.location.href = mail;
}

// print
if(get && (get == 'print')){
	$f('styleType').href = "/v006/inc/css/print.css";
	
	function stopADV() {
		if (typeof(makeAD) == 'function') {
       		makeAD = function() {return false;}
       		a=1;
	   	}
   		if (a!=1) {setTimeout("stopADV();",1);}
	}
	var a=0;
	stopADV();
	//self.print();	
}

function printPage(){
var urls = urlPage.replace(/\.html.*$/,'.html');
//alert(urls);
paginastampa=window.open(urls+'?print', 'Stampa', 'height=500,width=680,menubar=no,resizable=no,scrollbars=yes, toolbar=no');
}

function radioCinema(){
radio=window.open('/v006/inc/radioCinema/popup.html', 'RadioCinema', 'height=500,width=680,menubar=no,resizable=no,scrollbars=yes, toolbar=no');
}

function image(id){
	$("#"+id+"").attr("src", "/v006/img/"+id+".jpg");
}


function htmlLoad(type,id){
for(i=0; i<2; i++){
	if(i == id) $('#tab-'+id).attr("class","tab-m-a");
	else $('#tab-'+i).attr("class","tab-m-n");
}
$.ajax({		
	type: "POST",
	url: "/v006/inc/etc/"+type+".html",
	data:"",
	dataType: "html",
	beforeSend  :function(){},
	success: function(html){
		$("#trgMultiBox").html(html);	
	}
	
});	
}
