//
// +---------------------------------------------------------------------------+
// |  F O T O P A N E L                                 |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2007 fotocrib.com                                         | 
// | All rights reserved.                                                      |
// |                                                                           |
// | Redistribution and use in source and binary forms, with or without        |
// | modification, are permitted provided that the following conditions        |
// | are met:                                                                  |
// |                                                                           |
// | 1. Redistributions of source code must retain the above copyright         |
// |    notice, this list of conditions and the following disclaimer.          |
// | 2. Redistributions in binary form must reproduce the above copyright      |
// |    notice, this list of conditions and the following disclaimer in the    |
// |    documentation and/or other materials provided with the distribution.   |
// |                                                                           |
// | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR      |
// | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
// | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.   |
// | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,          |
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT  |
// | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY     |
// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT       |
// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF  |
// | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.         |
// +---------------------------------------------------------------------------+
// | For help, contact webmaster@fotocrib.com          |
// +---------------------------------------------------------------------------+
//
/**
  * @author Martin Okorodudu
 */


function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function updateMain() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("main").innerHTML=xmlHttp.responseText;
		document.getElementById("info").innerHTML= "";
	}
}

function updateInfo() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("info").innerHTML=xmlHttp.responseText;
	}
}

function updateHint() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("hint").innerHTML=xmlHttp.responseText;
	}
}

function updateCaption() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("caption").innerHTML=xmlHttp.responseText;
	}
}

function updateTag() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("tag").innerHTML=xmlHttp.responseText;
	}
}

function updateContainer() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("container").innerHTML=xmlHttp.responseText;
	}
}

function updateComment() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("new_comment").value = ""; 
		document.getElementById("comment_box").innerHTML = xmlHttp.responseText;
	}
}

function updateTest() { 
	if (xmlHttp.readyState==4) {  
		document.getElementById("box").innerHTML = xmlHttp.responseText;
	}
}

function test() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	}

	netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");	
	 
	url = "http://fotocrib.com/fotomail/login.php";
	xmlHttp.onreadystatechange = updateTest;
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("uname=martin325&passwd=esijolone");
}

function Person(name, age) {
	this.name = name
	this.age = age
}

Person.prototype = {
	getName : function() {
		return this.name	
	},

	getAge : function() {
		return this.age
	}
}

function createAlbum(aid) {
	html = "<iframe src=\"createAlbum.php?&aid=" +aid +"\" style=\"border-style:none;width:80%;height:80%\" /></iframe>";
	document.getElementById("main").innerHTML = html;
	document.getElementById("info").innerHTML= "";
}

function showMigrate() {
	html = 'Album Name: <input class="updates" type="text" id="name" /> &nbsp;&nbsp;' +
		' Directory Path: <input class="updates" type="text" id="path" /><br/><br/>' +
		'<input type="button" class="updates" value="migrate" onClick="migrate()" />';
	document.getElementById('main').innerHTML = html;
}

//grab and display photos from album with id
function migrate() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "migrate.php?name=" + document.getElementById('name').value;
	url+= "&path=" + document.getElementById('path').value;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//grab and display photos from album with id
function showPhotos(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showPhotos.php?id=" + id;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//grab and display photos from album with id, public view
function showPublicPhotos(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showPublicPhotos.php?id=" + id;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//grab and display photos from album with id, public view
function showPublicAlbums() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showPublicAlbums.php";
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//display photo, pid is the photo id
function showPhoto(pid) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showPhoto.php?pid=" + pid;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//display photo, pid is the photo id, public view
function showPublicPhoto(pid) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showPublicPhoto.php?pid=" + pid;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//display photo in a search context
function showSearchPhoto(pid, uid, term, scope) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showSearchPhoto.php?pid=" + pid;
	url+= "&uid=" + uid;
	url+= "&term=" + term;
	url+= "&scope=" + scope;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//display album information
function showAlbumInfo(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showAlbumInfo.php?id=" + id;
	xmlHttp.onreadystatechange=updateInfo;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//display photo information
function showPhotoInfo(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showPhotoInfo.php?id=" + id;
	xmlHttp.onreadystatechange=updateInfo;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function showHint(flag) {
	hint = "";
	if (flag == 1) {
		hint = "<i>my albums</i>";
	}
	else if (flag == 2) {
		hint = "<i>create a new album and upload photos</i>";
	} 
	else if (flag == 3) {
		hint = "<i>upload photos, delete albums, share albums ...</i>";
	}
	else if (flag == 4) {
		hint = "<i>create an album from images in a local directory</i>";
	}
	else if (flag == 5) {
		hint = "<i>perform tag based search</i>";
	}
	document.getElementById('hint').innerHTML = hint;
}

//show and input box in element with id, box
function inputBox(id, box) {
	html = "";
	if (box == "caption") {
		html = '<input class="updates" type="text" id="cap" value="Enter new caption here" ' +
		 		'onClick="javascript:document.getElementById(\'cap\').value=\'\'" size="70" />' +
		'<input type="button" class="options" value="update" onClick="changeCaption(\''  +id +'\')" />';
	}
	else if (box == "tag") {
		 html = '<input class="updates" type="text" id="newtag" value="Enter new tag here" ' +
		 		'onClick="javascript:document.getElementById(\'newtag\').value=\'\'" size="70" />' +
		'<input type="button" class="options" value="update" onClick="tag(\''  +id + '\')" />';
	}
	else if (box == "search") {
		html = '<input class="updates" type="text" id="term" value="Enter search term here" ' +
		 		'onClick="javascript:document.getElementById(\'term\').value=\'\'" size="40" /> ' +
		'<input type="button" class="options" value="go" onClick="search()" />';
	}
	else {
		html = '<input class="updates" type="text" id="newname" size="30" value="Enter new name here" ' +
		 		'onClick="javascript:document.getElementById(\'newname\').value=\'\'" size="70" />' +
		'<input type="button" class="options" value="update" onClick="renameAlbum(\''  +id + '\')" />';
	}
	document.getElementById(box).innerHTML = html;
}

//change caption of photo with id
function changeCaption(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "changeCaption.php?id=" + id +"&txt=" + document.getElementById('cap').value;
	xmlHttp.onreadystatechange=updateCaption;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//delete photo with id
function deletePhoto(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "deletePhoto.php?id=" + id;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//tag photo with id
function tag(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "tag.php?id=" + id + "&tag=" + document.getElementById('newtag').value;
	xmlHttp.onreadystatechange=updateTag;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//delete tag from photo with id
function deleteTag(id, tag) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "deleteTag.php?id=" + id + "&tag=" + tag;
	xmlHttp.onreadystatechange=updateTag;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//show album management view
function manageAlbums() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "manageAlbums.php";
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//delete album with id
function deleteAlbum(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "deleteAlbum.php?id=" + id;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//rename album with id
function renameAlbum(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "renameAlbum.php?id=" + id +"&name="  +document.getElementById('newname').value;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//display input boxes in studio depending on fn
//id is photo id, src is photo source
function showStudioParams(fn, id, src) {
	//define colors

	colors = "<select class=\"updates\" id=\"colors\">" +
					"<option value=\"FFFFFF\" style=\"background-color: White;color: #FFFFFF;\">White</option>" +
					"<option value=\"000000\" style=\"background-color: Black;color: #000000;\">Black</option>" +
					"<option value=\"808080\" style=\"background-color: Gray;color: #808080;\">Gray</option>" +
					"<option value=\"A9A9A9\" style=\"background-color: DarkGray;color: #A9A9A9;\">Dark Gray</option>" +
					"<option value=\"D3D3D3\" style=\"background-color: LightGrey;color: #D3D3D3;\">Light Gray</option>" +
					"<option value=\"7FFFD4\" style=\"background-color: Aquamarine;color: #7FFFD4;\">Aquamarine</option>" +
					"<option value=\"40E0D0\" style=\"background-color: Turquoise;color: #40E0D0;\">Turquoise</option>" +
					"<option value=\"87CEEB\" style=\"background-color: SkyBlue;color: #87CEEB;\">Sky Blue</option>" +
					"<option value=\"0000FF\" style=\"background-color: Blue;color: #0000FF;\">Blue</option>" +
					"<option value=\"000080\" style=\"background-color: Navy;color: #000080;\">Navy</option>" +
					"<option value=\"483D8B\" style=\"background-color: DarkSlateBlue;color: #483D8B;\">Dark Slate Blue</option>" +
					"<option value=\"800080\" style=\"background-color: Purple;color: #800080;\">Purple</option>" +
					"<option value=\"FF1493\" style=\"background-color: DeepPink;color: #FF1493;\">Deep Pink</option>" +
					"<option value=\"EE82EE\" style=\"background-color: Violet;color: #EE82EE;\">Violet</option>" +
					"<option value=\"FFC0CB\" style=\"background-color: Pink;color: #FFC0CB;\">Pink</option>" +
					"<option value=\"006400\" style=\"background-color: DarkGreen;color: #006400;\">Dark Green</option>" +
					"<option value=\"008000\" style=\"background-color: Green;color: #008000;\">Green</option>" +
					"<option value=\"9ACD32\" style=\"background-color: YellowGreen;color: #9ACD32;\">Yellow Green</option>" +
					"<option value=\"7CFC00\" style=\"background-color: LawnGreen;color: #7CFC00;\">Lawn Green</option>" +
					"<option value=\"6B8E23\" style=\"background-color: OliveDrab;color: #6B8E23;\">Olive Drab</option>" +
					"<option value=\"FFFF00\" style=\"background-color: Yellow;color: #FFFF00;\">Yellow</option>" +
					"<option value=\"FFA500\" style=\"background-color: Orange;color: #FFA500;\">Orange</option>" +
					"<option value=\"FF0000\" style=\"background-color: Red;color: #FF0000;\">Red</option>" +
					"<option value=\"B03060\" style=\"background-color: #B03060;color: #B03060;\">Maroon</option>" +
					"<option value=\"A52A2A\" style=\"background-color: Brown;color: #A52A2A;\">Brown</option>" +
					"<option value=\"DEB887\" style=\"background-color: BurlyWood;color: #DEB887;\">Burly Wood</option>" +
					"<option value=\"F5F5DC\" style=\"background-color: Beige;color: #F5F5DC;\">Beige</option>" +
					"<option value=\"FFDAB9\" style=\"background-color: PeachPuff;color: #FFDAB9;\">Peach Puff</option>" +
					"<option value=\"E6E6FA\" style=\"background-color: Lavender;color: #E6E6FA;\">Lavender</option>" +
					"<option value=\"8B4513\" style=\"background-color: #8B4513;color: #8B4513;\">Chocolate</option>" +
			"</select>";	
	colors2 = colors.replace(/colors/, "colors2");


	html = "";
	if (fn == "scale") {
		html = '<span>' +
				'percent: <input class="updates" type="text" id="pct" size="4" maxlength="4" /> ' +
				'<input type="button" class="options" value="process" onClick="process(\'scale\', \'' +id +'\')" />' +
			'</span>';
	}
	else if (fn == "resize") {
		html = '<span>' +
				'width: <input class="updates" type="text" id="w" size="4" maxlength="4" /> ' +
				'height: <input class="updates" type="text" id="h" size="4" maxlength="4" /> ' + 
				'<input type="button" class="options" value="process" onClick="process(\'resize\', \'' +id +'\')" />' +
			'</span>';
	}
	else if (fn == "round") {
		html = '<span>' +
				'radius: <input class="updates" type="text" id="radius" size="4" maxlength="4" /> ' +
				'background: ' +colors + 
				'<input type="button" class="options" value="process" onClick="process(\'round\', \'' +id + '\')" />' +
			'</span>';
	}
	else if (fn == "rframe") {
		html = '<span>' +
				'radius: <input class="updates" type="text" id="rradius" size="4" maxlength="4" /> ' +
				'thickness: <input class="updates" type="text" id="rthickness" size="4" maxlength="4" /> ' +
				'color: ' +colors + 
				' background: ' +colors2 +
				'<input type="button" class="options" value="process" onClick="process(\'rframe\', \'' +id + '\')" />' + 
			'</span>';
	}
	else if (fn == "frame") {
		html = '<span>' +
				'thickness: <input class="updates" type="text" id="thickness" size="4" maxlength="4" /> ' +
				'color: ' +colors + 
				'<input type="button" class="options" value="process" onClick="process(\'frame\', \'' +id +'\')" />' +
			'</span>';
	}
	else if (fn == "rotate") {
		html = '<span>' +
				'angle: <input class="updates" type="text" id="angle" size="4" maxlength="4" /> ' +
				'background: ' +colors + 
				'<input type="button" class="options" value="process" onClick="process(\'rotate\', \'' +id + '\')" />' +
				'</span>';
	}

	document.getElementById('params').innerHTML = html;
}

//show photo editing studio
function showStudio(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showStudio.php?pid=" + id;
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//process requests from studio
function process(fn, id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 

	rgb = "";
	rgb2 = "";
	if (document.getElementById('colors')) {
		rgb = document.getElementById('colors').value;
	}
	if (document.getElementById('colors2')) {
		rgb2 = document.getElementById('colors2').value;
	}
	src = document.getElementById('src').value;
	url = "";
	if (fn == "scale") {
		url = "process.php?pid=" + id + "&fn=" + fn + "&src=" + src + "&pct=" + document.getElementById('pct').value;
	}
	else if (fn == "resize") {
		url = "process.php?pid=" + id + "&fn=" + fn + "&src=" + src + "&w=" + document.getElementById('w').value;
		url+= "&h=" + document.getElementById('h').value;
	}
	else if (fn == "rotate") {
		url = "process.php?pid=" + id + "&fn=" + fn + "&src=" + src +"&angle=" +document.getElementById('angle').value +"&rgb=" + rgb;
	}
	else if (fn == "round") {
		url = "process.php?pid=" + id + "&fn=" + fn + "&src=" + src +"&radius=" +document.getElementById('radius').value +"&rgb=" + rgb;
	}
	else if (fn == "rframe") {
		url = "process.php?pid=" + id + "&fn=" + fn + "&src=" + src +"&rradius=" +document.getElementById('rradius').value +"&rgb=" + rgb;
		url+= "&rthickness=" +document.getElementById('rthickness').value  + "&rgb2=" + document.getElementById('colors2').value;
	}
	else if (fn == "frame") {
		url = "process.php?pid=" + id + "&fn=" + fn + "&src=" + src +"&thickness=" +document.getElementById('thickness').value +"&rgb=" + rgb;
	}

	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//save photo from studio
function save(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "save.php?pid=" + id +"&src=" + document.getElementById('src').value;
	xmlHttp.onreadystatechange=updateHint;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//user with id performs search on term
//scope = 0 => local, 1=> universal
function search() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "search.php?&term="  +document.getElementById('term').value;
	document.getElementById('search').innerHTML = "";
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function tagSearch(tag) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "search.php?&term="  +tag;
	url+= "&scope=1";
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//show info of photo with id from a search perspective
function showSearchInfo(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showSearchInfo.php?id=" + id;
	xmlHttp.onreadystatechange=updateInfo;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//add a comment to photo with id
function addComment(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "addComment.php?id=" + id + "&text=" + document.getElementById('new_comment').value;
	xmlHttp.onreadystatechange=updateComment;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//delete comment with cid on photo with id
function deleteComment(cid, id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "deleteComment.php?id=" + id + "&cid=" +cid;
	xmlHttp.onreadystatechange=updateComment;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

//show albums of user with id
function showAlbums() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "showAlbums.php";
	xmlHttp.onreadystatechange=updateMain;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function login() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	url = "login.php?uid=" + document.getElementById('uid').value;
	url+= "&passwd=" + document.getElementById('passwd').value;
	xmlHttp.onreadystatechange=updateContainer;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

