//GET DOM
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

if (document.getElementById)
	{
	isID = 1; 
	isDHTML = 1;
	}
else 
	{
	if (document.all) 
		{
		isAll = 1; 
		isDHTML = 1;
		}
	else 
		{
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) 
			{
			isLayers = 1; 
			isDHTML = 1;
			}
		}
	}

function getDOM(objectID,withStyle) 
	{
	var a;
	
	if (withStyle == 1) 
		{
		if (isID) 
			{
			if(document.getElementById(objectID))
				return (document.getElementById(objectID).style);
			}
		else 
			{ 
			if (isAll) 
				{ 
				return (document.all[objectID].style); 
				}
			else 
				{
				if (isLayers) 
					{ 
					return (document.layers[objectID]); 
					}
				};
			}
		}
	else 
		{
		if (isID) 
			{
			return (document.getElementById(objectID)); 
			}
		else 
			{ 
			if (isAll) 
				{ 
				return (document.all[objectID]); 
				}
			else 
				{
				if (isLayers) 
					{
					return (document.layers[objectID]); 
					}
				};
			}
		}
	}


//GLOBAL JS

var isHREF = false; //this is used to override a goTo event when the user clicks directly on a link (protects against double posts)

function z() 
	{
    isHREF = false;
	}

function init() 
	{
/*
        objMenu1 = new OpacityObject('conflair_menu1','/dropdown_back96');
        objMenu1.setBackground();
        
        objMenu2 = new OpacityObject('conflair_menu2','/dropdown_back96');
        objMenu2.setBackground();
        
        objMenu3 = new OpacityObject('conflair_menu3','/dropdown_back96');
        objMenu3.setBackground();
        
        objMenu4 = new OpacityObject('conflair_menu4','/dropdown_back96');
        objMenu4.setBackground();
        
        objMenu5 = new OpacityObject('conflair_menu5','/dropdown_back96');
        objMenu5.setBackground();
        
        objMenu6 = new OpacityObject('conflair_menu6','/dropdown_back96');
        objMenu6.setBackground();
*/
	}

function goTo(url, target) 
	{
    if (!isHREF)
		{
        if (target != '_self') 
			{
            window.open(url);          
			} 
		else 
			{
            window.location.href = url;
			}
		}
	}

function x(url) 
	{
    goTo(url, '_self');
	}


//TOP NAV JS
var menuTop = 45;
var menuPos_X = 400;

var domSMenu = null;
var oldDomSMenu = null;
var timer = 0;
var lDelay = 2;
var lCount=0;
var pause = 100; //100

//nav over
function a(td, menuNum, hasSubMenus)
	{
    menuCellOn(td);
	if(hasSubMenus)
		popMenu(menuNum);
	}

//nav out
function b(td) 
	{
    menuCellOff(td);
    timer=1;
    delayHide();
	}

//menu cell over
function p(td) 
	{
    timer=2;
    y(td);
	}

//menu cell over
function p2(td) 
	{
    timer=2;
	}

//menu cell out
function d(td) 
	{
    timer=2;
    z(td);
	}

//menu cell out (from <a>)
function e() 
	{
    timer=1;
    delayHide();
	}

//menu cell click (from <a>)
function f() 
	{
    isHREF = true;
    timer=0;
    delayHide();
	}


function g(td) 
	{
    timer=1;
    z(td);
	}

function h(td) 
	{
    timer=1;
    delayHide();
    z(td);
	}

function openMenuLink(link, target) 
	{
    timer=0;
    delayHide();
    goTo(link, target);
	}


function k()
	{
    timer=2;
	}


function y(td) 
	{
    if (td != null) 
		{
        topColorOn(td);
		}
	}

function z(td)
	{
    if (td != null)
		{
        topColorOff(td);
		}
	}



function topColorOn(currObj)
	{
    if(document.getElementById || (document.all && !(document.getElementById)))
		{
		currObj.style.backgroundImage="url(images/top/menu_on_back.gif)";
        currObj.style.backgroundRepeat="repeat-x";
		}
	}

function topColorOff(currObj)
	{
    if(document.getElementById || (document.all && !(document.getElementById)))
		{
        currObj.style.backgroundImage="";
		currObj.style.backgroundColor="#BAB9B9";
		}
	}


function popMenu(menuNum)
	{
    //window.status='popped';

	if (isDHTML) //browser supports DHTML
		{
        // Defines the DOMs	of the menu objects
		var idMenu = 'conflair_nav';
		var domMenu = getDOM(idMenu, 0);

		var idMenuOpt = 'conflair_nav' + menuNum;
		var domMenuOpt = getDOM(idMenuOpt, 0);		

		var idSMenu = 'conflair_menu' + menuNum;
		var domSMenu = getDOM(idSMenu, 1);

		// Sets the previous menu's visibility to hidden
		timer=2;
		if (oldDomSMenu && (oldDomSMenu != domSMenu))
			{
			oldDomSMenu.visibility = 'hidden'; 
			oldDomSMenu.zIndex = '0';
			lCount=0;
			}

		// Defines the positions of the sub-menus
		if (isID || isAll)
			{
            var menuPos_X = (domMenu.offsetLeft) + (domMenuOpt.offsetLeft) + 3;
			var menuPos_Y = (domMenu.offsetTop) + (domMenu.offsetHeight) + 2;
			}
		if (isLayers)
			{
			var menuPos_X = document.layers[idMenu].layers[idMenuOpt].pageX;
			var menuPos_Y = domMenu.pageY + domMenu.clip.height;
			}
		// Positions and shows the menu
		if (oldDomSMenu != domSMenu)
			{
			domSMenu.left = menuPos_X;
			domSMenu.top = menuPos_Y;
			domSMenu.zIndex = '100';
			oldDomSMenu = domSMenu;
            domSMenu.visibility = 'visible';
			}
		else // Resets oldDom if it is the same as the current DOM
			{
			// why?  oldDomSMenu = null;
			}
		}
	else // Returns a 'null' value for non-DHTML Browsers 
		{
		return null;
		}
	
	
	} //popMenu

function topNavColorOn(td)
	{
	if(document.getElementById||(document.all && !(document.getElementById)))
		{
		td.style.backgroundColor= "#D4D4D4"; //"#ffffff";
		}
	}

function topNavColorOff(td)
	{
	if(document.getElementById||(document.all && !(document.getElementById)))
		{
		td.style.backgroundColor= "#C3C2C2"; //#eeeeee";
		}
	}


function topNavSubMenuColorOn(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#99ccff";
}
}

function topNavSubMenuColorOff(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#bddcfa";
}
}

function menuCellOn(td)
	{
    if(document.getElementById||(document.all && !(document.getElementById)))
		{
        td.style.backgroundImage="url(images/top/menu_on_back.gif)";
        td.style.backgroundRepeat="repeat-x";
		}
	}

function menuCellOff(td)
	{
    if(document.getElementById||(document.all && !(document.getElementById)))
		{
        td.style.backgroundImage="";
        td.style.backgroundRepeat="";
		}
	}

function delayHide()
	{
    //window.status='timer=' + timer;

	// Checks to see if there is a menu showing and whether 
	// the global variable 'timer' has been set to 0
    if ((oldDomSMenu) && (timer == 0))
		{
        // Hides the old menu, resets menu conditions, 
        // and stops the function running
        oldDomSMenu.visibility = 'hidden'; 
        oldDomSMenu.zIndex = '0';
        oldDomSMenu = null;
        lCount=0; 

        //window.status='hidden';

        return false;
		}

	// Interupts the function if another menu is opened
    if (timer == 2)
		{
		lCount=0; return false;
		}

	// Repeats the function adding 1 to lCount each time until 
	// lCount is equal to lDelay and then sets 't' to 0 so that 
	// the menu will hide when it runs again
    if (timer == 1)
		{
        lCount = lCount + 1;
        if (lDelay <= lCount)
			{
            timer=0;
            lCount = 0;
			}
        
        if (lDelay >= lCount)
			{
            setTimeout('delayHide(' + timer + ')', pause);
            //window.status += "o";
			}
		}
	}

//TOOLTIPS
function showToolTip(IDName, evt, inPosX)
{
	if (isDHTML) //browser supports DHTML 
	{
		var tipDOM = getDOM(IDName + 'Tip', 0);
		var tipDOMStyle = getDOM(IDName + 'Tip', 1);
		var posX = getXCoord(evt);
		var posY = getYCoord(evt);
		var scrollX = getXScroll();
		var scrollY = getYScroll();
		var windowWidth;
		var windowHeight;
		var tooltipWidth;
		var tooltipHeight;

		//get tooltip width
		if (tipDOM.offsetWidth != null)
			tooltipWidth = tipDOM.offsetWidth;
		else if (tipDOM.clip.width != null)
			tooltipWidth = tipDOM.clip.width;

		//get tooltip height
		if (tipDOM.offsetHeight != null)
			tooltipHeight = tipDOM.offsetHeight;
		else if (tipDOM.clip.Height != null)
			tooltipHeight = tipDOM.clip.Height;

		//getWindowWidth
		if (window.innerWidth != null)
			windowWidth = window.innerWidth;
		else if (document.body.clientWidth != null)
			windowWidth = document.body.clientWidth;
		windowWidth -= 20;


		//getWindowHeight
		if (window.innerHeight != null)
			windowHeight = window.innerHeight;
		else if (document.body.clientHeight != null)
			windowHeight = document.body.clientHeight;

		if (((windowWidth < posX + tooltipWidth + 10) && isAll ) || ((windowWidth < posX - scrollX + tooltipWidth + 10) && !isAll ))
			posX = posX - tooltipWidth - 20;
		else
			posX = posX + 20;

		if (((windowHeight < posY + tooltipHeight + 20) && isAll ) || ((windowHeight < posY - scrollY + tooltipHeight + 20) && !isAll ))
			posY = posY - tooltipHeight - 20;
		else
			posY = posY + 20;
			
			
		if (inPosX > 0)
			posX = inPosX;
			
		if (tipDOMStyle.left != null)
		{
			tipDOMStyle.left = posX;
			tipDOMStyle.top = posY;

                        //alert("left");
		}
		
		if (tipDOMStyle.pixelLeft != null)
		{
			if(!(inPosX > 0))
				posX += scrollX;
			
			tipDOMStyle.pixelLeft = posX;
			tipDOMStyle.pixelTop = posY + scrollY;

                        //alert("pixelLeft");
		}
		
		if (tipDOMStyle.offsetLeft != null)
		{
			tipDOMStyle.offsetLeft = posX;
			tipDOMStyle.offsetTop = posY;
                        
                        //alert("offsetLeft");
		}

                //window.status="posX=" + posX;
		
		tipDOMStyle.visibility = 'visible';
		tipDOMStyle.zIndex = '1000';
	}
	else
	{
		return null;
	}
}

function hideToolTip(IDName)
{
	if (isDHTML)
	{
		var tipDOMStyle = getDOM(IDName + 'Tip', 1);
		tipDOMStyle.visibility = 'hidden';
		tipDOMStyle.zIndex = '-1';
	}
}

function getXCoord(evt)
{
	if (evt.x)
		return evt.x;
	else if (evt.pageX)
		return evt.pageX;
}

function getYCoord(evt)
{
	if (evt.y)
		return evt.y;
	else if (evt.pageY)
		return evt.pageY; 
}

function getXScroll()
{
	if (document.body.scrollLeft != null)
		return document.body.scrollLeft;
	else if (window.pageXOffset != null)
		return window.pageXOffset;
}

function getYScroll()
{
	if (document.body.scrollTop != null)
		return document.body.scrollTop;
	else if (window.pageYOffset != null)
		return window.pageYOffset;
}

function overB(obj, bool) 
{
	obj.className = (bool) ? "over" : "out";
}

function validateEMail(CurrElement)
	{
	var AtPresent, DotPresent, CharsAfterDot, AtPresentPosition, DotPosition, frc, j;
	
	frc = true;
	if(CurrElement.value.length > 0)
		{
		AtPresent = false;
		DotPresent = false;
		CharsAfterDot = 0;
		AtPresentPosition = 0;
		DotPosition = 0;
		//Check @
		for(j=1;j<CurrElement.value.length;j++)
			{
			if(CurrElement.value.charAt(j)=="@")
				{
				AtPresent = true;
				AtPresentPosition = j;
				}
			}
		if(AtPresent==false)
			{
			frc = false;
			alert("Invalid E-Mail address! Must include @");
			CurrElement.style.backgroundColor = "#ff0000";
			}

		//Check .
		for(j=(AtPresentPosition+1);j<CurrElement.value.length;j++)
			{
			if(CurrElement.value.charAt(j)==".")
				{
				DotPresent = true;
				DotPosition = j;
				}
			}
		if(DotPresent==false)
			{
			frc = false;
			alert("Invalid E-Mail address! Must include a dot (   .   )");
			CurrElement.style.backgroundColor = "#ff0000";
			}
			
		//Check # chars after .
		for(j=(DotPosition+1);j<CurrElement.value.length;j++)
			CharsAfterDot++;
		if(CharsAfterDot<2)
			{
			frc = false;
			alert("Invalid E-Mail address! Must have at least two characters after the dot.");
			CurrElement.style.backgroundColor = "#ff0000";
			}
		}
	else
		{
		frc = "noemail";
		}
	return frc;
	}