﻿/*
	DOMnews 1.0 
	homepage: http://www.onlinetools.org/tools/domnews/
	released 11.07.05
*/

/* Variabili che ? possibile cambiare */
	// posizione iniziale 
	var dn_startpos=325; 			
	// posizione finale
	var dn_endpos=-450; 			
	// 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';
	// ID del paragrafo generato
	var dn_paraID='DOMnewsstopper';
	//intervallo
	dn_interval=0;

	/* Initialise scroller when window loads */
	window.onload=function()
	{
		// check for DOM
		if(!document.getElementById || !document.createTextNode){return;}
		initDOMnews();
		// add more functions as needed
	}
	/* stop scroller when window is closed */
	window.onunload=function()
	{
		clearInterval(dn_interval);
	}

/*
	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);
		n.parentNode.insertBefore(newp,n.nextSibling);
		n.onmouseover=function()
		{		
			clearInterval(dn_interval);
		}
		n.onmouseout=function()
		{
			dn_interval=setInterval('scrollDOMnews()',dn_speed);
		}
	}

	function scrollDOMnews()
	{
		var n=document.getElementById(dn_newsID).getElementsByTagName('ul')[0];
		n.style.top=dn_scrollpos+'px';	
		if(dn_scrollpos==dn_endpos){dn_scrollpos=dn_startpos;}
		dn_scrollpos--;	
	}
function verificapassword() {
			if ( document.login.username.value == "") 
                  {if ( document.login.password.value == ""){alert ("Non hai specificato il nome utente e la password");}else{
				alert ("Non hai specificato il nome utente");}
				return (false);
			}

if ( document.login.password.value == "") 
                  {
				alert ("Non hai specificato la password");
				return (false);
			}
			}
			
function verificapassword1() {
			if ( document.crea.username.value == "") 
                  {if ( document.crea.password.value == ""){alert ("Non hai specificato il nome utente e la password da creare.Non è possibile creare un account vuoto!");}else{
				alert ("Non hai specificato il nome utente. Non è possibile creare un account senza nome utente!");}
				return (false);
			}


if ( document.crea.password.value == "") 
                  {
				alert ("Non hai specificato la password. Non è possibile creare un account con password vuota!");
				return (false);
			}
			}
			
function verificaevento(){
			if ( document.crea.giorno.value == "" || document.crea.mese.value == "" || document.crea.anno.value == "" || document.crea.titolo.value == "" || document.crea.corpo.value == ""){
				alert ("Non hai specificato tutti i campi obbligatori (data completa, titolo, corpo). Non e' possibile creare un evento senza i campi obbligatori !");
				return (false);
				}
				}
			
function verificaevento2(){
			if ( document.mod.nome.value == "" || document.mod.mou.value == "" || document.mod.yea.value == "" || document.mod.titolo.value == "" || document.mod.corpo.value == ""){
				alert ("Non hai specificato tutti i campi obbligatori (data completa, titolo, corpo). Non e' possibile modificare un evento senza i campi obbligatori !");
				return (false);
				}
				}	

			
function verificalink() {
			if ( document.creal.nome.value == "") 
                  {if ( document.creal.indirizzo.value == ""){alert ("Non hai specificato il nome del link e l'indirizzo da creare.Non è possibile creare un link vuoto!");}else{
				alert ("Non hai specificato il nome del link. Non è possibile creare un link senza specificare il nome del link stesso!");}
				return (false);
			}
			
			if ( document.creal.indirizzo.value == "") 
                  {
				alert ("Non hai specificato l'indirizzo. Non è possibile creare un link con indirizzo vuoto!");
				return (false);
			}
			}
			
function verificaprodotto(){
			if ( document.crea.user.value == ""){
				alert ("Non hai specificato il nome del profumo (obbligatorio) !");
				return (false);
				}
				}

function sicurocancella(){
			chiediConferma = confirm('Sei sicuro di voler cancellare la notizia selezionata?');
			if ( chiediConferma==true){
				return (true);}
			else{
				return (false);}
}

function controllomod(){
			chiediConferma1 = confirm('Sei sicuro di voler modificare la notizia selezionata?');
			if ( chiediConferma1==true){
				return (true);}
			else{
				return (false);}
}

function contrinsfotoalbum(){
	if( document.cfotoalbum.titolo.value == ""){
		alert('Devi inserire un titolo al fotoalbum');
		return(false);
		}
	if ( document.cfotoalbum.num.value == "" || isNaN(document.cfotoalbum.num.value)) {
		alert('Devi inserire un numero intero valido che corrisponde al numero di foto da caricare');
		return(false);
			}
}

function ahah(url,target,delay, function_extra, post){    

    var type = "GET";
    if(window.XMLHttpRequest){
          var req=new XMLHttpRequest();
    }else if(window.ActiveXObject){
          var req=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(req!=undefined){
        if(post)
            type = "POST";
        req.open(type,url,true);
        if(post){
            req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        }
        
        req.onreadystatechange=function(){
            if(req.readyState!=4){
                
            }else{                                                                
                ahahDone(req, url,target,delay, function_extra);
            }
        };
        
        req.send(post);
    }
}

function ahahDone(req, url,target,delay, function_extra){
    
    
    if(req.readyState==4)
    {
        
        alert('Caricamento in corso. Non chiudere la pagina web e non interferire con l\'upload dei files fino a che non arrivera la conferma che la creazione del fotoalbum e\' completata ');
        
        if(req.status==200)
        {
            if(target)
            {

                document.getElementById(target).innerHTML='';
                                document.getElementById(target).innerHTML=req.responseText;                                                
            }    
            
            if (function_extra){ 
                                             
                setTimeout(function_extra, 100);
                
            }
        }
    }
}

function contrinscomm(){
			if ( document.commenti.nome.value == ""){
				if( document.commenti.indirizzo.value == ""){
					if( document.commenti.commento.value == ""){
						alert("Non hai specificato: Nome, Indirizzo e-mail e commento (tutti i campi sono obbligatori)!");
						return(false);							}
					else										{
						alert("Non hai specificato: Nome e Indirizzo e-mail (tutti i campi sono obbligatori)!");
						return(false);							}
															}
				else										{
					if(document.commenti.commento.value == ""){
						alert("Non hai specificato: Nome e commento (tutti i campi sono obbligatorii)!");
						return (false);						  }
					else									  {
						alert("Non hai specificato: Nome (tutti i campi sono obbligatorii)!");
						return (false);						  } 	
															}
													}
			else									{
				if( document.commenti.indirizzo.value == ""){
					if( document.commenti.commento.value == ""){
						alert("Non hai specificato: Indirizzo e-mail e commento (tutti i campi sono obbligatori)!");
						return(false);							}
					else										{
						alert("Non hai specificato: Indirizzo e-mail (tutti i campi sono obbligatori)!");
						return(false);							}
															}
				else										{
					if( document.commenti.commento.value == ""){
						alert("Non hai specificato: commento (tutti i campi sono obbligatori)!");
						return(false);							}
					else										{
						return(true);							}
															}
					}
				}
				
function changeImage()
{
	var list = document.getElementById('optionlist');
	var array= list.options[list.selectedIndex].value.split("*");
	document.getElementById('grande').href=array[0];
	document.mainimage.src = array[0];
	var height= array[1];
	var width= array[2];
	if(height>width){
		document.mainimage.height=400;
		document.mainimage.width=300;
	}
	else{
		document.mainimage.height=300;
		document.mainimage.width=400;
	}
}

function prevImage()
{
	var list = document.getElementById('optionlist');
	if(list.selectedIndex == 0)
	{
		list.selectedIndex = list.options.length-1;
	}
	else
	{
		list.selectedIndex--;
	}
	changeImage();
}

function nextImage()
{
	var list = document.getElementById('optionlist');
	if(list.selectedIndex == list.options.length-1)
	{
		list.selectedIndex = 0;
	}
	else
	{
		list.selectedIndex++;
	}
	changeImage();
}

					
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
