// this set of functions powers the class="button" css rollovers
var W3CDOM = (document.createElement && document.getElementsByTagName);

function addButtonRollovers() {
	if (!W3CDOM) return;
	var divs = document.getElementsByTagName("a");
	for (var i=0; i<divs.length; i++) {
		if (divs[i].className.indexOf('button') >= 0) {
			divs[i].rollPosition = "-"+(divs[i].offsetWidth+5)+"px";
			divs[i].onmouseover = buttonRollOver;
			divs[i].onmouseout = buttonRollOut;
		}
	}
}
function buttonRollOver() {
	this.style.backgroundPosition = this.rollPosition;
}
function buttonRollOut() {
	this.style.backgroundPosition = "0 0";
}


/** 
 * function to allow us to add multiple onload events which works on all browsers
 * (including IE / Mac!)
 * From: http://liorean.web-graphics.com/scripts/themeswitch.html 
 **/

var loadEventHandler={  // The Event Handler main object
  Add:function(f){  // Function for adding onload handlers
    loadEventHandler.col[loadEventHandler.col.length]=f;  // Add event handler to collection
    if(typeof window.addEventListener!='undefined')  // If W3C compliant
      window.addEventListener('load',f,false);  // Apply event handler
    else if(!loadEventHandler.ieSet)  // Otherwise, unless already set
      if(typeof document.onreadystatechange!='undefined')  // If supported
        document.onreadystatechange=loadEventHandler.onload;  // Add In event handler handler
    loadEventHandler.ieSet=true;  // Specify that event handler already is set
    return(typeof window.addEventListener!='undefined')  // Return whether W3C compliant
  },
  onload:function(){  // Function for handling multiple onload handlers in IE
    var m=/mac/i.test(navigator.platform);  // Detect whether mac
    if(typeof document.readyState!='undefined')  // If supported
      if(m?document.readyState!='interactive':document.readyState!='complete')  // And not already finished
        return;  // Exit
    for(var i=0,f;(f=(i<loadEventHandler.col.length)?loadEventHandler.col[i]:null);i++)  // For all event handlers
      f();  // Run event handler
    return  // Exit
  },
  ieSet:false,  // Variable to say whether event handler is set or not
  col:[]  // Collection for event handlers
};

loadEventHandler.Add(addButtonRollovers);

// popup window for image galleries
function open_window_html(img_src, width, height, scroll, resize)
{
	if (!scroll) { scroll = "1";}
	if (!resize) { resize = "1";}

    window.open("/includes/popup.php?img=" + img_src + "", /*WARNING -- don't put any spaces in the window name */ "Large_image", "toolbar=0,location=0,directories=0,status=0, menubar=0,scrollbars=" + scroll + ",resizable=" + resize +", width=" + width + ", height=" + height + "");    
}

// write a header using flash or jpg depending on capabilities
// depends on flash_detect.js
function makeHeaderFlash() {
    var flashVersion = getFlashVersion();
    if (flashVersion < 6 || flashVersion == flashVersion_DONTKNOW || flashVersion == null) {
        document.write('<img src="/images/Banner_Flash_01.gif" width="720" height="145" alt="The Original Grillslinger" />');
    } else {
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="720" height="145" id="Banner_Flash_01" align="middle">');        document.write('<param name="allowScriptAccess" value="sameDomain" />');        document.write('<param name="movie" value="/images/Banner_Flash_01.swf" />');        document.write('<param name="quality" value="high" />');        document.write('<param name="bgcolor" value="#ffffff" />');        document.write('<embed src="/images/Banner_Flash_01.swf" quality="high" bgcolor="#ffffff" width="720" height="145" name="Banner_Flash_01" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');        document.write('</object>');
    }
}

