//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";

	image2 = new Image();
	image2.src = "images/gallery/HOU_000B.jpg";

	image3 = new Image();
	image3.src = "images/gallery/HOU_000E.jpg";

	image4 = new Image();
	image4.src = "images/gallery/HOUSE5.jpg";

	image5 = new Image();
	image5.src = "images/gallery/HOU_0008.jpg";

	image6 = new Image();
	image6.src = "images/gallery/HOUSE1GR.jpg";

	image7 = new Image();
	image7.src = "images/gallery/HOUSE1SC.jpg";

	image8 = new Image();
	image8.src = "images/gallery/SchmeerbauchFRNT.jpg";

	image9 = new Image();
	image9.src = "images/gallery/HOUSE2GR.jpg";

	image10 = new Image();
	image10.src = "images/gallery/HOUSE4KT.jpg";

	image11 = new Image();
	image11.src = "images/gallery/ROS_0012.jpg";

	image12 = new Image();
	image12.src = "images/gallery/SchmeerbauchTHT.jpg";

	image13 = new Image();
	image13.src = "images/gallery/SchmeerbauchDR.jpg";

	image14 = new Image();
	image14.src = "images/gallery/HOUSE2KT.jpg";

	image15 = new Image();
	image15.src = "images/gallery/SchmeerbauchPL3.jpg";

	image16 = new Image();
	image16.src = "images/gallery/SchmeerbauchFY.jpg";

	image17 = new Image();
	image17.src = "images/gallery/GaryPlayerDrGR2.jpg";

	image18 = new Image();
	image18.src = "images/gallery/House5LL2.jpg";

	image19 = new Image();
	image19.src = "images/gallery/GaryPlayerDrKT2.jpg";

	image20 = new Image();
	image20.src = "images/gallery/GaryPlayerDr.jpg";

	image21 = new Image();
	image21.src = "images/gallery/SchmeerbauchMB.jpg";

	image22 = new Image();
	image22.src = "images/gallery/HOU_0015.jpg";

	image23 = new Image();
	image23.src = "images/gallery/GaryPlayerLL.jpg";

	image24 = new Image();
	image24.src = "images/gallery/SchmeerbauchEXTc.jpg";

	image25 = new Image();
	image25.src = "images/gallery/SchmeerbauchKT1c.jpg";

	image26 = new Image();
	image26.src = "images/gallery/SchmeerbauchDRc.jpg";

	image27 = new Image();
	image27.src = "images/gallery/SchmeerbauchGRc.jpg";

	image28 = new Image();
	image28.src = "images/gallery/SchmeerbauchMBc.jpg";

	image29 = new Image();
	image29.src = "images/gallery/SchmeerbauchKT.jpg";

	image30 = new Image();
	image30.src = "images/gallery/SchmeerbauchEXT1.jpg";

	return true;
}

function showLayer(layer)
{
	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<30)
		step++
	else
		step=1
	setTimeout("slideit()",5000)
}
