function openPopup(url,name,width,height,resizable,scrollbars,menubar,toolbar,location,directories,status) {	
	popup = window.open(url, name, 'width=' + width + ',height=' + height + ',resizable=' + resizable + ',scrollbars=' + scrollbars
	+ ',menubar=' + menubar + ',toolbar=' + toolbar + ',location=' + location + ',directories=' + directories + ',status=' + status
	);

	if(popup != null)
	{
		popup.focus();
	}
}

// From the current URL, grab the file name only 
function getFileName()
{
	var fileName = location.href.substr(location.href.lastIndexOf('/') + 1);
	
	if(fileName.lastIndexOf('#') >= 0)
	{
		fileName = fileName.substring(0,fileName.indexOf('#'));
	}

	return fileName;
}

// Find the absolute position of a div
// NOTE: This function is taken from http://www.quirksmode.org/js/findpos.html
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


// These functions (getStyle, setStyle, toCamelCase) are taken from 
//  http://dhtmlkitchen.com/learn/js/setstyle/index.jsp
function getStyle(el, style) {
   if(!document.getElementById) return;
	
   var value = el.style[toCamelCase(style)];

   if(!value)
   {
		if(document.defaultView)
		{
			value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
		}
		else if(el.currentStyle)
		{
			value = el.currentStyle[toCamelCase(style)];
		}
	}
	return value;
}

function setStyle(objId, style, value) {
	document.getElementById(objId).style[style] = value;
}

function toCamelCase( sInput ) {
	var oStringList = sInput.split('-');

	if(oStringList.length == 1)   
		return oStringList[0];

	var ret = sInput.indexOf("-") == 0 ?
	   oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];

	for(var i = 1, len = oStringList.length; i < len; i++){
		var s = oStringList[i];
		ret += s.charAt(0).toUpperCase() + s.substring(1)
	}

	return ret;
}


function toCapitals(_str) {
        val = _str
        newVal = '';
        val = val.split(' ');
        for(var c=0; c < val.length; c++) {
                newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' ';
        }
        
		return newVal;
}

function openPopup(url,name,width,height,resizable,scrollbars,menubar,toolbar,location,directories,status) {	
	popup = window.open(url, name, 'width=' + width + ',height=' + height + ',resizable=' + resizable + ',scrollbars=' + scrollbars
	+ ',menubar=' + menubar + ',toolbar=' + toolbar + ',location=' + location + ',directories=' + directories + ',status=' + status
	);

	if(popup != null)
	{
		popup.focus();
	}
}


// From the current URL, grab a simple query string
//  (i.e. just a string after the ?, not a set of pairs
function getQuery()
{
	var queryStr = location.href.substr(location.href.lastIndexOf('?') + 1);
	return queryStr;
}

/*************************************************
 *				getQueryVariable
 * Grabs a query variable from the URL query string
 * Code from:
 *  http://www.activsoftware.com/code_samples/code.cfm/CodeID/59/JavaScript/Get_Query_String_variables_in_JavaScript
 *************************************************/
function getQueryVariable(variable) 
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");

    for (var i=0;i<vars.length;i++) {
	var pair = vars[i].split("=");

	if (pair[0] == variable) {
	    return pair[1];
	}
    }
    return -1;
}
