<!--

function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }


function extLink(url) {  //Open a Popup
    window.open(url); 
	return false;
	}
	
// DISABLE Right Clicking	
//document.oncontextmenu = new Function("return false")



function loadGalleryXML(xmlfileIn) {
    loadXMLDoc(xmlfileIn);
    return false;
    };


var req;

function loadXMLDoc(url) { // Load XML Document from a URL (Must be SAME domain)
    
    if (window.XMLHttpRequest) {
      req = new XMLHttpRequest();
      req.onreadystatechange = processReqChange;
      req.open("GET", url, true);
      req.send(null);
      
	  // branch for IE/Windows ActiveX version
      } else if (window.ActiveXObject) {
      isIE = true;
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send();
        }
      }
    };


function processReqChange() {  // XML onLoad handler
    
    if (req.readyState == 4) {
      if (req.status == 200) {  // only if "OK"
	    //XML is Loaded - Process it
        buildImageList();
        } else {
        alert("There was a problem retrieving the XML data:\n" +
        req.statusText);
        }
      }
    };

var dotCount = 0;

function buildImageList() {
    // loop through <item> elements and build a list of thumbnails
    var items = req.responseXML.getElementsByTagName("item");
  	var listStr = "";
	var dotsStr = "";
	
	dotsStr = "<a id=\"dotprev\" href=\"#P.1\" onclick=\"setTimeout('browseAnchors(0,1)',20)\" class=\"dots_prev\" title=\"Previous\"  ></a>"
	
    for (var i = 0; i < items.length; i++) {
      var imgTitle = getElementTextNS("", "title", items[i], 0);
      var imgDesc = "";
	try {
	  imgDesc = getElementTextNS("", "description", items[i], 0);
	  } catch (e) {
	  imgDesc = "";
	  }	  


	  var imgThumb = getElementTextNS("", "thumb", items[i], 0);
	  var imgThumb_m = getElementTextNS("", "thumb_m", items[i], 0);
	  
	  dotCount += 1;
      
	  listStr += "<div class=\"thumb\" id=\"P." + i + "\">";
      listStr += "<a href=\"#P."+(i)+"\" ";
      listStr += " onmouseOver=\"showGalRollover('imgGal" + i + "\','" + imgTitle + "','over','" + imgThumb + "','" + imgThumb_m + "','" + i + "');\" ";
      listStr += " onmouseOut=\"killGalRollover('imgGal" + i + "', '" + imgThumb + "', '" + i + "');\" ";
      listStr += " onclick=\"showGalRollover('imgGal" + i + "\','" + imgTitle + "','click','" + imgThumb + "','" + imgThumb_m + "', '" + i +  "');loadSlideShow(" + i + ");\" ";
      listStr += " title=\"" + imgTitle + "\" >";
      listStr += "<img alt=\"" + imgTitle + "\" id=\"imgGal" + i + "\" src=\"" + imgThumb + "\" width=\"175\" height=\"100\" />";
      listStr += "</a>"
      if (imgDesc != ""){
      listStr += "<h1>" + imgTitle + "</h1><h2>" + imgDesc + "</h2></div>";
	} else {
       listStr += "<h1>" + imgTitle + "</h1></div>";
	}
	  
    dotsStr += "<a id=\"dot" + i + "\" href=\"#P."+(i)+"\" onclick=\"setTimeout('browseAnchors(" + i + ",0)',20)\" class=\"dots\" title=\"" + imgTitle + "\"  ></a>";

      }
	  
	  dotsStr += "<a id=\"dotnext\" href=\"#P.1\" onclick=\"setTimeout('browseAnchors(0,2)',20)\"  class=\"dots_next\" title=\"Next\" ></a>"
	
	document.getElementById("menubuttons").innerHTML = dotsStr;
    document.getElementById("scroller").innerHTML =  listStr;
	shit();
    };
	
var currentDot = 0;
function browseAnchors(marknum, direction) {

	var nextdot = 0;
	var prevdot = 0;
	var dotIndx = dotCount - 1;
	var olddot = "dot" + currentDot;
	
	if (dotCount > 0) {
      for (var i = 0; i < dotCount; i++) {
        document.getElementById("dot" + i).className = "dots";
        }
      }
		
	if (direction == 0) { // Actual Dot Click
	  currentDot = marknum;	
	  }
    
	if (direction == 2) { // Next
	  currentDot = currentDot + 1;
	  }
	  
	if (direction == 1) { // Previous
	  currentDot = currentDot - 1;
	  }
	
    if (currentDot < 0) {
	  currentDot = dotIndx;
	  } 
    
	if (currentDot > dotIndx) {
	  currentDot = 0
	  }
	
    nextdot = currentDot + 1;
    prevdot = currentDot - 1;
	
    if (nextdot > dotIndx) {
      nextdot = 0;
      }
		
    if (prevdot < 0) {
      prevdot = dotIndx;
      }
		
    document.getElementById("dotnext").href = ("#P." + nextdot);
    document.getElementById("dotprev").href = ("#P." + prevdot);
    document.getElementById("dot" + currentDot).className = 'dots_m';

	return false;
	};



var dasGallTitle = "";
var dasGallDesc = "";
var dasGallUrl = "";
var dasGallImgCount = 0;
var dasGallImgArr = [];
var dasGallImgTitArr = [];
var dasGallCurrentPic = "";
var dasGallCurrentPicTitle = "";

function loadSlideShow(xmlElementIn) {
    // Read the XML for this group of images 
	var galleryParent = req.responseXML.getElementsByTagName("item")[xmlElementIn];
	var galleryNode = galleryParent.getElementsByTagName("gallery")[0];
	var imagesNode = galleryNode.getElementsByTagName("image");
	
	dasGallImgCount = 0;
    dasGallImgArr = [];
    dasGallImgTitArr = [];
		
	try {
	  dasGallTitle = galleryParent.getElementsByTagName("title")[0].firstChild.nodeValue;
	  } catch (e) {
	  dasGallTitle = "No Title";
	  }
		
	try {
	  dasGallDesc = galleryParent.getElementsByTagName("description")[0].firstChild.nodeValue;
	  } catch (e) {
	  dasGallDesc = "";
	  }
	
	try {
	  dasGallUrl = galleryParent.getElementsByTagName("link")[0].firstChild.nodeValue;
	  } catch (e) {
	  dasGallUrl = "";
	  }
	
	dasGallImgCount = imagesNode.length;
	
    for (var i = 0; i < imagesNode.length; i++) {
      var tImgFile = "";
	  var tImgTitle = "";
	  
	  try {
	    tImgFile = imagesNode[i].firstChild.nodeValue;
	    } catch (e) {
	    tImgFile = "";
	    }
		
	  try {
	    tImgTitle = imagesNode[i].attributes.getNamedItem("title").nodeValue;
	    } catch (e) {
	    tImgTitle = "No Image Title";
	    }
	  
	  if (tImgFile != "") {
	    dasGallImgArr.push(tImgFile);
	    dasGallImgTitArr.push(tImgTitle);
	    }
	  }
	
	// Open the First Image of the Series
	SlideShow(0);
	};
	
	
function SlideShow(imageNumber) {
	
	var newContent = ""
	var nextImg = 0;
	var imgNav = "";
	
	div = document.getElementById("rightContainer");
    div.innerHTML = "";
	div.style.visibility = "hidden";
			
	if (imageNumber + 1 >= dasGallImgCount) {
	  nextImg = 0;
	  } else {
	  nextImg = imageNumber + 1;
	  }

	for (var i = 0; i < dasGallImgArr.length; i++) {
	  
	  if (i == imageNumber) {
	    imgNav += "<div class=\"numberlinksOver\" >" +  (i + 1) + "</div>";
	    } else {
	    imgNav += "<div class=\"numberlinks\" onclick=\"SlideShow(" + i + ");\" title=\"" + dasGallImgTitArr[i] + "\" >" +  (i + 1) + "</div>";
	    }
	  
	
	  }
	
	newContent += "<div id=\"gallCont\">";
	newContent += "<table class=\"imgtbl\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" >"
	newContent += "<tr><td valign=\"bottom\"><div id=\"gallCont_img\"><div><img src=\"" + "/_images/loading.gif" + "\" /></div></div></td></tr></table>";	
	newContent += "<div id=\"gallCont_text\" style=\"visibility:hidden\" >";
    newContent += "<div id=\"currTitle\"><h1>" + dasGallImgTitArr[imageNumber] + "";
	if (dasGallUrl != "") {
	  
	 // newContent += "<a href=\"" + dasGallUrl + "\"  />";
	  newContent += "<img src=\"" + "/_images/url_icon.gif\" onclick=\"extLink('" + dasGallUrl + "');return false;\" title=\"Visit - "+ dasGallUrl +"\" width=\"13\" height=\"13\" class=\"urlicon\" /></a>";
	  }
	newContent += "</h1></div>";
	newContent += "<div id=\"numbesrnav\">" + imgNav + "<div class=\"clear\"></div>";
	newContent += "<div class=\"clear\">";
	
	
	  
	//newContent += "</div>";
    //newContent += "<h3>" + dasGallDesc + "</h3>";
	newContent += "</div></div>";
	
	var loader = new ImageLoader(dasGallImgArr[imageNumber]);
    loader.loadEvent = function(url, image, status){ //action to perform when the image is loaded
        
	    var imageholder = document.getElementById("gallCont_img");
	    imageholder.innerHTML = "";
		
		if (status > 0) {
		  imageholder.appendChild(image);
		
		  image.onclick = function(){
		    SlideShow(nextImg);
		    }
		  image.onmouseover= function(){
			  this.style.cursor = "hand";
			  }			
		  image.onmouseout= function(){
			  this.style.cursor = "auto";
			  }
		  image.alt = "Click for Next Image";
		  } else {
		  // Image was not found
		  imageholder.innerHTML = "The image could not be loaded!";

		  imageholder.onclick = function(){
		      SlideShow(nextImg);
		      }
			
		  imageholder.onmouseover= function(){
			  this.style.cursor = "hand";
			  }
			  
		  imageholder.onmouseout= function(){
			  this.style.cursor = "auto";
			  }	  
		  }
		  
		document.getElementById("gallCont_text").style.visibility = "visible";	
        }
   	
    div.innerHTML = newContent;
    div.style.visibility = "visible";
	loader.load();
	};
	


function getElementTextNS(prefix, local, parentElem, index) { // retrieve text of an XML document element
    var result = "";
    if (prefix && isIE) {
        // IE-Windows way of handling namespaces
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    	} else {
        result = parentElem.getElementsByTagName(local)[index];
    	}
		
    if (result) {
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        	} else {
            return result.firstChild.nodeValue;    		
        	}
    	} else {
        return "n/a";
    	}
	};



var gallSelectedImg = "";
var gallSelectedIndex = "";
var gallSelectedImg_up = "";
var gallSelectedImg_m = "";

function showGalRollover(dasImg, label, mState, upIMG, overIMG, dotNum) {	
	var mypopup = document.getElementById(dasImg);
	
	var myDot =  document.getElementById("dot" + dotNum);
	
	//var pos = DL_GetElementTop(mypopup);
	//var myleft = DL_GetElementLeft(mypopup);
	var bGdiv;	
	
	

	/*
	if (mState == "over") {
	  bGdiv = document.getElementById('gallHover');
	  bGdiv.style.width = myleft  + 'px';
	  } else {     
	  bGdiv = document.getElementById('gallThumbSelected');
	  document.getElementById('gallThumbSelected').style.visibility = 'visible';
	  document.getElementById('gallHover').style.visibility = 'hidden';
	  }
	  
	  
	  
	var varCSSstr1 = "";
	var varCSSstr2 = "";
	
    if (mState == "click") {
      varCSSstr1 = "gallClick_line1";
      varCSSstr2 = "gallClick_line2";
      } else {
      varCSSstr1 = "gallHover_line1";
      varCSSstr2 = "gallHover_line2";
	  }
	  
	 
	  
    bGdiv.style.top = pos + 'px';
    bGdiv.style.height = mypopup.height + 'px';	
    bGdiv.innerHTML = "<div id=\"" + varCSSstr1 + "\" style=\"width:"+ (myleft-15) + "px\" >" + category + "</div>";
    bGdiv.innerHTML += "<div id=\"" + varCSSstr2 + "\" style=\"width:"+ (myleft-15) + "px\" >" + label + "</div>";
	
	
    if (dasImg != gallSelectedImg & mState == "over" ) {
      bGdiv.style.visibility = 'visible';
      changeOpac(100, dasImg);
      }
	  
	 */
	  
    if (mState == "click") {
      if (gallSelectedImg != "") {
        //changeOpac(50, gallSelectedImg);
		var oldIMG = document.getElementById(gallSelectedImg);
		oldIMG.src = gallSelectedImg_up;
		browseAnchors(parseInt(dotNum),0);
		
        }
	

      gallSelectedImg = dasImg;
	  gallSelectedImg_m = overIMG
	  gallSelectedImg_up = upIMG
	  //bGdiv.style.visibility = 'visible';
	  window.scroll(0,0);
	  }  
	
	myDot.className = "dots_m";
	mypopup.src  = overIMG;
	
	};
	
	
function killGalRollover(dasImg, newIMG, dotNum) { // Kills the rollover state of the galler thumbs
    var bGdiv = document.getElementById("gallHover"); 
	var myDot =  document.getElementById("dot" + dotNum);
	var myimage = document.getElementById(dasImg);
	var myimage_src = myimage.src;
	
	//myimage_src = Left(myimage_src, myimage_src.length -6) + Right(myimage_src, 4);
	//alert(myimage_src);
    
	/*
    bGdiv.innerHTML = "";
    bGdiv.style.visibility = 'hidden';
    */
	if (dasImg != gallSelectedImg) {
      //changeOpac(50, dasImg);
	  myDot.className = "dots";
	  myimage.src = newIMG;
      }
	  
    };
	



var activeDiv
	
function pageLink(urlStr, pgTitle){
	activeDiv = "rightContainer";
	loadFile(urlStr, pgTitle);
	};


var reqText;

function loadFile(urlStr, pgTitle) { // Loads in HTML File in DIV
	
	if (pgTitle.length > 0) {
	  document.title = pgTitle;
	  }
	  	
    if (window.XMLHttpRequest) { // Non-IE browsers 
      reqText = new XMLHttpRequest(); 
      reqText.onreadystatechange = targetDiv; 
      try { 
        reqText.open("GET", urlStr, true); 
        } catch (e) { 
        alert(e); 
        } 
      reqText.send(null); 
      
	  } else if (window.ActiveXObject) { // IE 
        reqText = new ActiveXObject("Microsoft.XMLHTTP"); 
        if (reqText) { 
          reqText.onreadystatechange = targetDiv; 
          reqText.open("GET", urlStr, true); 
          reqText.send(); 
          } 
       } 
    };


function targetDiv() { 


    if (reqText.readyState == 4) { // Complete 
      if (reqText.status == 200) { // OK response 
	  
	    if (gallSelectedImg != '') {
		  //changeOpac(50, gallSelectedImg);
		  }
		
		if (gallSelectedImg.length > 0){
		  var oldIMG = document.getElementById(gallSelectedImg);
		  oldIMG.src = gallSelectedImg_up;
		 
		  }
		
		gallSelectedImg = "";
		
		
		if (dotCount > 0) {
		  for (var i = 0; i < dotCount; i++) {
		    document.getElementById("dot" + i).className = "dots";
			}
		   }
		

		
		
				
	    //document.getElementById('gallThumbSelected').style.visibility = "hidden";
		//document.getElementById('gallHover').style.visibility = "hidden";
		
		
	    document.getElementById(activeDiv).innerHTML = "";	
        document.getElementById(activeDiv).innerHTML = reqText.responseText;
		//document.getElementById(activeDiv).innerHTML = "reqText.responseText";
        } else { 
        document.getElementById(activeDiv).innerHTML = ("<div id=\"error\">Can't Load the requested File: " + reqText.statusText + "!</div>"); 
        } 
	   window.scroll(0,0);
      } 
    };



function addListener(element, type, expression, bubbling) { // Cross-browser element.addEventListener()
	bubbling = bubbling || false;
    if (window.addEventListener)	{ // Standard
      element.addEventListener(type, expression, bubbling);
      return true;
      } else if(window.attachEvent) { // IE
      element.attachEvent('on' + type, expression);
      return true;
      } else {
      return false;
      }
    };


var ImageLoader = function(url){
    this.url = url;
    this.image = null;
    this.loadEvent = null;
    };


ImageLoader.prototype = {
    load:function(){
      this.image = document.createElement('img');
      var url = this.url;
      var image = this.image;
      var loadEvent = this.loadEvent;
	
	  addListener(this.image, 'error', function(e){
	    if(loadEvent != null){
          loadEvent(url, image, 0);
          }
	    } , false);
	
	  addListener(this.image, 'load', function(e){
        if(loadEvent != null){
          loadEvent(url, image, 1);
          }
        }, false);
    
	  this.image.src = this.url;
      }	
    };




//-->