var popup_window;
var thePath, theImage;
var shownText;

function Open_Text_Pop_Up( text )
{
    popup_window=open("text_popup.html",null,"width=300,height=100,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no");
    popup_window.document.write( text );
    popup_window.focus();
}

function Open_Image_Pop_Up( image, path )
{
    theImage = image;
    thePath  = path;
    // Open new window
    popup_window=open("image_popup.html",null,"toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
    timer=setTimeout( "Check_DocLoadSts()", 200 );
    //popup_window.document.all[image].style.display = "";
    //popup_window.focus();
}

function Check_DocLoadSts() {
  if ( popup_window.isLoaded == "yes" ) {
    popup_window.isLoaded == "no"
    Display_Picture( thePath, theImage );
  }
  else {
    timer=setTimeout( "Check_DocLoadSts()", 200 );
  }
}

function Display_Picture( path, image ) {
  popup_window.document.images[0].src = "images/"+path+"/" + image + ".jpg";
  timer=setTimeout( "Check_ImageLoadSts()", 200 );
}
 
function Check_ImageLoadSts() {
  if ( popup_window.isLoaded == "yes" ) {
    popup_window.isLoaded == "no"
    Display_Text( theImage );
  }
  else {
    timer=setTimeout( "Check_ImageLoadSts()", 200 );
  }
}

function Display_Text( image ) {
  if( popup_window.document.all( image ) != null ) {
    popup_window.document.all( image ).style.display = "";
    popup_window.focus();
  }
}

function highlight( knappID ) {
  if (knappID != "") {
    document.all[knappID].style.color="#F0E0D0";
    document.all[knappID].style.backgroundColor="#383838";
    document.all[knappID].style.borderTopColor="#808080";
    document.all[knappID].style.borderRightColor="#303030";
    document.all[knappID].style.borderBottomColor="#303030";
    document.all[knappID].style.borderLeftColor="#808080";
  }
}

function unhighlight( knappID ) {
  if (knappID != "") {
    document.all[knappID].style.color="#C0C0C0";
    document.all[knappID].style.backgroundColor="#404040";
    document.all[knappID].style.borderColor="#404040";
  }
}

/* showIntroText: initiates detail text handling and shows first text */
function showIntroText( detailID ) 
{
    // Assumes no text previously displayed.
    // Check object model (IE or NS or whatever)
    if (document.all) {
        // IE
        // Show new text.
        document.all(detailID).style.display="";
    }
    else if (document.layers) {
        // NS
        document.layers(detailID).style.display="";
    }
    shownText = detailID;
}

/* showDetailText: displays hidden text identified by 'detail' */
function showDetailText( detailID, isShow ) 
{
  if (isShow == "show") {
    // Cursor enters an area. Show and mark relevant objects.
    if (detailID != shownText) {
       // Check object model (IE or NS or whatever)
      if (document.all) {
        // IE
        // Hide previously shown text if not equal to new text, then show new text.
        if (shownText != "") document.all(shownText).style.display="none";
        document.all(detailID).style.display="";
        shownText = detailID;
      }
      else if (document.layers) {
        // NS
        if (shownText != "") document.layers(shownText).style.display="none";
        document.layers(detailID).style.display="";
        shownText = detailID;
      }
    }
  }
  else {
    // Hide shown text
    if (detailID == shownText) {
       // Check object model (IE or NS or whatever)
      if (document.all) {
        // IE
        // Hide shown text if not equal to new text, then show new text.
        if (shownText != "") document.all(shownText).style.display="none";
        shownText = "";
      }
      else if (document.layers) {
        // NS
        if (shownText != "") document.layers(shownText).style.display="none";
        shownText = "";
      }
    }
  }
}
