function openWindow(in_sUrl )
{
	return window.open( in_sUrl , "","width=320,height=100");
}

function openWindow(in_sUrl , width , height)
{
	return window.open( in_sUrl , "","width="+width+",height="+height);
}

function procuraValor( object , pagina)
{

	url = '/video/admin/'+pagina+'?nome='+object.value;
	win = openWindow(url , 320 , 200 );

}

function abreNewsletter()
{
	window.open('gpp_template_newsletter.jsp','win1','width=600,height=440,menubar,scrollbars');
}

function procuraValorCliente( object , pagina)
{
	url = '/video/cliente/'+pagina+'?nome='+object.value;
	win = openWindow(url , 320 , 100 );

}

function retornaValor()
{
	win = window.opener;
	index = document.form1.ator.selectedIndex;
	alert( index );
	alert( document.form1.ator[index].value );
	alert( document.form1.ator[index].text );
	win.document.formulario.ator1.value = document.form1.ator[index].text;
	win.document.formulario.idator1.value = document.form1.ator[index].value;
	window.close();
}

function validaCEP(campo)
{
	myRegExp = /^(\d{5})-(\d{3})/g 
	return ! ( myRegExp.exec( campo.value ) == null );
}

function validaData(campo)
{
	myRegExp = /^(\d{2})\W(\d{2})\W(\d{4})/ 
	return ! ( myRegExp.exec( campo.value ) == null );
}
function validaCPF(CPF) {

  var i;
  var rcpf1, rcpf2;


  rcpf1 = CPF.value.substring(0,9);
  rcpf2 = CPF.value.substring(9,11);

  var num = /[^0-9]/;
  num = num.exec(CPF.value);
  if(CPF.value.length == 0)
  {
        CPF.focus();
        alert("CPF deve ser preenchido");
        CPF.select();
        return 1;
  } 
  if (num != null)
  {
        CPF.focus();
        alert("CPF deve ser númerico");
        CPF.select();
        return 1;
  }
  if (!(CPF.value.length == 11))
  {
        CPF.focus();
        alert("CPF inválido, Tamanho inválido.");
        CPF.select();
        return 1;
  }
  d1 = 0;
  for (i=0;i<9;i++)
    d1 += rcpf1.charAt(i)*(10-i);
  d1 = 11 - (d1 % 11);
  if (d1>9) d1 = 0;

  if (rcpf2.charAt(0) != d1)
  {
        CPF.focus();
        alert("CPF Inválido");
  	CPF.select();
        return 1;
  }
  d1 *= 2;
  for (i=0;i<9;i++)
    d1 += rcpf1.charAt(i)*(11-i);
  d1 = 11 - (d1 % 11);
  if (d1>9) d1 = 0;

  if (rcpf2.charAt(1) != d1)
  {
        CPF.focus();
        alert("CPF Inválido");
        CPF.select();
        return 1;
  }
  return 0;
}
