﻿var left = 0;

function MenuEff(obj,bool,url){
    obj.firstChild.src = obj.firstChild.src.split(url)[0]+url+((bool)?"_on":"")+obj.firstChild.src.split(url)[1];
}

function resize(obj){
    var h = (navigator.appName != "Microsoft Internet Explorer")?window.innerHeight:document.body.clientHeight;    
    obj.style.height = (h - 166) + "px";
    obj.scrolling = (navigator.appName != "Microsoft Internet Explorer")?"auto":"yes";
}

function url( src ){
    document.getElementById('conteudo').src = src;
}

function init(){
    var index = ( navigator.appName == "Microsoft Internet Explorer" )? 0 : 1;    
    if( document.getElementById('categorias') ) document.getElementById('categorias').childNodes[ index ].style.marginLeft = left + "px";    
    
    var mnu = document.getElementById( 'tblMenu' );
    var pag = document.getElementById( 'tblMain' );
    
    var h1 = document.body.clientHeight;
    var h2 = pag.clientHeight;
	var h4 = mnu.clientHeight + 10;
	
    mnu.style.height = Math.max( Math.max( h1 - 65, h4 ), h2 ) + "px";
    pag.style.height = Math.max( Math.max( h1 - 65, h4 ), h2 - 65 ) + "px"; 	
}

function moveback(){
    var index = ( navigator.appName == "Microsoft Internet Explorer" )? 0 : 1;    
    var _obj1 = document.getElementById('categorias');    
    var _obj2 = _obj1.childNodes[ index ];
        
    var _w1 = value(_obj1.style.width);
    var _w2 = value(_obj2.style.width);
    
    var _min = 0;
    var _max = _w1 - _w2;    
            
    if( value(_obj2.style.marginLeft) >= _max + 211 ){
        document.getElementById("setanext").style.display = "block";
        left = value(_obj2.style.marginLeft) - 211;
        _obj2.style.marginLeft = left + "px";            
    }else{
        document.getElementById("setaback").style.display = "none"; 
    }    
}

function value(str){
    return parseFloat(str.split('px')[0]);
}

function movenext(){
    var index = ( navigator.appName == "Microsoft Internet Explorer" )? 0 : 1;
    var _obj1 = document.getElementById('categorias');
    var _obj2 = _obj1.childNodes[ index ];    
    var _w1 = value(_obj1.style.width);
    var _w2 = value(_obj2.style.width);
    
    var _min = 0;
    var _max = _w1 - _w2;
    
    if( value(_obj2.style.marginLeft) <= _min - 211 ){    
        document.getElementById("setaback").style.display = "block";
        left = value(_obj2.style.marginLeft) + 211;
        _obj2.style.marginLeft = left + "px";
    }else{
        document.getElementById("setanext").style.display = "none";
    }    
}

