 
function d(el_id) {return document.getElementById(el_id);}

$(document).ready(function()
{
   //d("menu").innerHTML=getMenuXML();
   inner_expandmenus();
});

function inner_expandmenus(){
  setTimeout('move_up()', 130);
    expandingMenu(0);
    expandingMenu(1);
    expandingMenu(2);
    expandingMenu(3);
    expandingMenu(4);
    expandingMenu(5);
    expandingMenu(6);
    expandingMenu(7);
    expandingMenu(8);
    expandingMenu(9);
    expandingMenu(10);
    expandingMenu(11);
    expandingMenu(12);
    expandingMenu(13); 
}


function expandingMenu(num) {
    var speed = 500;
    
    var item_title = $("#menu ul").eq(num).children(":first");
    var items = $("#menu ul").eq(num).children().filter(function (index) { return index > 0; });
    
    /* hide items if not active */
    if (items.is(".active") == false) {
        items.hide();
    }

    /* add click functions + pointer to title */
    item_title.css({cursor:"pointer"}).toggle(
        function () {
            items.show(speed);
        }, function () {
            items.hide(speed);
        }
    )
}

function move_up() 
{
    var move = getCookie('move');
    if (move == '') return false;
    
    var menu = document.getElementById('menu');
    menu.scrollTop = move;
    
    // should i delete the cookie here
    // or reset it to zero
}


function do_click()
{
    moved = document.getElementById('menu');
    moved = moved.scrollTop;
    
    // record the cookie
    setCookie('move', moved, 1);
}

function getCookie(c_name)
{
    if (document.cookie.length > 0)
    {
        c_start = document.cookie.indexOf(c_name + "=")

        if (c_start != -1)
        { 
            c_start = c_start + c_name.length + 1 
            c_end = document.cookie.indexOf(";", c_start)
            
            if (c_end == -1) c_end = document.cookie.length
            return unescape(document.cookie.substring(c_start, c_end))
        } 
    }
    return 0;
}

function setCookie(c_name,value,expiredays)
{
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
    ((expiredays==null) ? "" : ";expires=" + exdate.toGMTString()) + '; path=/';
}


function gotoReport(rpt){
      eval(parent.location='index.php?key_id='+rpt);
 
 }


function getPage(file){
  // this.style.color="white";
//  d("maincontainer").innerHTML=getPagefromXML(file+'.xml');
 // getPageAjax(file);
  gotoReport(file);
  do_click() ;
  return false;
}
 
function getPageAjax(moveid){
     //get content
        d("action_id").value="TALCGET";
        d("key_id").value=moveid;
        var df = getInputElement("PHOTOGET");
        var controls=GetRequestInputValues(df);
        $.post("talc.php", controls, 
            function(data){
                d("maincontainer").innerHTML=data;
                
            }
        );
 }   
 
 function getInputElement(actid){
           return new Array("action_id", "key_id");
  }   
  
  
  function GetRequestInputValues(df){
        
        var controls = new Array();
        i=0; j=0;        
        for(i=0;i < df.length;i++)     {
            child_id = df[i];
            if (child_id) {
                var o = new Object();
                o.name = child_id;
                o.value =d(child_id).value;
                controls[j++] = o;
            }
        }
       return controls;
 } 