// JavaScript Document

//'suckerfish' drop-down code for IE from http://www.htmldog.com/articles/suckerfish/dropdowns/
sfHover = function() { 
	var sfEls = document.getElementById("horiz-nav").getElementsByTagName("LI"); 
	
	for (var i=0; i<sfEls.length; i++) { 
		sfEls[i].onmouseover=function() { 
			this.className+=" sfhover"; 
		} 
		sfEls[i].onmouseout=function() { 
			this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); 
		} 
	} 
} 
//comment out the line below if not using dropdowns
if (window.attachEvent) window.attachEvent("onload", sfHover);



// this function is called onLoad and places the alt text from 
// the featured image into the caption area on rotator pages
function initCaption() {
 if (document.getElementById) {
	var imgSrc = window.document.getElementById("featuredImg").src;
	var imgSrcArray = imgSrc.split('/');
	var i = imgSrcArray.length - 1;
	var filename = imgSrcArray[i];
  window.document.getElementById("caption").innerHTML = window.document.getElementById("featuredImg").alt + " - <a href='/show_img.php?img=" + filename + "'>Supersize Image</a>";;
 } else {
  //do nothing
 }
}


// showImg function used for thumbnail rotation into 
// "featuredImg" image.
function showImg(imgSrc, altText){
	//altText = altText with "&#039;" replaced with '
  if(document.getElementById){
	  //img src and alt swap code for modern browsers
	  window.document.getElementById("featuredImg").src = "assets/medium/" + imgSrc;
    window.document.getElementById("featuredImg").alt = altText;
		window.document.getElementById("caption").innerHTML = altText + " - <a href='/show_img.php?img=" + imgSrc + "'>Supersize Image</a>";
		
	} else {
	  //img src and alt swap code for NS4.x
		document.featuredImg.src = imgSrc;
		document.featuredImg.alt = altText;
	}//end if/else
}


//pop-up window function
function openPopup(URL, ww, hh) {
	var xcoord, ycoord, popWidth, popHeight;
	
	if(ww != null) {
		popWidth = ww;
	}
	else {
		popWidth = 450;
	}
	
	if(hh != null) {
		popHeight = hh;
	}
	else {
		popHeight = 550;
	}
	
	if(document.getElementById) {
		xcoord = Math.round((screen.availWidth - popWidth) / 2);
		ycoord = Math.round((screen.availHeight - popHeight) / 2);
	}
	
    myPopup = window.open(URL,'popupWindow','width=' + popWidth + ',height=' + popHeight + ',left=' + xcoord + ',top=' + ycoord + ',directories=no,menubar=yesn,status=no,resizable=1,scrollbars=yes');
    if (!myPopup.opener) {
         myPopup.opener = self;
	}
	
	myPopup.focus();
}
