/** *  * @author francesco * @author cristiano  * */
var pagina_redir = "";function List(){	this.script_page = '/ajax/send_list.php';	this.checkForm = function()	{		try		{			var nome = document.getElementById('nome');			var cognome = document.getElementById('cognome');			var telefono = document.getElementById('telefono');			var email = document.getElementById('email');			var register_me = document.getElementById('register_me');						if (!nome.value.match(/^[A-Za-z\u00C0-\u00F6\u00F8-\u00FF' ]{1,}$/))			{				alert('Nome non valido!');				return false;			}						if (!cognome.value.match(/^[A-Za-z\u00C0-\u00F6\u00F8-\u00FF' ]{1,}$/))			{				alert('Cognome non valido!');				return false;			}						if (!telefono.value.match(/^[0-9\+]{6,}$/))			{				alert('Telefono non valido!');				return false;			}						if (!email.value.match(/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})){1}$/))			{				alert('Indirizzo e-mail non valido!');				return false;			}						this.params['nome'] = new String(nome.value);			this.params['cognome'] = new String(cognome.value);			this.params['telefono'] = new String(telefono.value);			this.params['email'] = new String(email.value);			this.params['register_me'] = register_me.checked ? 1 : 0;		}		catch (e) { }				return true;	}	this.sendList = function()	{		if (this.checkForm())		{			this.setLoadingSrc('/immagini/vote_loader.gif');			this.setTarget(this.handleResponse);			this.setLoadingTarget(document.getElementById('sl_response'));			this.params['operazione'] = 'send_list';			this.makeRequest(this.script_page);		}	}		this.handleResponse = function(response)	{		var vars = decodeUrlVars(response);				if (vars['success'] == 'no')		{			document.getElementById('sl_response').innerHTML = '<a href="javascript:sl.sendList();"><img border="0" src="/template/immagini/invia_lista.gif" alt="invia_lista" /></a>';			alert(vars['message']);		}		else			window.location = '/result?r=yes&register=' + vars['register'];	}}List.prototype = new AjaxModule();List.prototype.constructor = List;function changeContent(id, qta){	id = parseInt(id);	qta = parseInt(qta);	td = document.getElementById('container_' + id);		td.innerHTML = '<input class="campiForm" id="quantita_' + id + '" name="quantita_' + id + '" type="text" size="3" maxlength="4" value="' + qta + '" />';	td.innerHTML += '<br />';	td.innerHTML += '<a href="javascript:setQuantity(' + id + ');" style="font-size:10px;">Salva</a>';		browser = new String(navigator.appName);	if (browser.indexOf('Internet Explorer') <= 0)		document.getElementById('quantita_' + id).focus();}function setQuantity(id){	id = parseInt(id);	/*location.href = '/update-cart?act=set&id=' + id + '&qta=' + parseInt(document.getElementById('quantita_' + id).value);*/	location.assign('/update-cart?act=set&id=' + id + '&qta=' + parseInt(document.getElementById('quantita_' + id).value));}

function swapHeader(pic){		document.getElementById("header_foto").src = pic;}function Logout(page, red, div){		this.t_page = page;		this.target = div;		this.redtarget = red;		this.exec = function()		{				try				{						pagina_redir = this.t_page;				document.getElementById(this.target).innerHTML = "Uscendo ...";				makeRequest("include_user/php/" + this.redtarget, this.redir, "POST", "");				} 		catch (e) 		{ 			/*document.getElementById(this.target).innerHTML = e.message;*/			alert(e.message);		}		}			this.redir = function()		{				if (xmlhttp.readyState == 4)				{						if (xmlhttp.status == 200) 				window.location.replace(pagina_redir);						else						{								var contentHTML = "<b>Errore durante il trasferimento dati.</b>";								contentHTML += "<br />Stato : " + xmlhttp.status;								document.getElementById(user_target).innerHTML = contentHTML;						}				}		}}function inviaRichiesta(value)
{	
	makeRequest("include_html/mini_sito.php", redir2, "POST", "id=" + value);
}

var redir2 = function()
{	
	if (xmlhttp.readyState == 4)	
	{		
		if (xmlhttp.status == 200)		
		{			
			getById("php_response").innerHTML = xmlhttp.responseText;		
		}		
		else		
		{			
			var contentHTML = "<b>Errore durante il trasferimento dati.</b>";			
			contentHTML += "<br />Stato : " + xmlhttp.status;			
			document.getElementById(user_target).innerHTML = contentHTML;		
		}	
	}
}

function handlePhp()
{	
	if (xmlhttp.readyState == 4)	
	{		
		if (xmlhttp.status == 200) 
			document.getElementById(user_target).innerHTML = xmlhttp.responseText;		
		else		
		{			
			var contentHTML = "<b>Errore durante il trasferimento dati.</b>";			
			contentHTML += "<br />Stato : " + xmlhttp.status;			
			document.getElementById(user_target).innerHTML = contentHTML;		
		}	
	}
}
function enterBox(id, text){	var box = document.getElementById(id);	if (box.value == text) 		box.value = "";}function exitBox(id, text){	var box = document.getElementById(id);	if (box.value == "")		box.value = text;} 
function checkForm(nome_form)
{
    var oForm = document.getElementById(nome_form);
    var field;
    
    for (var i = 0; i < oForm.elements.length; i++)
    {
        field = oForm.elements[i];

        switch (field.type)
        {
        	case "text" :
        	case "textarea" :
        	case "select-one" :
        	case "file" :

	            if (field.value.length <= 0)
	            {
		            alert("Il campo non puo' essere vuoto");
		            field.value = "";
					field.style.backgroundColor = "#f0f0f0";
					field.style.borderColor = "#ff0000";
					field.focus();
					return;
	            }
	            else if ((field.id == "coperti" || field.name == "coperti" || 
	            		field.id == "telefono" || field.name == "telefono" || 
	            		field.id == "cellulare" || field.name == "cellulare") &&
	            		isNaN(field.value))
	            {
	            	alert("Il campo puo' contenere solo numeri");
	                field.style.backgroundColor = "#f0f0f0";
					field.style.borderColor = "#ff0000";
	                field.value = "";
	                field.focus();
	                return;
	            }
	            else if ((field.id == "email" || field.name == "email") && (field.value.indexOf("@") <= 0 || field.value.indexOf("@") == field.value.length - 1))
	            {
	            	alert("E' necessario inserire una e-mail valida");
	                field.style.backgroundColor = "#f0f0f0";
					field.style.borderColor = "#ff0000";
	                field.value = "";
	                field.focus();
	                return;
	            }
	            else if ((field.id == 'giorno' || field.id == 'data' || field.name == 'giorno' || field.name == 'data'))
	            {
	            	var temp = field.value.split("/");
	            	if (temp[0].length != 2 || temp[1].length != 2 || temp[2].length != 4)
	            	{
	            		alert("La data deve essere in formato GG/MM/AAAA");
		                field.style.backgroundColor = "#f0f0f0";
						field.style.borderColor = "#ff0000";
		                field.value = "";
		                field.focus();
		                return;
	            	}
	            	else
	            	{
	            		field.style.backgroundColor = "";
		            	field.style.borderColor = "";
	            	}
	            }
	            else
	            {
	            	field.style.backgroundColor = "";
	            	field.style.borderColor = "";
	            }
	            
	            break;

            case "checkbox" :

				if (field.checked == false)
				{
					alert("Il campo deve essere selezionato");
					field.focus();
					return;
				}

				break;

            case "radio" :

				field = document.getElementsByName(field.name);

				var checked = false;
				for (var j in field)
					if (field[j].checked)
					{
						checked = true;
						break;
					}

				if (!checked)
				{
					alert("Deve essere selezionata almeno un'opzione");
					field[0].focus();
					return;
				}
            	
	            break;
        }
    }

    document.getElementById(nome_form).submit();
}

function cambia_foto(foto, titolo)
{
	var new_foto = new Image();
	new_foto.src = foto;
	var w = new_foto.width;
	var h = new_foto.height;
	var DIM_MAX = 275;
	
	if (w > DIM_MAX || h > DIM_MAX)
	{
		if (w > h)
		{
			h = h * DIM_MAX / w;
			w = DIM_MAX;
		}
		else
		{
			w = w * DIM_MAX / h;
			h = DIM_MAX;
		}
	}
	
	document.getElementById("foto_principale").src = foto;
	document.getElementById("foto_principale").width = w;
	document.getElementById("foto_principale").height = h;
	document.getElementById("foto_principale").alt = titolo;
	document.getElementById("foto_principale").title = titolo;
	document.getElementById("foto_principale").onclick = function()
	{
		openPhoto(foto);
	}
}

function openPhoto(foto)
{
	var new_foto = new Image();
	new_foto.src = foto;
	var w = new_foto.width;
	var h = new_foto.height;
	var DIM_MAX = 490;
	
	if (w > DIM_MAX || h > DIM_MAX)
	{
		if (w > h)
		{
			h = h * DIM_MAX / w;
			w = DIM_MAX;
		}
		else
		{
			w = w * DIM_MAX / h;
			h = DIM_MAX;
		}
	}
	
	var dimX = screen.width; //larghezza pagina
	var dimY = screen.height; //lunghezza pagina
	
	if (document.all) // IF IE
	{
		dimX = document.body.parentNode.scrollLeft + (dimX / 3);
		dimY = document.body.parentNode.scrollTop + 100;
	}
	else
	{
		dimX = window.scrollX + (dimX / 3); //larghezza pagina
		dimY = window.scrollY + 100; //lunghezza pagina
	}
	/*
	var box = document.createElement("div");
	box.id = "box_" + parseInt(Math.random() * 100);
	box.style.position = "absolute";
	box.style.top = "0px";
	box.style.left = "0px";
	box.style.width = screen.width + "px";
	box.style.height = screen.height + "px";
	
	var back = document.createElement("div");
	back.id = "back_div";
	back.style.position = "absolute";
	back.style.top = "0px";
	back.style.left = "0px";
	back.style.width = "100%";
	back.style.height = "100%";
	back.style.backgroundColor = "black";
	*/
	var wall = document.createElement("div");
	wall.id = "wall_div";
	wall.style.position = "absolute";
	wall.style.top = dimY + "px";
	wall.style.left = dimX + "px";
	wall.style.width = w + 10 + "px";
	wall.style.height = h + 50 + "px";
	wall.style.backgroundColor = "#F4F4EC";
	wall.style.border = "1px solid black";
	wall.style.textAlign = "center";
	
	var box_video = document.createElement("div");
	box_video.id = "box_div";
	box_video.style.position = "relative";
	box_video.style.paddingTop = "5px";
	box_video.style.width = "auto";
	box_video.style.height = "auto";
	box_video.innerHTML = '<img src="' + foto + '" width="' + w + '" height="' + h + '" />';

	var link = document.createElement("a");
	link.id = "link_box";
	link.className = "utility";
	link.style.position = "relative";
	link.style.top = "10px";
	link.innerHTML = "Chiudi";
	link.href = "javascript:;";
	link.onclick = function() 
	{ 
		document.body.removeChild(wall);
	}

	/*
	wall.appendChild(box_video);
	wall.appendChild(link);
	box.appendChild(back);
	box.appendChild(wall);
	document.body.appendChild(box);
	*/
	wall.appendChild(box_video);
	wall.appendChild(link);
	document.body.appendChild(wall);
	/*
	setOpacity(back.id, 50);
	setOpacity(wall.id, 100);
	*/
}

try { LLI.callBack("functions1_lib"); }
catch (e) {}
