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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

var browser = navigator.appName
var isNav, isIE
if (browser == "Netscape") { 
      isNav = true	
}
else { 
if (browser == "Microsoft Internet Explorer") { 
      isIE = true	
}
}


var cm=null;
document.onclick = new Function("show(null)")

function show(el,m) {
if (isNav) {
	if (m) {
		m.visibility='show';
			}
	if ((m!=cm) && (cm)) cm.visibility='hidden'
	cm=m
} 
if(isIE) {
	if (m) {
		m.style.visibility='';
			}
	if ((m!=cm) && (cm)) cm.style.visibility='hidden'
	cm=m
}

}

function submitData() {
        document.frmenquete.submit();
}

function abrejanela()
{
nj=window.open("","miniwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=200,height=180");
nj.document.open();
}


function TrocaSenhaEmail() {

    window.open('alterar_senha.php', 'TrocaSenha', 'scrollbars=no,toolbar=no,scrolling=no,location=no,directories=no,status=no,menubar=no,resizable=no,left=3,top=2,width=350,height=260');
}

function concatena() {
        usuario = document.logaloga.email.value.substring(0,document.logaloga.email.value.indexOf("@"));
        if (document.logaloga.email.value.indexOf("@") != -1) {
                if (document.logaloga.email.value.substring(document.logaloga.email.value.length-3,document.logaloga.email.value.length-2) != ".") {
                        dominio = document.logaloga.email.value.substring(document.logaloga.email.value.indexOf("@")+1, document.logaloga.email.value.lastIndexOf("."));
                }
                else {
                        dominio = document.logaloga.email.value.substring(document.logaloga.email.value.indexOf("@")+1, document.logaloga.email.value.length-7);
                }
                document.logaloga.login_username.value = (usuario + "." + dominio);
        }
        else {
                document.logaloga.login_username.value = document.logaloga.email.value;
        }
}

function valida_busca() {

     var Form; 
     Form = document.DaForm;

     if (Form.palavra.value.length == 0) {
	alert("Favor digitar uma categoria para a busca");
        Form.palavra.focus();
        return false;
     }
     if (Form.palavra.value.length < 2) {
	alert("Favor digitar uma palavra para a busca com mais de 2 letras");
        Form.palavra.focus();
        return false;
     }
     return true;
}

function checa(nform) {
	if (nform.newsmail.value == "") {
		alert("Informe seu e-mail.");
		nform.newsmail.focus();
		nform.newsmail.select();
		return false;
	} else {
		prim = nform.newsmail.value.indexOf("@")
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmail.select();
			return false;
		}
		if(nform.newsmail.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.newsmail.focus();
			nform.newsmailmail.select();
			return false;
		}
	}
		return true;
}

function Indica() {
    window.open('indica.htm', 'janela1', 'scrollbars=yes,toolbar=no,scrolling=yes,location=no,directories=no,status=no,menubar=no,resizable=no,top=2,width=460,height=500,left=330');
}

function submit_form(destiny) {
	document.theform.action = destiny;
	document.theform.submit();
}

function createWindow(url, WinName, theWidth, theHeight){
	var winLeft = (screen.width - theWidth) / 2;
	var winTop = (screen.height - theHeight) / 2;
	window.open(url, WinName, 'titlebar.maximize=no, scrollbars=no, resizable=no, width=' + theWidth + ', height=' + theHeight + ', left=' + winLeft + ', top=' + winTop);
	window.open(url, WinName, 'titlebar.maximize=no, scrollbars=no, resizable=no, width=' + theWidth + ', height=' + theHeight + ', left=' + winLeft + ', top=' + winTop);
}

function createScrollingWindow(url, WinName, theWidth, theHeight){
        var winLeft = (screen.width - theWidth) / 2;
        var winTop = (screen.height - theHeight) / 2;
        window.open(url, WinName, 'titlebar.maximize=no, scrollbars=yes, resizable=no, width=' + theWidth + ', height=' + theHeight + ', left=' + winLeft + ', top=' + winTop);
        window.open(url, WinName, 'titlebar.maximize=no, scrollbars=yes, resizable=no, width=' + theWidth + ', height=' + theHeight + ', left=' + winLeft + ', top=' + winTop);
}


function num_month(month){
	switch(month){
		case "Janeiro":
			return "01";
			break;
		case "Fevereiro":
			return "02";
			break;
		case "Março":
			return "03";
			break;
		case "Abril":
			return "04";
			break;
		case "Maio":
			return "05";
			break;
		case "Junho":
			return "06";
			break;
		case "Julho":
			return "07";
			break;
		case "Agosto":
			return "08";
			break;
		case "Setembro":
			return "09";
			break;
		case "Outubro":
			return "10";
			break;
		case "Novembro":
			return "11";
			break;
		case "Dezembro":
			return "12";
			break;
	}
}

function make_calendar(baselink, usrdate, usrmonth, usryear, wname){
	monthnames = new Array(
		"Janeiro",
		"Fevereiro",
		"Março",
		"Abril",
		"Maio",
		"Junho",
		"Julho",
		"Agosto",
		"Setembro",
		"Outubro",
		"Novembro",
		"Dezembro");
	
	var linkcount=0;
	linkdays = new Array();
	monthdays = new Array(12);
	monthdays[0]=31;
	monthdays[1]=28;
	monthdays[2]=31;
	monthdays[3]=30;
	monthdays[4]=31;
	monthdays[5]=30;
	monthdays[6]=31;
	monthdays[7]=31;
	monthdays[8]=30;
	monthdays[9]=31;
	monthdays[10]=30;
	monthdays[11]=31;

	todayDate=new Date();
	if (usrmonth != "") {
		usrmonth = usrmonth - 1;
	}
	if (usrdate == 0) {
		usrdate = todayDate.getDate();
	}
	if ((usrmonth != "") && (usryear != "")) {
		todayDate=new Date(usryear,usrmonth,usrdate);
	}
	thisday=todayDate.getDay();
	thismonth=todayDate.getMonth();
	thisdate = todayDate.getDate();
	
	thisyear=todayDate.getYear();
	thisyear = thisyear % 100;
	thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));

	//document.write("Dia de hoje: " + thisdate + "<br>");
	
	if (((thisyear % 4 == 0) && !(thisyear % 100 == 0)) || (thisyear % 400 == 0)) 
		monthdays[1]++;

	startspaces=thisdate;
	while (startspaces > 7) 
		startspaces-=7;

	startspaces = thisday - startspaces + 1;
	if (startspaces < 0) 
		startspaces+=7;
	document.write("<table width=\"10%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">");
    document.write("    <tr align=\"center\">  ");
    document.write("      <td width=\"13%\" bgcolor=\"#f5fbff\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">Dom</font></td> ");
    document.write("      <td width=\"17%\" bgcolor=\"#f5fbff\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">Seg</font></td> ");
    document.write("      <td width=\"13%\" bgcolor=\"#f5fbff\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">Ter</font></td> ");
    document.write("      <td width=\"15%\" bgcolor=\"#f5fbff\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">Qua</font></td> ");
    document.write("      <td width=\"13%\" bgcolor=\"#f5fbff\"><font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">Qui</font></td> ");
    document.write("      <td width=\"14%\" bgcolor=\"#f5fbff\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">Sex</font></td> ");
    document.write("      <td width=\"15%\" bgcolor=\"#f5fbff\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">Sab</font></td> ");
    document.write("    </tr> ");


    document.write("    <tr align=\"center\">  ");
	for (s=0;s<startspaces;s++) {
		document.write("<td width=\"13%\" bgcolor=\"#e5e1ee\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"> </td>");
	}
	count=1;
	while (count <= monthdays[thismonth]) {
		for (b = startspaces; b<7; b++) {
			linktrue=false;

			//Aqui abre-se a coluna do dia
			document.write("      <td width=\"13%\" bgcolor=\"#e5e1ee\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"> ");
			//Monta o link correspondente a cada dia...
			if (count <= monthdays[thismonth]) {
				url = baselink + "dia=" + count + "&mes=" + num_month(monthnames[thismonth]) + "&ano=" + thisyear;
				if(wname == ""){
					url = "<a class=\"calend\" href=\"" + url + "\">"
				}
				else{
					url = "<a class=\"calend\" href=\"javascript:createScrollingWindow('" + url + "', '" + wname + "', 640, 480);\">"
				}
				document.write(url);
				if(usrdate <= 0){
					if (count==thisdate) {
						document.write("<font color=\"#336633\">" + count + "</font>");
					}
					else{
						document.write(count);
					}
				}
				else{
					if (count==usrdate) {
						document.write("<font color=\"009868\">" + count + "</font>");
					}
					else{
						document.write(count);
					}
				}
				document.write("</a>");
			}
			else {
				document.write("&nbsp;");
			}

			//Fecha a coluna e o dia, e continua...
			document.write("		</td>");
			count++;
		}
		document.write("	</tr>");
	    document.write("    <tr align=\"center\">  ");
		startspaces=0;
	}
	
	document.write("	<tr align=\"center\" bgcolor=\"#f5fbff\"> ");
    document.write("      <td colspan=\"7\"> ");
    document.write("        <div align=\"right\"><font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#999999\"><b>" + monthnames[thismonth] + "/" + thisyear + "</b></font></div>");
    document.write("      </td>");
    document.write("    </tr>");
	document.write("</table>");
}
