function showprogress(){if (document.images.length == 0){document.getElementById("intro").style.visibility="hidden";} var loaded = 0;for (var i = 0; i < document.images.length; i++){ if (document.images[i].complete) { loaded++;}} var percentage = Math.round(100 * loaded / document.images.length); $("#perc").replaceWith("<div id='perc'>Loading... "+percentage+" % loaded</div>"); if (percentage == 100){ $("#intro").hide();var bheight=$("#logo").css("height"); $("#genslide img").css("width","100%");$("#genslide").css("height",bheight);$("#meetslide").css("height",bheight); $("#meetslide img").css("width","100%");$("#banner").css("height",bheight);document.getElementById("meetslide").style.visibility="visible";document.getElementById("genslide").style.visibility="visible";$("#genslide").cycle({ fx:"fade",speed:1000 });$("#meetslide").cycle({ fx:"fade",speed:2000 });window.clearInterval(ID);}} var ID = window.setInterval("showprogress();",500);
$(document).ready(function(){
//	alert("Sito in manutenzione, ci scusiamo per i disagi.");
	var rcheck = 0;
	function mesg()
	{
	if (rcheck == 0)
	{
		window.location.reload();
		rcheck++;
	}
	}
	$("#banner").resize(function(){
	$(window).resize(function(){	
	mesg();
	});
	});
});
function getMaxLength(textarea,maxlength){

	if (textarea.value.length > maxlength)
	{
		textarea.value = textarea.value.substring(0,maxlength);
	}
	updateCounter(textarea.value.length,maxlength);
}
function updateCounter(currentCount,maxlength){
	document.getElementById("counter").innerHTML = currentCount + "/" + maxlength;
}
function crypt(){
	var usr_txt = document.getElementById("usr").value; 
	var usr_txt_md5 = hex_md5(usr_txt);
	document.getElementById("usr").value = usr_txt_md5; 
	var usr_pwd = document.getElementById("pwd").value; 	
	var usr_pwd_md5 = hex_md5(usr_pwd);
	document.getElementById("pwd").value = usr_pwd_md5; 
}
function goto(form) { 
var index=form.langselect.selectedIndex;
if (form.langselect.options[index].value != "0") 
{
location=form.langselect.options[index].value;
}
}
function validate()
{
	var numericExpression = /^[0-9]+$/;
	var emailExpression = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	var nome_cognome=document.getElementById("nome_cognome").value;
	var azienda=document.getElementById("azienda").value;
	var indirizzo=document.getElementById("indirizzo").value;
	var email=document.getElementById("email").value;
	var urllogo=document.getElementById("urllogo").value;
	var username=document.getElementById("username").value;  
	var password=document.getElementById("password").value; 
	if (nome_cognome.length <= 0)
	{
		alert("Il campo 'Nome e cognome' è vuoto");
		return false;
	}
	if (azienda.length <= 0)
	{
		alert("Il campo 'Azienda' è vuoto");
		return false;
	}
	if (indirizzo.length <= 0)
	{
		alert("Il campo 'Indirizzo' è vuoto");
		return false;
	} 
	if (email.length <= 0)
	{
		alert("Il campo 'Email' è vuoto");
		return false;
	}
	if(!email.match(emailExpression))
	{
		alert("Il campo 'Email' non è valido");
		return false;
	} 
	if (urllogo.length <= 0)
	{
		alert("Il campo 'Url Logo' è vuoto");
		return false;
	}
	if (username.length <= 0)
	{
		alert("Il campo 'User Name' è vuoto");
		return false;
	}
	if (password.length <= 0)
	{
		alert("Il campo 'Password' è vuoto");
		return false;
	}
	var x=window.confirm("Confermi i dati inseriti?")
	if (x)
	{
		return true;
	}      
}
function validate_used()
{
	var numericExpression = /^[0-9]+$/;
	var sap_code=document.getElementById("sap_code").value;
	var model=document.getElementById("model").value;
	var year=document.getElementById("year").value;
	var hours=document.getElementById("hours").value;
	var prp_kva=document.getElementById("prp_kva").value;
	var ltp_kva=document.getElementById("ltp_kva").value;
	var engine_brand=document.getElementById("engine_brand").value;
	var engine_model=document.getElementById("engine_model").value;
	var alternator_brand=document.getElementById("alternator_brand").value;
	var alternator_model=document.getElementById("alternator_model").value;
	var img_bin=document.getElementById("img_bin").value;
	var warranty=document.getElementById("warranty").value;
	var delivery=document.getElementById("delivery").value;
	var price=document.getElementById("price").value;


	if (sap_code.length <= 0)
	{
		alert("Il campo 'codice SAP' è vuoto");
		return false;
	}
	if (sap_code.length > 9)
	{
		alert("Il campo 'codice SAP' è vuoto");
		return false;
	}
	if(!sap_code.match(numericExpression))
	{
		alert("Il campo 'codice SAP' deve essere numerico");
		return false;
	}
	if (model.length <= 0)
	{
		alert("Il campo 'modello' è vuoto");
		return false;
	}
	if (year.length <= 0)
	{
		alert("Il campo 'Anno di costruzione' è vuoto");
		return false;
	}
	if(!year.match(numericExpression))
	{
		alert("Il campo 'Anno di costruzione' deve essere numerico");
		return false;
	}
	if (hours.length <= 0)
	{
		alert("Il campo 'Ore di lavoro' è vuoto");
		return false;
	}
	if(!hours.match(numericExpression))
	{
		alert("Il campo 'Ore di lavoro' deve essere numerico");
		return false;
	}
	if (prp_kva.length <= 0)
	{
		alert("Il campo 'PRP KVA' è vuoto");
		return false;
	}
	if(!prp_kva.match(numericExpression))
	{
		alert("Il campo 'PRP KVA' deve essere numerico");
		return false;
	}
	if (ltp_kva.length <= 0)
	{
		alert("Il campo 'LTP KVA' è vuoto");
		return false;
	}
	if(!ltp_kva.match(numericExpression))
	{
		alert("Il campo 'LTP KVA' deve essere numerico");
		return false;
	}
	if (engine_brand.length <= 0)
	{
		alert("Il campo 'Marca motore' è vuoto");
		return false;
	}
	if (engine_model.length <= 0)
	{
		alert("Il campo 'Modello motore' è vuoto");
		return false;
	}
	if (alternator_brand.length <= 0)
	{
		alert("Il campo 'Marca alternatore' è vuoto");
		return false;
	}
	if (alternator_model.length <= 0)
	{
		alert("Il campo 'Modello alternatore' è vuoto");
		return false;
	}
	if (img_bin.length <= 0)
	{
		alert("Non è stata selezionata l'immagine");
		return false;
	}
	if (warranty.length <= 0)
	{
		alert("Il campo 'Garanzia' è vuoto");
		return false;
	}
	if (delivery.length <= 0)
	{
		alert("Il campo 'Consegna' è vuoto");
		return false;
	}
	if (price.length <= 0)
	{
		alert("Il campo 'Prezzo' è vuoto");
		return false;
	}
	if(!price.match(numericExpression))
	{
		alert("Il campo 'Prezzo' deve essere numerico");
		return false;
	}
	var x=window.confirm("Confermi i dati inseriti?")
	if (x)
	{
		return true;
	}
}  
function validate_used_modified()
{
	var numericExpression = /^[0-9]+$/;
	var sap_code=document.getElementById("sap_code").value;
	var year=document.getElementById("year").value;
	var hours=document.getElementById("hours").value;
	var prp_kva=document.getElementById("prp_kva").value;
	var ltp_kva=document.getElementById("ltp_kva").value;
	var price=document.getElementById("price").value;
	if(!sap_code.match(numericExpression))
	{
		alert("Il campo 'codice SAP' deve essere numerico");
		return false;
	}    
	if(!year.match(numericExpression))
	{
		alert("Il campo 'Anno' deve essere numerico");
		return false;
	}    
	if(!hours.match(numericExpression))
	{
		alert("Il campo 'Ore' deve essere numerico");
		return false;
	}    
	if(!prp_kva.match(numericExpression))
	{
		alert("Il campo 'Prp KVA' deve essere numerico");
		return false;
	}
	if(!ltp_kva.match(numericExpression))
	{
		alert("Il campo 'Ltp KVA' deve essere numerico");
		return false;
	}
	if(!price.match(numericExpression))
	{
		alert("Il campo 'Prezzo' deve essere numerico");
		return false;
	}    
	var x=window.confirm("Confermi i dati inseriti?\nHai verificato lo stato di attivazione?")
	if (x)
	{
		return true;
	}
	else
	{
		alert("Non hai confermato i dati");
		return false;
	}
}
function validate_new_page()
{
	var numericExpression = /^[0-9]+$/;
	var iChars = "!@#$%^&*()_+=[]\';,/{}|\":<>?§^£";
	var it=document.getElementById("it").value;
	var en=document.getElementById("en").value;
	var de=document.getElementById("de").value;
	var fr=document.getElementById("fr").value;
	var es=document.getElementById("es").value;
	var content_it=document.getElementById("content_it").value;
	var content_en=document.getElementById("content_en").value;
	var content_de=document.getElementById("content_de").value;
	var content_fr=document.getElementById("content_fr").value;
	var content_es=document.getElementById("content_es").value;
	if (it.length <= 0)
	{
	alert("Il campo 'Nome pagina in Italiano' è vuoto");
	return false;
	}
	if (it == en)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. IT EN");
	return false;	
	}
	if (it == de)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. IT DE");
	return false;	
	}
	if (it == fr)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. IT FR");
	return false;	
	}
	if (it == es)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. IT ES");
	return false;	
	}
	if (en == de)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. EN DE");
	return false;	
	}
	if (en == fr)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. EN FR");
	return false;	
	}
	if (en == es)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. EN ES");
	return false;	
	}
	if (de == fr)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. DE FR");
	return false;	
	}
	if (de == es)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. DE ES");
	return false;	
	}
	if (fr == es)
	{
	alert("I nomi pagina devono essere diversi nelle varie lingue. FR ES");
	return false;	
	}
	var extra_it=document.getElementById("extra_it").value;
	for (var i = 0; i < it.length; i++) {
		if (iChars.indexOf(it.charAt(i)) != -1) 
		{
			alert("Trovati caratteri speciali su nome pagina italiano");
			return false;
		}
	}
	for (var i = 0; i < en.length; i++) {
		if (iChars.indexOf(en.charAt(i)) != -1) 
		{
			alert("Trovati caratteri speciali su nome pagina inglese");
			return false;
		}
	}
	for (var i = 0; i < de.length; i++) {
		if (iChars.indexOf(de.charAt(i)) != -1) 
		{
			alert("Trovati caratteri speciali su nome pagina tedesco");
			return false;
		}
	}
	for (var i = 0; i < fr.length; i++) {
		if (iChars.indexOf(fr.charAt(i)) != -1) 
		{
			alert("Trovati caratteri speciali su nome pagina francese");
			return false;
		}
	}
	for (var i = 0; i < es.length; i++) {
		if (iChars.indexOf(es.charAt(i)) != -1) 
		{
			alert("Trovati caratteri speciali su nome pagina spagnolo");
			return false;
		}
	}
	if (it.length <= 0)
	{
		alert("Il campo 'Nome pagina in Italiano' è vuoto");
		return false;
	}
	if (en.length <= 0)
	{
		alert("Il campo 'Nome pagina in inglese' è vuoto");
		return false;
	} 
	if (de.length <= 0)
	{
		alert("Il campo 'Nome pagina in tedesco' è vuoto");
		return false;
	}
	if (fr.length <= 0)
	{
		alert("Il campo 'Nome pagina in francese' è vuoto");
		return false;
	}
	if (es.length <= 0)
	{
		alert("Il campo 'Nome pagina in spagnolo' è vuoto");
		return false;
	}
	if (content_it.length <= 0)
	{
		alert("Il campo 'Contenuti pagina in Italiano' è vuoto");
		return false;
	} 
	if (extra_it.length <= 0)
	{
		alert("Il campo 'Contenuti extra in Italiano' è vuoto");
		return false;
	}   
	var x=window.confirm("Confermi i dati inseriti?\nHai verificato lo stato di attivazione delle pagine?")
	if (x)
	{
		return true;
	}
	else
	{
		alert("Non hai confermato i dati");
		return false;
	}
}
function repeat_text(){
	var text = document.getElementById("it").value;
	document.getElementById("en").value = "da tradurre:" +text;
	document.getElementById("de").value = "da tradurre:" +text;
	document.getElementById("fr").value = "da tradurre:" +text;
	document.getElementById("es").value = "da tradurre:" +text;
}

function validateform()
{
	var emailExpression = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	var telefono=document.getElementById("telephone").value;
	var stato=document.getElementById("country").value;
	var email=document.getElementById("email").value;
	var name=document.getElementById("firstname").value;
	var cognome=document.getElementById("lastname").value;
	if (telefono.length <= 0)
	{
		alert("Il campo 'telefono' è vuoto. The field 'telephone' is empty.");
		return false;
	}
	if (stato.length <= 0)
	{
		alert("Il campo 'stato' è vuoto. The field 'country' is empty.");
		return false;
	}
	if(!email.match(emailExpression))
	{
		alert("Il campo 'Email' non è valido. The field 'email' is not valid." );
		return false;
	}
	if (name.length <= 0)
	{
		alert("Il campo \"nome\" è vuoto. The field \"Name\" is empty.");
		return false;
	}
	if (cognome.length <= 0)
	{
		alert("Il campo \"cognome\" è vuoto. The field \"Surname\" is empty.");
		return false;
	}
}




