﻿function init(menuID, ballID, imageName) {
	document.getElementById(menuID).className = 'menuCurr';
	//document.getElementById(ballID).src = imageName;
	//alert(document.getElementById(ballID).src);
}
function  nextGallery(galleryNum,gid) {
    elem = document.getElementById("scrollparent");
    elemScroll = document.getElementById("scroll");
    totalLen = elemScroll.clientHeight;
    intervals = 10;
    if (elem.LocationChangeMemInt)
        window.clearInterval(elem.LocationChangeMemInt);
    elem.LocationChangeMemInt = window.setInterval(
	function() {
	    var strT = elem.style.height;
		strT = strT.replace("px", "");
	    if (strT <= 0) {
	         window.clearInterval(elem.LocationChangeMemInt);
	         galleryPos = (galleryNum - 1)*330*-1;
	         elemScroll.style.top = galleryPos + "px";
	         //alert(elemScroll.clientHeight);
	         elem.style.height = "340px";
		    prevPageID = document.getElementById("gid").innerHTML;
		    document.getElementById(gid).className = "galleryNumCurr";
		    document.getElementById(prevPageID).className = "galleryNum";
		    document.getElementById("gid").innerHTML = gid;
	    }
		var nextPos = parseInt(strT) -20;
  	    //document.getElementById("test").innerHTML = nextPos;
		elem.style.height = nextPos + "px";
	}
	, intervals)
}

var STARTINGOPACITY = 40;

function scrollUp() {
    elem = document.getElementById("scrollparent");
    elemScroll = document.getElementById("scroll");
    totalLen = elemScroll.clientHeight;
    gap=-2;
    endT = totalLen *-1;
    intervals = 25;
    if (elem.LocationChangeMemInt)
        window.clearInterval(elem.LocationChangeMemInt);
    elem.LocationChangeMemInt = window.setInterval(
	function() {
	    var strT = elemScroll.style.top;
		strT = strT.replace("px", "");
	    if (strT <= endT) {
	         window.clearInterval(elem.LocationChangeMemInt);
	         scrollDown();
	    }
		var nextPos = parseInt(strT) + parseInt(gap);
  	   // document.getElementById("test").innerHTML = nextPos;
		elemScroll.style.top = nextPos + "px";
	}
	, intervals)
}
function scrollDown() {
    elem = document.getElementById("scrollparent");
    elemScroll = document.getElementById("scroll");
    totalLen = elemScroll.clientHeight;
  elemScroll.style.opacity = STARTINGOPACITY * .01;
  elemScroll.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
    gap=2;
    endT = 0;
    //alert(endT);
    intervals = 5;
    if (elem.LocationChangeMemInt)
        window.clearInterval(elem.LocationChangeMemInt);
    elem.LocationChangeMemInt = window.setInterval(
	function() {
	    var strT = elemScroll.style.top;
		strT = strT.replace("px", "");
	    if (strT >= endT) {
	         window.clearInterval(elem.LocationChangeMemInt);
			  elemScroll.style.opacity = 1;
  			  elemScroll.style.filter = 'alpha(opacity=100)';
	         var t=setTimeout("scrollUp()",2000);
	    }
		var nextPos = parseInt(strT) + parseInt(gap);
  	    //document.getElementById("test").innerHTML = nextPos;
		elemScroll.style.top = nextPos + "px";
	}
	, intervals)
}
function stopMove() {
    elem = document.getElementById("scrollparent");
    if (elem.LocationChangeMemInt)
        window.clearInterval(elem.LocationChangeMemInt);
       
}
function getPic(dir) {
        thisOne = document.getElementById("picarea");
		items = thisOne.getElementsByTagName("img");
		currPic = document.getElementById("currpicnum").innerHTML;
		nextPic = Number(currPic) + dir;
		if ((nextPic <= items.length) && (nextPic >= 1)) {
		    document.getElementById("currpicnum").innerHTML = nextPic;
		    document.getElementById("mainpic").src = items[nextPic - 1].src;
		    document.getElementById("mainpic").alt = items[nextPic-1].alt;
		    document.getElementById("pictitle").innerHTML = items[nextPic-1].alt;
		    //document.getElementById("mainlink").href = items[nextPic - 1].src;
		    //document.getElementById("mainlink").title = items[nextPic - 1].alt;
		}
	
	}
	function open_win(url_add, winW, winH, winX, winY) {
	    //alert('width=' + winW + 'height=' + winH + ',resizable=1,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
	    picwin = window.open(url_add, '_blank', 'width=' + winW + ' ,height=' + winH + ',resizable=1,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
	    picwin.moveTo(winX, winY);
	    picwin.focus();
	}

