function gosrc(urls,cosa)
{
	if(cosa=='prod'){var str = document.forms['thesrc'].scr1.value;}
	else{var str = document.forms['thesrc'].scr2.value;}
	
	if(str=='' || str == 'Cerca prodotto' || str == 'Cerca nel sito' )
	{
		return false;
	}

	window.location=urls+'cerca.html?wh='+cosa+'&str='+str;
	return true;
}

function chklogin(urls)
{
	// email
	var user = document.forms['loginuser'].login_user.value;
	if (user == '' || user == 'user')
	{
		alert("Attenzione! Devi indicare la tua user");
		document.forms['loginuser'].login_email.focus();
		return false;
	}

	// pwd
	var pwd = document.forms['loginuser'].login_pwd.value;
	if (pwd == '' || pwd == 'password')
	{
		alert("Attenzione! Devi indicare la tua password");
		document.forms['loginuser'].login_pwd.focus();
		return false;
	}

	var myRandom=parseInt(Math.random()*99999999);  // cache buster
	var param = "action=login&user=" + encodeURI(user) + "&pwd=" + encodeURI(pwd) + "&rnd=" + myRandom;

	var http = false;
	try{http = new XMLHttpRequest();}
	catch(e)
	{
		try{http = new ActiveXObject('Msxml2.XMLHTTP');}
		catch(e){http = new ActiveXObject('Microsoft.XMLHTTP');}
	}

	if (!http)
	{
		alert('ATTENZIONE, si è verificato un problema tecnico.');
		return false;
	}

	http.onreadystatechange = function()
	{
		if (http.readyState == 4 && http.status == 200)
		{
			var reply = http.responseText;
			var reponse=reply.split("|");

			if (reponse[0] == 'ok')
			{
				window.location=urls + 'area-riservata.html';
			}
			else
			{
				if (reponse[1] == 'user')
				{
					document.forms['loginuser'].login_user.focus();

					alert('ATTENZIONE, devi indicare indicare la tua user');
					return false;
				}

				else if (reponse[1] == 'pwd')
				{
					document.forms['loginuser'].login_pwd.focus();

					alert('ATTENZIONE, devi indicare la tua password');
					return false;
				}

				else if (reponse[1] == 'nouser')
				{
					document.forms['loginuser'].login_pwd.focus();

					alert('ATTENZIONE, la e-mail o la password non sono corrette. Ripetere l\'inserimento.');
					return false;
				}

				else
				{
					alert('ATTENZIONE, si è verificato un problema tecnico');
					return false;
				}
			}
		}
	}

	var urlTOcall = urls + 'include/azioni.html';
	http.open('POST', urlTOcall, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", param.length);
	http.setRequestHeader("Connection", "close");
	http.send(param);
}

