﻿function gfClick(dest)
{
	window.location = dest;
}
function gfClickWhy()
{
	window.open('whychange.asp',null,'width=645,height=515,location=no,toolbar=no,scrollbars=no,resizable=no,top=10,left=10');
}
function gfClickNew(dest,w,h)
{
	window.open(dest,null,"width=" + w + ",height=" + h + ",location=no,toolbar,scrollbars,resizable,top=0,left=0");
}
function gfClickHelp(dest)
{
	window.open(dest,null,"width=780,height=570,location=no,toolbar=no,scrollbars,resizable=no");
}
function gfGO(cmd,opt,opt2,opt3)
{
	if (opt) 
	{
		document.frm.h_opt.value = opt;
	}
	else
	{
		document.frm.h_opt.value = "";
	}
	if (opt2) 
	{
		document.frm.h_opt2.value = opt2;
	}
	else
	{
		document.frm.h_opt2.value = "";
	}
	if (document.frm.h_opt3) 
	{
		if (opt3) 
		{
			document.frm.h_opt3.value = opt3;
		}
		else
		{
			document.frm.h_opt3.value = "";
		}
	}
	document.frm.h_btn.value = cmd;
	document.frm.submit();
}
function gfGOF(cmd,fme)
{
	document.frm.h_btn.value = cmd;
	document.frm.submit();
}
function gfIconOvr(btn)
{
	window.event.srcElement.src = "images/" + btn + "on.gif";
}
function gfIconOut(btn)
{
	window.event.srcElement.src = "images/" + btn + ".gif";
}
function gfBtnOvr()
{
	window.event.srcElement.style.backgroundColor = "#000000";
	window.event.srcElement.style.color = "#FFCC33";
	window.event.srcElement.style.cursor = "hand";
}
function gfBtnOut()
{
	window.event.srcElement.style.backgroundColor = "";
	window.event.srcElement.style.color = "";
	window.event.srcElement.style.cursor = "default";
}
function gfTBtnOvr()
{
	window.event.srcElement.style.backgroundColor = "#FFCC33";
	window.event.srcElement.style.color = "#000000";
	window.event.srcElement.style.cursor = "hand";
}
function gfTBtnOut()
{
	window.event.srcElement.style.backgroundColor = "";
	window.event.srcElement.style.color = "";
	window.event.srcElement.style.cursor = "default";
}
function gfNavImg(fld,img)
{
	if (document.images)
	{
		document[fld].src = img;
	}
}
function gfNavOver()
{
	window.event.srcElement.style.backgroundColor = "#ffcc00";
	window.event.srcElement.style.color = "#000000";
	window.event.srcElement.style.cursor = "hand";
}
function gfNavOut()
{
	window.event.srcElement.style.backgroundColor = "";
	window.event.srcElement.style.color = "";
	window.event.srcElement.style.cursor = "default";
}
function gfOnLoad(fld)
{

	gOnLoad
	var i,j;
	for (i = 0; i < document.forms.length; i++)
	{
		for (j = 0; j < document.forms[i].length; j++)
		{
			if (document.forms[i][j].name == fld)
			{	
				document.forms[i][j].focus();
				//document.forms[i][j].select();
			}
		}
	}	
	
}
function gfImageError(obj)
{
	obj.src = 'images/imgerror.gif';
}
function gfArrowChange(obj, divchange)
{
    if(obj.src.indexOf("arrowdown.gif") >= 0)
    {
        obj.src = 'site/arrowright.gif';
        temp = document.getElementById(divchange);
		temp.className = "invisible";
		createCookie('arrow' + divchange, 'R', '');
    }
    else
    {
        obj.src = 'site/arrowdown.gif';
        temp = document.getElementById(divchange);
		temp.className = "visible"; 
		createCookie('arrow' + divchange, 'D', '');
    }
}
function hideDiv(divName)
{
    document.getElementById(divName).className = "invisible";
}
function showDiv(divName)
{
    document.getElementById(divName).className = "visible";
}
function swapDiv(divName)
{
    if(document.getElementById(divName).className == "visible")
    {
        document.getElementById(divName).className = "invisible";
    }
    else
    {
        document.getElementById(divName).className = "visible";
    }
}
function hideDivsIn(id) {
navRoot = document.getElementById(id);
for (i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
		if (node.nodeName=="DIV") {
			node.className="invisible";
		}
	}
}
function switchTo(id, hide) {
	hideDivsIn(hide);
	temp = document.getElementById(id);
	temp.className = "visible";
}
function mouseSwap(obj)
{
    var ext = obj.src.substr(obj.src.length - 4, 4);
    
    if(obj.src.indexOf('_on') >= 0)
    {
        obj.src = obj.src.substr(0, obj.src.length - 7) + ext;
    }
    else
    {
        obj.src = obj.src.substr(0, obj.src.length - 4) + '_on' + ext;
    }
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function swapRotate(id, count)
{
//   opacity(id, 100, 0, 1000);
    
//    shiftOpacity(id, 1000);
    document.getElementById(id).src = "images/rotate" + count + ".jpg";
    resetCircles();
    document.getElementById('circle' + count).src = "images/circle_on.jpg";
//    shiftOpacity(id, 1000);
    opacity(id, 0, 100, 1000);
}

function resetCircles()
{
    for(i = 1; i < 5; i++)
    {
        document.getElementById('circle' + i).src = "images/circle.jpg";
    }
}