else {
if(!temp_disable[targetElement.id])
{
var transPair = trans(lastSevenChars+c, e);
var oldString = transPair[0];
var newString = transPair[1];
}
else
{
var oldString = c;
var newString = c;
}
}
replaceTransStringAtCaret(targetElement, oldString.length, newString , selectionRange);
previous_sequence[targetElement.id ] += c;
if(previous_sequence[targetElement.id ].length > 6 ) previous_sequence[targetElement.id ] = previous_sequence[targetElement.id ].substring(previous_sequence[targetElement.id ].length-6);
if(event.preventDefault) event.preventDefault;
else if(event.cancelBubble) { event.cancelBubble = true; }
return false;
}
return true;
}
/**
- This is the function to which call during window load event for trasliterating textfields.
- The funtion will accept any number of HTML tag IDs of textfields.
- /
function transliterate(id) {
var len = arguments.length;
for(var i=0;i<len; i++)
{
var element = document.getElementById(arguments[i]);
if(element)
{
trasliteration_fields[arguments[i]] = true;
previous_sequence[arguments[i]] = '';
//element.onkeypress = tiKeyPressed;
if (element.addEventListener){
element.addEventListener('keypress', tiKeyPressed, false);
} else if (element.attachEvent){
element.attachEvent("onkeypress", tiKeyPressed);
}
}
}
}  
function transOptionOnClick(event)
{
var e = event || window.event;
var checkbox = (e.currentTarget || e.srcElement);
if(checkbox.checked)
{
enableTrasliteration(checkbox.value,true);
}
else
{
enableTrasliteration(checkbox.value,false);
}
}
// change this value to "after" or "before" to position transliteration option check box
var TO_POSITION = "after";
// check box message
var CHECKBOX_TEXT = "To Write Malayalam (Ctrl+M)";
// Default tranliteration state
var DEFAULT_STATE = true;
// call this function to add checkbox to enable/disable transliteration
function addTransliterationOption
{
var len = arguments.length;
for(var i=0;i<len; i++)
{
var element = document.getElementById(arguments[i]);
if(element)
{
var checkbox = document.createElement('input');
checkbox.id = arguments[i]+'cb';
checkbox.type = 'checkbox';
checkbox.value = arguments[i];
checkbox.onclick = transOptionOnClick;
checkbox.checked = DEFAULT_STATE;
var para = document.createElement('p');
para.appendChild(checkbox);
var text = document.createTextNode(CHECKBOX_TEXT);
para.appendChild(text);
if(TO_POSITION=="after") element.parentNode.insertBefore(para, element.nextSibling);
else if(TO_POSITION=="before") element.parentNode.insertBefore(para, element);
}
}
}  
/**
- This functions is to synchronize state transliteration state to fields from cookies
- /
function translitStateSynWithCookie {
var len = arguments.length;
for(var i=0;i<len; i++)
{
var element = document.getElementById(arguments[i]);
if(element)
{
var state = readCookie("tr"+arguments[i]);
var enable = DEFAULT_STATE;
if(parseInt(state) == 0) { enable=false; }
enableTrasliteration(arguments[i],enable);
}
}
}  
function writingStyleLBChanged(event) {
var e = event || window.event;
var listBox = (e.currentTarget || e.srcElement);  
if(listBox.selectedIndex == 0) {
rules = rules0;
memrules = memrules0;
}
else if(listBox.selectedIndex == 1) {
rules = rules1;
memrules = memrules1;
}
setCookie("transToolIndex", listBox.selectedIndex);
}