$(document).ready(function(){
	$('#menuHome').mouseover(function(){
		$('#menuHome').attr('src','img/menu/home_on.jpg');
	}).mouseout(function(){
		$('#menuHome').attr('src','img/menu/home_off.jpg');
	});
	$('#menuBusca').mouseover(function(){
		$('#menuBusca').attr('src','img/menu/busca_on.jpg');
	}).mouseout(function(){
		$('#menuBusca').attr('src','img/menu/busca_off.jpg');
	});
	$('#menuFale').mouseover(function(){
		$('#menuFale').attr('src','img/menu/faleconosco_on.jpg');
	}).mouseout(function(){
		$('#menuFale').attr('src','img/menu/faleconosco_off.jpg');
	});
	$('#menuInst').mouseover(function(){
		$('#menuInst').attr('src','img/menu/institucional_on.jpg');
	}).mouseout(function(){
		$('#menuInst').attr('src','img/menu/institucional_off.jpg');
	});
});

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_findObj(n, d) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

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 checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this;
}

bw=new checkBrowser();
timSpeed=50;
contHeight=225;

function makeScrollObj(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'										
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;		
	this.height=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.moveIt=moveIt; this.x; this.y;
	this.top=b_gettop										
	return this;
}

function moveIt(x,y){
	this.x=x;this.y=y;
	this.css.left=this.x;
	this.css.top=this.y;
}

function b_gettop(){
	var gleft=(bw.ns4 || bw.ns5) ? eval(this.css.top):eval(this.css.pixelTop);
	return gleft;
}

var altura=0;
var scrollTim;
var active=0;

function scroll(speed){
	clearTimeout(scrollTim)
	way=speed>0?1:0
	if((!way && oScroll[active].top()>-oScroll[active].height+contHeight) || (oScroll[active].top()<0 && way)){
		oScroll[active].css.top= oScroll[active].top()+speed;
		scrollTim=setTimeout("scroll("+speed+")",timSpeed)
	}
}

function noScroll(){
	clearTimeout(scrollTim);
}

function changeActive(num){
	oScroll[active].css.visibility='hidden'
	active=num
	oScroll[active].moveIt(0,0)
	oScroll[active].css.visibility='visible'
}

function scrollInit(){
	oScroll=new Array()
	oScroll[0]=new makeScrollObj('divScroll1','divCont')
		
	oScroll[0].css.visibility='visible'
	oControl=new makeScrollObj('divControl')
	oControl.css.visibility='visible'
}

function OpenPopUp (url, w, left, top, width, height) {
	window.open (url, w,'left=' + left + ', top=' + top + ', width=' + width + ', height=' + height + ', resize=yes, resize=no, scrolling=no, menubar=no, statusbar=no');
}

function OpenDetalhes (id) {
	link = 'detalhes.php?id=' + id;
	OpenPopUp (link, 'detalhes','10','10','900','700');
}

function imprimirDetalhes (id) {
	link = 'imprimir.php?id=' + id;
	OpenPopUp (link, 'detalhes','10','10','800','600');
}

function OpenLancamento (id) {
	link = 'lancamentos.php?id=' + id;
	window.open (link, 'lancamentos','left=10, top=0, width=900, height=700, resize=no, scrolling=yes, scrollbars=yes, menubar=no, statusbar=no');
}

function OpenHotsite (url) {
	window.open (url, 'hotsite','left=1, top=1, width=1, height=1, resize=no, menubar=no, statusbar=no');
}

function SendForm (form) {
	form.submit();
}
