function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function checkOS() {
  if(navigator.userAgent.indexOf('Linux') != -1)
    { var OpSys = "Linux"; }
  else if((navigator.userAgent.indexOf('Win') != -1) &&
  (navigator.userAgent.indexOf('95') != -1))
    { var OpSys = "Windows95"; }
  else if(navigator.userAgent.indexOf('Win') != -1)
    { var OpSys = "Windows3.1 or NT"; }
  else if(navigator.userAgent.indexOf('Mac') != -1)
    { var OpSys = "Macintosh"; }
  else { var OpSys = "other"; }
  return OpSys;
}

var OpSys = checkOS();

beginRollover = false;// This handles a bug in Nav4.0x that executes the code too quickly.

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                      (agt.indexOf("; nav") != -1)) );
var is_nav5 = (is_nav && (is_major == 5));
var is_nav5up = (is_nav && (is_major >= 5));

var is_ie   = (agt.indexOf("msie") != -1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) );
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
var isIE4, isIE4PC, isNav4PC, isNav4, isNav3;

if (is_ie4 || is_ie4up || is_nav5 || is_nav5up) {
	isIE4 = true;
	if (OpSys != "Macintosh") {
		isIE4PC = true;
	}
} else if (is_nav4) {
	isNav4 = true;
	if (OpSys != "Macintosh") {
		isNav4PC = true;
	}
} else if  (is_nav) {
	isNav3 = true;
}

self.name = "parentWin";
function openDec(url, name, w, h) {
        popupWin = window.open(url, name, 'resizable=0,scrollbars=0,width=' + w + ',height=' + h + '');
    // focus window (only for Navigator >= 3.0)
    if ( (navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) == "3") )
    popupWin.focus();
}

function StringTimeCorto(BrowserTime) {


var MonthofYear = new Array(12)
MonthofYear[0] = "gennaio"
MonthofYear[1] = "febbraio"
MonthofYear[2] = "marzo"
MonthofYear[3] = "aprile"
MonthofYear[4] = "maggio"
MonthofYear[5] = "giugno"
MonthofYear[6] = "luglio"
MonthofYear[7] = "agosto"
MonthofYear[8] = "settembre"
MonthofYear[9] = "ottobre"
MonthofYear[10] = "novembre"
MonthofYear[11] = "dicembre"

var theYear = BrowserTime.getYear()
if (theYear < 1900) { theYear = theYear + 1900 }

 return  " " + BrowserTime.getDate() + "/"   + BrowserTime.getMonth() + "/" + theYear
}

function StringTime(BrowserTime) {


var MonthofYear = new Array(12)
MonthofYear[0] = "gennaio"
MonthofYear[1] = "febbraio"
MonthofYear[2] = "marzo"
MonthofYear[3] = "aprile"
MonthofYear[4] = "maggio"
MonthofYear[5] = "giugno"
MonthofYear[6] = "luglio"
MonthofYear[7] = "agosto"
MonthofYear[8] = "settembre"
MonthofYear[9] = "ottobre"
MonthofYear[10] = "novembre"
MonthofYear[11] = "dicembre"

var theYear = BrowserTime.getYear()
if (theYear < 1900) { theYear = theYear + 1900 }


 return " " + BrowserTime.getDate() + " " + MonthofYear[BrowserTime.getMonth()] + " " + theYear
}

function Greeting(BrowserTime) {
     thisTime = BrowserTime.getHours()
     return true
}

function orainternet(BrowserTime) {
var thisT;
var thisM;
var thisS;
var iT;
     thisT = BrowserTime.getHours();
	 thisM = BrowserTime.getMinutes();
	 thisS = BrowserTime.getSeconds();
	 iT = (thisT*3600 + thisM*60 +thisS)*10/864;
     //return '<a href="javascript:;" onClick="popUpInternetTime()">' + iT + '</a>';
     return iT;
}

function addbookmark(pagina,titolo){
if (isIE4)
		window.external.AddFavorite(pagina,titolo);
else
	if (isNav4)
		alert ('ctrl-D per aggiungere ai preferiti');
	else
		alert ('non è possibile aggiungere bookmark');
}
function showImage(filename, imageName)
			{
		    	document.images[imageName].src = filename;
		    }


function stampa() {
            self.print();
			}
function principale(modulo) {
if (isIE4){
modulo.style.behavior='url(#default#homepage)';
modulo.setHomePage("http://mytech.mondadori.com/");
}


}

function popUpCruciverba(pPage) {
  var winOpts = 'resizable=no,scrollbars=no,width=560,height=560'; popUpWinCruciverba = window.open(pPage,'popCruciverba',winOpts);
}

function popUpMiss(pPage) {
  var winOpts = 'resizable=no,scrollbars=no,width=730,height=560'; popUpWinMiss = window.open(pPage,'popMiss',winOpts);
}

function popUpVota(pPage) {
  var winOpts = 'resizable=no,scrollbars=yes,width=486,height=570'; popUpWinMiss = window.open(pPage,'popVota',winOpts);
}

function popUpTesto(pPage) {
  var winOpts = 'width=468,height=370,scrollbars=no,menubar=no'; popUpWinTesto = window.open(pPage,'popTesto',winOpts);
}

function doLoadSec(s, max) {
    // the timeout value should be the same as in the "refresh" meta-tag
    // max is the nuber of pages
    var tempo;
    tempo = 1000 * s;
    setTimeout("refresh(" + max + ")", tempo);
}

function refresh(max) {
	var count = 0;
	var base = "";
	var temp = window.location.href;
	temp = temp.substring(0 , temp.length - 4);
	var u = temp.lastIndexOf('_');
	if (u == -1) {
		//sono alla prima pagina
		base = temp;
		count = 2;
	}
	else {
		//sono in pagina successiva
		base = temp.substring(0, u);
		count = eval(temp.substring(u+1,temp.length)) + 1;
	}
	if (max >= count) {
		temp = base + "_" + count + ".jsp";
	}
	else {
		//ho superato il contatore
		temp = base + ".jsp";
	}
    window.location.href = temp;
}

function openWin(url, name, scrollbar, w, h) {

       popupWin = window.open(url, name, 'resizable=1,scrollbars=' + scrollbar + ',width=' + w + ',height=' + h + '');
       // focus window (only for Navigator >= 3.0)

    if ( (navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) == "3") )

    popupWin.focus();

}


// ----------------------- UPLOAD FILE ----------------------------------------- //
function verificaCompleto() {
	var inString = "";
	var completo = 1;
	var estensioneCorretta = 1;

	inString = "" + document.invia_dati.name.value;
	if (inString.length < 1) {
		completo = 0;
	}
	inString = "" + document.invia_dati.surname.value;
	if (inString.length < 1) {
		completo = 0;
	}
	inString = "" + document.invia_dati.subject.value;
	if (inString.length < 1) {
		completo = 0;
	}
	inString = "" + document.invia_dati.email.value;
	if (!validateEmail(inString)) {
		completo = 0;
		document.invia_dati.email.select();
	}

	if(completo==0){
		alert("Completa tutti i campi, per favore");
		return false;
	} else {
		return true;
   	}
}


// Javascript per la verifica dell'indirizzo email //

function validateEmail(inString) {
	var alfaNum;
	var startPos;
	var ch;
	var ch;
	var up;
	var pp;
	var dom;

	ch = inString.lastIndexOf('@');
	dom = inString.substring(ch+1);
	pp = dom.indexOf('.');
	up = dom.lastIndexOf('.');

	//!*|,;:"<>()[]{}@&$#%
	if (inString.length < 6) { //indirizzo troppo corto
		return false;
	}
	if (ch < 1) { //@ troppo indierto
		return false;
	}
	if (pp < 1) {  //@ troppo vicina al primo .
		return false;
	}
	if (up > dom.length - 3) { //ultimo . troppo avanti
		return false;
	}
	if (up < dom.length - 7) {  //ultimo . troppo indietro
		return false;
	}

	startPos = 0;
	alfaNum = "!*|,;:<>()[]{}@&$#%?"; //!*|,;:<>()[]{}@&$#% caratteri vietati nel dominio
	while (startPos < dom.length) {
		ch = dom.charAt(startPos);
		if (alfaNum.indexOf(ch) >= 0) {
			return false;
		}
		startPos++;
	}

	return true;
}

// chiusura finestra //

function chiudi(){
    window.close() ;
}

