var iE = document.all ? true : false;

function draw(name, swf, width, height, vars, layout, plus) {
	if(name!=null&&swf!=null) {
		vars = vars!=null ? '?'+vars : '';
		width = width!=null ? width : '100%';
		height = height!=null ? height : '100%';
		
		plus = typeof(plus)=="string" ? plus : '';
				
		layout = layout==true ? ' style="float:left;'+plus+'"' : '';
		
		var fla = '<embed name="'+name+'" src="'+swf+'.swf'+vars+'" quality="high" wmode="transparent" menu="false" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"'+layout+' />'; 
		
		if(iE) fla = '<object name="'+name+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+swf+'.swf'+vars+'"'+layout+' /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" />'+fla+'</object>';
		
		document.write(fla);
	}
}

function formValidate(form, fields) {
	var pass = false;
	if(form!=null) {
		var to_eval = new Array();
		if(fields!=null && typeof(fields)=="string") {
			fields = String(fields).replace(',', '|');
			acept = new RegExp("^("+fields+")$");
			for(var i=0; i<form.elements.length; i++)
				if(acept.test(form.elements[i].name))
					to_eval.push(form.elements[i]);
		} else to_eval = form.elements;
		
		if(to_eval.length>0) {
			for(var i=0; i<to_eval.length; i++) {
				if(to_eval[i].type=="text" && to_eval[i].value==to_eval[i].defaultValue && /^[\s-]*$/.test(to_eval[i].value)) {
					alert("Esse campo precisa ser preenchido corretamente.");
					to_eval[i].focus();
					return false;
				} else if(String(to_eval[i].nodeName).toLowerCase()=="textarea" && /^[\s-]*$/.test(to_eval[i].value)) {
					alert("Esse campo precisa ser preenchido corretamente.");
					to_eval[i].focus();
					return false;
				}
			}
			pass = true;
		}
	}
	
	return pass;
}

function showLocal() {
	var content = '<html><head><title>Localiza&ccedil;&atilde;o</title></head><link title="default" href="./style.css" rel="stylesheet" type="text/css" /><body><a href="javascript:;" onclick="javascript: window.close();"><img src="./imgs/map.jpg" border="0" style="position:absolute;left:0px;top:0px" /></a></body></html>';
	var popup = window.open("./paper.htm", "mapa", "width=685,height=685");
	popup.document.write(content);
	popup.focus();
}

function openImg(file, w, h) {
	var content = '<html><head><title>Localiza&ccedil;&atilde;o</title></head><link title="default" href="./style.css" rel="stylesheet" type="text/css" /><body><a href="javascript:;" onclick="javascript: window.close();"><img src="./photos/'+file+'" border="0" style="position:absolute;left:0px;top:0px" /></a></body></html>';
	var popup = window.open("./paper.htm", "mapa", "width="+w+",height="+h);
	popup.document.write(content);
	popup.focus();
}