function getURL(url){
	window.location = url;
}

function setStyle(element, styleAttr, val){
// 	if (element type_of )
	if (typeof(element) == "string") element = document.getElementById(element);
	element.style[styleAttr] = val;
	return element;
}

function modifyStyle(name, attribute, value){
	theStyles = (ie) ? document.styleSheets[0].rules : document.styleSheets[0].cssRules;
	found = 0
	for (var i=0; i < theStyles.length; i++){
	    if (theStyles[i].selectorText == name){
	        eval("theStyles[i].style." + attribute + " = value;");
	        found = 1;
	    }
	}
	if (found == 0){
	    var mysheet=document.styleSheets[0]
	    if (ie) {
	        mysheet.addRule(name, attribute + ":" + value + ";");
	    }else{
	        mysheet.insertRule(name, attribute + ":" + value + ";");
	    }
	}
}

function addClass(element, name){
    if (typeof(element) == "string"){
        theElement = document.getElementById(element);
    }else if (typeof(element) == "object"){
        theElement = element
    }
    if (theElement != null){
        if (theElement.className.indexOf(name)<0)
            theElement.className += " " + name;
    } else {alert("cannot find element to add: "+element); }

//    if (typeof(element) == "object"){
    return element;
    //}
}

function removeClass(element, name){
    if (typeof(element) == "string"){
        theElement = document.getElementById(element);
    }else if (typeof(element) == "object"){
        theElement = element
    }
    if (theElement != null){
        var cnameregex = new RegExp(name, 'gi');
        theElement.className = theElement.className.replace(cnameregex, '');
    }else{ alert("cannot find element to remove: "+element); }
   
    return element;
}

function hide(ele){
	return setStyle(ele, 'display', 'none');
}

function show(ele){
	return setStyle(ele, 'display', 'inline');	
}


function setSelected(selectId, optionSelected){
 	for (var i=0; i < document.getElementById(selectId).length; i++) {
		if (document.getElementById(selectId)[i].value ==optionSelected) {
			document.getElementById(selectId)[i].selected = true;
		}
	}
	return true;
}

function setRadio(radioObjName, newValue) {
 	var radioObj = document.getElementsByName(radioObjName);
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}