var browser = navigator.appName;
var isIE  = (browser == "Microsoft Internet Explorer");
var version = navigator.appVersion;
var isIEVer7 = version.search("MSIE 7.0") > 0;
var isNS = (browser == "Netscape");
var isOpera = (browser == "Opera");

function $(i){return document.getElementById(i);}
function $$(e,p){p=p||document; return p.getElementsByTagName(e);}

function pageLoad() 
{
	if(document.getElementById("slideshow") != null)
	{
		slideshow.auto=true;
		slideshow.speed=5;
		//slideshow.link="linkhover";
		slideshow.info="information";
		slideshow.thumbs="slider";
		slideshow.left="slideleft";
		slideshow.right="slideright";
		slideshow.scrollSpeed=4;
		slideshow.spacing=5;
		slideshow.active="#fff";
		slideshow.init("slideshow","image","imgprev","imgnext","imglink");
	}
}

function showDiv(linkId){
	var picData =  document.getElementById("picData");
	var linkIdObj = document.getElementById(linkId);
	var x = findPosX(linkIdObj.parentNode);
	var y = findPosY(linkIdObj.parentNode);
	picData.style.left = (x + 2) + "px";
	picData.style.top = (y + 5) + "px";
	var title = linkIdObj.title;
	picData.innerHTML = title;
	picData.style.visibility = "visible";
}

function hideDiv(){
	document.getElementById("picData").style.visibility = "hidden";
}
function findPosX(obj)
{
	var curleft = 0;
	if(isIEVer7)
	{
		while(obj.parentNode){
			curleft += obj.offsetLeft ? obj.offsetLeft: 0;
			if(obj == document.body)
				break;
			obj = obj.parentNode;
		}
	} else {
		if (obj) {
			curleft = obj.offsetLeft;
		} else {
			curleft = 0;
		}
	}
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if(isIEVer7) {
		while(obj.parentNode){
			curtop += obj.offsetTop ? obj.offsetTop: 0;
			if(obj == document.body) 
				break;
			obj = obj.parentNode;
		}
	} else {
		if (obj) {
			curtop = obj.offsetTop;
		} else {
			curtop = 0;
		}
	}
	return curtop;
}

var a = 0;
var intervalID;
var cb;
var picToShow;
function contact() 
{
	cb = $('contactBox');
	cb.style.opacity = 0;
	cb.style.filter = 'alpha(opacity = 0)';
	$('mask').setAttribute("class","dialog-mask");
	cb.setAttribute("class","dialog-box");
	intervalID = setInterval ("addToAlpha(5,cb);",40);
}

function addToAlpha(amount,sender){
	a += amount;
	if(a >= 100) {
		sender.style.opacity = 1;
		sender.style.filter='alpha(opacity ='+ 100 +')';
		clearInterval(intervalID);
		a = 0;
	} else {
		sender.style.opacity = a/100;
		sender.style.filter='alpha(opacity ='+ a +')';
	}
}
function closeDialogBox() 
{
	clearInterval(intervalID);
	$('mask').setAttribute("class","hidden");
	$('contactBox').setAttribute("class","hidden contactBox");
	if(picToShow != null) {
		picToShow.innerHTML = "";
		picToShow.setAttribute("class","hidden");
	}
}

function checkForm(){ 
	if(document.contactBox.email.value == ''){ 
		alert("please enter your Email address so I can replay"); 
		document.contactBox.email.focus(); 
		return false; 
	} else {
		closeDialogBox();
		return true;
	}
} 

function showFullPreview(picName,width,height)
{
	var pageHeight = GetPageHeight();
	var pageWidth = GetPageWidth();
	picToShow = $('fullPreview');
	picToShow.style.opacity = 0;
	picToShow.style.filter = 'alpha(opacity = 0)';
	$('mask').setAttribute("class","fullPreviewMask");
	picToShow.setAttribute("class","");
	picToShow.innerHTML = '<img src="' + picName + '"'
						+ ' alt="fullPreviewPicture"'
						+ ' width="' + width + 'px"'
						+ ' height="' + height + 'px"'
						+ ' onclick="closeDialogBox()"'
						+ ' title="Click to close"'
						+ ' />';
	if(width == 500) // landscape picture
	{
		picToShow.style.top = (Math.round(pageHeight/2) - 165) + 'px';
		picToShow.style.left = (Math.round(pageWidth/2) - 250) + 'px';
	}
	if(height == 450) // portrait picture
	{
		picToShow.style.top = (Math.round(pageHeight/2) - 225) + 'px';
		picToShow.style.left = (Math.round(pageWidth/2) - 150) + 'px';
	}
	intervalID = setInterval ("addToAlpha(10,picToShow);",20);
}

function GetPageWidth(){
	// for all except Explorer
	if (self.innerWidth) {
		return self.innerWidth;
	// Explorer 6 Strict Mode
	} else if (document.documentElement && document.documentElement.clientWidth) {
		return document.documentElement.clientWidth;
	// other Explorers
	} else if (document.body) {
		return document.body.clientWidth;
	}
	return 0;
}
function GetPageHeight(){
	// for all except Explorer
	if (self.innerHeight) {
		return self.innerHeight;
	// Explorer 6 Strict Mode
	} else if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	// other Explorers
	} else if (document.body) {
		return document.body.clientHeight;
	}
	return 0;
}
