// JScript File

// NEWS ROTATOR
var rotateNewsStarted;
var currentRotateNews = new Array();
function rotateNews() {
    if(rotateNewsStarted==null) {
        //for(var i=1;i<2;i++) {
        var i = 1;  
        if (document.getElementById("notizie_left_"+i+"_1")!=null && document.getElementById("notizie_left_"+i+"_2")!=null)
              setInterval('doRotateNews('+i+')',5000);
        //}
        rotateNewsStarted=true;
    }
}


function doRotateNews(id) {
    if (currentRotateNews[id]==null) currentRotateNews[id] =2;
    //alert(currentRotateNews[id]);
    var div = document.getElementById("notizie_left_"+id+"_"+currentRotateNews[id]);
    if (div!=null) {
        globalNewsRightTab(currentRotateNews[id]);
        currentRotateNews[id]++;
    } else {
            currentRotateNews[id]=1;
            doRotateNews(id);
    }
   
}


var timerID = null;

var timerRunning = false;

function stopclock (){

        if(timerRunning)
                clearTimeout(timerID);

        timerRunning = false;

}

function showtime () {
        
       var now = new Date();

        var hours = now.getHours();

        var minutes = now.getMinutes();

        var seconds = now.getSeconds();

        var timeValue = "" + ((hours >12) ? hours -12 :hours);
        
        var timeValue = "" + hours;

        timeValue += ((minutes < 10) ? ":0" : ":") + minutes;

        timeValue += ((seconds < 10) ? ":0" : ":") + seconds;

        //timeValue += (hours >= 12) ? " pm" : " am";

        
        // you could replace the above with this

        // and have a clock on the status bar:

        // window.status = timeValue;
        
        if(document.all){
                document.all.clock.innerHTML = timeValue;
        }
        else if(document.getElementById){
                document.getElementById('clock').innerHTML  = timeValue;
        }
        else if(document.layers){
                document.layers['clock'].document.write(timeValue);
                document.layers['clock'].document.close()
        }

        timerID = setTimeout("showtime()",1000);

        timerRunning = true;

}

function startclock () {

/*
        // Make sure the clock is stopped
        
        stopclock();

        showtime();
*/
}



function submitSearchForm() {   
        
    var o = document.frm_cerca;
    //document.forms[0].submit();
    //alert(o);
    if (o!=null) o.submit();
        
}



    
    
function setLayoutId (nome, times) {
    
    objElementName = nome;		        
    
    if (typeof(times) == "undefined") {

        times = 200;
    }
    
    obj = document.getElementById(objElementName);
    		                      
    if (obj == null || document.getElementById("footer") == null) {
        
        // Ancora non disponibile. Ritento.. 
        if (times >= 1) setTimeout("setLayoutId('"+nome+"', "+(times-1)+")", 50);
        return;	
    }
    
        
    var newCorner = document.createElement('div');
    
	
    if (objElementName == "cerca") 		    newCorner.innerHTML = '<div class="layout" style="top: 0px;left: 0px;width: 5px;height: 30px;background-position: -7px 0px;"></div><div class="layout" style="top: 0px;right: 0px;width: 5px;height: 30px;background-position: -13px 0px;"></div>';
    if (objElementName == "colonna1")		newCorner.innerHTML = '<div class="layout" style="bottom: 0px;right: 0px;width: 7px;height: 7px;background-position: -22px -7px;"></div><div class="layout" style="bottom: 0px;left: 0px;width: 7px;height: 7px;background-position: -22px -0px;"></div>';
    if (objElementName == "colonna2")		newCorner.innerHTML = '<div class="layout" style="top: 0px;left: 0px;width: 4px;height: 4px;background-position: -18px 0px;"></div><div class="layout" style="top: 28px;right: 0px;width: 4px;height: 4px;background-position: -18px -4px;"></div><div class="layout" style="bottom: 10px;right: 0px;width: 4px;height: 4px;background-position: -18px -8px;"></div><div class="layout" style="bottom: 10px;left: 0px;width: 4px;height: 4px;background-position: -18px -12px;"></div>';
    if (objElementName == "colonna3")		newCorner.innerHTML = '<div class="layout" style="top: 0px;left: 0px;width: 4px;height: 4px;background-position: -18px 0px;"></div><div class="layout" style="top: 0px;right: 0px;width: 4px;height: 4px;background-position: -18px -4px;"></div><div class="layout" style="bottom: 10px;right: 0px;width: 4px;height: 4px;background-position: -18px -8px;"></div><div class="layout" style="bottom: 10px;left: 0px;width: 4px;height: 4px;background-position: -18px -12px;"></div>';
    if (objElementName == "colonna4")       newCorner.innerHTML = '<div class="layout" style="top: 0px;left: 0px;width: 4px;height: 4px;background-position: -18px 0px;"></div><div class="layout" style="top: 28px;right: 0px;width: 4px;height: 4px;background-position: -18px -4px;"></div><div class="layout" style="bottom: 10px;right: 0px;width: 4px;height: 4px;background-position: -18px -8px;"></div><div class="layout" style="bottom: 10px;left: 0px;width: 4px;height: 4px;background-position: -18px -12px;"></div>';
    
      
    
    if (objElementName == "list_contained")	newCorner.innerHTML = '<div class="layout" style="top: 0px;left: 0px;width: 4px;height: 56px;background-position: -29px 0px;"></div><div class="layout" style="top: 0px;right: 0px;width: 4px;height: 56px;background-position: -33px 0px;"></div>';
    
    
    if (objElementName == "tabs")		
    {
        
        if ( tabs_selected != "hockey" )
            newCorner.innerHTML += '<div class="layout" style="bottom: -4px;right: 0px;width: 5px;height: 5px;"></div>';
        if ( tabs_selected != "home" )    
            newCorner.innerHTML += '<div class="layout" style="background-position: 0px -6px;bottom: -4px;left: 0px;width: 5px;height: 5px;"></div>';		        
        //alert(newCorner.innerHTML);
    }
    
    obj.appendChild(newCorner);
}

function setSelectedMenu (nome, times) {

        objElementName = nome;
        
        nameById = "menu_"+objElementName;
        
        obj = document.getElementById(nameById);
        
        if (obj == null ) {
                
                // Ancora non disponibile. Ritento.. 
                if (times >= 1) setTimeout("setSelectedMenu('"+nome+"', "+(times-1)+")", 0);
                return;	
        }
               
        document.getElementById("menu_home").className 			= "";
        document.getElementById("menu_calcio").className 		= "";
        document.getElementById("menu_formula1").className 		= "";
        document.getElementById("menu_motomondiale").className 	= "";
        //document.getElementById("menu_ippica").className 		= "";
        document.getElementById("menu_tennis").className 		= "";
        document.getElementById("menu_basket").className 		= "";
        document.getElementById("menu_football").className 		= "";
        document.getElementById("menu_hockey").className 		= "";
        
        
        
        document.getElementById(nameById).className 			= "selected";
        

}



function loadSiteTop() {

    setTimeout("setLayoutId('tabs')", 0);
    setTimeout("setLayoutId('cerca')", 0);
            		
}

function loadSiteHome() {
    
    setTimeout("setSelectedMenu('"+tabs_selected+"')", 0);
    setTimeout("setLayoutId('colonna1')", 0);
    setTimeout("setLayoutId('colonna2')", 0);
    setTimeout("setLayoutId('colonna3')", 0);
	setTimeout("setLayoutId('colonna4')", 0);
    
            		
}

function loadSiteCoppe() {
    
    setTimeout("setSelectedMenu('"+tabs_selected+"')", 0); 
    setTimeout("setLayoutId('colonna1')", 0);
    setTimeout("setLayoutId('colonna2')", 0);      
            		
}

function loadSiteSquadra() {
    
    setTimeout("setSelectedMenu('"+tabs_selected+"')", 0); 
    setTimeout("setLayoutId('colonna1')", 0);
    setTimeout("setLayoutId('colonna3')", 0);      
            		
}

function loadSiteCalcio() {
    
    setTimeout("setLayoutId('colonna1')", 0);
    setTimeout("setLayoutId('colonna2')", 0);
    setTimeout("setLayoutId('colonna4')", 0);
    setTimeout("setLayoutId('list_contained')", 0);
    setTimeout("setSelectedMenu('"+tabs_selected+"')", 0);
            		
}

function loadSiteF1() {
    
    setTimeout("setLayoutId('colonna1')", 0);
    setTimeout("setLayoutId('colonna2')", 0);
    setTimeout("setLayoutId('colonna4')", 0);
    setTimeout("setSelectedMenu('"+tabs_selected+"')", 0);
          		
}

function loadPiloti() {
    
    setTimeout("setLayoutId('colonna1')", 0);
    setTimeout("setLayoutId('colonna3')", 0);
    setTimeout("setSelectedMenu('"+tabs_selected+"')", 0);
            		
}


function loadSiteBottom () {

   // setTimeout("addTopBanner_home()", 50);		        
            		
}


function sameHeight_home () {
    
    mainDiv  = document.getElementById("colonna1");
    
    //DocumentHeight = document.body.offsetHeight;
    
    //content_site = DocumentHeight - 196;		       
   
    
    if (mainDiv != null) {
        
        mainDivHeight  = mainDiv.offsetHeight;
        		        
        if ((mainDivHeight % 2) == 1 ) {

	        if (typeof(document.body.style.maxHeight) != "undefined") {

		        // IE 7, mozilla, safari, opera 9
		        mainDiv.style.minHeight = mainDivHeight + 'px';

	        } else {

		        // IE6, older browsers
		        mainDiv.style.height = (mainDivHeight + 1 ) + 'px';
	        }
        }
        else
        {
        
                if (typeof(document.body.style.maxHeight) != "undefined") {

		        // IE 7, mozilla, safari, opera 9
		        mainDiv.style.minHeight = mainDivHeight + 'px';
                        
	        } else {

		        // IE6, older browsers
		        mainDiv.style.height = mainDivHeight + 'px';
	        }
        
        }
             
        
    }
    
}




function addTopBanner (mtimes) {           
    var loc = new String(location);
    var pageName = loc.substr(loc.lastIndexOf("/")+1).split("?")[0].toLowerCase();
    //alert(pageName);
  
    if (typeof(mtimes) == "undefined") mtimes = 200;
    obj = document.getElementById("header");
    if (obj == null ) {
        if (mtimes >= 1) setTimeout("addTopBanner_home("+(mtimes-1)+")", 50);
        return;	
    }
    var TopBanner = document.createElement('div');
    TopBanner.setAttribute("id","bannertop");
    
    var bannerPage = "top728x90_sito.html";
    if (pageName=="" || pageName =="index.aspx") bannerPage = "top728x90_home.html";
    TopBanner.innerHTML = '<iframe src="/banners/'+bannerPage+'" width="728" height="90" scrolling="no" border="0" frameborder="0" style="display: block;position: absolute;top: 12px;right: 0px;"></iframe>';
      
    obj.appendChild(TopBanner);
}


function addRightBanner (ptimes) {
    var loc = new String(location);
    var pageName = loc.substr(loc.lastIndexOf("/")+1).split("?")[0].toLowerCase();
    //alert(pageName);
    
    if (typeof(ptimes) == "undefined")  ptimes = 200
    bannerdiv = document.getElementById("banner300x250");
    if (bannerdiv == null ) {
        // Ancora non disponibile. Ritento.. 
        if (ptimes >= 1) setTimeout("addRightBanner("+(ptimes-1)+")", 50);
        return;	
    }
    
    var bannerPage = "300x250_sito.html";
    if (pageName=="" || pageName =="index.aspx") bannerPage = "300x250_home.html";
    bannerdiv.innerHTML = '<iframe src="/banners/'+bannerPage+'" width="300" height="250" scrolling="no" border="0" frameborder="0"></iframe>';
}







var homeNewsTab_selected = 1;
var homeNewsTab_arry 	 = Array();

function homeNewsTab(num) {
                 
		var rotateNewsStarted = null;
		currentRotateNews[1]=1;
		rotateNews();
                   
	// Definizione conenuto da aggiungere
	
        for (i = 1; i <= 3; i++) {
                
                if ( i != num ){
                        document.getElementById("newsHomeContent_"+i).style.display = "none";
                        document.getElementById("homeNewsTab_"+i).className 			= "";
                } else {
                        document.getElementById("newsHomeContent_"+i).style.display = "block";
                        document.getElementById("homeNewsTab_"+i).className = "selected";

			obj_tmp_image = document.getElementById("img_"+i+"_1");

			if (obj_tmp_image != null) {
				
				obj_tmp_image.src = obj_tmp_image.getAttribute("rel");
			}

			// Show thumbnails
			for (p = 1; p <= 5; p++) {
				
				objTemp_img_thumbnail = document.getElementById("img_thumb_"+i+"_"+p);
				
				if (objTemp_img_thumbnail != null) {

					tmp_thumb_attribute = objTemp_img_thumbnail.getAttribute("rel");

					if (tmp_thumb_attribute != null) {

						if (tmp_thumb_attribute != "") {
				
							objTemp_img_thumbnail.src = tmp_thumb_attribute;
						}
					}
				}
			}
                } 
                
                
        }
   
}

function realtimeTab(num) {
        
	// Definizione conenuto da aggiungere

        for (i = 1; i <= 4; i++) {
                
                if ( i != num ){
                        document.getElementById("realtimeContent_"+i).style.display = "none";
                        document.getElementById("realtimeTab_"+i).className 			= "";
                } else {
                        document.getElementById("realtimeContent_"+i).style.display = "block";
                        document.getElementById("realtimeTab_"+i).className = "selected";
                } 
                
                
        }
   
}

function rearlTimeRedirect(num) {
    	window.location="realtime.aspx?tab="+num;
}



function switchTab(w) {
    var baseName = new String(w);
    baseNameTab = baseName.split('_')[0]+"_";
    baseNameContent = baseNameTab.replace("Tab_","Content_")
    currentContent = new String(w).replace("Tab_","Content_");
    for (i = 1; i <= 20; i++) {
        var tabId = baseNameTab+i;
        var contentId = baseNameContent+i;
        var tab = document.getElementById(tabId);
        var content = document.getElementById(contentId);
        if (tabId == w+"") {
            //alert("SHOW "+tab+" "+content);
            if (content!=null) content.style.display = "block";
            if (tab!=null) tab.className = "selected";
        } else {
            //alert("HIDE "+tab+" "+content);
            if (content!=null) content.style.display = "none";
            if (tab!=null) tab.className 			= "";
        }
                
    }
   
}

function homeF1Tab(num) {
        
	// Definizione conenuto da aggiungere
	
       for (i = 1; i <= 3; i++) {
                 
                if ( i != num ){
                        document.getElementById("listContent"+i).style.display = "none";
                        document.getElementById("homeF1Tab_"+i).className 			= "";
                } else {
                        document.getElementById("listContent"+i).style.display = "block";
                        document.getElementById("homeF1Tab_"+i).className = "selected";
                }
                
        }
   
}

function homeGlobal2Tab(num) {
        
	// Definizione conenuto da aggiungere
	
       for (i = 1; i <= 2; i++) {
                 
                if ( i != num ){
                        document.getElementById("Global2Content_"+i).style.display = "none";
                        document.getElementById("Global2Tab_"+i).className 			= "";
                } else {
                        document.getElementById("Global2Content_"+i).style.display = "block";
                        document.getElementById("Global2Tab_"+i).className = "selected";
                }
                
        }
   
}

function homeF1ClassificheTab(num) {
        
	// Definizione conenuto da aggiungere
	
        for (i = 1; i <= 2; i++) {
                 
                if ( i != num ){
                        document.getElementById("GlobalContentF1_"+i).style.display = "none";
                        document.getElementById("homeF1ClassificheTab_"+i).className 			= "";
                } else {
                        document.getElementById("GlobalContentF1_"+i).style.display = "block";
                        document.getElementById("homeF1ClassificheTab_"+i).className = "selected";
                }
                
        }
   
}

function homeCalcioTab(num) {
        
	// Definizione conenuto da aggiungere
	
	/*
    for (i = 1; i <= 2; i++) {
            	
            if ( i != num ){
                    document.getElementById("listContent"+i).style.display = "none";
                    document.getElementById("homeCalcioTab_"+i).className 			= "";
            } else {
                    
                    document.getElementById("listContent"+i).style.display = "block";
                    document.getElementById("homeCalcioTab_"+i).className = "selected";
                    
                    
            }
            
    }
    */
   
}

function homeCampionatoTab(num) {
        
	// Definizione conenuto da aggiungere
	
    for (i = 1; i <= 3; i++) {
            	
            if ( i != num ){
                    document.getElementById("newsGlobalContent_"+i).style.display = "none";
                    document.getElementById("homeCampionatoTab_"+i).className= "";
            } else {
                    
                    document.getElementById("newsGlobalContent_"+i).style.display = "block";
                    document.getElementById("homeCampionatoTab_"+i).className = "selected";
                    
                    
            }
            
    }
   
}

function coppeTab(num) {
        
	// Definizione conenuto da aggiungere
	
    for (i = 1; i <= 6; i++) {
            	
            if ( i != num ){
                    document.getElementById("coppeContent_"+i).style.display = "none";
                    document.getElementById("coppeTab_"+i).className 			= "";
            } else {
                    
                    document.getElementById("coppeContent_"+i).style.display = "block";
                    document.getElementById("coppeTab_"+i).className = "selected";
                    
                    
            }
            
    }
   
}

function homeUsaTab(num) {
        
	// Definizione conenuto da aggiungere
	
        for (i = 1; i <= 3; i++) {
                 
                if ( i != num ){
                        //document.getElementById("newsHomeContent_"+i).style.display = "none";
                        document.getElementById("homeUsaTab_"+i).className 			= "";
                } else {
                        //document.getElementById("newsHomeContent_"+i).style.display = "block";
                        document.getElementById("homeUsaTab_"+i).className = "selected";
                }
                
        }
   
}


function homeNewsRightTab (num, mtimes) {
   
        // Definizione conenuto da aggiungere
	    
        for (i = 1; i <= 4; i++) {
                obj = document.getElementById("newsHomeContent_"+i);
    
                if (obj == null ) {

                        // Ancora non disponibile. Ritento.. 
                        if (mtimes >= 1) setTimeout("homeNewsRightTab("+num+", "+(mtimes-1)+")", 50);
                        return;	
                }
                
                if ( obj.style.display == "block" || obj.style.display == "" )
                {                       
                         for (p = 1; p <= 5; p++) {
                                
                                if (document.getElementById("href_NHR_"+i+"_"+p) != null)
                                {
                                        if (p != num){
                                                document.getElementById("notizie_left_"+i+"_"+p).style.display = "none";
                                                document.getElementById("href_NHR_"+i+"_"+p).className = "";
                                        } else {
                                                document.getElementById("notizie_left_"+i+"_"+p).style.display = "block";
                                                document.getElementById("href_NHR_"+i+"_"+p).className = "selected";

						obj_tmp_image = document.getElementById("img_"+i+"_"+p);

						if (obj_tmp_image != null) {

							tmp_img_attribute = obj_tmp_image.getAttribute("rel");

							if (tmp_img_attribute != null) {

								if (tmp_img_attribute != "") {
				
									obj_tmp_image.src = tmp_img_attribute;
								}
							}
						}
                                        }
                                 }
                         }
                }
                        
        }
   
}


function globalNewsRightTab (num, mtimes) {
  
        // Definizione conenuto da aggiungere
	
                              
         for (p = 1; p <= 5; p++) {
                
                if (document.getElementById("href_NHR_1_"+p) != null)
                {
                
                        if (p != num){
                                document.getElementById("notizie_left_1_"+p).style.display = "none";
                                document.getElementById("href_NHR_1_"+p).className = "";
                        } else {
                                document.getElementById("notizie_left_1_"+p).style.display = "block";
                                document.getElementById("href_NHR_1_"+p).className = "selected";

				obj_tmp_image = document.getElementById("img_1_"+p);

				if (obj_tmp_image != null) {

					tmp_img_attribute = obj_tmp_image.getAttribute("rel");

					if (tmp_img_attribute != null) {

						if (tmp_img_attribute != "") {
				
							obj_tmp_image.src = tmp_img_attribute;
						}
					}
				}
                        }
                 }
         }
         
   
}

function coppeRightTab (num, mtimes) {
        
        // Definizione conenuto da aggiungere
	
                              
         for (p = 1; p <= 6; p++) {
                
                
                if (document.getElementById("href_NHR_1_"+p) != null)
                {
                
                        if (p != num){
                                document.getElementById("href_NHR_1_"+p).className = "";
                        } else {
                                 document.getElementById("href_NHR_1_"+p).className = "selected";
                        }
                 }
         }
         
   
}

var tabs_selected = "";
        var footer = false;	
	
		setTimeout("loadSiteTop()", 0);
		
		function winLoc(strParametri)
	    {
	            window.location = strParametri;
	    }

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function gotoUrlRisultati(senderId,url) {
   var o = document.getElementById(senderId);
   if (o !=null) {
       var url = url+"&giornata="+o.value;
       window.location = url;
   }
}


	function openPopupCustom(URL,nome,width,height) {
		if (nome == '') nome='DisplayWindow';
		window.open(URL,nome,'width='+width+',height='+height+',toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,title='+nome);
	}
	
		function openPopupFixed(URL,nome,width,height) {
		if (nome == '') nome='DisplayWindow';
		window.open(URL,nome,'width='+width+',height='+height+',toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,title='+nome);
	}