﻿function selectNews(id) 
{
    cmd = "../admin/gestioneNews.aspx?id=" + id;
    window.location.href = cmd;    
}

function selectRassegna(id) 
{
    cmd = "../admin/gestioneRassegna.aspx?id=" + id;
    window.location.href = cmd;    
}

function selectGiovani(id) 
{
    cmd = "../admin/gestioneGiovani.aspx?id=" + id;
    window.location.href = cmd;    
}

function selectAlbum(id) 
{
    cmd = "gallery.aspx?id=" + id;
    window.location.href = cmd;    
}

function selectPublicNews(id)
{
    cmd = "news.aspx?id=" + id;
    window.location.href = cmd;
}

function selectPublicRassegna(id)
{
    cmd = "comunicatiStampa.aspx?id=" + id;
    window.location.href = cmd;
}

function selectPublicGiovani(id)
{
    cmd = "giovani.aspx?id=" + id;
    window.location.href = cmd;
}

function selectVideo(id) 
{
    cmd = "../admin/gestioneVideo.aspx?id=" + id;
    window.location.href = cmd;
    
}

function selectPublicVideo(id) 
{
    cmd = "video.aspx?id=" + id;
    window.location.href = cmd;
    
}

function eraseTxt() 
{
    document.getElementById("txtTitoloNews").innerText = "";
    document.getElementById("txtData").innerText = "";
    document.getElementById("txtContenuti").innerText = "";
    document.getElementById("hdnName").value = "";
    document.getElementById("txtLink").innerText = "";
}

function eraseVideo() 
{
    document.getElementById("txtTitoloVideo").innerText = "";
    document.getElementById("txtData").innerText = "";
    document.getElementById("txtContenuti").innerText = "";
    document.getElementById("hdnName").value = "";
    document.getElementById("txtLink").innerText = "";
}

function caricaXML(par)
 {
    cmd = "/photoGallery/photoGallery.aspx?par=" + par;
    window.location.href = cmd;
	return false;
}

function caricaXMLAreaRiservata(par) {
    cmd = "../admin/gestioneImmagini.aspx?par=" + par;
    window.location.href = cmd;
    return false;
}



function dlApriNascondiCaricaImmagini()
{
    var ctrl = document.getElementById("divInserimentoImmagini");
    if (ctrl.style.visibility == "visible")
        ctrl.style.visibility = 'hidden';
    else
        ctrl.style.visibility = 'visible';       
}

function ChangeStyle() 
{
    var qs = window.location.search.replace('?', '');
    
    // Verifico che la pagina contenga una querystring
    // ed in caso lancio la procedura di recupero dei dati,
    // altrimenti avviso che non ci sono querystring definite
    if (qs) {
        // Definisco le variabili da recuperare in querystring
        var a, b, c;
       
        // Recupero il valore delle tre variabili con semplici
        // ma ingegnosi controlli a catena sulle stringhe
        // dopo averle divise in array di stringa
        //alert(qs);
        // Recupero il valore di a
        a = qs.split("=");

        // Controllo che le variabili siano state valorizzate
        a[1] == "" ? a[1] = "pulizie" : a[1] = a[1];
        alert(a[1]);
        //alert(a[1]);
        document.getElementById(a[1]).style.color = "red";
    }
}

/* Variabili che è possibile cambiare */	// posizione iniziale 	var dn_startpos=0; 				// posizione finale	var dn_endpos=-200; 				// Velocità dello scroller: un numero più alto indica una velocità inferiore 	var dn_speed=30;					// ID da assegnare al box delle news nel codice HTML	var dn_newsID='news';				// classe che lo script aggiunge quando Javascript è dsisponibile	var dn_classAdd='hasJS';			// Messaggio del link che stoppa lo scroller	var dn_stopMessage='Ferma lo scroller';		// ID del paragrafo generato	var dn_paraID='DOMnewsstopper';	/* Initialise scroller when window loads */	window.onload=function()	{		// check for DOM		if(!document.getElementById || !document.createTextNode){return;}		initDOMnews();		// add more functions as needed	}	/*	This is the functional bit, do not press any buttons or flick any switches	without knowing what you are doing!*/var dn_scrollpos=dn_startpos;/* Initialise scroller */function initDOMnews(){	var n=document.getElementById(dn_newsID);	if(!n){return;}	n.className=dn_classAdd;	dn_interval=setInterval('scrollDOMnews()',dn_speed);	var newa=document.createElement('a');	var newp=document.createElement('p');	newp.setAttribute('id',dn_paraID);	newa.href='#';	newa.appendChild(document.createTextNode(dn_stopMessage));	newa.onclick=stopDOMnews;	newp.appendChild(newa);	n.parentNode.insertBefore(newp,n.nextSibling);	n.onmouseover=function()	{				clearInterval(dn_interval);	}	n.onmouseout=function()	{		dn_interval=setInterval('scrollDOMnews()',dn_speed);	}}function stopDOMnews(){	clearInterval(dn_interval);	var n=document.getElementById('news');	n.className='';	n.parentNode.removeChild(n.nextSibling);	return false;}function scrollDOMnews(){	var n=document.getElementById(dn_newsID).getElementsByTagName('span')[1];	n.style.left=dn_scrollpos+'px';		if(dn_scrollpos==dn_endpos){dn_scrollpos=dn_startpos;}	dn_scrollpos--;	}function openCloseDiv(id){    var ctrl = document.getElementById(id);        if(ctrl.style.visibility == 'hidden')    {        ctrl.style.visibility ='visible';    }    else    {        ctrl.style.visibility ='hidden';    }}function openSearch(query){    alert(query);    window.location.href = 'www.google.com/search?sitesearch=udcparma.it%2Fudc&q='+query;}function openDiv(ID){    var ctrl = 'divContenuti_';    for(var i = 1; i<15; i++)    {        document.getElementById(ctrl+i).className = "hidden";    }    document.getElementById(ID).className = "visible";}

function setHeight() 
{
    var x = document.getElementById("divSinistraCenter").offsetHeight;
    var y = document.getElementById("divDestraCenter").offsetHeight;
    
   // alert(document.getElementById("divContenutiDestra").offsetHeight);
    
    if (x < y)
        document.getElementById("divSinistraCenter").style.height = y + 7 + "px";
    else
        document.getElementById("divDestraCenter").style.height = x - 7 + "px";
}

function setHeightHome() 
{
   
    var x = document.getElementById("divSinistraCenter").offsetHeight;
    var y = document.getElementById("divDestraCenter").offsetHeight;
    var w = document.getElementById("divRightCenter").offsetHeight;
    var max;
    //scopro il più alto
    if(x < y)
    {
        if(x < w)
        {
            if(y < w)
            {
                //w è il più alto
                max = w;
            }
            else
            {
                //y è il più alto
                max = y;
            }
        }
        else
        {
            //x < y e x > w, y è il più alto
            max = y;
        }
    }
    else
    {
        //x > y
        if(x < w)
        {
            // w è il più alto
            max = w
        }
        else
        {
            // x è il più alto
            max = x
        }
    }
    
    document.getElementById("divSinistraCenter").style.height = max + 7 + "px";
    document.getElementById("divDestraCenter").style.height = max + 7 + "px";
    document.getElementById("divRightCenter").style.height = max + 3 + "px";
}
