﻿// Load Functions
Event.observe(window, 'load', function() {
	/* Replacement calls. Please see documentation for more information. */
	/*
	if(typeof sIFR == "function"){
		// This is the preferred "named argument" syntax
		sIFR.replaceElement(named({sSelector:".sIFR", sFlashSrc:"/assets/flash/_p22-cezanne-altone.swf", sColor:"#ab965e", sLinkColor:"#ab965e", sBgColor:"#FFFFFF", sHoverColor:"#ab965e", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0&offsetLeft=0", sWmode:"transparent"}));
	}
	*/

	// Initialize XHTML External Link replacement
	externalLinks();

	// Fix PNGs
	fixPNG();
});

// Unload Functions
Event.observe(window, 'unload', function() {

});

/* Loading PNG Fix */
function fixPNG() {
	if (document.getElementById('logo_igt'))
	{
		objMyImage1 = new OpacityObject('logo_igt','http://www.visitidaho.org/golf/assets/images/logo-igt');
		objMyImage1.setBackground();
	}
}

// Generate Anti-SPAM E-Mail
function generateAddress(appearance, username, hostname, tld)
{
	var atsign = "&#64;";

	// If SAMEADDRSS is present, then the E-mail address will be shown instead of a custom value
	if (appearance == "SAMEADDRESS")
	{
		appearance = username + atsign + hostname + "." + tld;
	}

	var addr = username + atsign + hostname + "." + tld;
	document.write("<" + "a" + " " + "href=" + "mail" + "to:" + addr + " \/>" + appearance + "<\/a>");
}

// IE Hover Element Function
function ieHover() {
	var sfEls = document.getElementById("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"), "");
		}
	}
}

/* XHTML Compliant Open Window */
function externalLinks() {
	var anchors = $('.external');

	if (anchors) {
		for (var i = 0; i < anchors.length; i++)
		{
			anchors[i].target = "_blank";
		}
	}
}

/* SlideShow Pro Multi-Gallery */
function initializeGallery() {
	$('.gallery').each(function(i) {
		if (i != 0)
			$(this).hide();
		else
			embedGallery(0);
	});

	$('.galleryButton').each(function(i) {
		$(this).click(function() {
			embedGallery(i);
			return false;
		});
	});
}

function embedGallery(galleryID) {
	var galleryWindows = $('.gallery').get();
	var tempID = "";

	for (var i = 0; i < galleryWindows.length; i++)
	{
		tempID = "#gallery_window-" + i;

		if (i == galleryID)
			$(tempID).show();
		else
			$(tempID).hide();
	}

	var so = new SWFObject("/assets/flash/gallery/imagegallery.swf", "imagegallery" + galleryID, "415", "320", "7", "#333333");
	so.addParam("flashvars", "xmlfile=/assets/flash/gallery/project" + galleryID + ".xml");
	so.useExpressInstall('/assets/flash/expressinstall/playerProductInstall.swf');
	so.write("gallery_window-" + galleryID);
}