/* javascript for the gss website  */
/* File: gssjs.js                  */
/* Dir : /                         */
/* Vers: 2.03                      */
/* Date: 24/09/2007                */
/* ------------------------------- */
/*   ! !  A T T E N T I O N  ! !   */
/*    SAME FILE FOR GSS & EXPRO    */
/* ------------------------------- */
/* Adapted from boocrossing.com    */
/* Adapted from sellaband.com      */

/* FROM BOOKCROSSING */
/* Menu toggling function and variables  */
/* FROM SELLABAND    */
/* Div toggling functions                */

expires = new Date();
expires.setTime(expires.getTime() + (365 * 24 * 60 * 60 * 1000));

var DOM = (document.getElementById)? true : false;
var OP = (window.opera)? true : false;
var OP5 = (OP && DOM)? true : false;
var NS = (window.outerWidth && !OP)? true : false;
var NS6 = (NS && DOM)? true : false;
var NS4 = (NS && !DOM)? true : false;
var IE = (document.all && !OP)? true : false;
var IE5 = (IE && DOM)? true : false;
var IE4 = (IE && !DOM)? true : false;

function o(i){
    if (NS4) return document.layers[i];
    else if(typeof(i)!='string') return i;
    else if(document.getElementById) return document.getElementById(i);
    else if(document.all) return document.all[i];
    else return null;
};
function hide(x){o(x).style.display='none';};
function show(x){o(x).style.display='block';};
function showhide(x)
{
    var object = o(x);
    if(object.style.display=='none' || object.style.display=='')
        object.style.display='block';
    else
        object.style.display='none';
};

function toggleSubMenu(strMenuID,strServer) {
   mySubMenuDivID='m'+strMenuID;
   myMenuArrowImgID='mi'+strMenuID;
   myObj=GetObjectByID(mySubMenuDivID);
   myImgObj=GetObjectByID(myMenuArrowImgID);
   if(myObj.className=='submenuexpanded') {
     myObj.className='submenu';
     myImgObj.src="/images/menu-arrow-closed-11.gif";
     Set_Cookie(mySubMenuDivID,'0',expires,strServer,"/");
// probably added for sureness
//   Set_Cookie(mySubMenuDivID,'0',expires,null,"/");
   }
   else {
      myObj.className='submenuexpanded';
      myImgObj.src="/images/menu-arrow-open-11.gif";
      Set_Cookie(mySubMenuDivID,'1',expires,strServer,"/");
// probably added for sureness
//    Set_Cookie(mySubMenuDivID,'1',expires,null,"/");
    }
}

function GetObjectByID(strID){
     var Obj;
     if (NS4) Obj = document.layers[strID];
     else if (IE4) Obj = document.all[strID];
     else if (DOM) Obj = document.getElementById(strID);
     return Obj;
}

function Set_Cookie(name,value,expires,domain,path,secure) {
   document.cookie = name + "=" +escape(value) +
      ( (expires) ? ";expires=" + expires.toGMTString() : "") +
      ( (path) ? ";path=" + path : "") + 
      ( (domain) ? ";domain=" + domain : "") +
      ( (secure) ? ";secure" : "");
}

// expandable divs
function expand_div(link, what, expand, minimize) {
    what.style.height="auto";
    link.innerHTML = '<img class="see_all" src="/images/menu-arrow-up-11.gif" width="11" height="11" alt="" /> ' + minimize + ' <img class="see_all" src="/images/menu-arrow-up-11.gif" width="11" height="11" alt="" /></a>';
    link.onclick = function() { collapse_div(link, what, expand, minimize); return false; };
}

function collapse_div(link, what, expand, minimize) {
    what.style.height="";
    link.innerHTML = '<img class="see_all" src="/images/menu-arrow-down-11.gif" width="11" height="11" alt="" /> ' + expand + ' <img class="see_all" src="/images/menu-arrow-down-11.gif" width="11" height="11" alt="" /></a>';

    if (window.scrollTo) {
        // Scroll page to the top of the div
        // First find out how far our div is from the top of the page
        var top = what;
        var offset = top.offsetTop;
        while (top = top.offsetParent) {
            offset += top.offsetTop;
        }
        // And scroll there
        if (offset && offset > 40) {
            window.scrollTo(0, offset - 40);
        }
    }
    link.onclick = function() { expand_div(link, what, expand, minimize); return false; };
}

