var space = 110;
var curPos = 0;
var clickable = true;

function scroll(dir) {
if (!clickable) {
 return false;
}
 if (dir == 'forward') {
  if (Math.abs(curPos)/space < totalRows-1) {
   target = curPos-space;
  } else {
   return false;
  }
 } else {
  if (Math.abs(curPos)/space > 0) {
   target = curPos+space;
  } else {
   return false;
  }
 }
 doScroll(dir, target);
}

function doScroll(dir, target) {
clickable = false;
curPos = (dir == 'forward') ? curPos-10:curPos+10;
document.getElementById('tn').style.top = curPos+'px';
if ((dir == 'forward' && curPos > target) || (dir == 'backward' && curPos < target)) {
 scrolling = setTimeout("doScroll('"+dir+"', "+target+")", 1);
} else {
 document.getElementById('tn').style.top = target+'px';
 curPos = target;
 document.getElementById('row').innerHTML = (Math.abs(curPos)/space)+1 + ' of '+totalRows;
 clickable = true;
}
}

function chooseIt(id) {
info_split = info[id].split(":");
document.getElementById('frame_text').innerHTML = info_split[2];
obj = document.getElementById('galleryPic');
obj.src = "images/gallery/medium/"+info_split[1];
if (info_split[0] == 'h') {
 document.getElementById('frame_picture').className = 'picture_horiz';
 obj.width = '400';
 obj.height = '300';
} else {
 document.getElementById('frame_picture').className = 'picture_vert';
 obj.width = '300';
 obj.height = '400';
}
}

var posx = 0;
var posy = 0;

//function doSomethingInit() {
document.onmousemove = doSomething;
//}

function doSomething(e) {

	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}

    winSize = windowSize();
    
    centerOffset = (posx < winSize[0]/2) ? 12:-210;
	
	document.getElementById('hoverDiv').style.top = posy-25 + 'px';
	document.getElementById('hoverDiv').style.left = posx+centerOffset + 'px';
	
	//document.FormName.top.value = posy;
	//document.FormName.left.value = posx;
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}

function killSomething() {
 // Do nothing, which kills the movement of the div.
}

function hoverDiv(option, div_name, id) {
//document.onmousemove = doSomething;
obj = document.getElementById(div_name);
info_split = info[id].split(":");
document.getElementById('hoverDiv').innerHTML = info_split[2];
if (option == 'show') {
//	obj.style.top = posy-20 + 'px';
//	obj.style.left = posx+20 + 'px';
	obj.style.display = 'block';
} else {
// document.onmousemove = killSomething;
 obj.style.display = 'none';
}
}

function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
//  window.alert( 'Width = ' + myWidth );
//  window.alert( 'Height = ' + myHeight );
  return [myWidth,myHeight];

}