﻿function gosearch(){
    var f = document.getElementById("dmSearchFm");
    var q = document.getElementById("dmSearchTxtAct");
    var q2 = document.getElementById("dmSearchTxt");
    q2.value = q.value;    
    var t = document.getElementById("dmSearchToken");
    t.value = stoken;
    f.submit();
    return false;
}
function getParam(name) {
    var match = new RegExp(name + "=([^&]+)","i").exec(location.search);
    if (match==null) 
        match = new RegExp(name + "=(.+)","i").exec(location.search);
    if (match==null)
        return null;
    match = match + "";
    result = match.split(",");
    return result[1];
}

/* Debugging */
function parseResult(res){
    return displayObject(res);
}
function displayObject(ob){
    var h = '';
    if (typeof ob == 'object'){
        h += '<dl style="font-size: 10px;">';
        for (x in ob){
            h += '<dt>' + x + ' [' + typeof ob[x] + ']</dt>';
            h += '<dd>' + displayObject(ob[x]) + '</dd>';          
        }
        h += '</dl>';
    } else {
        h += ob;
    }   
    return h;
}
function displayHTML(text) {
    var h = text.replace(/&/g,"&amp;");
    h = h.replace(/</g,"&lt;");
    h = h.replace(/>/g,"&gt;<br>");
    return(h);
}
function sendnotify(cmd){
	var xhrq = false;
	if (window.XMLHttpRequest){xhrq = new XMLHttpRequest();}
	else if (window.ActiveXObject){xhrq = new ActiveXObject('Microsoft.XMLHTTP');}
	xhrq.open('GET', '/_notify/?' + cmd, true);
	xhrq.send(null);
	return false;
}
function getkey(e){
     var key;     
     if(window.event){
          key = window.event.keyCode; //IE
     } else {
          key = e.which; //firefox     
     }
     return key;
}
function checkkey(ev){
    var k = getkey(ev);
    if (k == 13){
        return gosearch();
    } else {
        return false;
    }
}