function caricaHomePage(){
	parent.MainFrame.location.href="../Layout/MainFrame.aspx";
}

function caricaMainFrame(url){
	parent.MainFrame.location.href=url;
}

function caricaTopFrame(url){
	if (url=="")
		parent.TopFrame.location.href="../layout/MainFrame.aspx";
	else
		parent.TopFrame.location.href=url;
}

function caricaRightFrame(){
	parent.RightFrame.location.href="../layout/RightFrame.aspx";
}

function ControllaMail(MailToCheck)
{
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if ((Filtro.test(MailToCheck))||(MailToCheck=="")){
		return true;
	}
	else{
		return false;
	}
}

function selezionaContenuto(obj){
	document.getElementById(obj).select();
}

function trim(inputString) {
	// Removes leading and trailing spaces from the passed string. Also removes
	// consecutive spaces and replaces it with one space. If something besides
	// a string is passed in (null, custom object, etc.) then return the input.
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") { // Check for spaces at the beginning of the string
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") { // Check for spaces at the end of the string
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	}
	return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function caricaSito(url){
	window.open(url,'','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=800,height=600,left=1,top=1');
}

function salvataggioUtentePossibile(){
	if (document.getElementById("txtLogin").value==""){
		document.getElementById("txtLogin").focus();
		alert('Inserire un valore nel campo \'login\' prima di richiedere il salvataggio');
		return false;
	}
	/*else if (document.getElementById("txtPwd").value==""){
		document.getElementById("txtPwd").focus();
		alert('Inserire un valore nel campo \'Password\' prima di richiedere il salvataggio');
		return false;
	}*/
	else if (document.getElementById("txtPwd").value!=document.getElementById("txtRipetiPwd").value){
		document.getElementById("txtPwd").focus();
		alert('Le 2 password inserite non sono uguali!');
		return false;
	}	
	else if (document.getElementById("txtNome").value==""){
		document.getElementById("txtNome").focus();
		alert('Inserire un valore nel campo \'Nome\' prima di richiedere il salvataggio');
		return false;
	}
	else if (document.getElementById("txtCognome").value==""){
		document.getElementById("txtCognome").focus();
		alert('Inserire un valore nel campo \'Cognome\' prima di richiedere il salvataggio');
		return false;
	}
	else if (document.getElementById("txtEmail").value==""){
		document.getElementById("txtEmail").focus();
		alert('Inserire un valore nel campo \'Email\' prima di richiedere il salvataggio');
		return false;
	}
	else if (!ControllaMail(document.getElementById("txtEmail").value)){
		document.getElementById("txtEmail").focus();
		alert('Inserire un valore corretto per l\'indirizzo Email');
		return false;
	}
	return true;
}
/* Toolbar in movimento*/
function setVariables(){
	if (navigator.appName == "Netscape") {
		v=".top=";
		h=".left=";
		//dS="document.";
		dS="";
		sD="";
		y="window.pageYOffset";
		x="window.pageXOffset";
	}
	else {	
		h=".pixelLeft=";
		v=".pixelTop=";
		dS="";
		sD=".style";
		y="document.body.scrollTop";
		x="document.body.scrollLeft";
	}
	checkLocationA()
}
movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0;

function checkLocation(){
	//object="object1";
	object="document.getElementById('object1')"
	yy=eval(y);
	xx=eval(x);
	ydiff=ystart-yy;
	xdiff=xstart-xx;
	if ((ydiff<(-1))||(ydiff>(1))) 
		movey=Math.round(ydiff/10),ystart-=movey
	if ((xdiff<(-1))||(xdiff>(1))) 
		 movex=Math.round(xdiff/10),xstart-=movex
	eval(dS+object+sD+v+ystart);
	eval(dS+object+sD+h+xstart);
	setTimeout("checkLocation()",10)
}

function checkLocationA(){
	ystart=eval(y);
	xstart=eval(x);
}
