﻿function sintaxeLogin(Value) {
    var regexp = /^[\w-]+$/;
    return regexp.test(Value);
}

function sintaxeContaEmail(Value) {
    var regexp = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
    return regexp.test(Value);
}

function validadata(Value) {
    if (Value.length == 0)
        return -1;

    var regExp = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
    if (!regExp.test(Value)) {
        return 0;
    } else {
    return 1;
    }
}

function CenterOnScreen(divName) {

    var div = document.getElementById(divName);
    if ( ! div )
    {
        return;
    }

    var Top = (window.screen.availHeight - div.clientHeight)/2;
    
    if (Top < 0)
    {
        Top = 0;
    }
    
    var Left = (window.screen.availWidth - div.clientWidth)/2;
    if (Left < 0)
    {
        Left = 0;
    }

    div.style.position = "absolute";
    div.style.visibility = "visible";
    div.style.display = "block";
    
    div.style.left = Left + "px";
    div.style.top = Top + "px";
}

function showDiv( divName )
{
  var div;
  div = document.getElementById( divName );
  if ( div )
  {
    div.style.visibility = "visible";
    div.style.display = "block";
  }
}

function hideDiv( divName )
{
  var div;
  div = document.getElementById( divName );
  if ( div )
  {
    div.style.visibility = "hidden";
    div.style.display = "none";
  }
}

function showhideDiv( divName )
{
  var div;
  div = document.getElementById( divName );
  if ( div )
  {
    if ( div.style.visibility == "hidden")
    {
      div.style.visibility = "";
      div.style.display = "";    
    } else 
    {
      div.style.visibility = "hidden";
      div.style.display = "none";
    }
  }
}

function showhideMenu( divTableName, divContentName )
{
    showhideDiv(divContentName);
    
    divContent = document.getElementById( divContentName );
    divTable = document.getElementById( divTableName );
    
    if (divContent.style.visibility == "" )
    {
        divTable.style.backgroundImage = "/theme/blue/images/1_z3_sel.gif";
    } else 
    {
        divTable.style.backgroundImage = "/theme/blue/images/1_z3.gif";
    }
    
}

var oldcolor;
function menu_mouseover(td, newcolor) {
    oldcolor = td.style.backgroundColor;

    if (newcolor == '') {
        newcolor = "#f5f5f5";
    }

    td.style.backgroundColor = newcolor;
}
function SetCookie(name, value) {
    document.cookie = name + "=" + escape(value);
}
function menu_mouseout(td) {
    td.style.backgroundColor = oldcolor;
}

function ShowMenu(me, div) {
    var obj, meobj;
    meobj = document.getElementById(me);
    meobj.innerHTML = "-";

    obj = document.getElementById(div);
    if (obj) {
        if (obj.style.display != "") {
            obj.style.display = "";
            obj.style.visibility = "";
            meobj.innerHTML = "-";
            SetCookie(me, "true");
        } else {
            obj.style.display = "none";
            obj.style.visibility = "hidden";
            meobj.innerHTML = "+";
            SetCookie(me, "false");
        }
    }
}

var MenuStart = 0;
var MenuOutCount = 0;
var MenuOutTimer = 0;
var menuid = "";

function MenuTimeOut() {
    window.clearTimeout(MenuOutTimer);
    if ((MenuOutCount == 0) && (MenuStart != 0)) {
        var obj;
        obj = document.getElementById(menuid);
        if (obj) {
            obj.style.visibility = "hidden";
            obj.style.display = "none";
            MenuOutCount = 0;
            menuid = "";
        }
        return;
    }

    MenuOutTimer = window.setTimeout("MenuTimeOut()", 1000);
}

function omm() {
    MenuOutCount--;
}

function imm() {
    MenuStart++;
    MenuOutCount++;
}

function mout() {
    MenuStart++;
    MenuOutCount == 0;
    window.clearTimeout(MenuOutTimer);
    MenuOutTimer = window.setTimeout("MenuTimeOut()", 1000);
}

function getY(oElement) {
    var iReturnValue = 0;
    while (oElement != null) {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}
function getX(oElement) {
    var iReturnValue = 0;
    while (oElement != null) {
        iReturnValue += oElement.offsetLeft;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}

function MenuMais(Origem, id) {
    var obj;
    if (menuid != "") MenuTimeOut();

    menuid = id;
    obj = document.getElementById(menuid);
    if (obj) {
        obj.style.left = getX(Origem) + "px";
        obj.style.top = (getY(Origem) + Origem.clientHeight + 15) + "px";
        obj.style.visibility = "visible";
        obj.style.display = "block";
        MenuOutTimer = window.setTimeout("MenuTimeOut()", 1000);
        MenuOutCount = 0;
        MenuStart = 0;
    }
}

function DenyChat(webid)
{
    hideDiv("chatinvite_" + webid);
    Paquera.DenyChat(webid);
}