function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function datetounixtime(human_date) {
    var humDate = new Date(human_date);
    if (humDate == "Invalid Date"){
        arrDate = human_date.split("-");
        humDate = new Date(arrDate[0],arrDate[1]-1,arrDate[2]);
    }
    var epoch = humDate.getTime()/1000.0;
    return epoch;
}
function parse_url(qs, replacekey, replacevalue){
    var newqs = [];
    var query = "";
    var found = false;
    if (qs.length > 0){
        var vars = qs.split("&");
        for(var i=0;i<vars.length;i++){
            var pair = vars[i].split("=");
            if (pair[0].toLowerCase() == replacekey.toLowerCase()){
                newqs.push(replacekey.toLowerCase() + "=" + URLEncode(replacevalue));
                found = true;
            }
            else {
                newqs.push(pair[0].toLowerCase() + "=" + URLEncode(pair[1]));
            }
        }
    }
    else {
        newqs.push(replacekey + "=" + replacevalue);
    }
    if (!found){
        newqs.push(replacekey.toLowerCase() + "=" + URLEncode(replacevalue));
    }
    if (newqs.length > 0){
        for(var j=0;j<newqs.length;j++){
            query += newqs[j];
            if (j+1 < newqs.length){
                query += "&";
            }
        }
    }
    return query;
}
function URLEncode (clearString) {
  var output = '';
  var x = 0;
  if (clearString === undefined) clearString = '';
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}
function redirect(address,query_string){
    var redirect_string = address;
    if (query_string != ""){
        redirect_string += "?" + query_string;
    }
    //alert(redirect_string);
    window.location=redirect_string;
}
function checkAll(FieldName, CheckValue)
{
    objCheckBoxes = document.getElementsByName(FieldName);
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function setIndexByVal(id, val){
    if (document.getElementById(id)){
        var sel = document.getElementById(id);
        for (i = 0; i < sel.length - 1; i ++ ){
            if (sel.options[i].value == val){
                sel.options[i].selected = true;
                break;
            }
        }
    }
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	if(radioObj.length == undefined){
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
    }
	for(var i = 0; i < radioObj.length; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function changeVis(div,type){
    if (document.getElementById(div)){
            mDiv = document.getElementById(div);
            mDiv.style.display = type;
    }
}
function flipVis(div){
	if (document.getElementById(div)){
            mDiv = document.getElementById(div);
            if(document.uniqueID && mDiv.currentStyle){
              oDisplay=mDiv.currentStyle.display;
            }

            if(document.defaultView && document.defaultView.getComputedStyle){
              oDisplay=document.defaultView.getComputedStyle(mDiv, '').getPropertyValue("display");
            }

            if (oDisplay != "none"){
                    mDiv.style.display = "none";
            }
            else {
                    mDiv.style.display = "block";
            }
	}
}
function keepAlive(display){
    xajax_keepAlive(display);
}
function countObj(obj){
    var count = 0;
    for(var i in obj){
        count++;
    }
    return count;
}
