// javascript page
function myAjax(page, tag, state, loading){
	var xhr;
	xhr = ajaxConnect();
	
  	var url = 'http://' + document.domain + '/ajax/'+page + '/' + state + '/' + Math.round(1000*Math.random()) + Math.round(1000*Math.random()) + Math.round(1000*Math.random());
	
   	xhr.open('GET', url, true);
   	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200) {
			document.getElementById(tag).innerHTML = xhr.responseText;
		}
		else
		{
			if(loading != null)
			document.getElementById(tag).innerHTML = (loading != "image")?loading:"<img src='images/check_user.gif' align='absmiddle' />";
		}		 
	}
   	xhr.send(null);
}

function ajaxConnect()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

/**
* Pops up a new window in the middle of the screen
*/
function popupWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function setFocus(name){
	document.getElementById(name).select();
	document.getElementById(name).focus();
}

function uniconvert(sourceareastr)
{
var strlen = sourceareastr.length;
var urdun="";
var str="";


      for (i = 0; i < strlen;  i++) { 
	var codestr = sourceareastr.charCodeAt(i);
	//alert(codestr);
	   switch(codestr) {
		case 184: codestr=1105;break; //eo
		case 168: codestr=1025;break; // capital EO
	
		case 175: codestr=1198; break; //capital UE
		case 191: codestr=1199; break; //ue
		
		case 170: codestr=1256; break; // capital OE
		case 186: codestr=1257; break; //oe
	   }
	   if (256>codestr && codestr>191) codestr=codestr+848;
	        switch(codestr) {
		case 1111: codestr=1199;break;   //u
		case 1031: codestr= 1198; break; //capital U
		
		case 1108: codestr=1257; break; //ou
		case 1028: codestr=1256; break; //capital OU
		}
           str=str+String.fromCharCode(codestr);
      } //end for   
   urdun=str;
    return urdun;
}	
function unicodeTextCutter(string, len)
{
	var newstr = string.substr(0,len);
	if(string.length > len)
		newstr+=' ...';
	document.write(newstr)
}