/*### START HERE... ########*/
//function divObject () {return isIE ? document.all ("divPhoto") : document.getElementById ("divPhoto");}
/*########################### PRELOAD IMAGES ##############################################*/
var arwPhotos = new Array ();
for (var i = 1;i < 16;i ++) { arwPhotos [i-1] = new Image (); arwPhotos [i-1].src = "images/PhotoGallery/img" + i + ".jpg"; }
/*########################### PRELOAD IMAGES ##############################################*/

//### COMMON ######
var DIV_WIDTH = 190;
var DIV_H_HEIGHT = 127;
var DIV_V_HEIGHT = 450;
var isNN = (navigator.appName.toLowerCase().indexOf('netscape') >= 0) ? true : false;
var isIE = (navigator.appName.toLowerCase ().indexOf ('microsoft') >= 0) ? true : false;
var isOther = (isIE) ? "IE" : ((isNN) ? "NN" : "Other")
var thisPic;
var thisBar;
var interval;
var imgCnt = 0;
var hasDone;
var isDoing;
var hasShrunken;
var hasWiden;
//this.wipeLeft = wipeLeft;
function initSS ()
{
	if (isIE){
		thisPic = document.images ("imgPhoto"); //### Pass names of your IMG and DIV elements here and
		thisBar = document.all ('divPhoto'); }  //### No more you need to refer them by names...
	else if (isNN){
		thisPic = document.getElementById ("imgPhoto");
		thisBar = document.getElementById ('divPhoto');}
	hasDone = false; hasShrunken = false; hasWiden = false; isDoing = false;
}
function setCenter ()
{
	var theWidth = getWidth ();
	thisBar.style.left = ((document.body.offsetWidth-theWidth) / 2)-9 //<- the approx. width of VScrollBar;
}

//### Implement effects as per need...
function wipeRight () {}
function wipeUp () {}
function wipeDown () {}
function wipeLeft ()
{
	//var curWidth = getWidth ();
	//alert (curWidth);
	if (isDoing && hasShrunken && ! hasWiden && ! hasDone) {
		if (isIE) thisPic.src = arwPhotos [imgCnt].src;
		else if (isNN) document.thisPic.src = arwPhotos [imgCnt].src;
	}
	if ((hasShrunken && hasWiden) && isDoing){
		hasDone = true; isDoing = false; hasWiden = false;hasShrunken = false; clearInterval (interval); return;}
	
	if (! hasShrunken){
		isDoing = true;
		shrunken ();
	}
	else if (! hasWiden && hasShrunken){
		isDoing = true;
		widen ();
	}
	if ((! hasShrunken || ! hasWiden) && ! hasDone) {
		clearInterval (interval);
		interval = setInterval (wipeLeft,1);
	}
}

/*### Utility functions..*/
function shrunken (){
	if (! hasShrunken && isDoing && getWidth () > 0) {
		thisBar.style.width = getWidth () - Math.min (getWidth (), 8);
	}
	else {hasShrunken = true;}
	//document.title="Shrinking " + hasShrunken;
}

function widen (){
	if (! hasWiden && isDoing && getWidth () < DIV_WIDTH) {
		thisBar.style.width = getWidth () + 8;
	}
	else {hasWiden = true;}
	//document.title="Widening " + hasWiden;
}

function getHeight (){
	var thisBar = document.getElementById (theBar);
	return (thisBar.style.height.indexOf ('px') > 0) ? eval (thisBar.style.height.substring (0,thisBar.style.height.indexOf ('px'))) : thisBar.style.height;
}
function getWidth (){	
	return (thisBar.style.width.indexOf ('px') > 0) ? eval (thisBar.style.width.substring (0,thisBar.style.width.indexOf ('px'))) : thisBar.style.width;
}
/*### Utility functions..*/

//### Call each routine per load of photo
function ShowSlides (dirNP){
	hasDone = false;
	if (dirNP.toLowerCase ().substring (0,1) == 'n') { //### Next is the direction
		if (imgCnt < arwPhotos.length-1) {wipeLeft ();imgCnt ++;}
		else {imgCnt = 0; return false;}
	}
	if (dirNP.toLowerCase ().substring (0,1) == 'p') { //### Previous is the direction
		if (imgCnt >= 1) {wipeLeft ();imgCnt --;}
		else {imgCnt = arwPhotos.length-1; return false;}
	}
	//window.status = "Current : " + imgCnt;
}

function selfCheck (){
	//alert ("Changed..."); if (getWidth () <= 0) wipeLeft ();
}
/*### OVER HERE... ######*/