var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

/*-----------------------------------------------------------------------------------------------*/

//Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/

function getBrowserInfo() {
	if (checkIt('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser 	= "Safari"
	else if (checkIt('omniweb')) browser 	= "OmniWeb"
	else if (checkIt('opera')) browser 		= "Opera"
	else if (checkIt('webtv')) browser 		= "WebTV";
	else if (checkIt('icab')) browser 		= "iCab"
	else if (checkIt('msie')) browser 		= "Internet Explorer"
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux')) OS 		= "Linux";
		else if (checkIt('x11')) OS 	= "Unix";
		else if (checkIt('mac')) OS 	= "Mac"
		else if (checkIt('win')) OS 	= "Windows"
		else OS 						= "an unknown operating system";
	}
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function prepareIE(height, overflow){
	bod = document.getElementsByTagName('body')[0];
	bod.style.height = height;
	bod.style.overflow = overflow;

	htm = document.getElementsByTagName('html')[0];
	htm.style.height = height;
	htm.style.overflow = overflow; 
}

function activate(){
	if (browser == 'Internet Explorer'){
		prepareIE('100%', 'hidden');
	}
	else{
		document.body.style.overflow = "hidden";
	}
}

function deactivate(){
	
	if (browser == "Internet Explorer"){
		prepareIE("auto", "auto");
	}
	else{
		document.body.style.overflow = "scroll";
	}
}

function gradient(id, level){
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id){
	var level = 0;
	while(level <= 1){
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}


// Open the lightbox

yPos = 0;
xPos = 0;


function setScroll(x, y){
	window.scrollTo(x, y); 
	activate();
}

function openbox(formtitle, fadin){
	getBrowserInfo();
	setScroll(xPos, yPos);
	var box = document.getElementById('box'); 
	document.getElementById('filter').style.display='block';
	
	var btitle = document.getElementById('boxtitle');
	btitle.innerHTML = formtitle;
	
	if(fadin){
		gradient("box", 0);
		fadein("box");
	}
	else{ 	
		box.style.display='block';
	}  	
}


// Close the lightbox

function closebox(){
	deactivate()
   	document.getElementById('box').style.display='none';
   	document.getElementById('filter').style.display='none';
}




