//PER LA MAIL LIST
function validation(theform) {
// take the next line out when done debugging
//return true;

    	if (theform.from.value == "") {
		negatory("un valido indirizzo e-mail");
		theform.from.focus();
		return false; }
 	if( !ValidateEmailID(theform.from.value) )
	{
		theform.from.focus();
		return false; 
	}


	if (theform.from.value.indexOf("@") == -1) {
		DisplayMessage ("There must be an at symbol (@) in your email address.");
		theform.from.value = "";
		theform.from.focus();
		return false; }
	if (theform.from.value.indexOf(".") == -1) {
		DisplayMessage ("There was no domain specified (ex. mydomain.com) in your email address.");
		theform.from.value = "";
		theform.from.focus();
		return false; }
	return true;
}
function negatory(strField) {
	DisplayMessage ("Per favore inserisci " + strField + " per iscriverti alla Mail List");
}
function cancelClick() {
	window.location.href = "/clinic/clinicmember.asp";
	return true;
}
function onSubmit() {
	if (validation(document.form1)) {
		document.form1.submit();
	}
}

function StringCharSearch(szString, szSearchChars)
{
	var		nIndex ;

	for( nIndex = 0 ; nIndex < szSearchChars.length ; nIndex++ )
	{
		if( -1 != szString.indexOf(szSearchChars.charAt(nIndex), 0) )
			return nIndex ;
	}

	return -1 ;
}

function ValidateEmailID(szEmailID)
{
	var		szInvalidChars = " \",><+&%'/\\^" ;

	if( "" == szEmailID )
	{
		DisplayMessage("Please enter E-mail address") ;
		return false ;
	}

	if( -1 == szEmailID.indexOf("@", 0) ||
			-1 != StringCharSearch(szEmailID, szInvalidChars) )
	{
		DisplayMessage("Invalid E-mail address") ;
		return false ; 
	}

	return true ;
}


//SMS
maxNumber = 125
function byVal(val, obj)	{
  var i = 0;
  while(i<obj.length)
	{
	var tmp = obj.options[i].value;
	if (tmp == val)	
		{
		obj.options[i].selected = true;
		return;
		}
	i++;
	}
}

function findPlusChar(field){
    var s = field;
    var j = 0;
	
       while ( ( s.indexOf( "+" ) != -1 ) && ( j < 160 ) ){
		s = s.replace( "+" , " " );
		j++;
		}
       j=0;
       while ( ( s.indexOf( "°" ) != -1 ) && ( j < 160 ) ) {
		s = s.replace( "°" , "+" );
		j++;
		}
     return s;
}
function getParm(string,parm){
  var startPos = string.indexOf(parm + "=");
  if (startPos >-1){
    startPos=startPos + parm.length + 1;
    var endPos = string.indexOf("&",startPos);
    if (endPos == -1) {
      endPos = string.length;
      }
    
    return unescape(string.substring(startPos,endPos));

    }
  return 0;
  }
  function startTimer()
{
 running = true
 now = new Date()
 now = now.getTime()
 endTime = now + (1000 * 0.1 * 1)
 showCountDown()
}

function showCountDown()
{
 var now = new Date()
 now = now.getTime()
 if (endTime - now <= 0)
 {
  if(navigator.appVersion.substring(5,25) != "compatible; MSIE 5.0")
  {
   document.forms['SMS'].num.focus()
   document.forms['SMS'].testo.focus()
  }
  upperMe(document.forms['SMS'].testo.value)
 }
 else
 {
  var delta = new Date(endTime - now)
  var theMin = delta.getMinutes()
  var theSec = delta.getSeconds()
  var theTime = theMin
  theTime += ((theSec < 10) ? ":0" : ":") + theSec
  if (running)
  {
   timerID = setTimeout("showCountDown()",1000)
  }
 }
}

function stopTimer()
{
 clearTimeout(timerID)
 running = false
}

function upperMe(inputStr)
{
 strlength= inputStr.length
 if (strlength > maxNumber )
 {
  document.forms['SMS'].testo.value=inputStr.substring(0,maxNumber)
  charleft = 0
 }
 else
 {
  charleft = maxNumber - strlength
 }
 document.forms['SMS'].num.value=charleft
 startTimer()
}
function upperMe2(form)
{
 inputStr = form.testo.value
 strlength= inputStr.length
 if (strlength > maxNumber )
 {
  form.testo.value=inputStr.substring(0,maxNumber)
  charleft = 0
 }
 else
 {
  charleft = maxNumber - strlength
 }
 form.num.value=charleft
	stopTimer()
}


//PER I BANNER IN MOVIMENTO

<!--
<!-- Hide from JavaScript-Impaired Browsers
/* First, if you load fewer or more than 6 sponsors
   into your rotator, change the "sponnr" variable
   to the actual number of sponsor .gifs you plan to
   load. */
number_of_sponsors=3;

var sctr=0;
var halt=0;
var isn=new Array();
for (i=0;i<number_of_sponsors;i++){
 isn[i]=new Image();
}

/* The sponsor .gif names are loaded into the isn[x]
   sponsor images array.  You may load any number of
   sponsor images (.gif or .jpg or both) into this
   array. They must all be the same size, however.
   Substitute your own .gif filenames for the ones
   shown here. Note that the first .gif must appear
   in the isn[0] array element. */
isn[0].src="imgbanner/gite.gif";
isn[1].src="imgbanner/tele.gif";
isn[2].src="imgbanner/trasporto.gif";


/* Finally, replace the URL's below with those of
   your sponsors IN THE SAME ORDER. */
var durl=new Array();
durl[0]="gite.htm";
durl[1]="telesoccorso.htm";
durl[2]="trasporto.htm";


/* This script is set to rotate every 10 seconds.
   (5000=5 seconds, so 30000 would equal 30, etc)
   You should change the number in the setTimeout()
   call below for the number of seconds you wish. */
function rotateIt(){
 if (halt!=1){
  sctr++;
  if (sctr>number_of_sponsors-1){
   sctr=0;
   }
  document.sponsor.src=isn[sctr].src;
  setTimeout("rotateIt()",6000);
  }
 }

/* This code will work just fine with or without
   frames.  However, if you are in frames and wish
   to replicate the TARGET="_top" call to remove
   frames, change the location.href call to:
    parent.location.href=durl[sctr];
   below. */
function doIt(){
 halt=1;
 location.href=durl[sctr];
 }

//PER LA DATA
function data (){
                        thisDate = new Date()
						giorno = thisDate.getDay();
                        oggi = thisDate.getDate();
                        monthNum = thisDate.getMonth();
						Year = thisDate.getYear();
						if (Year <=100)
							Year=1900+Year;
							
						        if (monthNum == 0) NomeMese = "Gennaio ";
                        else if (monthNum == 1) NomeMese = "Febbraio ";
                        else if (monthNum == 2) NomeMese = "Marzo ";
                        else if (monthNum == 3) NomeMese = "Aprile ";
                        else if(monthNum == 4) NomeMese = "Maggio ";
                        else if(monthNum == 5) NomeMese = "Giugno ";
                        else if (monthNum == 6) NomeMese = "Luglio ";
                        else if (monthNum == 7) NomeMese = "Agosto ";
                        else if (monthNum == 8) NomeMese = "Settembre ";
                        else if (monthNum == 9) NomeMese = "Ottobre ";
                        else if (monthNum == 10) NomeMese = "Novembre ";
                        else if (monthNum == 11) NomeMese = "Dicembre ";
						        if (giorno == 0) NomeGiorno = "Domenica";
						else if (giorno == 1) NomeGiorno = "Luned&igrave;";
						else if (giorno == 2) NomeGiorno = "Marted&igrave;";
						else if (giorno == 3) NomeGiorno = "Mercoled&igrave;";
						else if (giorno == 4) NomeGiorno = "Gioved&igrave;";
						else if (giorno == 5) NomeGiorno = "Venerd&igrave;";
						else if (giorno == 6) NomeGiorno = "Sabato";
                        document.write(NomeGiorno+' '+oggi+' '+NomeMese+ ' '+Year);

}

//CAMBIO IMMAGINI
function changeImg(component, img){
		//this function changes an image with another
		if (!document.images) return;
		document[component].src = img;
	}

// End Hiding -->



