function getFlashObject(id) {
	if (window.document[id]) {
		return window.document[id];
	}
	if (navigator.appName.indexOf("Microsoft Internet") == -1) {
		if (document.embeds && document.embeds[id])
			return document.embeds[id]; 
	} else {
		return document.getElementById(id);
	}
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
function setArabic(flashID, input) {
	var flashobject = getFlashObject(flashID);
	if (input.value.length>0) {
		flashobject.setArabicInputValue(input.value);
	} else {
		flashobject.setArabicInputValue('');
	}
}
function createArabicInput(flashID, inputID, inputValue, x, y, w, h, type) {
	var flashobject = getFlashObject(flashID);
	var flashdiv = flashobject.parentNode;
	var inputdiv = document.createElement('div');
	inputdiv.id = 'arabicdiv_'+inputID;
	inputdiv.style.position = 'absolute';
	inputdiv.style.left = (findPos(flashobject)[0]+x)+'px';
	inputdiv.style.top = (findPos(flashobject)[1]+y)+'px';
	if (inputValue == 'null') {
		inputValue = '';
	}
	if (type != "multiline") {
		inputdiv.innerHTML = '<input id="'+inputID+'" name="'+inputID+'" type="text" onkeyup="setArabic(\''+flashID+'\', this)" value="'+inputValue+'" cols="'+(w/8)+'" style="direction:rtl; border-style:none; background:none; width:'+(w-2)+'px;" />';
	} else {
		inputdiv.innerHTML = '<textarea id="'+inputID+'" name="'+inputID+'" onkeyup="setArabic(\''+flashID+'\', this)" cols="'+(w/8)+'" rows="'+(h/15)+'" style="direction:rtl; border-style:none; background:none; background:none; width:97%;">'+inputValue+'</textarea>';
	}
	flashdiv.appendChild(inputdiv);
	return 'arabicinput_'+inputID;
}
function removeArabicInput(flashID, inputID) {
	var flashobject = getFlashObject(flashID);
	var flashdiv = flashobject.parentNode;
	var inputdiv = document.getElementById(inputID);
	flashdiv.removeChild(inputdiv);
}
