  function show(theName) {
    obj = document.getElementById(theName);
    cl = obj.className.replace('hide','show');
    obj.className = cl;
  }

  function hide(theName) {
    obj = document.getElementById(theName);
    cl = obj.className.replace('show','hide');
    obj.className = cl;
  }

  function swapSub(theId) {
    hideAll();
    sub = document.getElementById('sub_' + theId);
    mai = document.getElementById('plus_' + theId);
    if (sub.className == 'show') {
      sub.className = 'hide';
      mai.src = 'images/shop/menu_open.gif';
    } else {
      sub.className = 'show';
      mai.src = 'images/shop/menu_close.gif';
    }
  }
  
  function hideSub(theId) {
    sub = document.getElementById('sub_' + theId);
    mai = document.getElementById('plus_' + theId);
    sub.className = 'hide';
    mai.src = 'images/shop/menu_open.gif';
  }
  
  function changePhoto(theId,theNum) {
    for (i = 1; i <= 3 ; i++) {
      img = document.getElementById('img_' + i);
      if (img) img.className = 'photo';
    }
    pho = document.getElementById('photo');
    img = document.getElementById('img_' + theNum);
    mor = document.getElementById('more_photos');
    pho.style.backgroundImage = 'url(images/product/' + theId + '_' + theNum + '.jpg)';
    img.className = 'photo_act';
    mor.className = 'hide';
  }

  function swapGender(theId) {
    gen = document.getElementById('gender');
    if (gen.value != theId) {
      co = document.getElementById('gender_' + theId);
      if (co.className == 'gender') co.className = 'gender_act';
      else co.className = 'gender';
    }
  }

  function selectGender(theId) {
    gen = document.getElementById('gender');
    old = gen.value;
    gen.value = theId;
    if (old != theId) {
      co = document.getElementById('gender_' + old);
      co.className = 'gender';
    }
    //document.theForm.submit();
  }
  
  function popInfo(pId) {
    po1 = document.getElementById('pop');
    ajax('template/pop.php?p=' + pId,'po1');
    po1.className = 'show';
    foo = document.getElementById('footer');
    alert(foo);
  }
  
  function getScreenWidth() {
    isNetscape = (navigator.appName == "Netscape");
    available = (isNetscape) ? window.innerWidth : document.body.clientWidth;
    return available;
  }
  
  function setHeights(corr) {
    con = document.getElementById('content');
    men = document.getElementById('submenu');
    pro = document.getElementById('product');
    foo = document.getElementById('footer');
    rig = document.getElementById('right');
    po1 = document.getElementById('pop');
    tex = document.getElementById('text');
    h = false;
    if (tex) {
      h = tex.offsetHeight;
      if (h <= 450) h = 450;
      text.style.height = h + 'px';
      foo.style.top = (h + 196) + 'px';
      ph = 0;
    } else if (pro) {
      h = pro.offsetHeight;
      if (h <= 435) h = 435;
      pro.style.height = (h) + 'px';
      foo.style.top = (h + 210) + 'px';
    } else {
      if (po1) {
        ph = po1.offsetHeight;
        if (ph < 372) ph = 372;
        po1.style.height = ph + 'px';
      } else ph = 0;
      if (con) {
        ph = 0;
        default_top = 607;
        if (!corr) corr = 0;
        h = Math.max(con.offsetHeight + 40,ph + 220);
        foo.style.top = (h - corr) + 'px';
        default_height = 300 + corr;
      } else foo.style.top = (default_top - corr) + 'px';
    }
    if (men.offsetHeight < 440) mh = 440;
    else mh = men.offsetHeight;
    mh.style.height = mh + 'px';
    w = getScreenWidth();
    rig.style.height = Math.round(foo.style.top.replace('px','') - 8) + 'px';
    rig.style.width = Math.round(w - 1000) + 'px';
      
  }
  function sizeMenu() {
    men = document.getElementById('menu');
    if (men.offsetHeight < 440) mh = 440;
    else mh = men.offsetHeight;
    men.style.height = mh + 'px';  
  }
  
  function setHome() {
    pro = document.getElementById('product');
    if (pro.offsetHeight > 165) {
        //alert(hom.offsetHeight);
        fla = document.getElementById('flashcontainer');
        bes = document.getElementById('bestseller');
        con = document.getElementById('content');
        fla.style.top = (pro.offsetHeight + 180) + 'px';
        h = (Math.round(fla.style.top.replace('px','')) + 103);
        bes.style.height = h + 'px';
        con.style.height = (h + 166) + 'px';
        positionFooter(pro.offsetHeight,2);
    }
  }
    
    
  
  function positionFooter(corr,distr) {
    w = getScreenWidth();
    loc = document.getElementById('location');
    foo = document.getElementById('footer');
    pro = document.getElementById('product');
    rig = document.getElementById('right');
    h = pro.offsetHeight;
    if (distr == 'undefined') {
        pro.style.height = (h + corr) + 'px';
    } else if (distr == 2) {
        corr = corr + 99;
        pro.style.height = (corr + 185) + 'px';
    }
    foo.style.top = (h + 210 + corr) + 'px';
    rig.style.height = Math.round(foo.style.top.replace('px','') - 8) - corr + 'px';
    rig.style.width = Math.round(w - 1000) + 'px';
  }



