/*
    Document   : portaleok.js
    Created on : 27 ottobre 2006, 15.37
    Author     : Gabriele Callimaci
*/


function popUp(url, winName) {
  window.open(url, winName, 'width=750, height=420, toolbar=no, location=no, menubar=no, status=no, scrollbars=no, resizable=no');
}



/* --- form: Begin --- */
function isEmpty(value) {
  if (value == null || value.length == 0)
    return true;
  for (var count = 0; count < value.length; count++) {
    if (value.charAt(count) != " ") return false;
  }
  return true;
}

function isEmptyRadio(radioGroup) {
  var sel = -1;
  for (i=0;i<radioGroup.length;i++){
    if (radioGroup[i].checked==true){
      sel=i;
      break; //exist for loop, as target acquired.
    }
  }
  return sel<0;
}

function isValidEmail(s) {
  goodEmail = s.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
  if (goodEmail==null) return false;
  return true;
}


function isValidString(formElement, formElementName) {
  if (isEmpty(formElement.value)) {
    alert("Il campo '"+formElementName+"' e' vuoto.");
    formElement.focus();
    return false;
  }
  return true;
}


function isValidMail(formElement, formElementName) {
  if (isEmpty(formElement.value) || !isValidEmail(formElement.value)) {
    alert("Il campo '"+formElementName+"' non e' valido.");
    formElement.focus();
    formElement.select();
    return false;
  }
  return true; 
}


function isValidId(formElement, formElementName) {
  if (formElement.value==-1) {
    alert("Il campo '"+formElementName+"' non e' valido.");
    formElement.focus();
    return false;
  }
  return true;
}


function toUpperCase(obj) {
  obj.value = obj.value.toUpperCase();
}

function firstUpperCase(obj) {
  obj.value = obj.value.charAt(0).toUpperCase() + obj.value.substring(1);
}
/* --- form: End --- */

