﻿// Funzioni generiche
var opera=navigator.userAgent.toLowerCase().indexOf("opera")!=-1;
var IE=document.all?true:false;
function apri_chiudi(ctl,op) {
d=ctl.style;if(op=='apri')d.display='';else if(op=='chiudi')d.display='none';else{if(d.display=='none')d.display=''; else d.display='none';}}
// Funzioni generiche (Fine)

//Tasto laterale - modifica animazione palla 15/06/07
function chtasto(lktd,classe){
    document.getElementById(lktd).className=classe;
}
//Tasto laterale (fine)
//Altro 13/05/2007
function OpenVideo(link){
    window.open(link,'','width=410,height=310,scrollbars=no,menubar=no,resizable=yes');}
function OpenWindow(link,w,h){
    window.open(link,'','width='+w+',height='+h+',scrollbars=no,menubar=no,resizable=yes');}
function OpenWindowLib(link){
if (link!='undefined' && link!=''){
    window.open(link,'','');}}
function OpenWindowInt(link){
    window.open(link,'','width=554,height=625,scrollbars=yes,menubar=no,resizable=yes');}

// Aggiungi ai preferiti 11/06/2006
function isMsie4orGreater() {
	var ua = window.navigator.userAgent; var msie = ua.indexOf ( "MSIE " );
	if (msie > 0)
		{return (parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) ) >=5) && (ua.indexOf("MSIE 4.0b") <0) ;}
	else {return false;}
}
var funzione1="Questa caratteristica non supportata dal browser in uso."
var funzione2=""
function addbookmark(){ //VECCHIO
	if (isMsie4orGreater()){window.external.AddFavorite(location.href, document.title)}
	else {alert(funzione1+"\n"+"\n"+funzione2+"\n")}
}
function addhomemark() {alert(funzione1+"\n"+"\n"+funzione2+"\n")}

function addbookmarkex(icon){
if( window.sidebar && window.sidebar.addPanel ) {
document.write( '<a href="javascript:window.sidebar.addPanel( document.title, location.href, \'\' );"><img src="'+icon+'" border="0" align="absmiddle" /><\/a>' );
} else if( window.opera && window.print ) {
	document.write( '<a title="'+document.title+'" rel="sidebar" href="'+location.href+'"><img src="'+icon+'" border="0" align="absmiddle" /><\/a>' );
} else if(window.external && ( navigator.platform == 'Win32' || ( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) ) {
	document.write( '<a href="javascript:window.external.AddFavorite( location.href, document.title );"><img src="'+icon+'" border="0" align="absmiddle" /><\/a>' );
} else {document.write( '<a href="javascript:alert(funzione1+\'\n\'+\'\n\'+funzione2+\'\n\');"><img src="'+icon+'" border="0" align="absmiddle" /><\/a>' );}
}
// Aggiungi ai preferiti (Fine)

// INIZIO INVIO AMICI 10/05/2007
function InvioAmici(link){
if(link=='undefined')link="http://www.aiorao.it";
window.open('amici.aspx?url=' + link,'','width=536,height=625,scrollbars=no,menubar=no,resizable=no');
}
function InvioAmiciSub(link,amicilink){
if(link=='undefined')link="http://www.aiorao.it";
window.open(amicilink + '?url=' + link,'','width=536,height=700,scrollbars=no,menubar=no,resizable=no');
}
// FINE INVIO AMICI
//VOZME AUTOMATICO
function LoadSito() {
    if (window.location.href == "http://www.aiorao.it/" || window.location.href == "http://aiorao.it/" || window.location.href == "www.aiorao.it/" || window.location.href == "http://www.aiorao.it" || window.location.href == "http://aiorao.it" || window.location.href == "www.aiorao.it") {
        Delete_Cookie('AUTOascolta', '/', '');
    } else {
    if (window.location.href != "http://www.aiorao.it/Default.aspx" & window.location.href != "http://aiorao.it/Default.aspx" & window.location.href != "www.aiorao.it/Default.aspx")
    { if (Get_Cookie('AUTOascolta') == 'yes') get_id('txtleggo', 'it', 'fm'); }
    else {}
      }
    checkAttDisAutoAscolta();
}
function AttivaAutoAscolta() { //Non utilizzato da /ascolta/index.htm
    Set_Cookie('AUTOascolta', 'yes', 1, '/', '', '');
}
function AttDisAutoAscolta(onlyCheck) {
    if (Get_Cookie('AUTOascolta') == 'yes'){
        Delete_Cookie('AUTOascolta', '/', '');
        if (document.getElementById('AUTOa')) document.getElementById('AUTOa').src = 'img/AscoltaAUTOd.gif';
    }
    else {
        AttivaAutoAscolta();
        if (document.getElementById('AUTOa')) document.getElementById('AUTOa').src = 'img/AscoltaAUTOa.gif';
    }
}
function checkAttDisAutoAscolta() {
    if (document.getElementById('AUTOa')) {
        if (Get_Cookie('AUTOascolta') == 'yes'){
            document.getElementById('AUTOa').src = 'img/AscoltaAUTOa.gif';}
        else {
            document.getElementById('AUTOa').src = 'img/AscoltaAUTOd.gif';}
    } 
}
//FINE VOZME AUTOMATICO
//Gestione cookie:
function Set_Cookie(name, value, expires, path, domain, secure) {
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime(today.getTime());

    /*
    if the expires variable is set, make the correct
    expires time, the current script below will set
    it for x number of days, to make it for hours,
    delete * 24, for minutes, delete * 60 * 24
    */
    if (expires) {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + (expires));

    document.cookie = name + "=" + escape(value) +
((expires) ? ";expires=" + expires_date.toGMTString() : "") +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
((secure) ? ";secure" : "");
}

function Get_Cookie(check_name) {
    // first we'll split this cookie up into name/value pairs
    // note: document.cookie only returns name=value, not the other components
    var a_all_cookies = document.cookie.split(';');
    var a_temp_cookie = '';
    var cookie_name = '';
    var cookie_value = '';
    var b_cookie_found = false; // set boolean t/f default f

    for (i = 0; i < a_all_cookies.length; i++) {
        // now we'll split apart each name=value pair
        a_temp_cookie = a_all_cookies[i].split('=');


        // and trim left/right whitespace while we're at it
        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

        // if the extracted name matches passed check_name
        if (cookie_name == check_name) {
            b_cookie_found = true;
            // we need to handle case where cookie has no value but exists (no = sign, that is):
            if (a_temp_cookie.length > 1) {
                cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }
            // note that in cases where cookie is initialized but no value, null is returned
            return cookie_value;
            break;
        }
        a_temp_cookie = null;
        cookie_name = '';
    }
    if (!b_cookie_found) {
        return null;
    }
}

function Delete_Cookie(name, path, domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
//Fine Gestione cookie