
// Gets The Select Option (given ctrl name) and goes to the specified url
function goOptUrl(url, optName) {
	var val = getSelectedOption(optName);

	if (val != '') {
		//redirect to given page 
		document.location = url + val;
	}
}

// Opens a popup window for previewing 
function goOptPopup(url, optName) {
	var val = getSelectedOption(optName);

	if (val != '') {
		window.open (url + val, "mywin", "menubar=0,status=0,toolbar=0,location=0,directories=0,resizable=0,scrollbars=1,width=430,height=400");
	}
}

function goOptPopOpen(url, optName) {
	var val = getSelectedOption(optName);

	if (val != '') {
		window.open (url + val, "mywin", "");
	}
}

function goPopup(url, width, height) {
	window.open (url, "mywin", "menubar=0,status=0,toolbar=0,location=0,directories=0,resizable=0,scrollbars=1,width=" + width + ",height=" + height);
}

function getSelectedItem(selList) {
	var selectedVal = '';
	
	var selList = CrossBrowserGet(selList);

	for(i=0;i<selList.length;i++) {
		if(selList.options[i].selected) {
			selectedVal = selList.options[i].value;
			break;
		}
	}
	return selectedVal;
}

function selectAllCheckboxes(chkName) {
	var chkCtrls = CrossBrowserGetList(chkName);
	
	if (chkCtrls.length != null) {
		var listSize = chkCtrls.length;
		for (i=0;i<listSize;i++) {
			chkCtrls[i].checked = true;
		}
	}
}

// return the selected value (if any) of a list of radio inputs
function getSelectedOption(optName) {
	var val = '';
	var optControls = CrossBrowserGetList(optName);

	if (optControls.length != null) {
		// Mulitple Values
		var size = optControls.length;
	
		//Check if we have a Episode selected
		for (i=0;i<size;i++) {
			if (optControls[i].checked==true){
				val = optControls[i].value;
				break;
			}
		}
	}
	else {
		if (optControls.value != null) {
			// Single Value (ie: only one in the list)
			val = optControls.value;
		}
	}
	
	return val;
}

// return the selected value (if any) of a list of radio inputs
function getSelectedOptionList(optName) {
	var val = '';
	var optControls = CrossBrowserGetList(optName);

	if (optControls.length != null) {
		// Mulitple Values
		var size = optControls.length;
	
		//Check if we have a Episode selected
		for (i=0;i<size;i++) {
			if (optControls[i].checked==true){
				val += optControls[i].value + ',';
			}
		}
		
		// Strip Last Comma If Found
		if (val.length > 0) {
			if (val.substring(val.length - 1,val.length) == ',') {
				val = val.substring(0, val.length - 1);
			}
		}
	}
	else {
		if (optControls.value != null) {
			// Single Value (ie: only one in the list)
			val = optControls.value;
		}
	}
	
	 
	return val;
}

// Enables A List Of Buttons (seperated by '|' char)
function enableButtons(btnList) {
	if (btnList.length > 0) {
		var btns = btnList.split('|');
		var tmpBtn;
		
		for (i=0;i<btns.length;i++) {
			tmpBtn = CrossBrowserGet(btns[i]);
			if (tmpBtn.disabled != null) {
				tmpBtn.disabled = false;
			}
		}
	}
	
	return true;
}


function CrossBrowserGet(elementID)
{
	if (document.getElementById)
	{
		return document.getElementById(elementID);
	}
	else if(document.all)
	{
		return eval("document.all." + elementID);
	}
	else
	{
		return eval("document.layer." + elementID);
	}
}

function CrossBrowserGetList(elementID) {
	if(document.all)
	{
		return eval("document.all." + elementID);
	}
	else
	{
		return eval("document.layer." + elementID);
	}
}

function CrossBrowserSetStyle(element, property, value)
{
	if (element.style)
	{
		eval("element.style." + property + "='" + value + "'");
	}
	else
	{
		eval("element." + property + "='" + value + "'");
	}
}

function CrossBrowserGetStyle(element, property)
{
	if (element.style)
	{
		return eval("element.style." + property);
	}
	else
	{
		return eval("element." + property);
	}
}