
//
// Popup Window
//
function popwin(url, name, width, height, location, menubar, status, toolbar, scrollbars)
{
	if (name == null)
	{
		name = "stdWin";
	}
	if (width == null)
	{
		width = 550;
	}
	if (height == null)
	{
		height = 500;
	}
	if (location == null)
	{
		location = "no"
	}
	if (menubar == null)
	{
		menubar = "yes"
	}
	if (status == null)
	{
		status = "yes"
	}
	if (toolbar == null)
	{
		toolbar = "yes"
	}
	if (scrollbars == null)
	{
		scrollbars = "yes"
	}

	popup = window.open(url, name, 'width=' + width + ',height=' + height + ',location=' + location + ',menubar=' + menubar + ',status=' + status + ',toolbar=' + toolbar +',scrollbars='+scrollbars+',resizable=yes,screenx=0,screeny=0,left=0,top=0');
	if (window.focus) setTimeout("popup.focus()",100);
}


//
// trigger onLoad function (do_onload)
//
if (window.addEventListener)
{
	window.addEventListener("load", do_onload, false);
}
else
{
	if (window.attachEvent)
	{
		window.attachEvent("onload", do_onload);
	}
	else
	{
	if (document.getElementById)
		{
			window.onload = do_onload;
		}
	}
}


function do_onload()
{
	setJSFunctionality();
	fixIE6flicker();
	showList();
}

function fixIE6flicker()
{
 	/*fix for flickering background images in IE 6*/ 
	var m = document.uniqueID /*IE*/ 
	&& document.compatMode /*>=IE6*/ 
	&& !window.XMLHttpRequest /*<=IE6*/ 
	&& document.execCommand ; 
	try
	{ 
		if(!!m)
		{ 
			m("BackgroundImageCache", false, true) /* = IE6 only */ 
		} 
	}
	catch(oh)
	{}; 	
}


/* Function used to allow links that have been hidden using the .rbsScreenReaderText class to be viewable if tabbed to by the user */
function toggleLinks(objElement)
{
	if (objElement.className=='rbsScreenReaderText')
  		objElement.className='rbsScreenReaderTextVisibleLink';
	else
		objElement.className='rbsScreenReaderText';
}

function setJSFunctionality ()
{
	if(document.getElementById("jsPrintPage"))
	{
		document.getElementById("jsPrintPage").style.display = "block";
	}
	if(document.getElementById("jsPopup"))
	{
		document.getElementById("jsPopup").style.display = "block";
	}
}



/*******************************************************
FLASH DETECT 2.5
All code by Ryan Parman and mjac, unless otherwise noted.
(c) 1997-2004 Ryan Parman and mjac
http://www.skyzyx.com
*******************************************************/
// This script will test up to the following version.
flash_versions = 20;
// Initialize variables and arrays
var flash = new Object();
flash.installed=false;
flash.version='0.0';
// Dig through Netscape-compatible plug-ins first.
if (navigator.plugins && navigator.plugins.length)
{
 for (x=0; x < navigator.plugins.length; x++)
 {
  if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1)
  {
   flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
   flash.installed = true;
   break;
  }
 }
}
// Then, dig through ActiveX-style plug-ins afterwords
else if (window.ActiveXObject)
{
 for (x = 2; x <= flash_versions; x++)
 {
  try {
   oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
   if(oFlash)
   {
    flash.installed = true;
    flash.version = x + '.0';
   }
  }
  catch(e) {}
 }
}
// Create sniffing variables in the following style: flash.ver[x]
// Modified by mjac
flash.ver = Array();
for(i = 4; i <= flash_versions; i++)
{
 eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true :  false;");
}

function includeFlash(flashFilePath, width, height, alternativeImageFilePath ,flashId, alternativeLink)
{
 var flashDiv = document.getElementById(flashId);
 if(flash.installed)
 {
  flashDiv.innerHTML = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'   codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'   WIDTH='"+width+"' HEIGHT='"+height+"'><PARAM NAME='movie' VALUE='"+flashFilePath+"'><PARAM   NAME='quality' VALUE='high'><EMBED src='"+flashFilePath+"' quality='high' WIDTH='"+width+"'   HEIGHT='"+height+"' ALIGN='' TYPE='application/x-shockwave-flash'   PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>" ;
 }
 else
 {
  var imageObject = document.createElement("img");
  imageObject.setAttribute("src",alternativeImageFilePath);
  imageObject.setAttribute("width",width);
  imageObject.setAttribute("height",height);
  var linkObject=document.createElement('a');
  linkObject.setAttribute('href',alternativeLink);
  if (alternativeLink)
  {
	linkObject.appendChild(imageObject);
  	flashDiv.appendChild(linkObject);
  }
  else
  {
	flashDiv.appendChild(imageObject);
  }
 }
}


//////// Common Form Validation elements ////////

//
// Removing spaces from the beginning of a string
//
function ltrim(strText)
{
	while (strText.charAt(0)==" ")
	{
		strText = strText.substring(1);
	}
	return strText;
}

//
// Removing spaces from the end of a string
//
function rtrim(strText)
{
	while (strText.charAt( strText.length-1 )==" ")
	{
		strText = strText.substring(0, strText.length-1);
	}
	return strText;
}

//
// Removes spaces from both ends using above functions
//
function trim(strText)
{
	strText = ltrim(strText);
	strText = rtrim(strText);
	return strText;
}

//
// Validation for to check a string includes @ and looks like it takes the form of an email address
//
function isEmailAddr(email)
{
	var result = false;
	var theStr = new String(email)
	var index = theStr.indexOf("@");
	if (index > 0)
	{
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
	return result;
}

//
// Validation to check if radion buttons have been selected
//
function validateRadioButtons(name)
	{
		var radioSelected = false;
		for (i = 0;  i < name.length;  i++)
		{
			if (name[i].checked)
			radioSelected = true;
		}

		return radioSelected;
	}


//
// Validation to check if checkboxes have been selected
//
function validateCheckboxes(theForm)
	{
		var boxchecked = false
		for (var m = 0; m < theForm.elements.length; m++)
		{
			if (theForm.elements[m].checked == true)
			{
				boxchecked = true
			}
		}

		if (boxchecked == false)
		{
			window.alert("Please select an option.");
			return false;
		}
	}
	
	
	
	
	
function tabs(){
	setTabs();
}

function setTabs(){
	var tabLink01 = $$('tabLink01', document.body, 'div');
	var tabLink02 = $$('tabLink02', document.body, 'div');
	var tabLink03 = $$('tabLink03', document.body, 'div');
	
	for(i=0; i<tabLink01; i++){
		
	}
}
	
	
function hideTabs(){
	var tabs01 = $('tabs01');
	var tabs = $$('tabs', document.body, 'content');
	
	
	if(tabs01){
		for(i=1; i<tabs.length; i++){
			Core.setStyle(tabs[i], {display: 'none'});
		}
	}
	
	eventDropDown(tabs);

}

function eventDropDown(tabs){
	var option = $('label01').getElementsByTagName('option');
	
	for(i=0; i<option.length; i++){
		setEvents(i, option, tabs);	
	}
}

function setEvents(el, option, tabs){
	Core.attachEvent(option[el], 'click', function(e){
		Core.setStyle(tabs[el], {display: 'block'});	
		for(i=0; i<tabs.length; i++){
			if(i != el){
				Core.setStyle(tabs[i], {display: 'none'});
			}
		}
		var firstTab = $$('firstTab', document.body, 'div')[el+1];
		Core.setStyle(firstTab, {display:'block'});
	});

}	

function listEvents(i, list, row){
	Core.attachEvent(list[i], 'click', function(e){
		if(i == 0){
			Core.setStyle(row, {display:'block'});				  
		}
		else{
			Core.setStyle(row, {display:'none'});	
		}
	});
}

function showList(){
	if(typeof($$) == "function") {
		var findList = $$('rbsLinkedList02', document.body, 'ul');
		var closeList = $$('rbsLinkedList03', document.body, 'ul');
		if(findList){
			for(var i=0; i<findList.length; i++){
				Core.setStyle(findList[i], {display: 'block'});
				Core.setStyle(closeList[i], {display: 'block'});	
			}
			
			for(var i=0; i<findList.length; i++){
				listEvents(i, findList, closeList);	
			}
		}
	}
}

function listEvents(el, findList, closeList){
	Core.attachEvent(findList[el], 'click', function(e){
		Core.setStyle(findList[el], {display: 'none'});	
		for(i=0; i<findList.length; i++){
			if(i != el){
				Core.setStyle(findList[i], {display: 'block'});	
			}
		}
	});
	
	Core.attachEvent(closeList[el], 'click', function(e){
		Core.setStyle(findList[el], {display: 'block'});	
	});
}



