// Klarus Sistemas
function ajax(){
	this.HTTPObject=function(){
		var objhttp=null;
		try{
			objhttp=new XMLHttpRequest;
		}catch(e){
			try{
				objhttp=new ActiveXObject("Msxml2.XMLHttp");
			}catch(ex){
				try{
					objhttp=new ActiveXObject("Microsoft.XMLHttp");
				}catch(exc){
					alert('Recursos de Asynchronous Javascript And XML(AJAX) não disponíveis!');
				}
			}
		}
		return objhttp;
	}
	this.sendAndLoad=function(page,method,params){
		var tis=this;
		var ajx=this.HTTPObject();
		if(!ajx)return;
		if(method!='GET' && method!='POST')method='GET';
		ajx.open(method,page,true);
		ajx.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		ajx.setRequestHeader("ENCODING", "ISO-8859-1");
		ajx.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
		ajx.onreadystatechange=function(){
			var obj=tis;
			if (ajx.readyState==4){
				obj.status=ajx.status;
				if(ajx.status==200){
					obj.response.Text=ajx.responseText;
					obj.response.XML=ajx.responseXML;
					obj.sucess=true;
				}else{
					obj.response.Text=ajx.responseText;
					obj.sucess=false;
				}
				obj.onLoad(obj.onLoadParams);
			}
			
		}
		ajx.send(params);
	}
	this.sucess=false,
	this.onLoadParams=null,
	this.onLoad=function(){},
	this.response={
		Text:'',
		XML:''
	}
	this.status=0;
	this.name='[Object]:AJAX';
}
function indicar(prm){
	var dv=document.getElementById('layer_indique');
	if(dv)return;
	dv=document.createElement('DIV');
	dv.id='layer_indique';
	with(dv.style){
		position='absolute';
		top=(((screen.height/2)-100)+document.body.scrollTop)+'px';
		left=((screen.width/2)-250)+'px';
		width='500px';
		height='300px';
	}
	var html='<table cellpadding="0" cellspacing="0" border="0">'
	html+='<tr><td width="24"><img src="images/sombra_cse.png"></td><td width="450" background="images/sombra_s.png"></td><td width="24"><img src="images/sombra_csd.png"></td></tr>'
  html+='<tr><td background="images/sombra_e.png"></td><td height="250" bgcolor="#FFFFFF" valign="top"><div align="right"><img src="images/btn_close_layer.gif" alt="Fechar" title="Fechar" onClick="document.body.removeChild(document.getElementById(\'layer_indique\'))"></div><iframe width="450" height="250" src="indicar.asp?'+prm+'" frameborder="0"></iframe></td><td background="images/sombra_d.png"></td></tr>'
  html+='<tr><td><img src="images/sombra_cie.png"></td><td background="images/sombra_i.png"></td><td><img src="images/sombra_cid.png"></td></tr></table>';
	dv.innerHTML=html;
	document.body.appendChild(dv);
}
function imprimir(){
	var pa=document.getElementById('print_area');
	if(!pa)return;
	var html='<html>';
	html+='<head><title>Dietadiet</title><link rel="stylesheet" type="text/css" href="estilo.css"></head>';
	html+='<body>'+pa.innerHTML+'</body>';
	html+='</html>';
	var pp=open('','PRINT','width=600,height=400,scrollbars=yes');
	if(!pp){
		alert('Um bloqueador de popups está impedindo o site de disponibilizar a matéria para impressão!\nDesative-o temporariamente e tente novamente.');
		return;
	}
	pp.document.open();
	pp.document.write(html);
	pp.document.close();
	pp.focus();
	pp.print();
}
var youtubevideo={
	tamanhos:new Array((new Array(320,265)),(new Array(425,344)),(new Array(480,385)),(new Array(640,505))),
	atual:0,
	resizing:false,
	operacao:null,
	aumentar:function(){
		if(this.atual>=2)return;
		if(this.resizing)return;
		this.operacao=true;
		this.atual+=1;
		this.resizeEfect();
	},
	diminuir:function(){
		if(this.atual<=0)return;
		if(this.resizing)return;
		this.operacao=false;
		this.atual-=1;
		this.resizeEfect();
	},
	resizeEfect:function(){
		this.resizing=true;
		var obj=document.getElementById('video_player');
		var emb=document.getElementById('embed_video_player');
		if(!obj){
			alert('Player não encontrado!');
			return;
		}
		var w=parseFloat(obj.width);
		var h=parseFloat(obj.height);
		if(this.operacao){
			w+=10;
			h+=9;
			if(w>this.tamanhos[this.atual][0])w=this.tamanhos[this.atual][0];
			if(h>this.tamanhos[this.atual][1])h=this.tamanhos[this.atual][1];
		}else{
			w-=10;
			h-=9;
			if(w<this.tamanhos[this.atual][0])w=this.tamanhos[this.atual][0];
			if(h<this.tamanhos[this.atual][1])h=this.tamanhos[this.atual][1];
		}
		obj.width=w;
		obj.height=h;
		if(emb){
			emb.width=w;
			emb.height=h;
		}
		if(w != this.tamanhos[this.atual][0] || h != this.tamanhos[this.atual][1])
			setTimeout("youtubevideo.resizeEfect();",50);
		else
			this.resizing=false;
	}
}
function validaEmail(eml){
	if(eml.length<10)return false;
	var valido='abcdefghijklmnopqrstuvwxyz-._@0123456789';
	var k;
	for(k=0;k<eml.length;k++)
		if(valido.indexOf(eml.substr(k,1))<0) return false;
	var a=eml.indexOf('@');
	var d=eml.lastIndexOf('.');
	if(a<0 || a==0 || a==(eml.length-1)) return false;
	if(d<0 || d==0 || d==(eml.length-1)) return false;
	if(d<a)return false;
	a=eml.substr(0,1);
	if(a=='.' || a=='-' || a=='_')return false;
	return true;
}
String.prototype.replaces=function(searchFor,replaceWith,caseSensitive,times){
	if(caseSensitive!=false && caseSensitive!=true) caseSensitive=true
	if(!times)times=0;
	var str=this;
	var pos=str.indexOf(searchFor);
	if(!caseSensitive) pos=str.toUpperCase().indexOf(searchFor.toUpperCase());
	var astr=new Array(2);
	var loops=0;
	while(pos>=0){
		loops++;
		if(pos==0){
			astr[0]='';
			astr[1]=str;
		}else{
			astr[0]=str.substr(0,pos);
			astr[1]=str.substr(pos+searchFor.length,str.length-pos);
		}
		astr[0]+=replaceWith;
		pos=astr[1].indexOf(searchFor);
		if(!caseSensitive) pos=astr[1].toUpperCase().indexOf(searchFor.toUpperCase());
		if(pos>=0){
			pos+=astr[0].length;
		}
		str=astr[0]+astr[1];
		if(loops==times) break;
	}
	return str;
}
/*
LB
*/
