//Funções copiadas de http://becomeinteractive.co.uk
// Standard functions - derived from the Dithered 1k JS library: http://www.dithered.com/javascript/
d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;var ie=d.all?1:0;var w3c=d.getElementById?1:0;
//d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;px='px';
//function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
//if(ie) w3c = 0;
// Get element
function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}g=(f)?f:d;if(g.all)return g.all[e];return g.getElementById(e);}
// Show element
function sE(e){l?e.visibility='show':e.style.visibility='visible';}
// Hide element
function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}
// Get X position
function gX(e){if(l){return e.left;}else if(ie){return e.style.pixelLeft;}else{return parseInt(e.style.getPropertyValue('left'));}}
function gX2(e){if(l){return e.left;}else {var curleft = 0;if (e.offsetParent){while(e.offsetParent){curleft += e.offsetLeft;e = e.offsetParent;}}else if(e.x)curleft += e.x;return curleft;}}
// Get Y position
function gY(e){if(l){return e.top;}else if(ie){return e.style.pixelTop;}else{return parseInt(e.style.getPropertyValue('top'));}}
function gY2(e){if(l){return e.top;}else {var curtop = 0;if(e.offsetParent){while(e.offsetParent){curtop += e.offsetTop;e = e.offsetParent;}}else if(e.y)curtop += e.y;return curtop;}}
// Get width
function gW(e){if(l) return e.clip.width; else return e.offsetWidth;}
// Get height
function gH(e){if(l) return e.clip.height; else return e.offsetHeight;}
// Set depth
function sZ(e,z){l?e.zIndex=z:e.style.zIndex=z;}
// Set X position
function sX(e,x){l?e.left=x:op?e.style.pixelLeft=x:e.style.left=x;}
// Set Y position
function sY(e,y){l?e.top=y:op?e.style.pixelTop=y:e.style.top=y;}
// Set width
function sW(e,w,m){if(!m)m=0;l?e.clip.width=w:op?e.style.pixelWidth=w:e.style.width=w-m;}
// Set height
function sH(e,h,m){if(!m)m=0;l?e.clip.height=h:op?e.style.pixelHeight=h:e.style.height=h-m;}
// Set layer clipping area
function sC(e,t,r,b,x){l?(X=e.clip,X.top=t,X.right=r,X.bottom=b,X.left=x):e.style.clip='rect('+t+' '+r+' '+b+' '+x+')';}
// Write HTML
function wH(e,h){if(l){Y=e.document;Y.open();Y.write(h);Y.close();}else if(e.innerHTML){e.innerHTML='';e.innerHTML=h;}}
// Copy HTML content from element e1 into e2
function cH(e1,e2){wH(e2,e1.innerHTML);}
// Move layer
function mL(e,x,y){sX(e,x);sY(e,y);}
// Resize layer
function rL(e,w,h,m){if(ie)m=0;sW(e,w,m);sH(e,h,m);}
// Browser width
function bW(){if(!ie) return window.innerWidth;else return document.body.clientWidth;}
// Browser height
function bH(){if(!ie) return window.innerHeight;else return document.body.clientHeight;}
// Roll image over
function rO(n,i,s){e=gE(n);e.src=(s==1)? i+"_over.gif": i+".gif";}
// Swap image
function sI(n,i){e=gE(n);e.src=i;}
// Preload images
function pI(){d.pli=new Array();var i,j=d.pli.length,a=pI.arguments;for(i=0;i<a.length;i++) if(a[i].indexOf("#")!=0){d.pli[j]=new Image;d.pli[j++].src=a[i];}}
// Change object class
function cC(n,c){e=gE(n);e.className=c;}
// Change object display (more than just hiding)
function dE(e,s){if(typeof e=="string")e=gE(e);if(!s)s=(e.style.display=='')?-1:1;e.style.display=(s==1)?'':'none';}

////
/*
  Easing Equations v1.4
  March 19, 2003
  (c) 2003 Robert Penner - Use freely, giving credit where you can.

  http://www.robertpenner.com/
*/

///////////// QUADRATIC EASING: t^2 ///////////////////
// t: current time, b: beginning value, c: change in value, d: duration
// t and d can be in frames or seconds/milliseconds

// quadratic easing in/out - acceleration until halfway, then deceleration
Math.easeInOutQuad = function (t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t + b;
	return -c/2 * ((--t)*(t-2) - 1) + b;
};


///////////// QUINTIC EASING: t^5  ////////////////////
// t: current time, b: beginning value, c: change in value, d: duration
// t and d can be frames or seconds/milliseconds

// quintic easing out - decelerating to zero velocity
Math.easeOutQuint = function (t, b, c, d) {
	return c*((t=t/d-1)*t*t*t*t + 1) + b;
};


/////////// BACK EASING: overshooting cubic easing: (s+1)*t^3 - s*t^2  //////////////
// back easing in - backtracking slightly, then reversing direction and moving to target
// t: current time, b: beginning value, c: change in value, d: duration, s: overshoot amount (optional)
// t and d can be in frames or seconds/milliseconds
// s controls the amount of overshoot: higher s means greater overshoot
// s has a default value of 1.70158, which produces an overshoot of 10 percent
// s==0 produces cubic easing with no overshoot
Math.easeInBack = function (t, b, c, d, s) {
	if (typeof s == "undefined") s = 1.70158;
	return c*(t/=d)*t*((s+1)*t - s) + b;
};

// back easing out - moving towards target, overshooting it slightly, then reversing and coming back to target
Math.easeOutBack = function (t, b, c, d, s) {
	if (typeof s == "undefined") s = 1.70158;
	return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
};

// back easing in/out - backtracking slightly, then reversing direction and moving to target,
// then overshooting target, reversing, and finally coming back to target
Math.easeInOutBack = function (t, b, c, d, s) {
	if (typeof s == "undefined") s = 1.70158;
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
};


//Hexa Sistemas funcões criadas para o site da Prefeitura Municipal de Bombinhas
//(c) Hexa Sistemas 2003
//created by Cristian Manoel Pinheiro
//e-mail: cr09@terra.com.br
//October 7, 2003

function gwinY(name){
	var result = '';
	var win = eval(name);
	if(ie){
		result = win.screenTop;
	}
	else{
		result = win.screenY;
	}
	return result;
}

function gwinX(name){
	var result = '';
	var win = eval(name);
	if(ie){
		result = win.screenLeft;
	}
	else{
		result = win.screenX;
	}
	return result;
}

function h_parseInt(value){
	var regexp = /[a-z]*/gi;
	var result = new String(value);
	result = result.replace(regexp,'');
	return parseInt(result.valueOf());
}

function anim(name,kind){

	if(typeof kind == 'undefined') kind = 1;

	//primeiro bloco
	var o = bmbmenu[name];
	var e = gE(name);//pega objeto
	var ease_fn = (!o.f) ? tween_ease_fn : o.f;//Seleciona função
	var v = (!o.v) ? delay : o.v;
	var current = false;

	//segundo bloco

	if(typeof o.current == 'undefined') o.current = true;
	if(typeof o.t == 'undefined') o.t = 0;
	if(!o.d) o.d = duration;
	if(typeof o.p == "undefined") o.p = 0;
	if(typeof o.x == "undefined") o.x = (kind == 1) ? gX2(e) : gX(e);
	if(typeof o.y == "undefined") o.y = (kind == 1) ? gY2(e) : gY(e);
	if(!o.h) o.h = gH(e);
	if(!o.w) o.w = gW(e);
	if(!o.tw) o.tw = o.w;
	if(!o.th) o.th = o.h;
	if(o.status){
		o.tcy = o.cy;
	}
	else{
		o.tcy = o.cy - o.cy;
	}

	//window.clearTimeout(o.timer);

	if(typeof o.tx != "undefined") {
		sX(e,Math.floor(Math[ease_fn](o.t,o.x,o.tx-o.x,o.d)));
		current = true;
	}
	if(typeof o.ty != "undefined") {
		sY(e,Math.floor(Math[ease_fn](o.t,o.y,o.ty-o.y,o.d)));
		current = true;
	}
	if(typeof o.th != 'undefined'){
		sH(e,Math.floor(Math[ease_fn](o.t,o.h,o.th-o.h,o.d)));
		current = true;
	}
	if(typeof o.tw != 'undefined'){
		sW(e,Math.floor(Math[ease_fn](o.t,o.w,o.tw-o.w,o.d)));
		current = true;
	}
	if(typeof o.cy != "undefined"){
		//calcula nova area de clip
		if(o.cy < 1) o.cy = 1;
		var nw = Math.floor(Math[ease_fn](o.t,o.cy,o.tcy-o.cy,o.d))
		sC(e,0,o.w,nw,0)
		current = true;
	}
	o.t++;

	if( !current ) o.t = o.d;

	if( o.t <= o.d ){
		o.timer = window.setTimeout("anim('"+name+"')",v);
		//window.status += '1';
		return;
	}

	if( o.p || o.cbf ){
		if( o.cbf ){
			if(!o.cbfd) o.cbfd = v;
			o.timer = window.setTimeout(o.cbf,o.cbfd);
			return;
		}
	}
}

function show_hide_data(obj,to,action){

	n = gE(to);
	o = gE(obj);

	//pega infos
	ny = gY2(n);//posição y
	nh = gH(n);//altura
	ow = gW(o);

	//seta posição
	if(typeof document.body.offsetWidth == 'undefined'){
		w_width = document.width;
	}
	else{
		w_width = document.body.offsetWidth;
	}
	//alert(document.body.offsetWidth);
	sX(o,(Math.ceil(w_width/2) - Math.ceil(ow/2)));
	sY(o,ny + nh);

	if(typeof action == 'undefined')
		{action = 'hide';}

	if(action == 'show'){
		sE(o);
	}

	if(action == 'hide'){
		hE(o);
		return false;
	}

}

function url(url){
	window.location.href = url;
}

function setactual(name){
	actual = name;
	window.status = name;
	return;
}

function resizeWindow(name,posx,posy,width,height){
 eval(name).resizeTo(width + 10,height + 30);
 eval(name).moveTo(posx,posy);
}

function imageview(id){
	//seta janela
	var options = "dependent=yes,directories=no,location=no,menubar=no,\npersonalbar=no,resizable=no,scrollbars=no,status=no,tollbar=no,width=100,height=100";
	//alert(options);
	if(typeof imagem == 'undefined')
	{
		imagem = window.open('image.php?id='+id,'imagem',options);
	}
	else
	{
		imagem.close();
		imagem = window.open('image.php?id='+id,'imagem',options);
	}
	return false;
}

function janela(url,nome,options){
	if(typeof options == "undefined"){
		options = "dependent=1,directories=1,location=0,menubar=0,personalbar=0,resizable=1,scrollbars=1,status=0,toolbar=1,width=640,height=460";
	}
	janela - window.open(url,nome,options);
	return;
}

function border(w,color1,color2,h1,h2){
	result ='<table width="'+w+'" cellspacing="0" border="0" cellpadding="0" align="center">\n';
	if(h1!=null)
		{result+='<tr><td bgcolor="'+color1+'" height="'+h1+'"><spacer type=block height="'+h1+'"></td></tr>';}
	else
		{result+='<tr><td bgcolor="'+color1+'" height=1 width="100%"><spacer type=block height=1 width="100%"></spacer></td></tr>';}
	if(h2!=null)
		{result+='<tr><td bgcolor="'+color2+'" height="'+h2+'"><spacer type=block height="'+h2+'"></td></tr>';}
	else
		{result+='<tr><td bgcolor="'+color2+'" height=1><spacer type=block height=1></spacer></td></tr>';}
	result+='</table>';
	document.write(result);
}

//zoomImage = new Object();
zoomImage.obj = Array();
zoomImage.factor = 0.10;
zoomImage.delay = 1000;
zoomImage.timer = 10;

function zoomImage(name,ini,end)
{
	if(typeof zoom_image[name] == 'undefined'){
		setImage(name,ini,end);
	}

	//alert(typeof zoom_image[name]);
	obj = zoom_image[name];
}

function loader(obj){
	hE(gE(obj));
}

//Variaveis
var bmbmenu = Array();//array contendo objetos relativos aos menus
var delay = 10;//delay para animação
var duration = 20;//duração da animação
var ease_fn = "easeOutQuint";
var count;
var timer
var actual = '';
