function clearField(field, exception){
  if (document.getElementById(field).value == exception)
      document.getElementById(field).value = '';
}

function requestCheckUser(num, path){
    
  var url 	   = '../'+path+'modules/AreaRis/xml/xmlCheckUser.php';
	if (num == 1){
      document.getElementById("form_login_1").action = url;
    	document.getElementById("form_login_1").submit();
  }
  else if (num == 2){
      document.getElementById("form_login_2").action = url;
    	document.getElementById("form_login_2").submit();
  }

}

function requestLogout(l, path){

  var url 	   = '../'+path+'modules/AreaRis/xml/xmlLogout.php?l='+l;
	document.location.href = url; //+'?'+params;
    
}

function requestModificaProfilo(campoKO, path){

  var l               = document.getElementById("l");
  var new_u           = document.getElementById("new_u");
  var new_p           = document.getElementById("new_p");
  var new_p2          = document.getElementById("new_p2");
  var email           = document.getElementById("email");
  var conferma_email  = document.getElementById("conferma_email");

	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
  
  var colorKO       = "#F88888";
  
  if (new_u.value != "" || new_p.value != "" || new_p2.value != "" || email.value != "" || conferma_email.value != ""){
  
      if (new_p.value != "" && new_p2.value != "" && new_p.value != new_p2.value){
        
        document.getElementById("password_required").innerHTML = campoKO[0];
        document.getElementById("password_required").style.color = colorKO;
        document.getElementById("password_required").style.visibility = "visible";
        document.getElementById("new_p").style.backgroundColor = colorKO;
        document.getElementById("new_p2").style.backgroundColor = colorKO;
        new_p.value = '';
        new_p2.value = '';
        new_p.focus();
      
      }
      else if (email.value != "" || conferma_email.value != "" || email.value != conferma_email.value){
      
        document.getElementById("email_required").innerHTML = campoKO[0];
        document.getElementById("email_required").style.color = colorKO;
        document.getElementById("email_required").style.visibility = "visible";
        document.getElementById("email").style.backgroundColor = colorKO;
        document.getElementById("conferma_email").style.backgroundColor = colorKO;
        cognome.focus();
      
      }
    
      else{
        
        var url 	   = '../'+path+'modules/AreaRis/xml/xmlModificaProfilo.php';
      	var params 	 = 'l='+l.value+'&new_u='+new_u.value+'&new_p='+new_p.value+'&new_p2='+new_p2.value+'&email='+email.value+'&conferma_email='+conferma_email.value;
        var method 	 = 'POST';
      	
      	document.getElementById("modifica_profilo_div").innerHTML = '<div style="margin: 0 auto; text-align: center;"><br /><br /><div style="width: 32px; height: 32px; margin: 0 auto; text-align: center;"><img src="../'+path+'modules/AreaRis/images/loading.gif" /></div><br />'+campoKO[3]+'...</div>';
        myXMLHTTPRequest(method, url, params, responseModificaProfilo);
    
      }
  }
}



function responseModificaProfilo(httpRequest){
	if (myXMLHTTPResponse(httpRequest, "text/xml")){

		var xmldoc = myXMLHTTPResponse(httpRequest, "text/xml");
		var msg  = xmldoc.getElementsByTagName('msg').item(0).firstChild.data;
    var l  = xmldoc.getElementsByTagName('l').item(0).firstChild.data;
  	
  	document.getElementById("modifica_profilo_div").innerHTML = msg;
		
	}
	else{
	}
}

function change(url, page, pagination, sort, key){
  url += '?page='+page+'&pagination='+pagination+'&orderBy='+sort+'&keyword='+key;
  location.href = url;
}

function changeOrderBy(url, page, pagination, sort, key){
  change(url, page, pagination, sort, key);
}

function changePagination(url, page, pagination, sort, key){
  change(url, page, pagination, sort, key);
}

function changePage(url, page, pagination, sort, key){
  change(url, page, pagination, sort, key);
}

function next(url, page, pagination, sort, key){
  change(url, page, pagination, sort, key);
}

function prev(url, page, pagination, sort, key){
  change(url, page, pagination, sort, key);
}
