// JavaScript Document
function goTo(selObj, url){
	window.location=url+selObj.options[selObj.selectedIndex].value;
	return true
}

function swapDiv() {
  var i,p,v,obj,args=swapDiv.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

function showHideDiv() {
	var obj,args=showHideDiv.arguments;
	with(document) 
		if (getElementById && (obj=getElementById(args[0]))){
			if(obj.style){ obj=obj.style; obj.display=='none'? obj.display='block' : obj.display='none';}	
	}
}

function delCheck() {
	if (confirm("Are you sure you want to delete this item?")) {
		return true;
	}
	else {
		return false;
	}
}



function getHTTPObject(){
	if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest){
		return new XMLHttpRequest();
	}
	else {
		alert ("Your browser does not support AJAX.");
		return null;
	}
}

function getRadioValue(elementName)
{
    var element = document.getElementsByName(elementName);
    var bt_count = element.length; // can't use element.length in the loop, as it would decrement
 
    for (var i = 0; i <bt_count; i++)
        if (element[i].checked == true)
            return element[i].value;
}

function quizActivate(radioName,cat){
	var id= getRadioValue(radioName);
	httpObject=getHTTPObject();
	if (httpObject != null){
		httpObject.open("GET", "/admin/adm_quizactive.php?id="+id+"&cat="+cat, true);
		httpObject.send(null);
	}
}

function catCheck(element){
	if(element.value==999){
		showHideDiv('newcat')
	}
}

function checkRadio(elementName){
	if(!getRadioValue(elementName)){
		alert("Please select upload type");
		return false
	}
	else {
		return true;
	}
}
