function show_calendar2(str_target, str_datetime, str_path) {
	var arr_months = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno",
		"Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"];
	var week_days = ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt2(str_datetime));
	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"<STYLE type=\"text/css\">\n"+
		".BODYtest {font-size:10pt; font-family:verdana} \n"+
		"</STYLE>\n"+
		"	<title>Calendario</title>\n"+
		"</head>\n"+
		"<BODY bgcolor=\"#CECFCE\" class=\"BODYtest\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#4682B4\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar2('"+
		str_target+"', '"+ dt2dtstr2(dt_prev_month)+"', '"+str_path+"');\">"+
		"<img src=\""+str_path+"prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"previous month\"></a></td>\n"+
		"	<td bgcolor=\"#4682B4\" colspan=\"5\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
		"	<td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar2('"
		+str_target+"', '"+dt2dtstr2(dt_next_month)+"', '"+str_path+"');\">"+
		"<img src=\""+str_path+"next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"next month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#87CEFA\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#DBEAF5\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr2(dt_current_day)+"'; window.close();\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr2(dt_current_day)+"'; window.close();\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	str_buffer +=
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</BODY>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=200,height=220,status=no,resizable=no,top=200,left=200");
	vWinCal.opener = self;
	vWinCal.focus();
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt2 (str_datetime) {
	var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
	if (!re_date.exec(str_datetime))
//		return alert("Data non valida, usa il formato gg/mm/aaaa: "+ str_datetime);
		return (new Date());
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));
}
function dt2dtstr2 (dt_datetime) {
	__appo_date = dt_datetime.getDate();
	__appo_date = (__appo_date >= 10 ? __appo_date : "0" + __appo_date);
	__appo_month = dt_datetime.getMonth()+1;
	__appo_month = (__appo_month >= 10 ? __appo_month : "0" + __appo_month);
	return (new String (
			__appo_date +"/"+(__appo_month)+"/"+dt_datetime.getFullYear()));
}

function small_window(myurl) {
var newWindow;
var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=400,height=350,left=500,top=275';
newWindow = window.open(myurl, "Hupac", props);
}
// Adds the list of selected items selected in the child
// window to its list. It is called by child window to do so.  
function addToParentList(sourceList) {
destinationList = window.document.forms[0].testpub;
destinationHide = window.document.forms[0].valtest;
destinationHide.value = "";
for(var count = destinationList.options.length - 1; count >= 0; count--) {
destinationList.options[count] = null;
}
for(var i = 0; i < sourceList.options.length; i++) {
if (sourceList.options[i] != null)
destinationList.options[i] = new Option(sourceList.options[i].text, sourceList.options[i].value );
destinationList.options[i].text = sourceList.options[i].text;
if (i == 0) destinationHide.value = sourceList.options[i].text; else destinationHide.value = destinationHide.value+", "+sourceList.options[i].text;
   }
}
// Marks all the items as selected for the submit button.  
function selectList(sourceList) {
sourceList = window.document.forms[0].testpub;
for(var i = 0; i < sourceList.options.length; i++) {
if (sourceList.options[i] != null)
sourceList.options[i].selected = true;
}
return true;
}

// Deletes the selected items of supplied list.
function deleteSelectedItemsFromList(sourceList) {
var maxCnt = sourceList.options.length;
destinationHide = window.document.forms[0].valtest;
destinationHide.value = "";
for(var i = maxCnt - 1; i >= 0; i--) {
if ((sourceList.options[i] != null) && (sourceList.options[i].selected == true)) {
sourceList.options[i] = null;
      }
   }
   for(var i = 0; i < sourceList.options.length; i++) {
if (sourceList.options[i] != null)
if (i == 0) destinationHide.value = sourceList.options[i].text; else destinationHide.value = destinationHide.value+", "+sourceList.options[i].text;
   }
}

var expDays = 1;
var largeExpDate = new Date ();
largeExpDate.setTime(largeExpDate.getTime() + (expDays * 24 * 3600 * 1000));
//pathname = location.pathname;
//myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/';
myDomain = "t6shoplight"

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}

//Funzione che crea un cookie
function SetCookie (name, value) {
	document.cookie = name + "=" + escape (value) + "; expires=Sun, 12-12-2050 23:59:59 GMT; path=";
	
	return true;
}

function stampa(){
    if (navigator.appName == "Netscape"){
         window.print() ;  
    }else{
        var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        WebBrowser1.ExecWB(6, 2);
        WebBrowser1.outerHTML = "";  
    }
}

function WinOpen(filename){
	window.open(filename,'Bando','status=no,resizable=no,scrollbars=no,width=430,height=150');
}

function CheckForm(){
var tf;
tf = window.confirm("Attenzione! Continuando verra' generato il codice ICL e non sara' piu' possibile effettuare modifiche.\nProcedere?")
  if (tf == true) window.document.forms[0].submit()
}

function CheckFormModifica(){
var tf;
tf = window.confirm("Attenzione! Continuando non sara' piu' possibile effettuare modifiche.\nProcedere?")
  if (tf == true) window.document.forms[0].submit()
}

function controlla(nomeform)
  {
  var PTerminal = nomeform.SearchPTerminal.value;
  var ATerminal = nomeform.SearchATerminal.value;
  var PNazione = nomeform.PNazione.options[nomeform.PNazione.selectedIndex].value;
  var ANazione = nomeform.ANazione.options[nomeform.ANazione.selectedIndex].value;

  if(PTerminal == "" & PNazione == "") 
    alert('Please select the departure terminal');
  else
  {
  if(ATerminal == "" & ANazione == "") 
    alert('Please select the destination terminal');
  else
    nomeform.submit();
}
}

function controllaimporto(nomeform)
{
srcListImp = nomeform.importo;
decimali  = nomeform.importodec;
destHide = nomeform.valtipimm;
importoHide = nomeform.valimporto;
if(isNaN(srcListImp.value) | isNaN(decimali.value) | srcListImp.value.indexOf(".")!=-1 | decimali.value.indexOf(".")!=-1) {
alert('Attenzione, indicare un valore numerico per l\'importo');
if(isNaN(decimali.value) | decimali.value.indexOf(".")!=-1) {
decimali.value='00';
decimali.focus();
}
if(isNaN(srcListImp.value) | srcListImp.value.indexOf(".")!=-1) {
srcListImp.value='';
srcListImp.focus();
}
}
else{
controlla(nomeform);}
}

function terminal_window(myurl) {
var newWindow;
var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=400,height=200,left=500,top=275';
newWindow = window.open(myurl, "Hupac", props);
}

function prices_window(myurl) {
var newWindow;
var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=400,height=200,left=500,top=275';
newWindow = window.open(myurl, "Hupac", props);
}

function contact_window(myurl) {
var newWindow;
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=500,height=400,left=400,top=175';
newWindow = window.open(myurl, "Hupac", props);
}

function note_window(myurl) {
var newWindow;
var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=400,height=250,left=500,top=275';
newWindow = window.open(myurl, "Hupac", props);
}

function search_terminal_window(myurl) {
var newWindow;
var props = 'scrollBars=yes,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=400,height=350,left=500,top=275';
newWindow = window.open(myurl, "Hupac", props);
}

function controlla_country(nomeform)
  {
  var PCountry = nomeform.PNazione.options[nomeform.PNazione.selectedIndex].value;
  var ACountry = nomeform.ANazione.options[nomeform.ANazione.selectedIndex].value;

  if(PCountry == "")
    {
    alert('Please select the departure country');
    return false;
    }
  else
  {
  if(ACountry == "") 
    {
    alert('Please select the destination country');
    return false;
    }
  else
    return true;
}
}


