var startanim = false;
function animatepanorama () {
	p = document.getElementById("panorama");
	m = document.getElementById("moto");
	if ( parseInt(p.style.top) > -150 && startanim ) {
		p.style.top = (parseInt(p.style.top) - 1) + "px" ;
		if ( parseInt(p.style.top) < -50 ) {
			m.filters.item('DXImageTransform.Microsoft.Alpha').opacity=m.filters.item('DXImageTransform.Microsoft.Alpha').opacity+1;
			m.filters.item('DXImageTransform.Microsoft.Alpha').finishOpacity=m.filters.item('DXImageTransform.Microsoft.Alpha').finishOpacity+2;
		}
		window.setTimeout("animatepanorama()",20);
	}
	else {
		if ( startanim == false ) {
			startanim = true;
			window.setTimeout("animatepanorama()",1000);
		}
		else {
			m.filters.item('DXImageTransform.Microsoft.Alpha').opacity=100;
			m.filters.item('DXImageTransform.Microsoft.Alpha').finishOpacity=100;
			//End of animation - load scroller
			window.setTimeout("fillscroller()",1000);
		}
	}
}

function revealpicture (s) {
	document.getElementById("speciallink" + s + "bg").style.backgroundColor = "transparent"
}

function coverpicture(s) {
	document.getElementById("speciallink" + s + "bg").style.backgroundColor = "#666666"
}

function moveScrollerUp() {
//	document.getElementById("scrolleruparrow").style.backgroundColor = "#ffefdf";
	document.getElementById("uparrow").style.display="none";
	document.getElementById("uparrowon").style.display="inline";
	document.getElementById("scrollercontentdiv").style.top = (document.getElementById("scrollercontentdiv").style.posTop - 2) + "px";
	movingup = window.setTimeout("moveScrollerUp()",25);
}
function moveScrollerDown() {
//	document.getElementById("scrollerdownarrow").style.backgroundColor = "#ffefdf";
	document.getElementById("downarrow").style.display="none";
	document.getElementById("downarrowon").style.display="inline";
	document.getElementById("scrollercontentdiv").style.top = (document.getElementById("scrollercontentdiv").style.posTop + 2) + "px";
	movingdown = window.setTimeout("moveScrollerDown()",25);
}
function scrollerStop(dir) {
	switch (dir) {
		case "up":
			window.clearTimeout(movingup);
			document.getElementById("uparrowon").style.display="none";
			document.getElementById("uparrow").style.display="inline";
			break;
		case "down":
			window.clearTimeout(movingdown);
			document.getElementById("downarrowon").style.display="none";
			document.getElementById("downarrow").style.display="inline";
			break;
	}
}
function fillscroller() {
	srcbase = "\/resize.asp\?path=d:\\home\\iksploronline.com\\wwwroot\\igallery34\\iksplor_Gallery\\<<pic>>\&width=120"
	fisherYates(imgarr);
	cnt = 1;
	for ( lp=0;lp<imgarr.length;lp++ ) {
		//account for movement of blank el 0 when array is randomized
		if ( imgarr[lp].length > 0 ) {
			i = document.getElementById("scrollerimg" + cnt);
			srctxt = srcbase.replace("<<pic>>",imgarr[lp]);
			i.src = srctxt;
			cnt++;
		}
	}
	//document.getElementById("scrollercontentdiv").style.display="inline"
}
function fillimgarr (s) {
	imgarr = s.split("||");
}
function fisherYates ( myArray ) {
  var i = myArray.length;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = myArray[i];
     var tempj = myArray[j];
     myArray[i] = tempj;
     myArray[j] = tempi;
   }
}
function horzscroll (scrolldiv,speed) {
	rel=/-?\d+/;
	reu=/[a-z]+/;
	divs = document.getElementById(scrolldiv).getElementsByTagName("div");
	//alert(divs[0].id + "-" + divs[0].style.left);
	for (d=0;d<divs.length;d++) {
		p=divs[d];
		pl=p.style.left.match(rel).valueOf();
		pl--;
		//check to see if the image has scrolled off the screen
		if (pl < 0) {
			iw = p.getElementsByTagName("img")[0].style.width.match(rel).valueOf();
			if (pl < (iw*-1)) { 	//move img to end of line
				if (d==0) {	//move behind last image
					anchorimg = divs[divs.length-1];
					pad = 0;
				}
				else {		//move behind prior image in array
					anchorimg = divs[d-1];
					pad = 1;
				}
				ap = anchorimg.style.left.match(rel).valueOf();
				iw = anchorimg.getElementsByTagName("img")[0].style.width.match(rel).valueOf();
				pl = (ap*1)+(iw*1)+(pad*1);
			}
		}
		pu=p.style.left.match(reu);
		p.style.left=pl + pu;
	}
	window.setTimeout("horzscroll('" + scrolldiv + "'," + speed + ")",speed);
}

var email = "tim@iksploronline.com"

function confirmSubmit() {
	i=confirm("Are you sure you want to delete this record")
	if (i == true) { return true; }
	else { return false; }
}
function processFilters(obj) {
	fkey		=obj.id.substr(6,1);
	func		=obj.id.substr(10,4);
	if ( func == "hide" ) { retfunc="show" } else { retfunc="hide" }
	ele		=obj.id.substr(14,99);
	sa		=obj.id.substr(7,2);
	sakey		=obj.id.substr(9,1);
	fcontainerels	=obj.parentNode.id.split("|");
	fcontainer	=fcontainerels[1];
	ftagtype	=fcontainerels[2];
	if ( sa == "SA" ) {	//special processing to show All element
		document.getElementById("filter" + fkey + "SS" + sakey + "showAll").style.visibility="visible";
		sa = "AS";
	}
	else {
		if ( sa == "AS" ) { sa = "SA" }
	}
	//hide this element
	obj.style.visibility="hidden";
	//show corresponding element
	arFilters = document.getElementById(obj.parentNode.id).getElementsByTagName("span")	//this is used later as well
	if ( sa == "SS" ) {	//special processing for the show All element
		for (f=0;f<arFilters.length;f++) {
			if ( arFilters[f].id.substr(7,3) == "SA" + sakey ) {
				arFilters[f].style.visibility="visible";
			}
			if ( arFilters[f].id.substr(7,3) == "AS" + sakey ) {
				arFilters[f].style.visibility="hidden";
			}
		}
	}
	else {
		document.getElementById("filter" + fkey + sa + sakey + retfunc + ele).style.visibility="visible";
	}
	//now show or hide the actual elements
	arEles = document.getElementById(fcontainer).getElementsByTagName(ftagtype);
	if ( func == "hide" ) {		//hiding is easy. Just find any items in the container and hide them
		for (e=0;e<arEles.length;e++) {
			if ( arEles[e].id.indexOf(ele,0)>=0 && arEles[e].style.display!="none" ) {
				arEles[e].style.display="none";
			}
		}
	}
	else {	//showing is not so easy. Only show those items not hidden by other filters
		//first, find all the hidden filters for this filter group
		hlist = "";
		slist = "";
		for (f=0;f<arFilters.length;f++) {
			affkey = arFilters[f].id.substr(6,1);
			if ( fkey == affkey ) { //same filter group
				afele=arFilters[f].id.substr(14,99);
				affunc=arFilters[f].id.substr(10,4);
				afsa=arFilters[f].id.substr(7,2);
				if ( affunc == "show" && arFilters[f].style.visibility == "visible" && afsa != "SS" ) { //disregard show all filters	
					hlist = hlist + (hlist!=""?"|":"") + afele;
				}
				//build the show list at the same time in case this is a show all
				afsakey=arFilters[f].id.substr(9,1);
				if ( sa == "SS" && afsakey == sakey && afsa == "SA" ) {
					slist = slist + (slist!=""?"|":"") + afele;
				}
			}
		}
		if ( sa != "SS" ) { slist = ele }
		//now loop through the container elements comparing each element in filter flag list
		//against the hide list and the show list
		//if a filter flag matches a show flag AND is not in the hide list, show the element				
		arHide = hlist.split("|");
		arShow = slist.split("|");
		for (e=0;e<arEles.length;e++) {
			if ( (arEles[e].style.display=="none") && (arEles[e].id.indexOf(ele,0)>=0 || sa == "SS") ) { //not applicable if already showing
				//find if this element needs to stay hidden
				d = "allow";
				arFlags = arEles[e].id.split("|");
				//alert( "test-" + (arEles[e].style.display=="") + " F-" + arFlags + " H-" + arHide + " S-" + arShow)
				for (f=0;f<arFlags.length;f++) {
					for (h=0;h<arHide.length;h++) {
						if ( arFlags[f] == arHide[h] ) {
							d = "forbid";
							break;
						}
					}
				}
				//if showing is still allowed, see if this element should be shown
				if ( d == "allow" ) {
					for (f=0;f<arFlags.length;f++) {
						for (s=0;s<arShow.length;s++) {
							if ( arFlags[f] == arShow[s] ) {
								arEles[e].style.display="inline";
								break;
							}
						}
					}
				}
			}
		}
	}
}

