

//IFRAME CODE TO CONTROL THE WINDOW CONTENTS NAD THE HOIGHT OF THE FRAME
function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 0 + "px";
  }
}
function loadIframe(iframeName, url) {

  if ( window.frames[iframeName] ) {

    window.frames[iframeName].location = url;   

    return false;

  }

  else return true;

}


function Search_Shop_Click(){
	
	document.getElementById('content').src  = "<%=ROOTURL%>/EzShop_2005/EzShop_Stock_List.asp?Mode=SearchResult&BRA_ID=<%=BRA_ID%>&FRC_ID=<%=FRC_ID%>&SHOW_MENU=FALSE&USE_IFRAME=TRUE&Search_Keywords=" + document.getElementById('Search_Keywords').value 

}


// This is the code for the drop down menus for the master catagories.


function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// LIST ALL SHOW/HIDE ELEMENT IDS HERE


menus_array = new Array ('HELMETS', 'CLOTHING', 'GLOVES', 'CA');
menus_status_array = new Array ();// remembers state of switches
img_close2 = 'images/open_cat.jpg';
img_open2 = 'images/open_cat.jpg';

function showHideSwitch (theid) {
  if (document.getElementById) {
    var switch_id = document.getElementById(theid);
    var imgid = theid+'Button';
    var button_id = document.getElementById(imgid);
    if (menus_status_array[theid] != 'show') {
      button_id.setAttribute ('background', img_close2);
      switch_id.className = 'showSwitch2';
	  menus_status_array[theid] = 'show';
	  document.cookie = theid+'=show';
    }else{
      button_id.setAttribute ('background', img_open2);
      switch_id.className = 'hideSwitch2';
	  menus_status_array[theid] = 'hide';
	  document.cookie = theid+'=hide';
    }
  }
}
function resetMenu () { // read cookies and set menus to last visited state
  if (document.getElementById) {
    for (var i=0; i<menus_array.length; i++) {
      var idname = menus_array[i];
      var switch_id = document.getElementById(idname);
      var imgid = idname+'Button';
      var button_id = document.getElementById(imgid);
      if (getCookie(idname) == 'show') {
	    button_id.setAttribute ('background', img_close2);
        switch_id.className = 'showSwitch2';
	    menus_status_array [idname] = 'show';
	  }else{
	    button_id.setAttribute ('background', img_open2);
        switch_id.className = 'hideSwitch2';
	    menus_status_array [idname] = 'hide';
	  }
    }
  }
}

function CloseMe(){
parnet.document.location = '';
window.close();
}


//IFRAME CODE FOR THE HEIGHT OF THE FRAME

function goSetHeight() {
  if (parent == window) return;
  else parent.setIframeHeight('content');
}
