/**
 * Verifica se l'argomento e' una mail valida
 */
function checkMail(caller)
{
	var x = caller;
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$$/;
    if (filter.test(x))
       return true;
    else
    	return false;
}

/**
 * Lascia inserire in un campo solamente valori numerici
 */
function ctrl_num(e)
{
	if (window.event)
    	var code = window.event.keyCode;    
	else if (e)
   		var code =  e.which; 
	else
   		var code = 0;     
   	if ((code<48 || code >57) &&  (code!=8 &&  code!=0))	
		return false;
	return true;
}

//  

function vai(arg) {
//alert(arg);
top.location = arg;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function scegli_immagine(arg) {
//

document.form_registrazione.immagine.value = arg;

}

function invia_dati()  {
document.form_registrazione.submit();
}
//
function invia_login() {
//alert("send login");

var usrid = document.form_login.user.value;
var password = document.form_login.pw.value;

if(usrid == "Pincopallo" && password == "123456") {
top.location.href = "homeOK.htm"
//
} else {
alert("Utente non registrato. Compila il form se vuoi registrarti");
//
      jQuery("#formregistrazione").fadeIn(1000, function () {
        jQuery("formregistrazione").fadeIn(20);
      });
//
}

}
//
function uscita() {
top.location.href = "home1.htm"
}
//
function set_invisibile(arg) {
//alert("set_invisibile" + arg);
document.getElementById('sottomenu'+arg).style.visibility = 'hidden';
}
//
function set_visibile(arg) {
//alert("set_visibile" + arg);
document.getElementById('sottomenu'+arg).style.visibility = 'visible';
}
//
function sendlogin() {
//document.form_login.hiddenlocation.value= top.location.href;
document.form_login.hiddenlocation.value= document.location.href;
document.form_login.submit();
}
//
function over1(arg,id_contenuto) {
//
	for(n=1; n<=arg; n++) {
		//document.getElementById('star'+n).src = 'immagini/star_on.gif';
		document.getElementById('star'+id_contenuto+"_"+n).src = 'immagini/star_on.gif';
	}
}
//
function out1(arg,id_contenuto) {
//
	for(n=1; n<=arg; n++) {
		//document.getElementById('star'+n).src = 'immagini/star.gif';
		document.getElementById('star'+id_contenuto+"_"+n).src = 'immagini/star.gif';
	}
}
//
function over2(arg) {
//
for(n=1; n<=arg; n++) {
document.getElementById('star2_'+n).src = 'immagini/star_on.gif';
	}
}
//
function out2(arg) {
//
for(n=1; n<=arg; n++) {
document.getElementById('star2_'+n).src = 'immagini/star.gif';
	}
}
//
    jQuery(document).ready(function(){ 
        jQuery(document).pngFix(); 
        
    //
    //alert("PNG fix attivo");
    }); 
//
function apri_upload() {
//
     //alert("apri upload");
      jQuery("#upload").fadeIn(1000, function () {
        jQuery("upload").fadeIn(20);
      });
//
}
//
function apri_login() {
/** 
* funzione Apri pannello "Login"
*/
      jQuery("#login").fadeIn(1000, function () {
        jQuery("login").fadeIn(20);
      });
}

function apri_registrazione() {
/** 
* funzione Apri pannello "Registrati"
*/
//alert("xxx");
      jQuery("#formregistrazione").fadeIn(1000, function () {
        jQuery("formregistrazione").fadeIn(20);
      });
	    //
	     jQuery("#login").fadeOut(1000, function () {
        jQuery("login").fadeOut(20);
      });
}


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;
}

function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) {
  if (getCookie(NameOfCookie)) {
    document.cookie = NameOfCookie + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function check_registrazione() {
//
var  registrazioneOK = getCookie("CookieRegistrazione");
//alert("registrazione = "+ registrazioneOK);
if(registrazioneOK == "OK") {
document.write("| <a href=\"javascript:delCookie('CookieRegistrazione');history.go(0);\">Esci</a> ");
} else {
document.write("| <a class=\"login\" href=\"javascript:void(0);\">Entra</a> ");
}
//
}
//
function leggiCookie(NameOfCookie){
var IE = navigator.appName.indexOf("Microsoft") != -1;
var filmato = IE ? window.mainMovie : window.document.mainMovie;
//
       //var stringa =  unescape(document.cookie);
//
    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;
        var stringa = unescape(document.cookie.substring(begin, end));
    } 
  }
window.document.menuflash.SetVariable("registrazione",stringa);
}
//
function leggiUtente(NameOfCookie){
var IE = navigator.appName.indexOf("Microsoft") != -1;
var filmato = IE ? window.mainMovie : window.document.mainMovie;
//
       //var stringa =  unescape(document.cookie);
//
    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;
        var stringa = unescape(document.cookie.substring(begin, end));
    } 
  }
window.document.menuflash.SetVariable("utente",stringa);
}
//
function messaggio_login(arg1,arg2) {
//
/*
var code = arg1;
//
if (document.getElementById) {

var newdiv = document.createElement("div");
newdiv.innerHTML = code;
var messaggiologin = document.getElementById("messaggiologin");
messaggiologin.appendChild(newdiv);


        //
        
        document.getElementById('messaggiologin').innerHTML=code; 
   } else if (document.all) {
        document.all('messaggiologin').innerHTML=code; 
  }  else if (document.layers) {
        document.layers['messaggiologin'].innerHTML=code; 
  }
  if(arg2 == '1') {// se la user id non corrisponde
  var tmppw = getCookie('CookiePw')
  //alert("pw = "+tmppw);
  document.form_login.pw.type="password"; 
  document.form_login.pw.value = tmppw; 
  document.form_login.user.value = ""; 
  document.form_login.user.focus();
  }
//
  if(arg2 == '2') {// se la password non corrisponde
  var tmpuser = getCookie('CookieUser')
  //alert("user = "+tmpuser);
  document.form_login.user.value = tmpuser; 
  document.form_login.pw.value = ""; 
  document.form_login.pw.focus();
  }
//
*/
}

/*
function ricettario_diff_over(arg) {
//

	if (arg==1){
		ricettario_diff_out(5);
		document.getElementById('star'+1).src = 'immagini/star_on.gif';
		document.getElementById('fix_diff').value = '';
	}
	else
		for(n=1; n<=arg; n++) {
			document.getElementById('star'+n).src = 'immagini/star_on.gif';
		}
}

//
function  ricettario_diff_out(arg) {
//

	if (arg==1){
		ricettario_diff_out(5);
		document.getElementById('star'+1).src = 'immagini/star_on.gif';
		document.getElementById('fix_diff').value = '';
	}
	else
	{
		if (document.getElementById('fix_diff').value != 'x')
			for(n=1; n<=arg; n++) {
				document.getElementById('star'+n).src = 'immagini/star.gif';
			}
	}
	
}

function fix_diff(diff){
	document.getElementById('fix_diff').value = 'x';
	document.getElementById('f_difficolta').value = diff;
	//alert('f_difficolta' + document.getElementById('f_difficolta').value);
}
//

*/

function ricettario_diff_over(arg) {
//

	if (arg==1){
		ricettario_diff_out(5);
		document.getElementById('star'+1).src = 'immagini/ricettario/cappellino2_on.gif';
		document.getElementById('fix_diff').value = '';
	}
	else
		for(n=1; n<=arg; n++) {
			document.getElementById('star'+n).src = 'immagini/ricettario/cappellino2_on.gif';
		}
}




//
function  ricettario_diff_out(arg) {
//

	if (arg==1){
		ricettario_diff_out(5);
		document.getElementById('star'+1).src = 'immagini/ricettario/cappellino2_on.gif';
		document.getElementById('fix_diff').value = '';
	}
	else
	{
		if (document.getElementById('fix_diff').value != 'x')
			for(n=1; n<=arg; n++) {
				document.getElementById('star'+n).src = 'immagini/ricettario/cappellino2_off.gif';
			}
	}
	
	
}


function valorizza(diff){
	
	//alert('f_difficolta' + document.getElementById('fix_diff').value);
	document.getElementById('fix_diff').value = 'x';
	document.getElementById('f_difficolta').value = diff;
	//document.my_form.submit(); 
	//return false;
}

