// generic
var url = document.location.href;
var get = location.search.slice(1);

function go(p,so){
        if(so != 'mac'){ 
        document.main.p.value=p;
        document.main.sql_limit.value = (p*2);
        document.main.submit();
        }else{
        document.mac.p.value=p;
        document.mac.sql_limit.value = (p*2);
        document.mac.submit();
        } 
 }

function $f(id){
	return document.getElementById(id);
}

// gestione toolbar per sezione download
function makeToolbar(LEVEL1,LEVEL2){
	if((LEVEL2 != '') && (LEVEL2 != 'generico') && (LEVEL2 != null)){
		var urlSection = LEVEL2;
		if (LEVEL2 == 'scienze'){urlSection = 'scienza';}
		if (LEVEL2 == 'rubriche'){urlSection = 'collaboratori';}
		if (LEVEL2 == 'curiosita'){urlSection = 'stranomavero';}
	}

	$("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(url)+'&title='+title+'',
		'http://oknotizie.alice.it/post.html.php?url='+escape(url)+'&title='+title+'&category=',
		'http://digg.com/submit?phase=2&url='+escape(url)+'&title='+title+'',
		'http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk='+escape(url)+'&title='+title+'',
		'http://www.facebook.com/sharer.php?u='+escape(url)+'&t='+title+'');
	for (i in socialType){
		if(type == socialType[i])window.open(socialLink[i]);
	}
}


// send
function send(url, title){
var body = 'Ho trovato questo articolo su Tiscali Tecnologia 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 Tecnologia: ' + title + '&body=' + body;
    window.location.href = mail;
}

// print
if(get && (get == 'print')){
	$f('styleType').href = "/v004/inc/css/print.css";
	self.print();	
	function stopADV() {
		if (typeof(makeAD) == 'function') {
       		makeAD = function() {return false;}
       		a=1;
	   	}
   		if (a!=1) {setTimeout("stopADV();",1);}
	}
	var a=0;
	stopADV()
}

function printPage(){
	var urls = url.replace(/\.html.*$/,'.html');
	//alert(urls);
	paginastampa=window.open(urls+'?print', 'Stampa', 'height=500,width=600,menubar=no,resizable=no,scrollbars=yes, toolbar=no');
}

function radioCinema(){
radio=window.open('/v006/inc/radioCinema/popup.html', 'RadioCinema', 'height=500,width=530,menubar=no,resizable=no,scrollbars=yes, toolbar=no');
}

function image(id){
	$("#"+id+"").attr("src", "/v004/img/"+id+".jpg");
}

$(document).ready(function() {
       //$('#banner664x70accesso').html('<iframe width="664" scrolling="no" height="95" frameborder="no" src="http://ads.tiscali.it/adw-bin/searchAD.pl?n=2" framespacing="0"></iframe>');
})

/* SET VALUE OF QUERYSTRING ON RELATED ARTICLES */
function setQueryString(){
	var querystring  = location.search;
	querystring 	 = querystring.substring(1);
	var lastArticles = $(".lastNews > ul > li > a").attr('href');
	addQueryString	 = lastArticles+'?'+querystring;
	$(".lastNews > ul > li > a").each(function(index) {
		$(this).attr('href',$(this).attr('href')+'?'+querystring);
	});
}

function displayOn(id){
		$('#'+id).slideDown("slow");
		}
		function displayOff(id){
			$('#'+id).slideUp("slow");
		}	

	/* gestione dei moduli scaricati, recenti, consigliati presenti nella home di download  */
	function cLabel(id,so,type,el){			
		for(i=0; i<el; i++){
			if(i == id){
				document.getElementById(type+"_"+id).className = type+"On";
			}			
			else{
				document.getElementById(type+"_"+i).className = type+"Off";
			}
		}
		var urlBox = 'lib/function.php?type='+type+"&so="+so+"&id="+id;
		htmlLoad(urlBox,type,so);  		
	}

	
	
	function htmlLoad(urlBox,type,so){		
	if((type=="novita") || (type=="top100")){type = "listaHome";}
	$.ajax({		
		type: "POST",
		url: urlBox,
		data:"",
		dataType: "html",
		beforeSend  :function(){},
		success: function(html){
			$("#divTrg_"+type).html(html);				
	   	}
	   	
	});	
	//alert(type);
	}
	
	
	function switchTab(id,label,cont,so,type){
		bgUl = document.getElementById('label_cont');
		
		var i = 0;
		while(i < 2){
			if(id==i){
				bgUl.className = 'bg_label_list_'+id;		
				$f(label+id).className = 'a_label';
			}
			else{			
				$f(label+i).className = '';
			}		
			i++;
		}
		if(type == "lista"){
			var urlBox = '/download/lib/function.php?listaCategorie='+so;	
		}else{			
			var urlBox = '/download/lib/function.php?type='+type+"&id="+id+"&limit="+15+"&so="+so;
		}
		htmlLoad(urlBox,type,so); 		
	}	

