function usernameField(toggle) {
	var f = document.getElementById('username');
	
	if (toggle == "focus") {
		if (f.value == "[enter your username]") {
			f.value = '';
			f.style.color = '#000000';	
		}
	} else {
		if ((f.value == "[enter your username]") || (f.value == "")) {
			f.style.color = '#CCCCCC';
			f.value = '[enter your username]';
		} else {
			f.style.color = '#000000';
		}
	}
}

function passwordField(toggle) {
	var f = document.getElementById('password');
	
	if (toggle == "focus") {
		if (f.value == "[enter your password]") {
			f.value = '';
			f.type = 'password';
			f.style.color = '#000000';	
		}
	} else {
		if ((f.value == "[enter your password]") || (f.value == "")) {
			f.style.color = '#CCCCCC';
			f.type = 'text';
			f.value = '[enter your password]';
		} else {
			f.style.color = '#000000';
		}
	}
}

function showPNG() {
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	}
}

// AJAX Xml Object

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 userLogin(language) {
	var xmlHttp = null;
	xmlHttp=GetXmlHttpObject();
	var page="/scripts/user_login.php";
	if (language == "fr") {
		var url = "language=fr&username="+document.getElementById('username_fr').value+"&password="+document.getElementById('password_fr').value;
	} else {
		var url = "language=en&username="+document.getElementById('username_en').value+"&password="+document.getElementById('password_en').value;
	}
	xmlHttp.onreadystatechange=function() {
		stateChanged(xmlHttp);
	}
	xmlHttp.open("POST",page,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", url.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(url);
}

function stateChanged(xmlHttp) {
	if (xmlHttp.readyState==4) { 
		if (xmlHttp.responseText.substr(0,1) == '+') {
			alert(xmlHttp.responseText);
		} else 	if (xmlHttp.responseText.substr(0,4) == 'url=') {
			window.location.href = xmlHttp.responseText.replace('url=','');
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

