function sndSmReq(userIp,userId,contestId,mtxt) {
	var theContent = document.getElementById('sm'); 
	// switch UL with a loading div
	theContent.innerHTML = '<div class="loading"></div>';
	
    xmlhttp.open('get', './ajax/sm.php?p='+userIp+'&i='+userId+'&c='+contestId+'&t='+mtxt);
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(null);	
}

function handleResponse() {
  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText(update[0], update[1]);
        }
		}
    }
}

function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"
    if (DOM) {
        var viewer = document.getElementById(div2show);
        viewer.innerHTML = text;
    }  else if(IE) {
        document.all[div2show].innerHTML = text;
    }
}

/* =============================================================== */
function runSM(){
	var mtxt = document.getElementById("mtxt").value;
	var contestId = document.getElementById("c").value;
	var userIp = document.getElementById("userIp").value;
	var userId = document.getElementById("userId").value;
	//alert(userIp+','+userId+','+contestId+','+mtxt);
	sndSmReq(userIp,userId,contestId,mtxt);	
}