var resultPlace;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 setOutput() {    if (httpObject.readyState === 4) {        switch (resultPlace) {        case 1:            document.getElementById('operation').innerHTML = httpObject.responseText;			if ( window.student !== undefined ) {				showmenu(course);			}            break;        case 2:            document.getElementById('up').innerHTML = httpObject.responseText;            break;        case 3:            document.getElementById('result').innerHTML = httpObject.responseText;            break;        case 4:            document.getElementById('fa').innerHTML = httpObject.responseText;            break;        case 5:            document.getElementById('stu').innerHTML = httpObject.responseText;            break;        case 6:            document.getElementById('menu').innerHTML = httpObject.responseText;            break;        case 7:            document.getElementById('stu').innerHTML = httpObject.responseText;            break;        case 8:            document.getElementById('zo').innerHTML = httpObject.responseText;            break;        case 9:            document.getElementById('home').innerHTML = httpObject.responseText;            break;        case 10:            document.getElementById('subaccount').innerHTML = httpObject.responseText;            break;        default:            if (resultPlace !== "") {                document.getElementById(resultPlace).innerHTML = httpObject.responseText;            } else {                alert("Unknown result place!");            }        }    }}function opencourse(val) {    resultPlace = 1;	student = 1;	course = val;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=opencourse&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function addhw(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=StepOne&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function nexthomework(val, hwkey) {    resultPlace = 1;    var val1 = document.getElementById('hn').value;    var val2 = document.getElementById('hc').value;    var val3 = document.getElementById('date1').value;    var val4 = document.getElementById('date2').value;    var val5 = document.getElementById('hf').value;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=StepTwo&id=' + val + '&hname=' + val1 + '&hcapacity=' + val2 + '&startdate=' + val3 + '&enddat=' + val4 + '&numfield=' + val5 + '&hwkey=' + hwkey + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function edithomework(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=edithomework&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function nextedithomework(val, hwkey) {    resultPlace = 1;    var val1 = document.getElementById('hn').value;    var val2 = document.getElementById('hc').value;    var val3 = document.getElementById('date1').value;    var val4 = document.getElementById('date2').value;    var val5 = document.getElementById('hf').value;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=StepTwoEdit&id=' + val + '&hname=' + val1 + '&hcapacity=' + val2 + '&startdate=' + val3 + '&enddat=' + val4 + '&numfield=' + val5 + '&hwkey=' + hwkey + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function deletehomework(val, hwkey) {    var val1 = confirm("are you sure want to delete this homework?");    if (val1 === true) {		resultPlace = 'result' + val;		httpObject = getHTTPObject();		if (httpObject !== null) {			httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=deletehomework&id=' + val + '&hwkey=' + hwkey + '&time=' + Math.random() * 100000);			httpObject.onreadystatechange = setOutput;			httpObject.send(null);		} else {			alert("Error!");		}    } else {}}function addroom(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=addroom&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function nextaddroom(val1) {    resultPlace = 1;    var val2 = document.getElementById('hn').value;    var val3 = document.getElementById('msg').value;    var val4 = document.getElementById('date1').value;    var val5 = document.getElementById('date2').value;    var val6 = document.getElementById('room_id').value;	if (val2 !== "" && val3 !== "" && val4 !== "" && val5 !== "") {		httpObject = getHTTPObject();		if (httpObject !== null) {			httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=nextaddroom&id=' + val1 + '&rid=' + val6 + '&title=' + val2 + '&msg=' + val3 + '&start=' + val4 + '&end=' + val5 + '&time=' + Math.random() * 100000);			httpObject.onreadystatechange = setOutput;			httpObject.send(null);		} else {			alert("Error!");		}	} else {		alert('You have to fill in all the fields');	}}function viewcalendar(val) {    var k = window.open('http://' + window.location.hostname + "/calendar.php?id=" + val, "Date", "width=200, height=240, top=50, left=250");    k.resizeTo(200, 240);    k.moveTo(300, 300);}function insertdate(d, t) {    window.close();    if (t == 1) {        window.opener.document.getElementById('date1').value = d;    } else {        window.opener.document.getElementById('date2').value = d;    }}function showmenu(val) {    resultPlace = 6;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=openmenu&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function shome(val) {    resultPlace = 9;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=showhomeworks&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function openhw(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=openhomeworks&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function marks(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showhomework&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function smarks(val1, val2) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=showmarks&id=' + val1 + '&sid=' + val2 + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function openh(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=browsehomework&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function updatemark(val1, valz, val2, val3) {    resultPlace = 'cm' + val3;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=addmark&va=' + val1 + '&key=' + val2 + '&sid=' + val3 + '&id=' + valz + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function updatenoteformark(val1, valz, val2, val3) {    resultPlace = 'cm' + val3;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=addnote&va=' + val1 + '&key=' + val2 + '&sid=' + val3 + '&id=' + valz + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function showcourse(val) {    resultPlace = 7;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=showco&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function opera(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=courseperation&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function ret(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showcourse&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function borwse(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=browse&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function news(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=news&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function snews(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=news&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function addnews(val) {    resultPlace = 1;    var val1 = document.getElementById('ti').value;    var val2 = document.getElementById('tx').value;    var val3 = document.getElementById('newsid').value;    if (val1 !== "" && val2 !== "") {        httpObject = getHTTPObject();        if (httpObject !== null) {            httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=addnews&newsid=' + val3 + '&id=' + val + '&title=' + val1 + '&text=' + val2 + '&time=' + Math.random() * 100000);            httpObject.onreadystatechange = setOutput;            httpObject.send(null);        } else {            alert("Error!");        }    } else {        alert("empty");    }}function upload(val) {    var winpops = window.open("http://" + window.location.hostname + "/functions.php?type=upload&id=" + val, "files", "width=450,height=360,status=yes,scrollbars=yes,location=no");}function info(val) {    var winpops = window.open("http://" + window.location.hostname + "/functions.php?type=info&id=" + val, "", "width=400,height=100,status");}function delco(val) {    var val1 = confirm("are you sure want to delete this course?!!");    if (val1 === true) {		resultPlace = 'result' + val;		httpObject = getHTTPObject();		if (httpObject !== null) {			httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=disablecourse&id=' + val + '&time=' + Math.random() * 100000);			httpObject.onreadystatechange = setOutput;			httpObject.send(null);		} else {			alert("Error!");		}    } else {}}function settc(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showsetting&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function savesettings(val) {	var val2 = document.getElementById('hwcheck').checked;	var val3 = document.getElementById('rmcheck').checked;	var val4 = document.getElementById('newscheck').checked;	var val5 = document.getElementById('flcheck').checked;	var val6 = document.getElementById('mkcheck').checked;	var val7 = document.getElementById('grcheck').checked;    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showsetting&id=' + val + '&do=savesettings&hw=' + val2 + '&rm=' + val3 + '&news=' + val4 + '&fl=' + val5 + '&mk=' + val6 + '&gr=' + val7 + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function setclosecourse(val) {    resultPlace = 3;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showsetting&id=' + val + '&do=openclose&now=close&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function setopencourse(val) {    resultPlace = 3;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showsetting&id=' + val + '&do=openclose&now=open&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function activate(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=activate&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function active(val) {    resultPlace = 'result' + val;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=active&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function down(val) {    window.location.href = val;}function showfiles(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=showfiles&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function detai(val) {}function subsc(val1, val2) {    resultPlace = 8;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=supscribe&id=' + val1 + '&sid=' + val2 + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function deactive(val) {    resultPlace = 'result' + val;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=deactive&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function editnews(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=editnews&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function deletenews(val) {    var val1 = confirm("are you sure want to delete this news?");    if (val1 === true) {		resultPlace = 'result' + val;		httpObject = getHTTPObject();		if (httpObject !== null) {			httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=deletenews&id=' + val + '&time=' + Math.random() * 100000);			httpObject.onreadystatechange = setOutput;			httpObject.send(null);		} else {			alert("Error!");		}    } else {}}function editroom(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=editroom&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function showroommessage(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showroommessage&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function deleteroom(val) {    var val1 = confirm("are you sure want to delete this room?");    if (val1 === true) {		resultPlace = 'result' + val;		httpObject = getHTTPObject();		if (httpObject !== null) {			httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=deleteroom&id=' + val + '&time=' + Math.random() * 100000);			httpObject.onreadystatechange = setOutput;			httpObject.send(null);		} else {			alert("Error!");		}    } else {}}function readnews(val1, val2, val3) {    resultPlace = 8;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=readnews&id=' + val1 + '&course=' + val2 + '&user=' + val3 + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function showreadnews(val, val2) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showreadnews&id=' + val + '&newsid=' + val2 + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function slistroom(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=listroom&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function sopenroom(val) {    resultPlace = 1;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=openroom&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function saddroommessage(val1) {    resultPlace = 2;    var val2 = document.getElementById('msg').value;    var val3 = document.getElementById('room_id').value;    var val4 = document.getElementById('user_id').value;	if (val2 !== "" && val3 !== "" && val4 !== "") {		httpObject = getHTTPObject();		if (httpObject !== null) {			httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=s&action=saddroommessage&id=' + val1 + '&rid=' + val3 + '&uid=' + val4 + '&msg=' + val2 + '&time=' + Math.random() * 100000);			httpObject.onreadystatechange = setOutput;			httpObject.send(null);		} else {			alert("Error!");		}	} else {		alert('You have to fill in all the fields');	}}function showstats(val) {    resultPlace = 10;    httpObject = getHTTPObject();    if (httpObject !== null) {        httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=showstats&id=' + val + '&time=' + Math.random() * 100000);        httpObject.onreadystatechange = setOutput;        httpObject.send(null);    } else {        alert("Error!");    }}function disableaccount(val) {    var val1 = confirm("are you sure want to delete this account?");    if (val1 === true) {		resultPlace = 'result' + val;		httpObject = getHTTPObject();		if (httpObject !== null) {			httpObject.open('get', 'http://' + window.location.hostname + '/shake.php?type=t&action=disableaccount&id=' + val + '&time=' + Math.random() * 100000);			httpObject.onreadystatechange = setOutput;			httpObject.send(null);		} else {			alert("Error!");		}    } else {}}