function popups(pg,nome,fs,w,h,rolagem) {
	if(fs) { // fullscreen
		var w=screen.availWidth,h=screen.availHeight;
		var winObj = window.open(pg,nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left=0,top=0');
		with(winObj) { moveTo(0,0); resizeTo(w,h); focus(); }
	} else { // popup normal
		var winObj=window.open(pg,nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.width-w)/2)+-10)+',top='+(((screen.height-h)/2)+-30));
		winObj.focus();
	}
}
// MOSTRA/OCULTA TEXTOS NAS DIVS DE SABER MAIS

function show(topic,msg){
if	(document.getElementById(msg).style.display == "none")
	{
	document.getElementById(topic).className = "active_link";
	document.getElementById(msg).style.display = "";
	
	}
	else
	{
	document.getElementById(msg).style.display = "none";
	document.getElementById(topic).className = "link";
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function msgSubmit(idform,idmsg){
	$('#'+idform).slideUp();
	$('#'+idmsg).fadeIn("slow");
}

/* ON LOAD */
if (window.attachEvent){
	MM_preloadImages(
					 '../../img/btn_navbar_exposicao_on.gif',
					 '../../img/btn_navbar_nossa_vida_on.gif.gif',
					 '../../img/btn_navbar_saiba_mais_on.gif.gif',
					 '../../img/btn_navbar_sua_vida_on.gif'
					);
}
	else if (window.addEventListener){
}
/* // ON LOAD */

function soNumeros(e){
 //Caso Internet Explorer(IE) outros (Other)
 if (navigator.appName.indexOf('Microsoft') != -1){
 	clientNavigator = "IE";
 }else{
 	clientNavigator = "Other";
 }

 //Função permite digitação de números
 	if (clientNavigator == "IE"){
 		if (e.keyCode < 48 || e.keyCode > 57){
 			return false
 		}
 	}else{
 		if ((e.charCode < 48 || e.charCode > 57) && e.keyCode == 0){
 			return false
 		}
 	}

} 

function FormataCampo(Campo,teclapres,mascara, sai) {

	if (sai == "S" && consistente == "N") {
		if (obrigatorio == "N" && Campo.value.length > 0) {
			obrig_fixo = "S";
			Consist(Campo.maxLength, Campo);
			obrig_fixo = "N";
		}
		if (obrigatorio == "S" || Campo.value.length > 0) {
			if (sai == "S") {
				if (Campo.value.length != mascara.length) {
					alert('O campo precisa estar neste formato:\n\n       '+ mascara);
					Campo.value = "";
				}
				erro = "S";
				return false;
			}
		}
	}
	if (sai == "S" && obrigatorio == "N" && Campo.value.length > 0) {
		obrig_fixo = "S";
		Consist(Campo.maxLength, Campo);
		obrig_fixo = "N";
		if (consistente == "N") {
			alert('O campo precisa estar neste formato:\n\n       '+ mascara);
		}
	}


	strtext = Campo.value;
	tamtext = strtext.length;
	tammask = mascara.length;
	arrmask = new Array(tammask);
	for (var i = 0 ; i < tammask; i++) {
		arrmask[i] = mascara.slice(i,i+1)
	} 

	//alert(teclapres.keyCode );
	if (((((arrmask[tamtext] == "#") || (arrmask[tamtext] == "9"))) || (((arrmask[tamtext+1] != "#") || (arrmask[tamtext+1] != "9"))))) {
		if ((teclapres.keyCode >= 35 && teclapres.keyCode <= 40)||(teclapres.keyCode >= 48 && teclapres.keyCode <= 57)||(teclapres.keyCode >= 96 && teclapres.keyCode <= 105)||(teclapres.keyCode == 8)||(teclapres.keyCode == 9) ||(teclapres.keyCode == 46) ||(teclapres.keyCode == 13)||(teclapres.keyCode == 16)){
			Organiza_Casa(Campo,arrmask[tamtext],teclapres.keyCode,strtext)		
		} else {
			Detona_Event(Campo,strtext)
		}
	} else {
		if ((arrmask[tamtext] == "A")) {
			charupper = event.valueOf()
			Detona_Event(Campo,strtext)
			masktext = strtext + charupper 
			Campo.value = masktext
		}
	}
}

function Organiza_Casa(Campo,arrpos,teclapres_key,strtext){
     if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 8)){
       separador = arrpos
       masktext = strtext + separador
       Campo.value = masktext
     }
}

function Detona_Event(Campo,strtext){
     event.returnValue = false
     if (strtext != "") {
       Campo.value = strtext
     }
}
    
function check_date(field){
     var checkstr = "0123456789";
     var DateField = field;
     var Datevalue = "";
     var DateTemp = "";
     var seperator = "/";
     var day;
     var month;
     var year;
     var leap = 0;
     var err = 0;
     var i;
     var strDataMsg = "";

        err = 0;
        DateValue = DateField.value;
       /* Delete all chars except 0..9 */
       for (i = 0; i < DateValue.length; i++) {
          if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
             DateTemp = DateTemp + DateValue.substr(i,1);
          }
       }
       DateValue = DateTemp;
       /* Always change date to 8 digits - string*/
       /* if year is entered as 2-digit / always assume 20xx */
       if (DateValue.length == 6) {
          DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
       if (DateValue.length != 8) {
          err = 19;
		  strDataMsg = "A data informada é inválida.";		  
		}

       /* year is wrong if year = 0000 */
       year = DateValue.substr(4,4);
       if (year == 0) {
          err = 20;
		strDataMsg = "O ano informado é inválido.";
       }
       
       if (year > 2009) {
          err = 20;
		strDataMsg = "O ano informado é inválido.";
       }
       
       if (year < 2007) {
          err = 20;
		strDataMsg = "O ano informado é inválido.";
       }
      
       /* Validation of month*/
       month = DateValue.substr(2,2);
       if ((month < 1) || (month > 12)) {
          err = 21;
		  strDataMsg = "O mês informado é inválido.";
       }

       /* Validation of day*/
       day = DateValue.substr(0,2);
       if (day < 1) {
         err = 22;
		 strDataMsg = "o dia informado é inválido.";
       }

       /* Validation leap-year / february / day */
       if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
          leap = 1;
       }
       if ((month == 2) && (leap == 1) && (day > 29)) {
          err = 23;
		  strDataMsg = "O mês informado possui no máximo 29 dias.";
       }
       if ((month == 2) && (leap != 1) && (day > 28)) {
          err = 24;
		  strDataMsg = "O mês informado possui no máximo 28 dias.";
       }
       /* Validation of other months */
       if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
          err = 25;
		  strDataMsg = "O mês informado possui no máximo 31 dias.";
       }
       if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
          err = 26;
		  strDataMsg = "O mês informado possui no máximo 30 dias.";
       }
       /* if 00 ist entered, no error, deleting the entry */
       if ((day == 0) && (month == 0) && (year == 00)) {
          err = 0; day = ""; month = ""; year = ""; seperator = "";
       }
       /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
       if (err == 0) {
          //DateField.value = day + seperator + month + seperator + year;
          return true;
       }
       else {
          //alert(strDataMsg);
          //DateField.select();
          //DateField.focus();
          return false;
       }
    }
    
function dotNetValidaData(src, args){
     var data = document.getElementById("txtData");
     if ( check_date(data) )
          args.IsValid = true;
     else
          args.IsValid = false;
}

