// FUN��O PARA MENU DO HEADER
var menuSlider=function(){
	var m,e,g,s,q,i; e=[]; q=8; i=8;
	return{
		init:function(j,k){
			m=document.getElementById(j); e=m.getElementsByTagName('li');
			var i,l,w,p; i=0; l=e.length;
			for(i;i<l;i++){
				var c,v; c=e[i]; v=c.value; if(v==1){s=c; w=c.offsetWidth; p=c.offsetLeft}
				c.onmouseover=function(){menuSlider.mo(this)}; c.onmouseout=function(){menuSlider.mo(s)};
			}
			if(g){
			g=document.getElementById(k); g.style.width=w+'px'; g.style.left=p+'px';
			}
		},
		mo:function(d){
			clearInterval(m.tm);
			if(d){
			var el,ew; el=parseInt(d.offsetLeft); ew=parseInt(d.offsetWidth);
			}
			m.tm=setInterval(function(){menuSlider.mv(el,ew)},i);
		},
		mv:function(el,ew){
			if (g) {
			var l,w; l=parseInt(g.offsetLeft); w=parseInt(g.offsetWidth);
			}
			if(l!=el||w!=ew){
				if(l!=el){var ld,lr,li; ld=(l>el)?-1:1; lr=Math.abs(el-l); li=(lr<q)?ld*lr:ld*q; if(g){ g.style.left=(l+li)+'px' }}
				if(w!=ew){var wd,wr,wi; wd=(w>ew)?-1:1; wr=Math.abs(ew-w); wi=(wr<q)?wd*wr:wd*q; if(g){ g.style.width=(w+wi)+'px'} }
			}else{clearInterval(m.tm)}
}};}();

// SHOW/HIDE DE GENEROS
var state = 'none';

function show(layer_ref) {
	obj = document.getElementById(layer_ref);
	obj.style.display = 'block';
} 

function hide(layer_ref) {
	obj = document.getElementById(layer_ref);
	obj.style.display = 'none';
}


// ACTIVE / DESACTIVE
var activate = 'desactive';

function activate(layer_ref) {
	if (activate == 'active') {
		activate = 'desactive';
	}
	else {
		activate = 'sactive';
	}
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.display = activate");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[layer_ref].display = activate;
	}
	if (document.getElementById &&!document.all) {
		hza = document.getElementById(layer_ref);
		hza.style.display = activate;
	}
} 


function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance, exit, text, characters)
{
  var entranceObj = getObject(entrance);
  var exitObj     = getObject(exit);
  var length      = characters - entranceObj.value.length;
  var strER       = /((http(s)?:\/\/|www\.)[a-z0-9-]+(\.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?)/;

  if ( strUrl = entranceObj.value.match(strER) )
  {
    length = length + strUrl[1].length;
  }
  
  if (length <= 0)
  {
    length = 0;
    text   = '<span class="disable"> '+text+' </span>';

    entranceObj.value = entranceObj.value.substr(0,characters);
  }

  exitObj.innerHTML = text.replace("{CHAR}", length);
}

function ajaxLoader(div,url)
{
    upd = new Ajax.Updater(div,url);
}
