var activeta;
var switched;
var oldelement;
function setKeyboardMode()
{
	var phonetic = getCookie("phonetic");
	if (null==phonetic) phonetic='false';
	//alert(phonetic);
    
    // mizan: added for english keyboard.
    
    var englishkb = getCookie("englishkb");
    if (null==englishkb) englishkb='false';

	var unicode = getCookie("unicode");
	if (null==unicode) unicode='true';
	//alert(unicode);
	var bijoykb = getCookie("bijoykb");
	if (null==bijoykb) bijoykb='false';
	
	if(englishkb == 'true')
    {
       makeEnglishEditor(activeta);
       
    }
    /*else if(bijoykb=='true' && phonetic=='false'){
		//alert("making BijoyKb Content "+activeta);
		makeBijoyKeybdEditor(activeta);
	}
	else if (unicode=='true' && phonetic=='true')
	{
		*/
		//alert("making UniPhonetic "+activeta);
		makeUniPhoneticEditor(activeta);
		/*
	}
	else if(unicode=='false' && phonetic=='true')
	{
		//alert("making AsciiPhonetic "+activeta);
		makeAsciiPhoneticEditor(activeta);
	}
	else if(unicode=='true' && phonetic =='false')
	{
		//alert("making Unijoy "+activeta);
		makeUnijoyEditor(activeta);
	}
	else if(unicode=='false' && phonetic =='false')
	{
		//alert("making AsciiUnijoy "+activeta);
		makeAsciiUnijoyEditor(activeta);
	}*/
}

function convertToAscii(FromElement, ToElement)
{
	var unicode = $(FromElement).value;
	var converted_bijoy = ConvertToASCII('bijoy', unicode);
	$(ToElement).value = converted_bijoy;
}

function insertEnglish2()
{
	activeta = "comment-body2";
	eng = document.getElementById("english2").value;
	insertAtCursor("[Bswjk]" + eng + "[/Bswjk]");
}

function propagate()
{
	/*$(document.body).observe('click', function(event){
	var elm = Event.element(event);
	//alert(elm.className);
	if (elm.className=="bngtext" || elm.className=="bng_text"){
	activeta = elm.id;
	//alert(activeta);

	setKeyboardMode();
	oldelement=activeta;
	}
	});

	$(document.body).observe('focus', function(event){
	var elm = Event.element(event);
	alert(elm.className);
	if (elm.className=="bngtext" || elm.className=="bng_text"){
	activeta = elm.id;
	//alert(activeta);

	setKeyboardMode();
	oldelement=activeta;
	}
	});*/

	$$('input.bng_text','input.bng_text2','textarea.bng_text','textarea.bng_text2', 'input.bng_small_text').each(function(s)
	{
		s.observe('focus', function(event)
		{
			activeta = s.id;
			setKeyboardMode();
			oldelement=activeta;
		}
		)
	}
	);
	
	

}
/* thanks to scott andrew [http://www.scottandrew.com/weblog] for this awesome cookie func */
function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
	( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
	( ( path ) ? ';path=' + path : '' ) +
	( ( domain ) ? ';domain=' + domain : '' ) +
	( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
	( ( path ) ? ';path=' + path : '') +
	( ( domain ) ? ';domain=' + domain : '' ) +
	';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}


var AU = function()
{
	this.update = function(url, params, containerid)
	{
		new Ajax.Request( url, {
			method: 'post',
			encoding: 'utf-8',
			onSuccess: function(transport) {

				$(containerid).innerHTML = transport.responseText;
			},
			onFailure: function(transport) {
				alert('call failed')
			},
			parameters: ""+params
		}
		);
	}

	this.updateProxy = function(url, params,containerid)
	{
		var proxyurl = "http://localhost/bba/proxy.php?url="+encodeURIComponent(url);
		new Ajax.Request( proxyurl, {
			method: 'post',
			onSuccess: function(transport) {
				if (null!=containerid)
				$(containerid).innerHTML = transport.responseText
				//alert(transport.responseText);
			},
			onFailure: function(transport) {
				alert('call failed')
			},
			parameters: ""+params
		}
		);
	}
}

var AU = new AU();




