// Property of the Columbus Dispatch - use of these routines not allowed without permission

//--------------------------------------------------------------
//	Tab_Create	Creates Tab Object
//--------------------------------------------------------------
function Tab_Create(NewTabSetName){
	this.TabSetName = NewTabSetName;
	this.ActiveColor = "yellow";
	this.InactiveColor = "white";
	this.ActiveBackgroundImage = "/shared/images/tab-corner-dkblu.gif";
	this.InactiveBackgroundImage = "/shared/images/tab-corner-666.gif";
	this.Activate = Tab_Activate;
//deb alert("Setup:"+NewTabName);
}


//--------------------------------------------------------------
//	Tab_Activate	Activates a Tab within Tab Object
//--------------------------------------------------------------
function Tab_Activate(Tab) {
 //deb alert("Tab_Activate"+Tab);
	var MaxTabs = 10;
	var TabNameParts = Tab.split("_");
	var TabId = TabNameParts[0];					//alert(TabId);
	var TabGroup = TabNameParts[1].substr(0,1);		//alert(TabGroup);
	var TabNumber = TabNameParts[1].substr(1);		//alert(TabNumber);
				// Hide Everything
	for (i=1; i <= MaxTabs; i++) {
		TabName = TabId+ "_"+ TabGroup + i;
		//deb alert(TabName);
		try {
			GetReference(TabName + "_Info").style.visibility = 'hidden';
			GetReference(TabName + "_Info").style.display = 'none';

			GetReference(TabName).style.cssText = "color:" + this.InactiveColor + "; background: url('" + this.InactiveBackgroundImage + "') no-repeat right top;";
			// deb alert(TabName + ":"+GetReference(TabName).style.cssText);
			throw "error";
		}
		catch(error) {
		// alert("no tab" + error)
		}

	}
			//Activate selected Tab
	GetReference(Tab + "_Info").style.visibility = 'visible';
	GetReference(Tab + "_Info").style.display = 'block';
	GetReference(Tab).style.cssText = "color:" + this.ActiveColor + "; background: url('" + this.ActiveBackgroundImage + "') no-repeat right top;";
	// deb alert(Tab + ":"+GetReference(Tab).style.cssText);
}


//--------------------------------------------------------------
//	GetReference	Returns the Reference for a field based on browser
//--------------------------------------------------------------
function GetReference(field) {
	var Refer;
		// DOM capable, ie, Netscape 7
	if (parseInt(navigator.appVersion) >=5) { Refer=document.getElementById(field);}
		// IE
	else if (document.all) { Refer=document.all[field];}
		// Netscape 4
	else if (document.layers) {  Refer=document.layers[field];}

//alert("here");
	return(Refer);
}


//--------------------------------------------------------------
//	Activate	Original Tab Function - only so old software does not have to be upgraded
//--------------------------------------------------------------
function Activate(Tab) {
	var Tab_Tmp = new Tab_Create('Tab_8');
	Tab_Tmp.ActiveColor="red";
	Tab_Tmp.Activate(Tab);
}


//--------------------------------------------------------------
// GetUrlValue	 Returns the value for a parameter from the url
//--------------------------------------------------------------
function GetUrlValue(parameter) {
	var urlEnd = document.URL.indexOf('?');
	var values = new Array();
	var fields;
	if (urlEnd != -1) {
		var params = document.URL.substring(urlEnd+1, document.URL.length).split('&');
		for(i=0; i<params.length; i++) {
			fields = params[i].split('=');
			values[fields[0]] = fields[1];
			if(fields[0].toLowerCase() == parameter.toLowerCase()) return (unescape(fields[1]));
		}
	}
//	value = unescape(values[parameter]);
	//deb alert("here:"+value);
	return ("");
}


//--------------------------------------------------------------
// SetSelectedIndex	 Sets choice for a Select based on a value
//--------------------------------------------------------------
function SetSelectedIndex(objSelect, sValue) {
	for (var i = 0; i < objSelect.length; ++i) {
  		if (objSelect[i].text.toLowerCase() == sValue.toLowerCase()) {
			objSelect.selectedIndex = i;
			return;
		}
	}
}


//--------------------------------------------------------------
// SetRadioSelected	 Sets Radio based on a value associated with button
//--------------------------------------------------------------
function SetRadioSelected(radioGroup){
	// Code to be developed based on following concept
/*
	var radios = document.getElementById ('radios');
	if (radios) {
	  var inputs = radios.getElementsByTagName ('input');
	  if (inputs) {
	    for (var i = 0; i < inputs.length; ++i) {
	      if (inputs[i].type == 'radio' && inputs[i].name == 'letter')
	        inputs[i].checked = inputs[i].value == 'two';
	    }
	  }
*/
}

//------------------------------------
//		Gets the value of the Radio Button selected
//			Returns:	returns value or null??
//------------------------------------
function GetRadioValue(radioGroup){
  	for(var i=0; i < radioGroup.length; i++)  {
	  	if(radioGroup[i].checked) {
				// Code Here
		}	
	}
	return "";
}

//------------------------------------
//		Check Radio Buttons in group
//			Returns:	true - if a Radio Button checked
//------------------------------------
function CheckRadioGroup(radioGroup){
  	for(var i=0; i < radioGroup.length; i++)  {
	  	if(radioGroup[i].checked)
			return true;
	}
	return false;
}