function toggle_display(elementID) {
        var e = document.getElementById(elementID);
        if(e.style.display == "block") {
                e.style.display='none';
        }
        else {
                e.style.display='block';
        }
}
function popUp(url, w, h) {
		var windowprops = "width=" + w + ",height=" + h + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=0,left=0";
		imgwin = window.open(url,'remote',windowprops);
}

function show(element) {
	if (element) {
		element.style.display = 'block';
	}
}

function hide(element) {
	if (element) {
		element.style.display = 'none';
	}
}

function toggleDisplay(element) {
	var e = document.getElementById(element);
	
	if (e.style.display == 'none') {
		show(e);
	} else {
		hide(e);
	}
	return false;
}

function getURL(token) {
	if (!token || token == '') {
		return location.href;
	} else {
		var url = location.href;
		if (url.indexOf(token) == -1) {
			return url;
		} else {
			return url.substring(0, url.indexOf(token));
		}
	}
	
}

function getURLParam(name, url) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp(regexS);
	if (!url) {
		url = location.href;
	}
	var results = regex.exec(url);
	if (results == null)
		return "";
	else
		return results[1];
}

// http://snippets.dzone.com/tag/add

// ----------------------------------------------------------------------------
// HasClassName
//
// Description : returns boolean indicating whether the object has the class name
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function hasClassName(objElement, strClass) {
	var class_name = objElement.getAttribute('class');
	if (!class_name) {
		class_name = objElement.className;
	}
	// if there is a class
	if ( class_name ) {
		// the classes are just a space separated list, so first get the list
		var arrList = class_name.split(' ');
		// get uppercase class for comparison purposes
		var strClassUpper = strClass.toUpperCase();
		// find all instances and remove them
		for ( var i = 0; i < arrList.length; i++ ) {
			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper ) {
				// we found it
				return true;
			}
		}
	}
	// if we got here then the class name is not there
	return false;
}
// 
// HasClassName
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// AddClassName
//
// Description : adds a class to the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function addClassName(objElement, strClass, blnMayAlreadyExist) {
	var class_name = objElement.getAttribute('class');
	if (!class_name) {
		class_name = objElement.className;
	}
	// if there is a class
	if ( class_name )	{
		// the classes are just a space separated list, so first get the list
		var arrList = class_name.split(' ');
		// if the new class name may already exist in list
		if ( blnMayAlreadyExist ) {
			// get uppercase class for comparison purposes
			var strClassUpper = strClass.toUpperCase();
			// find all instances and remove them
			for ( var i = 0; i < arrList.length; i++ ) {
				// if class found
				if ( arrList[i].toUpperCase() == strClassUpper ) {
					// remove array item
					arrList.splice(i, 1);
					// decrement loop counter as we have adjusted the array's contents
					i--;
				}
			}
		}
		// add the new class to end of list
		arrList[arrList.length] = strClass;
		// add the new class to beginning of list
		//arrList.splice(0, 0, strClass);
		// assign modified class name attribute
		objElement.setAttribute('class', arrList.join(' '));
		if (document.all) { // IE only
			objElement.className = arrList.join(' ');
		}
	}
	// if there was no class
	else {
		// assign modified class name attribute
		objElement.setAttribute('class', strClass);
		if (document.all) { // IE only
			objElement.className = strClass;
		}
	}
}
// 
// AddClassName
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// RemoveClassName
//
// Description : removes a class from the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to remove
//
function removeClassName(objElement, strClass) {
	var class_name = objElement.getAttribute('class');
	if (!class_name) {
		class_name = objElement.className;
	}
	// if there is a class
	if ( class_name ) {
		// the classes are just a space separated list, so first get the list
		var arrList = class_name.split(' ');
		// get uppercase class for comparison purposes
		var strClassUpper = strClass.toUpperCase();
		// find all instances and remove them
		for ( var i = 0; i < arrList.length; i++ ) {
			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper ) {
				// remove array item
				arrList.splice(i, 1);
				// decrement loop counter as we have adjusted the array's contents
				i--;
			}
		}
		// assign modified class name attribute
		objElement.setAttribute('class', arrList.join(' '));
		if (document.all) { // IE only
			objElement.className = arrList.join(' ');
		}
	}
	// if there was no class
	// there is nothing to remove
}
// 
// RemoveClassName
// ----------------------------------------------------------------------------