// variabile contenente il nome del Cookie di riferimento....
search = "rcsLogin=";
// ====================================================================================
function verificaPWD () {
	if (document.invioPasswordForm.email.value == "") {
		alert("Inserire l'indirizzo email");
		return false;
	}
	return true;
}
//=====================================================
function submitPWD() {
	if (verificaPWD())
		document.invioPasswordForm.submit();
}
// =====================================================
function goSubmit(action, url) {
	document.formDati.action = url;
	document.formDati.actionSubmit.value = action;
	document.formDati.submit();
}
// ============= POPUP ======================
function popupPassword(url) {
	window.open(url,"","toolbar=no,width=380,height=240,top=50,left=50,directories=no,status=no,statusbar=no,resizable=1,menubar=no,scrollbars=no");
}
// ============= POPUP ======================
function Popup2(url) {
	window.open(url,"","toolbar=no,width=380,height=240,top=50,left=50,directories=no,status=no,statusbar=no,resizable=1,menubar=no,scrollbars=no");
}
// ============= MODIFICA ====================
function modifica() {
	document.modifica.callerPage.value = document.location.href;
	document.modifica.submit();
}
// ============= VERIFICA ====================
/*function verifica() {
	//document.login.url.value = "" + document.location.href.substring((document.location.href.indexOf("/auth/")));
	document.login.url.value = "" + document.location.href;
	if (document.login.username.value == "" || document.login.password.value == "") {
		alert("Impostare Username e Password");
		return false;
	}
	return true;
}*/
// ============= LOGOUT ======================
function logout() {
	document.logout.submit();
}
// ============= VERIFICA =======================
function verifica() {
	document.login.url.value = document.location.href;
	if (document.login.username.value == "" || document.login.password.value == "") {
		alert("Impostare Username e Password");
		return false;
	}
	return true;
}
// =============================================
function logon(urlKo) {
	document.login.username.value = document.formDati.tUsername.value;
	document.login.password.value = document.formDati.tPassword.value;
	document.login.urlKo.value = urlKo
	if (verifica()) {
		document.login.submit();
	}
}
// ============= LOGIN =======================
function iscrizione() {
	document.iscrizione.url.value = document.location.href;
	document.iscrizione.submit();
}
// ============= BOXLOGIN ====================
function getLoginValue() {
	var value = "notFound";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) 
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			value = document.cookie.substring(offset, end);
			if (value.indexOf("|") > -1) 
				value = value.substring(0, value.indexOf("|"));
		}
	}
	return value;
}
// ============= ISCOOKIEVALID ====================
function getIsLoginValid() {
	var value = getLoginValue();
	if (value == "notValid")
		return false;
	else
		return true;
}

// ============= ISCOOKIEVALID ====================
function getIsCookieValid() {
	var value = "" + getLoginValue();
//alert("value: " + value);
	if (value == "notFound" || value == "undefined" || value == "notValid") {
//alert("false");
		return false;
	} else {
//alert("true");
		return true;
	}
}
// ============== VERIFICA ======================
function verifica() {
	if (document.login.username.value == "" || document.login.password.value == "") {
		alert("Impostare Username e Password");
		return false;
	}
	return true;
}
// ================= FORM ======================
function formLogin (url, operation) {
	document.write('<form name="login" method="post" action="/registrati/loginServlet" onsubmit="return verifica();">');
	document.write('<input type="hidden" name="debugLevel" value="0">');
	document.write('<input type="hidden" name="applicationName" value="COR">');
	document.write('<input type="hidden" name="operation" value="' + operation + '">');
	document.write('<input type="hidden" name="registration" value="/registrati/registration.jsp">');
	document.write('<input type="hidden" name="url" value="' + url + '">');
	document.write('<input type="hidden" name="urlKo" value="">');
	document.write('<input type="hidden" name="username">');
	document.write('<input type="hidden" name="password">');
	document.write('</form>');
}
function formLogout () {
	document.write('<form name="logout" method="post" action="/registrati/loginServlet" onsubmit="return verifica();">');
	document.write('<input type="hidden" name="debugLevel" value="0">');
	document.write('<input type="hidden" name="applicationName" value="COR">');
	document.write('<input type="hidden" name="operation" value="logout">');
	document.write('<input type="hidden" name="registration" value="/index.shtml">');
	document.write('<input type="hidden" name="url" value="/index.shtml">');
	document.write('<input type="hidden" name="urlKo" value="/index.shtml">');
	document.write('<input type="hidden" name="username">');
	document.write('<input type="hidden" name="password">');
	document.write('</form>');
}
function formModifica () {
	document.write('<form name="modifica" method="post" action="/registrati/userServlet">');
	document.write('<input type="hidden" name="applicationName" value="COR">');
	document.write('<input type="hidden" name="operation" value="verify">');
	document.write('<input type="hidden" name="callerPage" value="">');
	document.write('<input type="hidden" name="urlOk" value="/registrati/password_verifica.jsp">');
	document.write('<input type="hidden" name="urlKo" value="/registrati/errorPage.jsp">');
	document.write('</form>');
}

function galleria(path,n_galleria){
pathcompleta="/speciali/"+path+"/galleria/sopra.html?"+n_galleria
path_sin="/speciali/popup/foto.html"
path_des="/speciali/popup/vuoto.html"
newWin=open("","","menubar=no,location=no,toolbar=yes,status=no,scrollbars=yes,resizable=no,width=680,height=480");
newWin.document.write('<html><head><title>Galleria di immagini</title>');
newWin.document.write('</head>');
newWin.document.write('<frameset rows="45,*" border="0" frameborder="NO" framespacing="0">');
newWin.document.write('<frame src="'+pathcompleta+'" name="sopra" scrolling="NO" marginheight="5" marginwidth="5">');
newWin.document.write('<frameset cols="120,*" border="0" frameborder="NO" framespacing="0">');
newWin.document.write('<frame src="'+path_sin+'" name="sin">');
newWin.document.write('<frame src="'+path_des+'" name="des">');
newWin.document.write('</frameset></frameset>');
newWin.document.write('<noframes><body>Per visualizzare questa pagina &egrave; necessario un browser che supporti i frames</body></noframes>');
newWin.document.write('</html>');
//newWin.frames["sopra"].location.href=pathcompleta
}
