﻿/**
 * Crea una cookie - nombre [valor] [duracion (s)] [ruta] [dominio] [segura (bool)]
 *
 * Notas:
 * - Si no se indica duración (o se establece a false) la cookie se borra al salir
 * - Si no se indica una ruta se asigna la del documento donde ejecutamos el script
 */
function escribirCookie(nombre, valor, duracion, ruta, dominio, segura){ // v2010-03-26
    if(duracion){
        var expires = new Date();
        expires.setUTCMilliseconds(expires.getUTCMilliseconds() + 1000*duracion);
    }

    document.cookie = escape(nombre) + "=" + (valor? escape(valor) : "") +
        (expires ? "; expires=" + expires.toGMTString() : "") +
        (ruta    ? "; path="    + escape(ruta) : "") +
        (dominio ? "; domain="  + escape(dominio) : "") +
        (segura  ? "; secure" : "");
}


/**
 * Elimina la cookie indicada
 */
function borrarCookie(nombre){ // v2010-03-26
    escribirCookie(nombre, "", -86400*365*10);
}


/**
 * Devuelve el valor de la cookie indicada o null si no existe
 */
function leerCookie(nombre){ // v2010-03-26
    var re = new RegExp("^(" + escape(nombre) + ")=(.*)$", "i");
    var c = document.cookie.split(/;\s*/);

    for(var i in c){
        if(re.test(c[i])){
            return unescape(re.exec(c[i])[2]);
        }
    }
    return null;
}
function load() {
    tit = new Array();
    txt = new Array();
    ima = new Array();
    ima[0]='02.png';
    ima[1]='01.png';
    ima[2]='03.png';
    if (document.getElementById('ctl00_Dalt1_HyperLink1').innerHTML == 'Inici'){
        tit[0]='Benvinguts al nostre municipi';
        txt[0]='El nostre terme municipal, situat al bell mig del sud de Menorca.<br />La seva situació geogràfica, entre barrancs, el converteixen en un indret únic,<br />ple de natura, que ha sabut combinar... <a href="/Contingut.aspx?IdPub=1636" target="_self">+info</a>';
        tit[1]='Les platges, el nostre principal atractiu';
        txt[1]='El principal atractiu amb què compta el Municipi des Migjorn Gran són<br />les seves platges i cales d\'aigües blaves i transparents que ocupen<br />uns 2.250 metres quadrats d\'arena blanca... <a href="/Contingut.aspx?IdPub=1656" target="_self">+info</a>';
        tit[2]='Sant Tomàs';
        txt[2]='La urbanització de Sant Tomàs s\'inicià devers l\'any 1962 quan<br />els germans Antoni i Josep Mercadal Fornaris començaren les gestions per promocionar<br />una nova zona turística dins terres... <a href="/Contingut.aspx?IdPub=1640" target="_self">+info</a>';
    }
    if (document.getElementById('ctl00_Dalt1_HyperLink1').innerHTML == 'Inicio'){
        tit[0]='Bienvenidos a nuestro municipio';
        txt[0]='Nuestro municipio, situado justo en la mitad sur de Menorca.<br />Su situación geográfica, entre barrancos, lo convierte en un sitio único,<br />lleno de naturaleza, que ha sabido combinar... <a href="/Contingut.aspx?IdPub=1636" target="_self">+info</a>';
        tit[1]='Las playas, nuestro bien más preciado';
        txt[1]='El más preciado bien con el que cuenta Es Migjorn Gran son sus<br />playas y calas de aguas azules y transparentes que ocupan<br />unos 2.250 metros cuadrados con arena blanca... <a href="/Contingut.aspx?IdPub=1656" target="_self">+info</a>';
        tit[2]='Sant Tomàs';
        txt[2]='La urbanización de Santo Tomás se inició alrededor del año 1962,<br />cuando los hermanos Antoni y Josep Mercadal Fornaris empezaron las gestiones<br />para promocionar una nueva zona turística... <a href="/Contingut.aspx?IdPub=1640" target="_self">+info</a>';
    }
    if (document.getElementById('ctl00_Dalt1_HyperLink1').innerHTML == 'Home'){
        tit[0]='Welcome to our district';
        txt[0]='Our District, situated in the southern part of Minorca.<br />lts geographical location, among gullies, makes it a unique natural setting combining<br />economic growth with protection of the environment... <a href="/Contingut.aspx?IdPub=1636" target="_self">+info</a>';
        tit[1]='The beaches, our most valuable asset';
        txt[1]='The most valuable assets of Es Migjorn Gran are its beaches and coves,<br />washed by clear blue water, some 2,250 square metres of<br />white sand... <a href="/Contingut.aspx?IdPub=1656" target="_self">+info</a>';
        tit[2]='Sant Tomàs';
        txt[2]='The residential complex Sant Tomàs was born around 1962 when two brothers,<br />Antoni and Josep Mercadal Fornaris,<br />began dealings to develop a new tourist resort... <a href="/Contingut.aspx?IdPub=1640" target="_self">+info</a>';
    }
    total = tit.length;
    ale = Math.floor(Math.random() * total);
    document.getElementById('ctl00_Dalt1_Label2').innerHTML = tit[ale];
    document.getElementById('ctl00_Dalt1_Label3').innerHTML = txt[ale];
    document.getElementById('DivDalt2').style.backgroundImage = 'url(/imas/header/' + ima[ale] + ')';
    puntos = '';
    for (u=0;u<total;u++)
    {
        if (u == ale){
            puntos = puntos + '&nbsp;<img src="/imas/general/PuntBlau.png" alt="" />';
        }else{
            puntos = puntos + '&nbsp;<img src="/imas/general/PuntGris.png" alt="" />';
        }
        document.getElementById('DivDaltPunts').innerHTML = puntos;
    }
    avantiempo()
}
function tiempo() {
    if(ale == total-1){
        ale = -1;
    }
    ale = ale +1;
    document.getElementById('ctl00_Dalt1_Label2').innerHTML = tit[ale];
    document.getElementById('ctl00_Dalt1_Label3').innerHTML = txt[ale];
    document.getElementById('DivDalt2').style.backgroundImage = 'url(/imas/header/' + ima[ale] + ')';
    puntos = '';
    for (u=0;u<total;u++)
    {
        if (u == ale){
            puntos = puntos + '&nbsp;<img src="/imas/general/PuntBlau.png" alt="" />';
        }else{
            puntos = puntos + '&nbsp;<img src="/imas/general/PuntGris.png" alt="" />';
        }
        document.getElementById('DivDaltPunts').innerHTML = puntos;
    }
}
function parartiempo(){
    clearTimeout(tempo);
}
function avantiempo(){
    tempo = setInterval("tiempo()", 10000);
}
