﻿// JScript File

  String.prototype.replaceAll = function(
strTarget, // The substring you want to replace
strSubString // The string you want to replace in.
){
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
 
// Keep looping while an instance of the target string
// still exists in the string.
while (intIndexOfMatch != -1){
// Relace out the current instance.
strText = strText.replace( strTarget, strSubString )
 
// Get the index of any next matching substring.
intIndexOfMatch = strText.indexOf( strTarget );
}
 
// Return the updated string with ALL the target strings
// replaced out with the new substring.
return( strText );
}
  function breadcrumbs(sClass, sDelimiter)
  {
    if(!sDelimiter) sDelimiter = '>';
    var sURL = (location.pathname.indexOf('?') != -1) ? location.pathname.substring(0, location.pathname.indexOf('?')) : location.pathname;
        sURL = (location.pathname.charAt(0) == '/') ? location.pathname.substring(1) : location.pathname;
    var aURL = sURL.split('/');
    if(aURL)
    {
      //alert(aURL);
      var sOutput = '<a href="http://www.geiger-air.com/index.html">Home</a> ' + sDelimiter + ' ';
      var sPath = '/';
      for(var i = 0; i < aURL.length; i++)
      {
       if (aURL[i]=='index.html' || aURL[i]=='')
        {
        break;
        }
        else if( aURL[i]=='C:' || aURL[i]=='Hermetic%20Rush'||aURL[i]=='NewSite'||aURL[i]=='Posts'||aURL[i]=='Full')
        {
        sPath += aURL[i] + '/';
        
        }
        else if(i==aURL.length-2)
        {
            sOutput +=aURL[i];
        }
        else
        {
        sPath += aURL[i] + '/';
        sOutput += '<a href="' + sPath + 'index.html"';
        if(sClass) sOutput += ' class="' + sClass +'"';
        var _aURL=aURL[i].replaceAll('%20',' ');
        sOutput += '>' + aURL[i] + '</a>';
        sOutput += ' ' + sDelimiter + ' ';
        //alert(sOutput);
        }
      }
      //sOutput +=aURL[j].replace('%20',' ').replace('%20',' ');
      var _sOutput=sOutput.replaceAll('%20',' ');
        //alert(sOutput);alert(_sOutput);
         document.write(_sOutput);
    }
  }
  String.prototype.trim = function ()
{
 var regExp = /^\s+|\s+$/;

 return this.replace(regExp, '');
};
String.prototype.padLeft = function (totalWidth, paddingChar)
{
 var paddedValue = new String(this);
 paddedValue = paddedValue.trim();

 while ( paddedValue.length < totalWidth )
 {
  paddedValue = paddingChar + paddedValue;
 }

 return paddedValue;
}
String.prototype.padRight = function (totalWidth, paddingChar)
{
 var paddedValue = new String(this);
 paddedValue = paddedValue.trim();

 while ( paddedValue.length < totalWidth )
 {
  paddedValue += paddingChar;
 }

 return paddedValue;
}
  function overlay(image) {
   //alert(image);
    //alert("'"+String(image).substring(String(image).length-4,String(image).length-6)+"'");
    var j = parseInt(String(image).substring(String(image).length-4,String(image).length-6),10);
    //alert(j);
    var prev= document.getElementsByClassName("previous");
    var next= document.getElementsByClassName("next");
//     if (j>1 && j<9)
//    {
     for (var i = 0; i<prev.length;i++){
      //alert("next->http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j-1).padLeft(2,'0')+".jpg");
      prev[i].onclick=function() {overlay("http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j-1).padLeft(2,'0')+".jpg");};
      prev[i].style.visibility = (j == 1 | image == "") ? "hidden" : "visible";
     }
     for (var i = 0; i<next.length;i++){
      //alert("next->http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j+1).padLeft(2,'0')+".jpg");
     next[i].onclick=function() {overlay("http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j+1).padLeft(2,'0')+".jpg");};
     next[i].style.visibility = (j == 3 | image == "") ? "hidden" : "visible";
     }
//    }
//    else if (j==9 || j==10)
//    {
//     for (var i = 0; i<prev.length;i++){
//     alert("9http://www.geiger-air.com/images/references/referenceletters_Page_0"+String(j-1)+".jpg");
//      prev[i].onclick=function() {overlay("http://www.geiger-air.com/images/references/referenceletters_Page_0"+String(j-1)+".jpg");};
//     }
//     for (var i = 0; i<next.length;i++){
//      alert("9http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j+1)+".jpg");
//     next[i].onclick=function() {overlay("http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j+1)+".jpg");};
//     }
//    }
//    else if (j>10 && j<22)
//    {
//     for (var i = 0; i<prev.length;i++){
//     //alert("9-22http://www.geiger-air.com/images/references/referenceletters_Page_"+j+".jpg");
//      prev[i].onclick=function() {overlay("http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j-1)+".jpg");};
//     }
//     for (var i = 0; i<next.length;i++){
//      //alert("9-22http://www.geiger-air.com/images/references/referenceletters_Page_"+j+".jpg");
//     next[i].onclick=function() {overlay("http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j+1)+".jpg");};
//     }
//    }
     el = document.getElementById("overlay");
	el.style.visibility = (image == "") ? "hidden" : "visible";
	if(el.style.visibility == "visible")
	{
	    el_image=document.getElementById("modalPopup");
        //alert(el_image);
        //alert(image);
        imageHTML="<img src=\""+image+"\" border=\"0\" >"
        //alert(imageHTML);
        el_image.innerHTML=imageHTML;
        }
   
}
window.document.onkeydown = function(evt)
{
if(evt.keyCode == 27)
{

    var prev= document.getElementsByClassName("previous");
    var next= document.getElementsByClassName("next");
el = document.getElementById("overlay");
	el.style.visibility = "hidden";
	 for (var i = 0; i<prev.length;i++){
      //alert("next->http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j-1).padLeft(2,'0')+".jpg");
     // prev[i].onclick=function() {overlay("http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j-1).padLeft(2,'0')+".jpg");};
      prev[i].style.visibility = "hidden";
     }
     for (var i = 0; i<next.length;i++){
      //alert("next->http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j+1).padLeft(2,'0')+".jpg");
     //next[i].onclick=function() {overlay("http://www.geiger-air.com/images/references/referenceletters_Page_"+String(j+1).padLeft(2,'0')+".jpg");};
     next[i].style.visibility = "hidden";
     }
}
}