function print_page(){
var html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
   html += '<html>';
   html += '<head>';
   html += '<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">';
   html += '<link rel="stylesheet" href="templates/style/style.css" type="text/css">';
   html += '<title>'+document.title+'</title>';
   html += '</head>';
   html += '<body>';
		   
   html += '<div style="width:600px;background-color:#FFFFFF;">';
   html += '  <div align="right" style="text-align:right;height:104px;background-image:url(templates/images/bg_title_email.png);background-repeat:no-repeat;padding:86px 4px 0 0;"><font size="2" color="#00428C" face="Verdana, Arial, Helvetica, sans-serif"><b>'+document.getElementById('subtitle').innerHTML+'</b></font></div>';
   html += '  <div style="height:340px;border-top:5px solid #00428C;border-bottom:2px solid #00428C;padding:10px 0 10px 0;"><font size="2" color="#00428C" face="Verdana, Arial, Helvetica, sans-serif">'+document.getElementById('cont').innerHTML+'</font></div>';
   html += '  <div align="center" style="text-align:center;padding-top:4px;"><font size="1" color="#668EBA" face="Verdana, Arial, Helvetica, sans-serif">Corso Sicilia, 56 - 95131 Catania - Tel. 095 312142 - Fax 095 316810<br><font color="#668EBA">info@odccatania.it</font> - <font color="#668EBA">www.odccatania.it</font><br>P.I. 03868740873 - C.F. 93027300875</font></div>';
   html += '</div>';

   html += '</body>';
   html += '</html>';

   var ident_prt = window.open("","print","height=1,width=1,top="+(screen.height)+",left="+(screen.width));
   ident_prt.document.open();
   ident_prt.document.write(html);
   ident_prt.print();
   ident_prt.document.close();
   ident_prt.close(); 
}

// get cookie
function getCookie(NameOfCookie){
	if (document.cookie.length > 0) { 
		begin = document.cookie.indexOf(NameOfCookie+"="); 
	if (begin != -1){ 
		begin += NameOfCookie.length+1; 
		end = document.cookie.indexOf(";", begin);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(begin, end)); } 
	}
	return null; 
}

// set cookie
function setCookie(NameOfCookie, value, expirehours){
	var ExpDate = new Date ();
	ExpDate.setTime(ExpDate.getTime() + (expirehours * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + ((expirehours == null) ? ";" : "; expires=" + ExpDate.toGMTString());
}

// preload images
// simplePreload( '01.gif', '02.gif' );
function simplePreload(){
  	 var args = simplePreload.arguments;
  	 document.imageArray = new Array(args.length);
  	 for(var i=0; i<args.length; i++)
  	 {
    	 document.imageArray[i] = new Image;
    	 document.imageArray[i].src = args[i];
  	 }
}
	 
// switch images
// switchImage( 'nomeImg', '01.gif' );
function switchImage(imgName, imgSrc){
	if (document.images){
		if (imgSrc != ''){
		 document.images[imgName].src = imgSrc;
		}
	}
}

// openWindow('urlPage', 'namePopup', 'width', 'height', 'yes/no', 'yes/no');
function openWindow(mypage,myname,w,h,resizable,scrollbars){ 
	w = (Number(w) + 1);
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0; 
	settings = 'scrollbars='+scrollbars+',resizable='+resizable+',status=no,height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition;
	win = window.open(mypage,myname,settings);
}

// correct date
function areCharsInList(s,list) {
	var i,c;
	for (i=0;i<s.length; i++) {
		c = s.charAt(i);
	if (list.indexOf(c) == -1)
		return false;
	}
return true;
}

function isDate(str){
	if(str.length!=10){
		return false;
	}
	if(str.charAt(2)!='/' || str.charAt(5)!='/'){
		return false;
	}
	if( !areCharsInList(str.substring(0,2)+str.substring(3,5)+str.substring(6,10), '1234567890') ){
		return false;
	}
	if(str.substring(3,5)>12){
		return false;
	}
	if(str.substring(0,2)>31){
		return false;
	}
return true;
}

function returnSelection(radioButton) {
	var selection=null;
	for(var i=0; i<radioButton.length; i++) {
		 if(radioButton[i].checked) {
		   selection=radioButton[i].value;
		   return selection;
		 }
	}
	return selection; 
} 

function stampDate(){
	var months = new Array(12);
	months[0]  = "gennaio";
	months[1]  = "febbraio";
	months[2]  = "marzo";
	months[3]  = "aprile";
	months[4]  = "maggio";
	months[5]  = "giugno";
	months[6]  = "luglio";
	months[7]  = "agosto";
	months[8]  = "settembre";
	months[9]  = "ottobre";
	months[10] = "novembre";
	months[11] = "dicembre";
	
	var days = new Array(6);
	days[0]  = "Domenica";
	days[1]  = "Lunedì";
	days[2]  = "Martedì";
	days[3]  = "Mercoledì";
	days[4]  = "Giovedì";
	days[5]  = "Venerdì";
	days[6]  = "Sabato";
	
	var timestamp = new Date();
	
	var lday      = days[timestamp.getDay()];
	var day       = timestamp.getDate();
	var lmonth    = months[timestamp.getMonth()];
	var year      = timestamp.getYear();
	
	if ( navigator.appName == "Netscape" )
		 year=1900 + year;
	
	document.write(lday+", "+day+" "+lmonth+" "+year);
}

function stampClock(){
	var clock_time = new Date();
	var clock_hours = clock_time.getHours();
	var clock_minutes = clock_time.getMinutes();
	var clock_seconds = clock_time.getSeconds();
	
	if (clock_hours < 10){
		clock_hours = "0" + clock_hours;
	}
	if (clock_minutes < 10){
		clock_minutes = "0" + clock_minutes;
	}
	if (clock_seconds < 10){
		clock_seconds = "0" + clock_seconds;
	}
	
	var clock_div = document.getElementById('clock');
	clock_div.innerHTML = clock_hours + ":" + clock_minutes + ":" + clock_seconds;
	
	setTimeout("stampClock()", 1000);
}

function sendMail(){
	location.href="mailto:info@odccatania.it";	
}

//Attilio: super funzione di validazione.... UTILISSIMA 
	function validate_form(frm, obj){
		// INPUT:
		// frm : oggetto form
		// frm : oggetto contenente le informazioni sui controlli da validare
		var expr_str = /\w+/;
		var expr_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		var expr_data = /^(\d{1,2})\/(\d{1,2})\/(\d{2,5})$/;
		var expr_zero = /0/;
		var expr_numero = /[0-9]/;
			//~ for (i=0; i< frm.elements.length; i++){
				//~ alert(frm.elements[i].name + "'"+ frm.elements[i].value +"'" );
			//~ }
		for (i=0; i< frm.elements.length; i++){
			frmobj = frm.elements[i];
			name = frmobj.name;
			valore = frmobj.value;
			//~ alert(name + ", '" + valore + "'");

			if (name in obj ){
				//~ alert(name + ", '" + valore + "'");
				valido = 1;
				if (valore =='') {
					//campo vuoto
					alert("Attenzione!\nIl campo " + obj[name].name + " e\' obligatorio per il completamento del salvataggio");
					valido=0;
				}else if( obj[name].valid=='dd/mm/yyyy'){
					if (!expr_data.test(valore)){
						alert("Attenzione!\nIl campo " + obj[name].name +" e\' stato inserito in maniera non corretta.\nInserire il valore nel formato corretto (gg/mm/aaaa).");
						valido=0;
					}
				}else if( obj[name].valid=='email'){
					if (!expr_email.test(valore)){
						alert("Attenzione!\nIl campo " + obj[name].name +" e\' stato inserito in maniera non corretta.\nInserire il valore nel formato corretto (aaaaa@bbbbb.ccc).");
						valido=0;
					}
				}else if( obj[name].valid=='numero'){
					if (!expr_numero.test(valore)){
						alert("Attenzione!\nIl campo " + obj[name].name +" e\' stato inserito in maniera non corretta.\nIl campo richiede che sia inserito un numero.");
						valido=0;
					}
				}else if( obj[name].valid==valore){
					// ultima condizione: parametrica nel campo valid è specificato il campo errore
					if (valore==0){
						alert("Attenzione!\nIl campo " + obj[name].name +" e\' obligatorio per il completamento del salvataggio");
						valido=0;
					}
				}
				
				if (valido==0){
					frmobj.focus();
					//~ i = frm.elements.length;
					return false;
				}
			}
		}
		return true;
	}

