/**
 * Generic (Bijl)
 */
function setCookie(cookieName,cookieValue) {
   document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;expires=0";
}
function getCookie(name) {
   var index = document.cookie.indexOf(name + "=");
   if (index == -1) return null;
   index = document.cookie.indexOf("=", index) + 1;
   var endstr = document.cookie.indexOf(";", index);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(index, endstr));
}
function onfocusHandler() {
   setCookie("id_window",window.name);
}
if (window.self != window.top) {window.top.location = window.self.location;}
if (window.name == '') {
   var r = Math.random().toString();
   window.name = r.substr(2);
   setCookie("id_window",window.name);
} 

/**
 * Object detection
 */
if (!document.getElementById) {
  alert('Devido à versão do seu browser, alguns items desta página poderão aparecer incorrectamente.');
}

/**
 * Validate emails
 */
function isValidEmail(emailAddress) {
  var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return re.test(emailAddress);
}

function openwindow(url, w, h) {
      winStats='toolbar=no,location=no,directories=no,menubar=no,'
      winStats+='scrollbars=yes,width='+ w +',height='+ h

      if (navigator.appName.indexOf("Microsoft")>=0) {
         winStats+=',left=10,top=25'
       }else{
         winStats+=',screenX=10,screenY=25'
       }
       window.open(url,"",winStats);
}


