/*****************************************************************
GENERIC SITE FUNCTIONS
*****************************************************************/
<!--
//	DOM
var IE=false;
var MOZ5=false;
var NS=false;

//	Detect browser
detectBrowser();

/*
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
*/

//	Determine the current browser
function detectBrowser() 
{
	if (document.all) {
	  IE = true;
	}
	else if (document.layers) {
	  NS = true;
	}
	else if (document.getElementById) {
	  MOZ5 = true;
	}
	else {
	  NS = true;
	  // No known browser support for layers
	}
}

function over(img,ext)
{
	if (ext == null)
		img.src=site_root + 'img/' + img.id + '_f2.jpg';
		
	else
		img.src=site_root + 'img/' + img.id + '_f2.' + ext;
}

function out(img,ext)
{
	if (ext == null)
		img.src=site_root + 'img/' + img.id + '.jpg';
		
	else
		img.src=site_root + 'img/' + img.id + '.' + ext;
}

function openTour(tour,bandwidth)
{
	var width=480;
	var height=360;
	
	switch (bandwidth)
	{
		case 'dialup':
			width=240;
			height=180;
			
			break;
			
		default:
	}
	
	window.open(tour,'tour','status=false,height='+height+',width='+width);
}

function viewImage(img)
{	
	window.open(img,'img','height=600,width=800');
}
	

function preloadImages()
{
	if (!document.images)
		return;
		
	for (i = 0; i < document.images.length ; i++)
	{
		img = new Image();
		img_src = site_root + 'img/' + document.images[i].id + '_f2.jpg';
		img.src = img_src;
	}
	
	return true;
}

//	Get document object by string names
function getObj(str,array)
{
	if (IE)
		obj = document.all[str];
		
	else if (MOZ5)
	{
		if (array!=null)
			obj = document.getElementsByName(str);
		else
			obj = document.getElementById(str);
	}
	else 
		obj = document.layers[str];
		
	if (obj == null)
		return false;
		
	return obj;
}

function insert(obj,str)
{
	if (!obj)
		return false;
		
	if (IE || MOZ5)
		obj.innerHTML = str;
		
	else
		obj.write(str);
	
	return;
}

function setStyle(o,fieldclass)
{   
    if(o){
    	if (IE)
    		return o.setAttribute('className',fieldclass);

    	else
    		return o.setAttribute('class',fieldclass);
    }
}
	
//	Empties a dropdown box
//	Params - object[,object,object...]
function emptyDD()
{
	a=emptyDD.arguments;
	
	for (i=0;i<a.length;i++)
	{
		obj=a[i];
		
		if (!obj || !obj.options)
			continue;

		for(j=0;j<obj.options.length;j++)
			obj.options[j]=null;
	}	
}

function fillTxt(msg,t,e)
{	
	if (t==null)
		return false;
		
	switch (e)
	{
		case 'on':
			if (t.value==msg)
				t.value='';
				
			break;
			
		case 'off':
			if (t.value=='')
				t.value=msg;
				
			break;
	}
	
	return;
}

function showMsg(msg,mode)
{
//	Get object
	m=getObj('msg_layer');
	
	if (!m)
		return;
		
//	Insert message
	insert(m,msg);
	
//	Position layer
	center(m);
	
//	Display Layer
	m.style.display='inline';
	
	window.onscroll=center;
	window.onresize=center;
}

function center(obj)
{			
	if (window.pageYOffset)
	{
		var left=(window.innerWidth/2)-275;
		var top=parseInt(((window.innerHeight/2)-65))+parseInt(window.pageYOffset);
	}
	else
	{
		var left=(document.body.clientWidth/2)-275;
		var top=parseInt(document.body.clientHeight)-parseInt(((screen.width/2)-65));
	}
	
	if (top<=230)
		top=230;
		
	obj.style.left=left+'px';
	obj.style.top=top+'px';
}

function openGallery(root)
{
	if (root==null)
		root = '.';
		
	window.open(root+'','','width=680,height=570,scrollbars=no');
}

//-->
