//BROWSER SNIFFER

function Is() {
    this.ie4 = document.all && !document.getElementById;
	this.ns4 = document.layers;
	this.ie5 = document.all && document.getElementById;
	this.ns6 = document.getElementById && !document.all;
}

var is = new Is()

if(is.ns4) {
	doc = "document";
	sty = "";
	htm = ".document"
}
else if(is.ie4 || is.ie5) {
	doc = "document.all";
	sty = ".style";
	htm = ""
}
else if(is.ns6) {
	doc = "document.getElementById(";
	sty = ").style";
	htm = ""
}

//PRELOADER
function preLoad() 
{
	image1 = new Image();
	image1.src = "images/gallery/GAR_0009.jpg";


	return true;
}

function showLayer(layer)
{
	hideLyr = eval(doc + '["PR1"]' + sty);
	hideLyr.visibility = "hidden";
	hideLyr = eval(doc + '["PR2"]' + sty);
	hideLyr.visibility = "hidden";
	hideLyr = eval(doc + '["PR3"]' + sty);
	hideLyr.visibility = "hidden";
	hideLyr = eval(doc + '["PR4"]' + sty);
	hideLyr.visibility = "hidden";
	showLyr = eval(doc + '["' + layer + '"]' + sty);
	showLyr.visibility = "visible";
}

function hideLayer(layer)
{
	hideLyr = eval(doc + '["' + layer + '"]' + sty);
	hideLyr.visibility = "hidden";
}

var win=null;
function NewWindowHood(mypage,myname,w,h,scroll){
	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
}

function NewWindow(mypage, name)
{
	settings='top=0,left=0,scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes';
	win=top.open(mypage, name);
}

//var top = 0;
var clipTop = 0;
//var clipLeft = 0;
//var clipWidth = 212;
//var clipBottom = 0;
//var topper = 300;
var lyrheight = 0;

function prepLyr()
{
//alert("in prepLyr");
	var textLyr = eval(doc + '["scrollText"]' + sty);
	//messageLyr = eval(doc + '["loadingMessage"]' + sty);
	if (is.ns4)
	{
		lyrheight = textLyr.clip.bottom;
		//lyrheight += 20;
		textLyr.clip.top = clipTop;
		textLyr.clip.left = clipLeft;
		textLyr.clip.right = clipRight;
		textLyr.clip.bottom = clipBottom;
	}
	else
	{
		if(is.ns6)
		{
			lyrheight = lyrheightNS6;
			lyrwidth = document.getElementById("scrollText").offsetWidth;
		}
		else
		{
			lyrheight = scrollText.offsetHeight;
			lyrwidth = scrollText.offsetWidth;
		}
			
		textLyr.clip = 'rect('+clipTop+' '+clipRight+' '+clipBottom+' 0)'
	}
	textLyr.visibility = "visible";
	//messageLyr.visibility = "hidden";
	//preLoad();
}

var loop = false;
//var direction = "up";
var timer1 = null;
function scroll(dir)
{
	textLyr = eval(doc + '["scrollText"]' + sty);
	//lyrheight = text.offsetHeight;
    direction = dir;
    speed = 1;
    var y_pos = parseInt(textLyr.top);
    var x_pos = parseInt(textLyr.left);
	if(direction == "down") 
	{
		if(clipBottom > lyrheight)
			return;
		textLyr.top = (y_pos-(speed));
		clipTop += speed;
		clipBottom  += speed;
		if (is.ns4)
		{
			textLyr.clip.top = clipTop;
			textLyr.clip.bottom = clipBottom;
			//alert(textLyr.clip.top);
		}
		else
		{
			clipstring = 'rect('+clipTop+' '+lyrwidth+' '+clipBottom+' 0)';
			textLyr.clip = clipstring;
		}
		clearTimeout(timer1);
		timer1 = setTimeout("scroll(direction,speed)", 2);
	} 
	else if(direction == "up") 
	{
		if(y_pos > top)
			return;
		textLyr.top = (y_pos+(speed));
		clipTop -= speed;
		clipBottom  -= speed;
		if (is.ns4)
		{
			textLyr.clip.top = clipTop;
			textLyr.clip.bottom = clipBottom;
			//alert(textLyr.clip.top);
		}
		else
		{
			clipstring = 'rect('+clipTop+' '+lyrwidth+' '+clipBottom+' 0)';
			textLyr.clip = clipstring;
			//textLyr.top = topper;
		}
		clearTimeout(timer1);
		timer1 = setTimeout("scroll(direction,speed)", 2);
	}
	else if(direction == "right") 
	{
		if(clipRight > lyrwidth)
			return;
		textLyr.left = (x_pos-(speed));
		clipLeft += speed;
		clipRight  += speed;
		if (is.ns4)
		{
			textLyr.clip.left = clipLeft;
			textLyr.clip.right = clipRight;
			//alert(textLyr.clip.top);
		}
		else
		{
			clipstring = 'rect('+clipTop+' '+clipRight+' '+clipBottom+' '+clipLeft+')';
			textLyr.clip = clipstring;
		}
		clearTimeout(timer1);
		timer1 = setTimeout("scroll(direction,speed)", 2);
	} 
	else if(direction == "left") 
	{
		if(x_pos > leftStop)
			return;
		textLyr.left = (x_pos+(speed));
		clipLeft -= speed;
		clipRight  -= speed;
		if (is.ns4)
		{
			textLyr.clip.left = clipLeft;
			textLyr.clip.right = clipRight;
			//alert(textLyr.clip.top);
		}
		else
		{
			clipstring = 'rect('+clipTop+' '+clipRight+' '+clipBottom+' '+clipLeft+')';
			textLyr.clip = clipstring;
			//textLyr.top = topper;
		}
		clearTimeout(timer1);
		timer1 = setTimeout("scroll(direction,speed)", 2);
	}
	return;
}	

function stopScroll()
{
	if (timer1) clearTimeout(timer1);
}

var step=1
var whichimage=1
function slideit(){
	if (!document.images)
		return
	//If the browser is IE 4.x
	if (document.all)
		slide.filters.blendTrans.apply()
	if(!is.ns4)
		document.slide.src=eval("image"+step+".src")
	//If the browser is IE 4.x
	if (document.all)
		slide.filters.blendTrans.play()
	whichimage=step
	if (step<3)
		step++
	else
		step=1
	setTimeout("slideit()",5500)
}
