var sitepath = '/AicaSkill/';


var whitespace = " \t\n\r";                     

function isEmpty(s){
  return ((s == null) || (s.length == 0))
}
function isWhitespace (s){
  var i;
  if (isEmpty(s)) return true;
  for (i = 0; i < s.length; i++){   
    var c = s.charAt(i);
    if (whitespace.indexOf(c) == -1) return false;
  }
  return true;
}

function isEmail (s){
  if (isEmpty(s)) 
    if (isEmail.arguments.length == 1) return false;
    else return (isEmail.arguments[1] == true);
  if (isWhitespace(s)) return false;
  var i = 1;
  var sLength = s.length;
  while ((i < sLength) && (s.charAt(i) != "@")){ i++}
  if ((i >= sLength) || (s.charAt(i) != "@")) return false;
  else i += 2;
  while ((i < sLength) && (s.charAt(i) != ".")){ i++}
  if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
  else return true;
}


function puliscitext(elm){
	if (!elm.base) elm.base = elm.value
	if (elm.value == elm.base) elm.value = "";
	else if (elm.value == "") elm.value = elm.base;
}


function invia(){
		var frm = document.forms["toplogin"];
		frm.submit();
		frm.password.value = '';
		frm.user.value = '';
	}
function inviaEC(){
		if (document.getElementById("numexpertcard").value!=''){
			var frm = document.forms["expertcard"];
			frm.submit();
		}
	}
function autoSubmit(e)
{
	var o  = (e != null ? e.target : event.srcElement);
	var ev = (e != null ? e : event);
	if (ev.keyCode == 13) {
		if (document.getElementById("numexpertcard").value!=''){
			inviaEC();
		}
		else{
			if (document.getElementById("user").value!=''){
				invia();
			}
		}
		return;
	}
}


function ZoomForm1(str){
   	searchWin = window.open(str,'eucip','left=0, top=0, scrollbars=no, width=550, height=450, resizable=no, status=no, location=no, toolbar=no');
   	// searchWin.refer = self;
}


function ZoomForm2(str){
   	searchWin = window.open(str,'eucip','left=0, top=0, scrollbars=no, width=550, height=500, resizable=no, status=no, location=no, toolbar=no');
   	// searchWin.refer = self;
}

function ZoomForm3(str){
   	searchWin = window.open(str,'funzioni','left=0, top=0, scrollbars=no, width=550, height=400, resizable=no, status=no, location=no, toolbar=no');
   	// searchWin.refer = self;
}



function WebDate() {
   var now = new Date();
   var year= now.getYear();if (year < 1000) year += 1900;
   nameDay = new Array('Domenica','Lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato');
   nameMth = new Array('Gennaio','Febbraio','Marzo','Aprile','Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre','Dicembre');
   document.write('<font size="1"><div align="left"> <p>&nbsp; '+nameDay[now.getDay()]+ ' ' + now.getDate() + " " + nameMth[now.getMonth()] + " " + year+'</p> </div></font>');
   
}

function footer(path) {
document.write('<table class="tabVuotaPiccola">');
document.write('<tr> </tr>');
document.write('<td> </td>');
document.write('</table>');
document.write('<table class="TabFooter" width="865" height="60" valign="top" align="center">');
document.write('<tr>');
document.write('<td> <font size="1"><font color="#336699"><b>My</b></font><font color="#FF0033"><b>T</b></font><b><font color="#666666">EST</font></b> &egrave; distribuito in esclusiva da <b>SKILL ON LINE</b> - P. IVA 07962400011<br>');
document.write(' Sede operativa: C.so R. Margherita, 497, 10151 TORINO - Tel: 0039 011 4530663 - Fax: 0039 011 7382404<br>');
document.write('<a href="http://www.skillonline.org">www.skillonline.org -</a> <a href="mailto:info@skillonline.org">info@skillonline.org</a> ');
document.write('/ <a href="http://www.aicaskill.it">www.aicaskill.it</a> - <a href="mailto:info@aicaskill.it">info@aicaskill.it</a></font></td>');
document.write('</tr>');
document.write('</table>');
}


function header(path) {
document.write('<table class="TabInizio" align="center" width="865" bgcolor="#CCCCCC">');
document.write('  <tr>');
document.write('    <td colspan="2" align="center"><img src="immagini/header1.jpg" width="100%" height="95" usemap="#Map"');  
document.write(' border="0"></td>');  
document.write(' </tr>');  
document.write(' <tr> '); 
document.write('    <td colspan="2" valign="bottom"> ');
document.write('      <table class="TabInizio" cellspacing="0" cellpadding="0" bgcolor="#CCCCCC" width="100%" valign="center">');
document.write('        <tr bgcolor="#CCCCCC" valign="center"> ');
document.write('          <td width="18%" bgcolor="#CCCCCC" valign="center"> ');
document.write('            <div class="cse-branding-left" style="background-color:#CCCCCC;color:#000000">');
document.write('<div class="cse-branding-form-middle" style="background-color:#CCCCCC;color:#000000">');
            
document.write('<script type="text/javascript">WebDate()');
document.write('  </script>');
document.write('            </div>  </div>');

document.write('            </td>');
document.write('          <td width="82%" bgcolor="#CCCCCC" align="right"> ');
document.write('<br>');
document.write('       <div class="cse-branding-left" style="background-color:#CCCCCC;color:#000000">');
document.write('	   <div class="cse-branding-form-middle" style="background-color:#CCCCCC;color:#000000">');
document.write('		<form action="http://www.google.it/cse" id="cse-search-box" target="_blank">');
document.write('                  <div> ');
document.write('                    <style type="TabInizio/css"> @import url(http://www.google.com/cse/api/branding.css); </style>');
document.write('<input type="hidden" name="cx" value="partner-pub-8666908133727353:gs7jkl8wzyj" />');
document.write('  <input type="hidden" name="ie" value="ISO-8859-1" />');
document.write(' <font size="1">Ricerca personalizzata</font> ');
document.write(' <input type="text" name="q" size="24" />&nbsp;<input type="submit" name="sa" value="Cerca" />&nbsp;');
document.write('                  </div>');
document.write('                </form>');
document.write(' </div>');
document.write('</div>');

document.write('</td>');
document.write('</tr>');

document.write('      </table>');
document.write('    </td>');
document.write('  </tr>  ');
document.write(' 	 </table>');
}





function TestInt(num) {
	var t =parseInt(num);
	if (isNaN(t)) {
		return false;
	} else {
		return true;
	}
}
	

function padZeros(num, totalLen) {
	var numStr = num.toString() // Initialize return value
	// as string
	var numZeros = totalLen - numStr.length;// Calculate no. of zeros
	if (numZeros > 0) {
		for(var i =1;i <=numZeros; i++) {
			numStr = "0" + numStr;
		}
	}

	return numStr;
}

	
function CheckDate(cmp) {
	if (cmp==null) return true;
	if (isEmpty(cmp.value)) return true;
	var buff = cmp.value.split('/');
	if (buff.length==3) {
		if ( TestInt (buff[0]) && TestInt (buff[1]) && TestInt (buff[2])  ) {
			if (( parseInt(buff[1])<=12 ) &&  ( parseInt(buff[1])<=31 ) ) {
				switch (parseInt(buff[1])) {
					case 2:
						if ( parseInt(buff[0])>daysInFebruary (buff[2]) ) break;
					case 4:
					case 6:
					case 9:
					case 11:
						if ( parseInt(buff[0])>30 ) break;
					default:
						if (buff[2]<100) buff[2]= eval(buff[2]+ '+' + 2000);
						cmp.value=padZeros(buff[0],2) + '/' + padZeros(buff[1],2) + '/' + padZeros(buff[2],4);
						if (cmp.onchange!=null) cmp.onchange.call (cmp);
						return true;
				}
			}
		}
	}

//alert('Date not valid!!! eg. dd/mm/yyyy');
	cmp.value='';
	return false;
}

