﻿  function getQueryValue(name) {
      var value = "";
      if ( (i=location.search.indexOf('?'+name))==-1 && (i=location.search.indexOf('&'+name,3))==-1 )
        return null;
      else
        i += name.length+2;
      if ( (j=location.search.indexOf("&",i))!=-1 )
        value = location.search.substring(i,j);
      else
        value = location.search.substring(i,location.search.length);
      for ( i=0; i<value.length; i++ )
        if ( value.charAt(i)=='+' )
         value = value.substring(0,i)+' '+value.substring(i+1,value.length);
      return unescape(value);
  }

  function loadFlash(swfFile) {
    var fo = new FlashObject(swfFile, "animationName", "1024", "256", "7", "#FFFFFF");
    fo.addParam("allowScriptAccess", "sameDomain");
    fo.addParam("quality", "high");
    fo.addParam("scale", "noscale");
    fo.addParam("loop", "false");
    fo.addParam("bgcolor", "#FFFFFF");
    fo.addParam("wmode","transparent");
    fo.write("story_swf");
  }
  
  function showTitles() {
    with (document) {
      getElementById('story_title_large').innerHTML = titleLargeArray[currIndexForThumbnails];
      getElementById('story_title_small').innerHTML = titleSmallArray[currIndexForThumbnails];
    }
  }
  
  function processHover(control,baseImageName,ext,mode) {
    if (mode == 1) {
      if (control.id == "up_button") {
        if (currIndex > 0) {
          control.src = "images/" + baseImageName + "_hover." + ext;
        }
      }
      if (control.id == "down_button") {
        if (currIndex < storyCount-1) {
          control.src = "images/" + baseImageName + "_hover." + ext;
        }
      }
      if ((control.id == "pageprev_button") || (control.id == "bottom_pageprev_button")) {
        if (currPage > 1) {
          control.src = "images/" + baseImageName + "_hover." + ext;
        }
      }
      if ((control.id == "pagenext_button") || (control.id == "bottom_pagenext_button")) {
        if (currPage < Math.ceil(catalogThumbCount/16)) {
          control.src = "images/" + baseImageName + "_hover." + ext;
        }
      }
    } else if (mode == 0) {
      if (control.id == "up_button") {
        if (currIndex > 0) {
          control.src = "images/" + baseImageName + "_enabled." + ext;
        }
      }
      if (control.id == "down_button") {
        if (currIndex < storyCount-1) {
          control.src = "images/" + baseImageName + "_enabled." + ext;
        }
      }
      if ((control.id == "pageprev_button") || (control.id == "bottom_pageprev_button")) {
        if (currPage > 1) {
          control.src = "images/" + baseImageName + "_enabled." + ext;
        }
      }
      if ((control.id == "pagenext_button") || (control.id == "bottom_pagenext_button")) {
        if (currPage < Math.ceil(catalogThumbCount/16)) {
          control.src = "images/" + baseImageName + "_enabled." + ext;
        }
      }
    }
  }
  
  function navigate(offset) {
    if ((currIndex+offset < 0) || (currIndex+offset >= storyCount)) {
      return;
    }
    currIndex += offset;
    with (document) {
      getElementById('story_thumb').src = "story/thumb/"+thumbArray[currIndex];
      
      var buttonPhase = pageName == "default" ? "on" : "off"; 
      if (currIndex > 0) {
        getElementById('up_button').src = "images/bbsimage_20_"+buttonPhase+"_enabled.jpg";
      } else {
        getElementById('up_button').src = "images/bbsimage_20_"+buttonPhase+"_disabled.jpg";
      }
      if (currIndex < storyCount-1) {
        getElementById('down_button').src = "images/bbsimage_21_"+buttonPhase+"_enabled.jpg";
      } else {
        getElementById('down_button').src = "images/bbsimage_21_"+buttonPhase+"_disabled.jpg";
      }
    }
  }
  
  function showAbout(anchor) {
    with (document) {
      var newPos;
      newPos = documentElement.scrollTop+10;
      getElementById('pop_frame').style.top = Math.round(newPos).toString()+"px";
      newPos = ((body.clientWidth-1077)/2)+192;
      getElementById('pop_frame').style.left = Math.round(newPos).toString()+"px";
      getElementById('pop_frame').style.visibility = "visible";
      getElementById('pop_frame').src = "about.aspx?anchor=" + anchor;
      var catalogGrid = getElementById('catalog_grid');
      if (catalogGrid) {
        catalogGrid.style.filter = "alpha (opacity=50)";
      }
    }
  }
      
  function hideAbout() {
    with (document) {
      getElementById('pop_frame').style.visibility = "hidden";
      getElementById('pop_frame').src = "";
      var catalogGrid = getElementById('catalog_grid');
      if (catalogGrid) {
        catalogGrid.style.filter = "alpha (opacity=100)";
      }
    }
  }
