var message="All images on this web site are protected by copyright laws. Unauthorized use of our materials is strictly prohibited."

function click(e) {
	if (document.all)  {
		if (event.button==2 || event.button==3) {
			alert(message);
			return false;
		}
		if (document.layers) {
			if (e.which == 3) {
				alert(message);
				return false;
			}
		}
	}
	if (document.layers) {
		document.captureEvents(Event.MOUSEDOWN);
	}
}

var bLoaded = false;
var licLoaded = false;


function Loaded() {
	bLoaded = true;
}

function LoadViewer(Image) {
	settings="toolbar=no,location=no,directories=no," + "status=no,menubar=no,scrollbars=no," + "resizable=no,width=600,height=600";
	vURL = "../Viewer.asp?i=" + Image;
	Licwin = window.open(vURL,"ImageViewer",settings);

	if (!bLoaded) {
		window.location.replace(location.href);
	}
}


function LoadViewer2(Image) {
	settings="toolbar=no,location=no,directories=no," + "status=no,menubar=no,scrollbars=no," + "resizable=no,width=600,height=600";
	vURL = "../Viewer.asp?i=" + Image;
	Licwin = window.open(vURL,"ImageViewer",settings);

//	if (!bLoaded) {
//		window.location.replace(location.href);
//	}
}


function LoadLicense() {
	settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=500";
	vURL = "LicenseAgreement.asp";
	Lblwin = window.open(vURL,"License Viewer",settings);

	if (!licLoaded) {
		window.location.replace(location.href);
	}
}


function LoadDownloader() {
	settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=500";
	vURL = "ImageDownload.asp";
	Lblwin = window.open(vURL,"Image Downloader",settings);
	window.location.replace(location.href);
}



var image_index = 0;

function imageItem(image_location) {
//alert("ImageItem for " + image_location);
this.image_item = new Image();
this.image_item.src = image_location;
}

function get_ImageItemLocation(imageObj) {
//alert("Get_ImageItemLocation");
return(imageObj.image_item.src)
}

function generate(x, y) {
//alert("Generate");
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}

function getNextImage() {
//alert("getNextImage");
	if (random_display) {
		image_index = generate(0, number_of_image-1);
	}
	else {
		image_index = (image_index+1) % number_of_image;
	}
	vLnk = document.getElementById("ImgLink");
	if (vLnk != null) {
		vLnk.href="/Galleries/Image.asp?image=" + image_nums[image_index];
	}
	vCpyRt = document.getElementById("CopyrightText");
	if (vCpyRt != null) {
		vCpyRt.innerHTML ="Copyright &copy; " + image_cpyrt[image_index];
	}

var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}

function rotateImage(place) {
//alert("Rotating " + number_of_image + " images");
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}


function submitSearch() {
	document.SearchForm.submit();
}

function submitStockSearch() {
	document.StockSearchForm.submit();
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function LTrim(str, sChar)
{
	sTemp = str;
	while (sTemp.charAt(0) == sChar) {
		sTemp = Right(sTemp, sTemp.length-1);
	}
	return sTemp;
}
function StringFill(OrigStr, sChar, nMode, nMaxLength)
{
	sResult = OrigStr;
	nLen = nMaxLength - OrigStr.length;
	if (nLen > 0) {
		sFillStr = "";
		for (var i = 0; i < nLen; i++) {
			sFillStr += sChar;
		}
		switch (nMode) {
			case 1:	// fill at front
				sResult = sFillStr + OrigStr;
				break;
			case 2: // fill at back
				sResult = OrigStr+ sFillStr;
				break;
		}
	}
	return sResult;
}


var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function showhide(obj, e, visible, hidden){
	if (ie5||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible
	else if (e.type=="click")
	obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
			if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
			edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	if (typeof dropmenuobj!="undefined") //hide previous menu
		dropmenuobj.style.visibility="hidden"
	clearhidemenu()
	if (ie5||ns6){
		obj.onmouseout=delayhidemenu
		dropmenuobj=document.getElementById(dropmenuID)
		if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
		dropmenuobj.onmouseover=clearhidemenu
		dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
		showhide(dropmenuobj.style, e, "visible", "hidden")
		dropmenuobj.x=getposOffset(obj, "left") - 175
		dropmenuobj.y=getposOffset(obj, "top") - 100
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
	return clickreturnvalue()
}

function clickreturnvalue(){
	if ((ie5||ns6) && !enableanchorlink) return false
	else return true
}

function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
		return true;
	return false;
}

function dynamichide(e){
	if (ie5&&!dropmenuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu()
}

function delayhidemenu(){
	delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
}