// JavaScript Document
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function elencoProv(){
	$('#negozi').attr('disabled','disabled');
	if ( $("#idregione option:selected").val() != 0){
		$("#idprovince").load("dativarihtml.php?data=elencoProv&idreg="+$("#idregione option:selected").val() );
		$("#idprovince").removeAttr("disabled");

	}
}
function elencoNeg(){
	if ( $("#idprovince option:selected").val() != 0){
		$("#negozi").load("dativarihtml.php?data=elencoNeg&idprov="+$("#idprovince option:selected").val() );
		$("#negozi").removeAttr("disabled");
	}
}

function elencoNegLista(){
	if ( $("#idprovince option:selected").val() != 0){
		$("#listaNegozi").load("dativarihtml.php?data=elencoNegLista&idprov="+$("#idprovince option:selected").val() );
	}
}

function vaiNegozio(){
	if($("#negozi option:selected").val() != 0){
			document.location.href = "negozi.php?idneg="+$("#negozi option:selected").val();
		}
	
	}

	
function ControllaMail(EmailAddr)  {
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if (Filtro.test(EmailAddr)) {
		return true;
	} else {
		return false;
	}
}



function controllaObbligatori() {
	tmpval=0;
	$('.obblRiga').each(function(){
		if($(this).val() == '') {
				tmpval=tmpval+1
		} 						 
	});
	
	$('.obblSelect').each(function(){
		if($('option:selected', this ).val() == '') {
				tmpval=tmpval+1
		} 						 
	});
	
	$('.obblCheck').each(function(){
		idcheck= $(this).attr('id')	;					  
		if($('#'+$(this).attr('id')+':checked').val() === undefined) {
				tmpval=tmpval+1
		} 						 
	});
	
	if (tmpval == 0 ){
		return true;
	} else {
		return false;
	}
}



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}	
