function MM_validateForm() {
//  ---------------------------------------
	if (document.getElementById) {
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		firstField = new Array();
		for (i=0; i<(args.length-2); i+=4) {
			test=args[i+2];
			label = args[i+3];
			val=document.getElementById(args[i]);
			if (val) {
				nm=val.name;
				elInput = val;
				elInput.className = "";
				if ((val=val.value)!="") {
					if (test.indexOf('isEmail')!=-1) {
						p=val.indexOf('@');
						if (p<1 || p==(val.length-1)) {
							errors+='- '+label+' inválido.\n';
							elInput.className = "campoErrado";
							firstField.push(elInput);
						}
					} else if (test!='R') {
						num = parseFloat(val);
						if (isNaN(val)) {
							errors+='- '+label+' deve ser um número válido.\n';
							elInput.className = "campoErrado";
							firstField.push(elInput);
						}
						if (test.indexOf('inRange') != -1) {
							p=test.indexOf(':');
							min=test.substring(8,p);
							max=test.substring(p+1);
							if (num<min || max<num) {
								errors+='- '+label+' deve ser um número entre '+min+' e '+max+'.\n';
								elInput.className = "campoErrado";
								firstField.push(elInput);
							}
						}
					}
				} else if (test.charAt(0) == 'R') {
					errors += '- '+label+' é obrigatório.\n';
					elInput.className = "campoErrado";
					firstField.push(elInput);
				}
			}
		}
		if (errors) {
			alert('Os seguintes erros ocorreram:\n'+errors);
			firstField[0].focus();
		}
		document.MM_returnValue = (errors == '');
	}
}


$(function(){
		   
	$('#galleryNew').after('<ul id="nav">').cycle({
		fx:     'fade',
		speed:  'slow',
		timeout: 0,
		pager:  '#nav',
		
		// callback fn that creates a thumbnail to use as pager anchor
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#"><img src="' + slide.src + '" /></a></li>';
			}
	
	});
	
	
	$('#speedyCycle #box').before('<ul id="links">').cycle({ 
		fx:     'fade',
		speed:		1000,
		timeout:	0,
		cleartype:	1,
		pager:		'#links',
		prev:		'#speedyCycle .prev',
		next:		'#speedyCycle .next',
		pagerAnchorBuilder: function(idx, slide){
			return '<li><a href="#">' + $(slide).find("span").attr("title") +'</a></li>';
			}

	});
	
});


$(document).ready(function(){

		$("#login_username").click(function(){
		
		if($("#login_username").val() == "e-mail@hiway.com.br")
			$("#login_username").val("");   
		});
		
		
		$("#login_username").blur(function(){
		
		if($("#login_username").val() == "")
			$("#login_username").val("e-mail@hiway.com.br");
			
	});
		
		
		$("#secretkey").click(function(){
		
		if($("#secretkey").val() == "senha")
			$("#secretkey").val("");   
		});
		
		
		$("#secretkey").blur(function(){
		
		if($("#secretkey").val() == "")
			$("#secretkey").val("senha");
			
	});
		
	$("#tvwSuporte li a").click(function(){
		if( $(this).parent().find("ul").css("display") == 'none'){
			$(this).parent().find("ul").slideDown("slow");
			$(this).attr("class","on");
		}else{
			$(this).parent().find("ul").slideUp("slow");
			$(this).attr("class","");
		};
	});
		
	
});