function Verifica_Email(email, obrigatorio){   
//Se o parâmetro obrigatório for igual à zero, significa que elepode estar vazio, caso contrário, não   
    var email = document.getElementById(email);   
    if((obrigatorio == 1) || (obrigatorio == 0 && email.value != "")){   
        if(!email.value.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+)/gi)){   
            alert("Informe um e-mail válido");   
            email.focus();   
            return false   
        }   
    }   
}   
  
function Verifica_Cep(cep, obrigatorio){   
//Se o parâmetro obrigatório for igual à zero, significa que elepode estar vazio, caso contrário, não   
    var cep    = document.getElementById(cep);   
    var strcep = cep.value;   
    if((obrigatorio == 1) || (obrigatorio == 0 && strcep != "")){   
        if (strcep.length != 9){   
            alert("CEP informado inválido.");   
            cep.focus();   
            return false   
        }else{   
            if (strcep.indexOf("-") != 5){   
                alert("Formato de CEP informado inválido.");   
                cep.focus();   
                return false   
            }else{   
                if (isNaN(strcep.replace("-","0"))){   
                    alert("CEP informado inválido.");   
                    cep.focus();   
                    return false   
                }   
            }   
        }   
    }       
}   
  
function formatar(src, mask){ 
//Formata para os diversos tipos
/*
CNPJ - OnKeyPress="formatar(this, '##.###.###/####-##')"
CPF - OnKeyPress="formatar(this, '###.###.###-##')"
DATA - OnKeyPress="formatar(this, '##/##/####')"
*/
    if (SoNumeros(src) == true) { 
       var i = src.value.length;
       var saida = mask.substring(0,1);
       var texto = mask.substring(i);
       if (texto.substring(0,1) != saida){
          src.value += texto.substring(0,1);
       }
    }
}

function currencyFormat(fld, milSep, decSep, e){
//Formata o campo numerico
//onKeyPress="return(currencyFormat(this,'.',',',event));" 
//onKeyPress="return(currencyFormat(this,',','.',event));"
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  var strCheck = '0123456789';
  var aux = aux2 = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;

  if (whichCode == 13) return true;  // Enter
  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  len = fld.value.length;
  for(i = 0; i < len; i++)
  if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
  aux = '';
  for(; i < len; i++)
  if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
  aux += key;
  len = aux.length;
  if (len == 0) fld.value = '';
  if (len == 1) fld.value = '0'+ decSep + '0' + aux;
  if (len == 2) fld.value = '0'+ decSep + aux;
  if (len > 2) {
    aux2 = '';
    for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
    }
    fld.value = '';
    len2 = aux2.length;
    for (i = len2 - 1; i >= 0; i--)
    fld.value += aux2.charAt(i);
    fld.value += decSep + aux.substr(len - 2, len);
  }
  return false;
}

function SoNumeros(e){
//Permite somente numeros
/*
onKeyPress="return Tecla(event);"
*/
 if (document.all) // Internet Explorer
  var tecla = event.keyCode;
 else if(document.layers) // Nestcape
  var tecla = e.which;
  if (tecla > 47 && tecla < 58 ) // numeros de 0 a 9
   return true;
  else
   {
    if (tecla != 8) // backspace
     event.keyCode = 0;
     //return false;
    else
     return true;
   }
}	


// description: draggable modal windows

// parameters to f_dialogOpen: 
//	1. path or web address of the document to open in the dialog window - required
//	2. window title - optional
//	3. string with comma separated list of window features. format feature=value. Supported features are width, height, left, top, css - all optional, reasonable defaults apply


var N_BASEZINDEX = 0;
var RE_PARAM = /^\s*(\w+)\s*\=\s*(.*)\s*$/;

// this function makes the document numb to the mouse events by placing the transparent layer over it
function f_putScreen (b_show) {

	if (b_show == null && !window.b_screenOn)
		return;

	if (b_show == false) {
		window.b_screenOn = false;
		if (e_screen) e_screen.style.display = 'none';
		return;
	}

	// create the layer if doesn't exist
	if (window.e_screen == null) {
		window.e_screen = document.createElement("div");
		e_screen.innerHTML = "&nbsp;";
		document.body.appendChild(e_screen);

		e_screen.style.position = 'absolute';
		e_screen.id = 'eScreen';
		
		// attach event
		if (document.addEventListener) {
			document.addEventListener('mousemove', f_dragProgress, false);
			window.addEventListener('resize', f_putScreen, false);
			window.addEventListener('scroll', f_putScreen, false);
		}
		if (window.attachEvent) {
			document.attachEvent('onmousemove', f_dragProgress);
			window.attachEvent('onresize', f_putScreen);
			window.attachEvent('onscroll', f_putScreen);
		}
		else {
			document.onmousemove = f_dragProgress;
			window.onresize = f_putScreen;
			window.onscroll = f_putScreen;
		}
	}

	// set properties
	var a_docSize = f_documentSize();
	e_screen.style.left = a_docSize[2] + 'px';
	e_screen.style.top = a_docSize[3] + 'px';
	e_screen.style.width = a_docSize[0] + 'px';
	e_screen.style.height = a_docSize[1] + 'px';
	e_screen.style.zIndex = N_BASEZINDEX + a_windows.length * 2 - 1;
	e_screen.style.display = 'block';
}

// returns the size of the document
function f_documentSize () {

var n_scrollX = 0,
	n_scrollY = 0;

	if (typeof(window.pageYOffset) == 'number') {
		n_scrollX = window.pageXOffset;
		n_scrollY = window.pageYOffset;
	}
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop )) {
		n_scrollX = document.body.scrollLeft;
		n_scrollY = document.body.scrollTop;
	}
	else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		n_scrollX = document.documentElement.scrollLeft;
		n_scrollY = document.documentElement.scrollTop;
	}

	if (typeof(window.innerWidth) == 'number')
		return [window.innerWidth, window.innerHeight, n_scrollX, n_scrollY];
	if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
		return [document.documentElement.clientWidth, document.documentElement.clientHeight, n_scrollX, n_scrollY];
	if (document.body && (document.body.clientWidth || document.body.clientHeight))
		return [document.body.clientWidth, document.body.clientHeight, n_scrollX, n_scrollY];
	return [0, 0];
}

function f_dialogOpen (s_url, s_title, s_features) {
	if (!window.a_windows)
		window.a_windows = [];
		
	// parse parameters
	var a_featuresStrings = s_features.split(',');
	var a_features = [];
	for (var i = 0; i < a_featuresStrings.length; i++)
		if (a_featuresStrings[i].match(RE_PARAM))
			a_features[String(RegExp.$1).toLowerCase()] = RegExp.$2;
	
	// create element for window
	var n_nesting = a_windows.length;

	var e_window = document.createElement("div");
	e_window.style.position = 'absolute';
	var n_width  = a_features.width  ? parseInt(a_features.width)  : 300;
	var n_height = a_features.height ? parseInt(a_features.height) : 200;
	var a_docSize = f_documentSize ();
	e_window.style.left = (a_features.left ? parseInt(a_features.left) : ((a_docSize[0] - n_width)  / 2) + a_docSize[2]) + 'px';
	e_window.style.top  = (a_features.top  ? parseInt(a_features.top)  : ((a_docSize[1] - n_height) / 2) + a_docSize[3]) + 'px';
	e_window.style.zIndex = N_BASEZINDEX + a_windows.length * 2 + 2;
	
	e_window.innerHTML = 
		'<table border="2" class="' +
		(a_features.css ? a_features.css : 'dialogWindow') +
		'"><tr><th onmousedown="f_dragStart(' + n_nesting + ', event)" onmouseup="f_dragEnd()" onmousemove="f_dragProgress(event)" onselectstart="return false"><span style="float:left"">' +
		(s_title ? s_title : 'Dialog Window') +
		'</span><img src="imagens/close_icon.gif" onclick="top.f_dialogClose();" onmousedown="return false;" style="float:right"></th></tr><tr><td><iframe width="' + n_width +
		'" height="' + n_height +
		'" src="' + s_url + '"></iframe></td></tr></table>';
	document.body.appendChild(e_window);
	a_windows[n_nesting] = e_window;
	
	// put the screen
	f_putScreen(true);
}

function f_dialogClose () {

	var n_nesting = a_windows.length - 1;
	// destroy element
	if (a_windows[n_nesting].removeNode)
		a_windows[n_nesting].removeNode(true);
	else if (document.body.removeChild)
		document.body.removeChild(a_windows[n_nesting]);
	a_windows[n_nesting] = null;
	a_windows.length = n_nesting;

	// move the screen
	f_putScreen(n_nesting ? true : false);
}


// drag'n'drop functions
function f_dragStart (s_name, e_event) {
	if (!e_event && window.event) e_event = window.event;

	// save mouse coordinates
	window.n_mouseX = e_event.clientX;
	window.n_mouseY = e_event.clientY;
	window.e_draggedWindow = window.a_windows[s_name];
	return false;
}
function f_dragProgress (e_event) {
	if (!e_event && window.event) e_event = window.event;
	if (!e_event || window.e_draggedWindow == null) return;

	var n_newMouseX = e_event.clientX;
	var n_newMouseY = e_event.clientY;
	
	window.e_draggedWindow.style.left = (parseInt(window.e_draggedWindow.style.left) - window.n_mouseX + n_newMouseX) + 'px';
	window.e_draggedWindow.style.top  = (parseInt(window.e_draggedWindow.style.top)  - window.n_mouseY + n_newMouseY) + 'px';
	
	window.n_mouseX = n_newMouseX;
	window.n_mouseY = n_newMouseY;
}

function f_dragEnd () {
	window.e_draggedWindow = null;
}
















function AbrirFotoMembros(foto,quantidade)
{
    parent.AbrirPopupFotos(foto,quantidade,"Membros","OpalaClubeRJ.Com.Br",550,550);
}

function AbrirFotoEventos(foto,quantidade)
{
    parent.AbrirPopupFotos(foto,quantidade,"Eventos","OpalaClubeRJ.Com.Br",550,550);
}


//Centraliza a popup de fotos na página
function AbrirPopupFotos(foto,quantidade,tipo,titulo,largura,altura) {

var w = 800, h = 600;

if (document.all || document.layers) {
   w = screen.availWidth;
   h = screen.availHeight;
}

var popW = largura, popH = altura;
var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
window.open('../ver_foto.asp?foto=' + foto + '&quantidade=' + quantidade + '&tipo=' + tipo,'Opala','width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ',toolbar=0,status=0,menubar=0,scrollbars=0,directories=0');
}


//Centraliza o popup na página
function AbrirPopUp(url,ww,hh,nome) {

var w = 800, h = 600;

if (document.all || document.layers) {
   w = screen.availWidth;
   h = screen.availHeight;
}

var popW = ww, popH = hh;
var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
window.open(''+url+'',''+nome+'','width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ',toolbar=0,status=0,menubar=0,scrollbars=0,directories=0');

}
          
 





























function Verificar() 
{
var ctrl=window.event.ctrlKey;
var alt=window.event.altKey;
var tecla=window.event.keyCode;
var shift=window.event.shiftKey;

if (tecla==27) {event.keyCode=0; event.returnValue=false;} // BLOQUEIA O ESC //
//if (shift) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;}
//if (ctrl && tecla==65) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ A (selecionar tudo)//
//if (ctrl && tecla==66) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ B (Favoritos)//
//if (ctrl && tecla==67) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ C (Copiar)//
//if (ctrl && tecla==99) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ c (Copiar)//
//if (ctrl && tecla==86) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ V (Colar)//
//if (ctrl && tecla==118) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ v (Colar)//
//if (ctrl && tecla==97) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ a (selecionar tudo)//
//if (ctrl && tecla==98) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ b (Favoritos)//
//if (ctrl && tecla==73) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ I (Favoritos)//
//if (ctrl && tecla==105) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ i (Favoritos)// 
//if (ctrl && tecla==78) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ N (Nova Janela)//
//if (ctrl && tecla==110) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ n (Nova Janela)// 
//if (ctrl && tecla==27) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ ESC (Menu Iniciar)//
//if (ctrl && tecla==108) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ L (Localizar)// 
//if (ctrl && tecla==76) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ l (Localizar)//
//if (ctrl && tecla==116) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL+ F5 (Atualizar)// 
//if (ctrl) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O CTRL//
//if (tecla==08) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O Backspace (Voltar)//
//if (tecla==116) {alert("Tecla bloqueada"); event.keyCode=0; event.returnValue=false;} // BLOQUEIA O F5 (Atualizar)//
//if (alt) {alert("Tecla bloqueada"); event.keyCode=0; event.altKey=0; event.returnValue=false;} //BLOQUEIA O ALT//
//if (alt && tecla==115) {alert("Tecla bloqueada"); event.keyCode=0; event.altKey=0; event.returnValue=false;} //BLOQUEIA O ALT//
//if (alt && tecla==06) {alert("Tecla bloqueada"); event.keyCode=0; event.altKey=0; event.returnValue=false;} // BLOQUEIA O AlT + TAB//

}
