// JavaScript Document

function checkFieds(FormName,RequiredFields)
{
var FieldList = RequiredFields.split(",");
var BadList = new Array();
var meil = true;
var tel = true;
var finalCall = false;
for(var i = 0; i < FieldList.length; i++) {
	var s = eval('document.' + FormName + '.' + FieldList[i] + '.value');
	s = StripSpacesFromEnds(s);

	if(s.length < 1) {  BadList.push(FieldList[i]); }
	if((FieldList[i]=='email') && (s.length > 1))
	{
		meil = isEmail(s);
	}
	if((FieldList[i]=='telefono') && (s.length > 1))
	{
		tel = IsNumeric(s);
		
	}
	}
if((BadList.length < 1) && meil==true && tel==true){finalCall =  true; }

var message = new String();
if(BadList.length > 0) {
for(var i = 0; i < BadList.length; i++) 
	{ 
		if(BadList[i]=='nome')
			{ message += '\n' + 'Il campo "nome" e obbligatoria'; }
		 if(BadList[i]=='cognome')
			{ message += '\n' + 'Il campo "cognome" e obbligatoria'; }
		 if(BadList[i]=='email')
			{ message += '\n' + 'Il campo "e-mail" e obbligatoria'; }
		if(BadList[i]=='via')
			{ message += '\n' + 'Il campo "via" e obbligatoria'; }
		if(BadList[i]=='civico')
			{ message += '\n' + 'Il campo "civico" e obbligatoria'; }
		if(BadList[i]=='cap')
			{ message += '\n' + 'Il campo "cap" e obbligatoria'; }
		if(BadList[i]=='citta')
			{ message += '\n' + 'Il campo "citta" e obbligatoria'; }
		if(BadList[i]=='provincie')
			{ message += '\n' + 'Il campo "provincie" e obbligatoria'; }
		if(BadList[i]=='nazione')
			{ message += '\n' + 'Il campo "nazione" e obbligatoria'; }
		if(BadList[i]=='telefono')
			{ message += '\n' + 'Il campo "telefono" e obbligatoria'; }
		if(BadList[i]=='login')
			{ message += '\n' + 'Il campo "login" e obbligatoria'; }
		if(BadList[i]=='password')
			{ message += '\n' + 'Il campo "password" e obbligatoria'; }
	}//endwhile
	
}//endif badlist	
if(!meil)	{
	finalCall = false;
	message += '\n' + "L'e-mail e sbagliato";
}

if(!tel)	{
	finalCall = false;
	message += '\n' + 'Numero di telefono non valido';
}

if(finalCall==false)
{
	alert(message);
	return false;
} else
	{
		return true;
	}
//return message;
}

function StripSpacesFromEnds(s)
{
while((s.indexOf(' ',0) == 0) && (s.length> 1)) {
	s = s.substring(1,s.length);
	}
while((s.lastIndexOf(' ') == (s.length - 1)) && (s.length> 1)) {
	s = s.substring(0,(s.length - 1));
	}
if((s.indexOf(' ',0) == 0) && (s.length == 1)) { s = ''; }
return s;
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
   
	/***********************************************
	* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
	* This notice MUST stay intact for legal use
	* Visit http://www.dynamicdrive.com/ for this script and 100s more.
	***********************************************/
	
	var delayb4scroll=1000; //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
	var marqueespeed=1; //Specify marquee scroll speed (larger is faster 1-10)
	var pauseit=1; //Pause marquee onMousever (0=no. 1=yes)?
	var tim;
	////NO NEED TO EDIT BELOW THIS LINE////////////
	
	var copyspeed=marqueespeed;
	var pausespeed=(pauseit==0)? copyspeed: 0;
	var actualheight='';
	
	function scrollmarquee(){
		//document.write(parseInt(cross_marquee.style.top));
			//if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) {
		if (document.getElementById('track').value == "") {
			if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) {
				cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px";
				//alert(actualheight);
			}
			else {
				//alert(parseInt(marqueeheight));
				cross_marquee.style.top=parseInt(marqueeheight)-8+"px";
			}
		}
	}
	
	//press down
	function pressdown() {
		document.getElementById('track').value = "yes";
		
			if (parseInt(cross_marquee.style.top)<(actualheight)) {
				cross_marquee.style.top=parseInt(cross_marquee.style.top)+ 10 +"px";
				//alert(parseInt(cross_marquee.style.top) + "---" + actualheight + " marqueeheight: " + parseInt(marqueeheight) );
				//alert(actualheight);
				tim = setTimeout("pressdown()", 150);
			}
			else {
				//alert(parseInt(marqueeheight));
				cross_marquee.style.top=parseInt(marqueeheight)*(-1)+"px";
				tim = setTimeout("pressdown()", 150);
			}
	}
	
	//press up
	function pressup() {
		document.getElementById('track').value = "yes";
		//cross_marquee.style.top=parseInt(cross_marquee.style.top)+10+"px";
		//alert(document.getElementById('track').value);
		
			if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) {
				cross_marquee.style.top=parseInt(cross_marquee.style.top)-10 +"px";
				//alert(parseInt(cross_marquee.style.top) + "---" + actualheight + " marqueeheight: " + parseInt(marqueeheight) );
				//alert(actualheight);
				tim = setTimeout("pressup()", 150);
			}
			else {
				
				cross_marquee.style.top=parseInt(marqueeheight)-8+"px";
				tim = setTimeout("pressup()", 150);
				//alert(cross_marquee.style.top);
			}
	}
	
	//on mouse out
	function mouse_out() {
		document.getElementById('track').value = "";
		clearTimeout(tim);
		//alert(document.getElementById('track').value);
		scrollmarquee;
	}
	
	//init()
	function initializemarquee(){
		cross_marquee=document.getElementById("vmarquee");
		cross_marquee.style.top=0;
		marqueeheight=document.getElementById("marqueecontainer").offsetHeight;
		actualheight=cross_marquee.offsetHeight;
		if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
			cross_marquee.style.height=marqueeheight+"px";
			cross_marquee.style.overflow="scroll";
			return
		}
		setTimeout('lefttime=setInterval("scrollmarquee()",35)', delayb4scroll);
	}
	
	//event listener
	if (window.addEventListener) {
		window.addEventListener("load", initializemarquee, false);
	}
	else if (window.attachEvent) {
		window.attachEvent("onload", initializemarquee);
	}
	else if (document.getElementById) {
		window.onload=initializemarquee;
	}
   