function debug(str){
	document.getElementById("debug").innerHTML = str;	
}

function setHandler(element, eventType, handler, capture){
	if (element.addEventListener)
		element.addEventListener(eventType, handler, capture);
	else if (element.attachEvent)
		element.attachEvent("on" + eventType, handler);
	else
	    alert("error: unable to set event handler");
}

function getRadioGroupValue(radioGroup){
	for(var i = 0; i < radioGroup.length; i++){
		if(radioGroup[i].checked) return radioGroup[i].value;	
	}
	return null;
}


function queryString() {
	var qsParm = new Array();
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
	   var pos = parms[i].indexOf('=');
	   if (pos > 0) {
		  var key = parms[i].substring(0,pos);
		  var val = parms[i].substring(pos+1);
		  qsParm[key] = val;
		}
	}
	return qsParm;
}

/*
    *  dependent - Subwindow closes if parent(the window that opened it) window closes
    * fullscreen - Display browser in full screen mode
    * height - The height of the new window, in pixels
    * width - The width of the new window, in pixels
    * left - Pixel offset from the left side of the screen
    * top - Pixel offset from the top of the screen
    * resizable - Allow the user to resize the window or prevent resizing
    * status - Display the status bar or not
*/
function launchPopup(url, tgt){
	window.open( url, tgt, "status=0, scrollbars=1, height=400, width=600, resizable=0");	
}