
function popup(url,width,height){
	window.open(url,'popup','scrollbars=yes, top=80, left=80, menubar=no, resizable=no, status=no, width='+width+', height='+height);
}

function conferma(messaggio, url){
	if(confirm(messaggio)){
		return true;
	}
	return false;
}


function chk_txt(o,v){
	if(o.value.search('[a-zA-Z0-9]') == -1){
		if(arguments.length==1) alert('Campo ' + o.name + ' errato');
		else if(arguments.length==2) alert(v);
		o.focus();
		return false;
	}
	return true;
}

function chk_int(o,m){
	if(!o.value || o.value.search('[^0-9]') != -1){
		if(arguments.length==1) alert('Campo ' + o.name + ' errato');
		else if(arguments.length==2) alert(m);	
		o.focus();
		return false;
	}
	return true;
}
//togliere http!!!
function chk_url(o){
	if(o.value.search('[a-z]+://[a-zA-Z0-9]+\.[a-zA-Z0-9]+') == -1){
		alert('Campo ' + o.name + ' errato');
		o.focus();
		return false;
	}
	return true;
}
function chk_url1(o,m){
	if(o.value.search('[a-zA-Z0-9]+\.[a-zA-Z0-9]+') == -1){
		if(arguments.length==2){
			alert(m);
			o.focus();
		}
		return false;
	}
	return true;
}

function chk_passwd(o,v){
	if(o.value.search('[a-zA-Z0-9]') == -1 || o.value.length < 9 ){
		if(arguments.length==1) alert('Campo ' + o.name + ' errato');
		else if(arguments.length==2) alert(v);
		o.focus();
		return false;
	}
	return true;
}

function chk_passwd2(o1,o2,v){
	if( o1.value != o2.value ){
		if(arguments.length==1) alert('Campo ' + o.name + ' errato');
		else if(arguments.length==2) alert(v);
		o.focus();
		return false;
	}
	return true;
}


function azzera(url){
	window.location.href = url;
}
function chk_email(o,d){
	if(o.value.search("^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\\.[a-zA-Z]{2,4}$") == -1){
		alert(d);
		o.focus();
		return false;
	}
	return true;
}
function chk_select(o,d){
	if(!o[o.selectedIndex].value || !o.selectedIndex){
		alert(d);
		o.focus();
		return false;
	}
	return true;
}

function chk_radiobutton(o,m){
	/*
	var ctrl = false;
	
	for(i;i<o.length;i++){
		if( o.checked ){
			ctrl = true;
			break;
		}
	}
	
	if(!ctrl){
		alert(m);
		return false;
	}
	
	return true;
	*/
	return false;
}

//////////////////////////////////////////////////////////////////////////

function chk_aut1(){
	if(!document.registrazione.flag_privacy1.checked){
		alert("E' necessario fornire il proprio consenso");
	     document.registrazione.focus();
	     return(false);
	}else{
	 return(true);
	}
}

function chk_aut2(lang_id){
	//alert(document.contacts.autorizzazione[1].checked);
	if(lang_id == '2'){
		return(true);
	}else{
		if(document.contacts.autorizzazione[1].checked){
			alert("E' necessario fornire il proprio consenso");
			return(false);
		}else{
		 return(true);
		}
	}
}

//autorizzazione
function chk_informativa(){
	if(document.contacts.autorizzazione.value == '1'){
		alert("E' necessario fornire il proprio consenso");
	     document.contacts.focus();
	     return(false);
	}else{
	 return(true);
	}
}


function chk_iscriz_newsletter(lang_id){
	
	if(lang_id == '2')
		msg = 'Required field';
	else
		msg = 'Campo obbligatorio';
	
	with(document.contacts){
		if( chk_txt(nome,msg) && chk_txt(cognome,msg) && chk_email(email,msg) && chk_aut2() ){
			return true;
		}
		return false;
	}
}

