//	Ancor Scrolling
//	===============
var ScrollLinks = {
	currentHash: false,
	start: function(){
		this.scroll = new fx.Scroll({duration: 1500, transition: fx.sineOut, onComplete: function(){this.end();}.bind(this)});
		this.allinks = $c(document.getElementsByTagName('a'));
		this.allinks.each(function(lnk){
			if ((lnk.href && lnk.href.indexOf('#') != -1) && ( (lnk.pathname == location.pathname) 
				|| ('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) {
				lnk.onclick = function(){
					ScrollLinks.scroll.clearTimer();
					this.initialHref = this.href;
					this.initialHash = this.hash;
					this.href = "javascript:void(0)";
					setTimeout(function(){this.href = this.initialHref;}.bind(this), 200);
					ScrollLinks.go(this);
				}
			}
		});
	},

	go: function(link){
		this.currentHash = link.initialHash.slice(1);
		if (this.currentHash) {
			this.allinks.each(function(lnk){
				if (lnk.id == ScrollLinks.currentHash){
					if (window.opera) lnk =  [lnk].find('parentNode');
					ScrollLinks.scroll.scrollTo(lnk);
					return;
				}
			});
		}
	},

	end: function(){
		if (!/Konqueror|Safari|KHTML/.test(navigator.userAgent)) window.location.hash = "#"+this.currentHash;
		this.currentHash = false;
	}
}


//	Random Images
//	=============

//	strElementID = "imgBanner"
//	strCommaDelimitedImageUrls = "Images/Banner1.jpg,Images/Banner2.jpg,Images/Banner3.jpg,Images/Banner4.jpg,Images/Banner5.jpg,Images/Banner6.jpg,Images/Banner7.jpg"


function randomImage(strElementID, strCommaDelimitedImageUrls) {
	var images = strCommaDelimitedImageUrls.split(",")
	var ran = 60/images.length;
	var currentdate = 0;
	var core = 0;
			
	currentdate = new Date();
	core = currentdate.getSeconds();
	core = Math.floor(core/ran);

	document.getElementById(strElementID).src = images[core];
	
	return;
}




//	Popup Images
//	============
function ShowPopupImage(strImageUrl, strTitle, intWindowWidth, intWindowHeight)
{
/*	
	// Using Window.js
	if (objWindow == null)
	{
		objWindow = new Window('Popup', {title: "Gurnell Software", bottom:70, left:0, width:intWindowWidth, height:intWindowHeight, zIndex:150, opacity:1, resizable: false})
	}

	objWindow.Title = strTitle;
	objWindow.getContent().innerHTML = "<img src=\"" + strImageUrl + "\" alt=\"" + strTitle + "\" class=\"imgPopupImage\" />"
	objWindow.showCenter();

*/

	var intLeft = (screen.width - intWindowWidth) / 2;
	var intTop = (screen.height - intWindowHeight) / 2;
	var strProps = 'scrollbars=no,titlebar=yes,resizable=yes,width=' + intWindowWidth + ',height=' + intWindowHeight + ',top=' + intTop + ',left=' + intLeft;
		
	s_objPackageWindow = open(strImageUrl, '', strProps);
	s_objPackageWindow.opener = window;
	return;
}





