
	var http = createRequestObject();
	var response;


	function checkAll(field) {
		for (i = 0; i < field.length; i++) {
			field[i].checked = true ;
		}
	}


	function unCheckAll(field) {
		for (i = 0; i < field.length; i++) {
			field[i].checked = false ;
		}
	}


	// Ajax request object
	function createRequestObject()
	{
		var tmpXmlHttpObject;

		
        	// Mozilla, Safari 
		if (window.XMLHttpRequest) 
		{
        		tmpXmlHttpObject = new XMLHttpRequest();
		}

		// IE would use this method ...
		else if (window.ActiveXObject) 
		{
			tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
		}

		return tmpXmlHttpObject;
	}


	function saveDesktop() 
	{
		var req = "/s/Wigit/Desktop/?action=update";

		for (i=0; i < wigit.length; i++)
		{
			var wi = document.getElementById(wigit[i]);

			var x = wi.offsetLeft;
			var y = wi.offsetTop;
			var w = wi.offsetWidth;
			var h = wi.offsetHeight;

			req += "&"+wigit[i]+"="+x+"|"+y+"|"+h+"|"+w;

		} 

		//make a connection to the server
		http.open("get", req);

		//assign a handler for the response
		http.onreadystatechange = processResult;

		//actually send the request to the server
		http.send(null);
	}


	function setZindex(obj) 
	{
		obj.style.zIndex = zIndexI;
		zIndexI++;
	}


	function positionWigits() 
	{
		// Set the desktop height
		var winH = document.documentElement.clientHeight;

		var h = (winH > 700)? (winH - 150) : 600;

		var d = document.getElementById("desktop");

		d.style.height = h+"px";

		for (i=0; i < wigit.length; i++)
		{
			var w = document.getElementById(wigit[i]);

			w.style.zIndex = "1";
			w.style.position = "absolute";
			w.style.top = ycord[i] + "px";	
			w.style.left = xcord[i] + "px";	

			w.style.height = heigh[i] + "px";
			w.style.width = width[i] + "px";
		} 
	}



        function deleteNn (id) {

                if(confirm('Are you sure you want to remove this message? It will still be available by searching.')) {

                        var msgId = "nn" + id;

                        var msgObj = document.getElementById(msgId);

                        msgObj.style.display = "none";

                        var req = "/s/User/Seen_It/?object=announcements&object_id=" + id;

                        //make a connection to the server
                        http.open("get", req);

                        //assign a handler for the response
                        http.onreadystatechange = processResult;

                        //actually send the request to the server
                        http.send(null);
                }
        }



        function deleteMsg (id) {

                if(confirm('Are you sure you want to delete this message?')) {

                        var msgId = "msg" + id;

                        var msgObj = document.getElementById(msgId);

                        msgObj.style.display = "none";

                        var req = "/s/User/Messages_Delete/?id=" + id;

                        //make a connection to the server
                        http.open("get", req);

                        //assign a handler for the response
                        http.onreadystatechange = processResult;

                        //actually send the request to the server
                        http.send(null);

                }
        }


        function processResult()
        {
		response = "";

                //check if the response has been received from the server
                if (http.readyState == 4)
                {
                        //read and assign the response from the server
                        response = http.responseText;
                }
        }


	function launch_sntv(program,channel) 
	{
		var params  = "location=no,toolbar=no,status=no,scrollbars=no,menubar=no,";
		    params += "resizable=no,width=800,height=600,top=10,left=10";
		var sntv = window.open ("/s/SNTV/Main/?program="+program+"&channel="+channel,"sntvWin",params);
	}



	var gAutoPrint = true; // Tells whether to automatically call the print function

	function printSpecial()
	{
		if (document.getElementById != null)
		{
			var html = '<HTML>\n<HEAD>\n';

			if (document.getElementsByTagName != null)
			{
				var headTags = document.getElementsByTagName("head");

				if (headTags.length > 0)
				{	
					html += headTags[0].innerHTML;
				}
			}

			html += '\n</HEAD>\n<BODY>\n';

			var legacyFrame = self.frames["legacyFrame"];

			var printReadyElem;


			if (legacyFrame != null) 
			{
				printReadyElem = legacyFrame.document.getElementById('printReady');
			}
			else 
			{
			 	printReadyElem = document.getElementById("printReady");
			}

			if (printReadyElem != null)
			{
				html += printReadyElem.innerHTML;
			}
			else
			{
				alert("Could not find the printReady function");
				return;
			}

			html += '\n</BODY>\n</HT>';

			var printWin = window.open("","printSpecial");
			printWin.document.open();
			printWin.document.write(html);
			printWin.document.close();

			if (gAutoPrint) {
				printWin.print();
			}
		}
	}
