﻿// JScript File
var nowFieldOnBlur='';

function clientBrowser()
{
    var agt=navigator.userAgent.toLowerCase();
    if (agt.indexOf('msie') != -1)
        return 0;
    if (agt.indexOf('firefox') != -1)
        return 1;
    return -1;
}

// Show/Hide Menu TreeView
function collapseTreeView(oImg,altHide,altShow)
{
    oTable = oImg;
    while(oTable.tagName != "TABLE")
    {
        oTable = oTable.parentNode;
        if (oTable == null)
            return false;
    }

    oButtonRow = oImg.parentNode.parentNode.parentNode;
    sTitle = oTable.rows[0].cells[0].children[0].children[0].innerText;
    oTreeRow = oTable.rows[1];
    if (oTreeRow.style.display == 'none')
    {
        oImg.src = oImg.src.replace("ico_open", "ico_close");
        if(altHide != null) oImg.alt = altHide;
        oButtonRow.children[0].style.display = '';
        oButtonRow.children[1].style.display = '';
        oTreeRow.style.display = '';
        oButtonRow.children[2].style.borderLeft='solid 1px White';
        oButtonRow.children[2].style.borderRight='solid 1px Gray';
        oButtonRow.children[2].style.borderBottom='solid 1px Gray';
        oTable.parentNode.style.width="20%";
        oImg.parentNode.children[1].style.display = 'none';
    }
    else
    {
        oImg.src = oImg.src.replace("ico_close", "ico_open");
        if(altShow != null) oImg.alt = altShow;
        oButtonRow.children[0].style.display = 'none';
        oButtonRow.children[1].style.display = 'none';
        oTreeRow.style.display = 'none';
        oButtonRow.children[2].style.borderLeft='';
        oButtonRow.children[2].style.borderRight='';
        oButtonRow.children[2].style.borderBottom='';
        oTable.parentNode.style.width="17px";
        oVertical = oImg.parentNode.children[1];
        oVertical.innerText = '';
        for(var i = 0; i < sTitle.length; i++)
        {
            var cAdd = sTitle.substring(i, i + 1);
            if (oVertical.innerText != '' || (cAdd != ' ' && cAdd != '\t' && cAdd != '\n' && cAdd != '\r'))
                oVertical.innerHTML += cAdd + '<BR>';
        }
        oVertical.style.display = '';
    }
    
    if (window.onresize != null)
        window.onresize();
}

function collapseMessageTreeView(oImg,altHide,altShow)
{
    oTable = oImg;
    while(oTable.tagName != "TABLE")
    {
        oTable = oTable.parentNode;
        if (oTable == null)
            return false;
    }
    
    if (oTable.rows[1].style.display == 'none')
    {
        oImg.src = oImg.src.replace("ico_open", "ico_close");
        if(altHide != null) oImg.alt = altHide;
        oTable.rows[1].style.display = '';
        oImg.parentNode.children[0].style.display = '';
        oTable.parentNode.style.width="20%";
        oImg.parentNode.children[2].style.display = 'none';
    }
    else
    {
        oImg.src = oImg.src.replace("ico_close", "ico_open");
        if(altShow != null) oImg.alt = altShow;
        oTable.rows[1].style.display = 'none';
        oImg.parentNode.children[0].style.display = 'none';
        oTable.parentNode.style.width="17px";
        oVertical = oImg.parentNode.children[2];
        oVertical.innerText = '';
        sTitle = oImg.parentNode.children[0].innerText;
        for(var i = 0; i < sTitle.length; i++)
        {
            var cAdd = sTitle.substring(i, i + 1);
            if (oVertical.innerText != '' || (cAdd != ' ' && cAdd != '\t' && cAdd != '\n' && cAdd != '\r'))
                oVertical.innerHTML += cAdd + '<BR>';
        }
        oVertical.style.display = '';
    }
}

function collapseTable(objName)
{
    var obj = document.getElementById(objName);
    
    if(obj != null)
    {
        if(obj.style.display == 'none')
        {
            obj.style.display = '';
        }
        else
        {
            obj.style.display = 'none';
        }
    }
}


var ctrlModified = null;

function disabledControls(popupWindowID)
{
    if (clientBrowser() == 1)   // if firefox
        return;
    if (ctrlModified != null)
        return;
    var tagNames = new Array("SELECT");
    ctrlModified = new Array();
    for(i = 0; i < tagNames.length; i++)
    {
        var tagElements = document.getElementsByTagName(tagNames[i]);
        for(j = 0; j < tagElements.length; j++)
        {
			
            saved = new Object();
            saved.control = tagElements[j];
            saved.display = tagElements[j].style.display;
			ctrlModified[ctrlModified.length] = saved;
			
			tmpControl = document.createElement('INPUT');
			
			tmpControl.style.top = tagElements[j].offsetTop;
			tmpControl.style.left = tagElements[j].offsetLeft;
			tmpControl.style.width = tagElements[j].offsetWidth;
		    if (tagElements[j].offsetHeight > 2)
			{
			    tmpControl.style.height = tagElements[j].offsetHeight - 2;
			}
			tmpControl.style.overflow = 'hidden';
			tmpControl.setAttribute('className', 'pagingbar_ctl');
			tmpControl.id = 'tmpControl';
			switch (tagNames[i])
			{
			case 'SELECT':
			    if (tagElements[j].size > 1)
			    {
			        for (k = 0; k < tagElements[j].options.length; k++)
			        {
			            tmpControl.value += tagElements[j].options(k).text;
			            if (k > 0)
			                tmpControl.value += '\r\n';
			        }
			    }
			    else if (tagElements[j].selectedIndex != -1)
			        tmpControl.value = tagElements[j].options(tagElements[j].selectedIndex).text;
			default:
			}
			
			tagElements[j].style.display = 'none';
			tagElements[j].insertAdjacentElement('beforeBegin', tmpControl);
        }
    }
}

function restoreControls(popupWindowID)
{
    if (clientBrowser() == 1)   // if firefox
        return;
    if (ctrlModified != null)
    {
        for (i=0; i < ctrlModified.length; i++)
        {
            var saved = ctrlModified[i];
            saved.control.style.display = saved.display;
        }
        temporalControls = document.getElementsByName('tmpControl');
        
        for (i=temporalControls.length - 1; i >= 0 ; i--)
            temporalControls[i].parentNode.removeChild(temporalControls[i]);
            
        ctrlModified = null;
    }
    
}
//To hide and show the toolbar - Begin
function HideScrollBars()
{    
}

function ValidateInteger(elementName, messageValidate)
{
    var bResult=true;
    var elementControlI = document.getElementById(elementName);
    
        if (StringIsInteger(elementControlI.value)!=true)
        {
            alert(messageValidate);
            elementControlI.focus();
            elementControlI.select();
            bResult=false;
        }
        
    return bResult;
}

function ShowScrollBars()
{
}
//To hide and show the toolbar - End

function ValidEmailFormat(email, emailDelimiter, messageToPrompt, viewErrorList)
{
    var emailArray = new Array();
    var emails = '';
    
    emailArray = email.split(emailDelimiter);
    
    for (var i = 0; i < emailArray.length; i++)
    {
        if (!emailArray[i].match(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/))
        {
            emails += '\'' + emailArray[i] + '\'\n';
        }
    }

    if (emails != '')
    {	
        if (messageToPrompt != null && messageToPrompt != '')
    	{    
    	    if (viewErrorList && (emailArray.length > 1))
	        {	        
	            alert(messageToPrompt + ":\n\n" + emails.substring(0, emails.length - 1));
            }
	        else
	        {
    	        alert(messageToPrompt);
	        }
	    }
	    	    
	    return false;
	}
	
	return true;
}

function validateMaxLengthText(element, maxlength)
{
    var valueOld = element.value;
    var lengthUp = parseInt(valueOld.length);
    
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    
    if (element.value.length > maxlength) {
        element.value = valueOld.substring(0,maxlength);
    }
}

function IsNumeric(e)
{
    
    var code = 0;
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    
	if (clientBrowser() == 0)
    {
        if (e.shiftKey)
        if (code != 9 && code != 35 && code != 36 && code != 37 && code != 39 )        
        return false;

        if (e.ctrlKey)
        if (code == 17 || code == 67 || code == 86)
            return true;
    }
    else
    {
        if ((e.modifiers & Event.SHIFT_MASK) > 0)
        if (code != 9 && code != 35 && code != 36 && code != 37 && code != 39 )        
        return false;

        if ((e.modifiers & Event.CONTROL_MASK) > 0)
        if (code == 17 || code == 67 || code == 86)
            return true;    
    
    }

	
    switch(code)
    
        {
            case 13: /*"Enter"*/
            return true
            break;
            case 8: /*"Back"*/
            return true
            break;            
            case 9: /*"Tab"*/
            return true
            break;
            case 17: /*"Tab"*/
            return true
            break;
            case 46: /*"Del"*/
            return true
            break;
            case 35: /*"End"*/
            return true
            case 36: /*"Home"*/
            return true
            case 37: /*"Arrow Left"*/
            return true
            break;
            case 38: /*"Arrow Up"*/
            return true
            break;
            case 39: /*"Arrow Right"*/
            return true
            break;
            case 40: /*"Arrow Down"*/
            return true
            break;
        }            

    var ValidChars = "0123456789";
    var IsNumber=false;
    var Char;
    for (i = 0; i < ValidChars.length; i++) 
        { 
            if (code == ValidChars.charCodeAt(i) || code == (ValidChars.charCodeAt(i) + 48)) 
            {
            IsNumber = true;
            }
        }
    if (IsNumber == false)
    {
        if (e.preventDefault) {
            e.preventDefault();
            e.stopPropagation();
        } else {
            e.keyCode = 0;
            e.returnValue = false;
        }
    }                   
    return IsNumber;
}

function StringIsInteger(value)
{
    var response = true;
    
    if ((parseInt(value) != value) && value != '')
    {
        response = false;
    }
    
    return response;
}

function StringIsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function IsDecimal(e)
{
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    
	if (clientBrowser() == 0)
    {
        if (e.shiftKey)
        if (code != 9 && code != 35 && code != 36 && code != 37 && code != 39 )        
        return false;

        if (e.ctrlKey)
        if (code == 17 || code == 67 || code == 86)
            return true;
    }
    else
    {
        if ((e.modifiers & Event.SHIFT_MASK) > 0)
        if (code != 9 && code != 35 && code != 36 && code != 37 && code != 39 )        
        return false;

        if ((e.modifiers & Event.CONTROL_MASK) > 0)
        if (code == 17 || code == 67 || code == 86)
            return true;    
    
    }	
    
    switch(code)
    
        {
            case 13: /*"Enter"*/
            return true;
            case 8: /*"Back"*/
            return true;
            case 9: /*"Tab"*/
            return true;
            case 17: /*"Tab"*/
            return true;
            case 46: /*"Del"*/
            return true;
            case 35: /*"End"*/
            return true;
            case 36: /*"Home"*/
            return true;
            case 37: /*"Arrow Left"*/
            return true;
            case 38: /*"Arrow Up"*/
            return true;
            case 39: /*"Arrow Right"*/
            return true;
            case 40: /*"Arrow Down"*/
            return true;
            case 110: /*"dot "*/
            case 190: /*"dor in numeric key pad"*/
            return (e.srcElement.value.indexOf('.') == -1);
            case 109: /*"dot "*/
            case 189: 
            return (e.srcElement.value.indexOf('-') == -1);
        }            

    var ValidChars = "-0123456789";
    var IsDecimal=false;
    var Char;
  
    for (i = 0; i < ValidChars.length; i++) 
    {
        if (code == ValidChars.charCodeAt(i) || code == (ValidChars.charCodeAt(i) + 48))
        {
            IsDecimal = true;
            break;
        }
    }
    
    if (code == 189 || code == 109)
        IsDecimal = true;
        
    
    if (IsDecimal == false)
    {
        if (e.preventDefault) {
            e.preventDefault();
            e.stopPropagation();
        } else {
            e.keyCode = 0;
            e.returnValue = false;
        }
    }
    return IsDecimal;
}

function StringIsDecimal(sText, lenDecimal)
{
    var ValidChars = "-0123456789.";
    var IsDecimal = true;

    for (i = 0; i < sText.length == true; i++)
        if (ValidChars.indexOf(sText.charAt(i)) == -1)
        {
            IsDecimal = false;
            break;
        }
    if (IsDecimal)
    {
        var firstDot = sText.indexOf('.') + 1;
        if (firstDot > 0)
        if (sText.indexOf('.', firstDot) > -1)
            IsDecimal = false;
    }
    
    var pattern = "^\\-?[0-9,]{0,}\\.?\\d{0," + lenDecimal + "}$";
    var reg = new RegExp(pattern);
        
    if (!reg.test(sText)) {
        IsDecimal = false;
    }
    else {
        IsDecimal = true;
    }
        
    return IsDecimal;
}

function formatDecimal(o, formatValue, unformatValue)
{
    if (formatValue && unformatValue)
    {
        if (o.value == eval(unformatValue))
            o.value = eval(formatValue);
    }
    else
    {
        var aParts = o.value.split(getNumberDecimalSeparator());
        var newValue = '';
        for(var ii = 0; ii < aParts[0].length; ii += 3)
        {
            var jj = aParts[0].length - ii - 3;
            var kk = jj < 0 ? 0 : jj;
            if (ii > 0)
                newValue = getNumberGroupSeparator() + newValue;
            newValue = aParts[0].substr(kk, 3 + jj - kk) + newValue;
        }
        o.value = newValue;
        if (aParts.length > 1)
            o.value += getNumberDecimalSeparator() + aParts[1];
    }
}

function prepareDecimal(o, formatValue, unformatValue)
{
    if (formatValue)
        eval(formatValue + ' = "' + o.value + '";');

    var newValue = '';
    for (ii = 0; ii < o.value.length; ii++)
    {
        cDig = o.value.substring(ii, ii+1);
        if (cDig != getNumberGroupSeparator())
            newValue += cDig;             
    }
    o.value = newValue;

    if (unformatValue)
        eval(unformatValue + ' = "' + o.value + '";');
    o.select();
}

//To disable the arrows key
function KeyCheck(e)
{
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
   
   switch(code)
   {
      case 33://Rt Pag
        return false;
        break;
      case 34://Fw pag
        return false;
        break;
      case 35://Home
        return false;
        break;
      case 36://End
        return false;
        break;
      case 37://Left
        return false;
        break;
      case 38://Up  
        return false;
        break;
      case 39://Right    
        return false;
        break;
      case 40://Down 
        return false;
        break;
  }
}

//Set the treeview status
function isopentree(objImage)
{
    var filename = objImage.src
    
    if (filename.indexOf('ico_open') != -1)
    {
        setVarTree(1);
    }
    else
    {
        setVarTree(0);
    }
}

function setVarTree(varStatus)
{   
    var url= applicationWebMethodsPage;
    var postData = new Array("action=1", "status=" + varStatus);
    CallServerWebMethod(url, false, setvartreeCallBack, postData);
    return false;
}

function setvartreeCallBack(result)
{
}

function showShadow()
{
    var oShadowContent = document.getElementById('shadowContent');
    if (oShadowContent != null)
    {
        var oShadow1 = document.getElementById('shadow1');
        oShadow1.style.top = oShadowContent.offsetTop + 0;
        oShadow1.style.left = oShadowContent.offsetLeft + 0;
        oShadow1.style.width = oShadowContent.offsetWidth;
        oShadow1.style.height = oShadowContent.offsetHeight;
        
        var oShadow2 = document.getElementById('shadow2');
        oShadow2.style.top = 1;
        oShadow2.style.left = 1;
        oShadow2.style.width = oShadowContent.offsetWidth;
        oShadow2.style.height = oShadowContent.offsetHeight;
        
        var oShadow3 = document.getElementById('shadow3');
        oShadow3.style.top = 1;
        oShadow3.style.left = 1;
        oShadow3.style.width = oShadowContent.offsetWidth;
        oShadow3.style.height = oShadowContent.offsetHeight;
        
        var oShadow4 = document.getElementById('shadow4');
        oShadow4.style.top = 1;
        oShadow4.style.left = 1;
        oShadow4.style.width = oShadowContent.offsetWidth;
        oShadow4.style.height = oShadowContent.offsetHeight;
        
        var oShadow5 = document.getElementById('shadow5');
        oShadow5.style.top = 1;
        oShadow5.style.left = 1;
        oShadow5.style.width = oShadowContent.offsetWidth;
        oShadow5.style.height = oShadowContent.offsetHeight;
        
        if (window.onresize == null)
            window.onresize = showShadow;
    }
}

function PosiCombo(objCombo, StrValue)
{
    for(var I=0; I<objCombo.options.length; I++)
    {
        if (objCombo.options[I].value==StrValue) objCombo.selectedIndex=I;
    }
}

function getValue(obj)
{
    if(typeof(obj) == "undefined")
    {
        return '';
    }  

    if (typeof(obj.type)=="undefined")
    {
        if (obj[0].type == "radio")
        {
            for (var I = 0; I < obj.length; I++)
            {
                if (obj[I].checked)
                {
                    return obj[I].value;
                }
            }            
            return "";
        }
    }
    else if (typeof(obj) == 'object')
    {
        if(obj.type =='select-one')
        {
            return obj.options[obj.selectedIndex].value;
        }
        else if (obj.type == 'checkbox')
        {
            if (obj.checked == true)
            {
                return "1";
            }
            else
            {
                return "0";          
            }
        }
        else
        {
            return obj.value;
        }
    }  
}

function RemoveString(valueToProcess, valueToRemove) 
{
    var i = valueToProcess.indexOf(valueToRemove);
    var temp = '';

    if (i == -1)
    {
        return valueToProcess;
    }

    temp += valueToProcess.substring(0,i) + RemoveString(valueToProcess.substring(i + valueToRemove.length), valueToRemove);

    return temp;
}

function RemoveSpaces(string) 
{
    var tempString = '';
    
    string = '' + string;
    splitString = string.split(" ");

    for(i = 0; i < splitString.length; i++)
    {
        tempString += splitString[i];
    }
    
    return tempString;
}

function Trim(value)
{
    while('' + value.charAt(0)==' ')
    {
        value = value.substring(1, value.length);
    }
    
    return value;
}

function handlerFocusOnObject(objectID)
{
    var objectToFocus = document.getElementById(objectID);
    
    try
    {
        if (objectToFocus.style.display != 'none')
        {
            objectToFocus.focus();
        }
        else
        {
            if (objectToFocus.onerror != null) objectToFocus.onerror();
        }
    }
    catch(err)
    {
        if (objectToFocus.onerror != null) objectToFocus.onerror();
    }
}

function SetFocus(objectID)
{
    setTimeout('handlerFocusOnObject("' + objectID + '");', 0);
}

function IsPhone(eventObject, eventType)
{
    var validChars = "0123456789[]() -+";
    var keysNotAllowed = new Object();
    keysNotAllowed.single = new Object();
    keysNotAllowed.single['13'] = 'Enter outside text fields';
    keysNotAllowed.alt = new Object();
    keysNotAllowed.ctrl = new Object();
    keysNotAllowed.shift = new Object();

    return isValidEvent(eventObject, eventType, keysNotAllowed, validChars)
}

function isValidEvent(evt, evtType, badKeys, validChars)
{
    this.target = evt.target || evt.srcElement;
    this.keyCode = evt.keyCode || evt.which;
    var targtype = this.target.type;

    var ie = document.all;
    var w3c = document.getElementById&&!document.all;

    if (w3c)
    {
        if (document.layers)
        {
            this.altKey = ((evt.modifiers & Event.ALT_MASK) > 0);
            this.ctrlKey = ((evt.modifiers & Event.CONTROL_MASK) > 0);
            this.shiftKey = ((evt.modifiers & Event.SHIFT_MASK) > 0);
        }
        else
        {
            this.altKey = evt.altKey;
            this.ctrlKey = evt.ctrlKey;
            this.shiftKey = evt.shiftKey;
        }
        // Internet Explorer
    }
    else
    {
        this.altKey = evt.altKey;
        this.ctrlKey = evt.ctrlKey;
        this.shiftKey = evt.shiftKey;
    }
    
    //var validChars = "0123456789[]() -+";

    // Keys to be disabled can be added to the lists below.
    // The number is the key code for the particular key
    // and the text is the description displayed in the
    // status window if the key [combination] is pressed.
    //var badKeys = new Object();
    //badKeys.single = new Object();
    //badKeys.single['8'] = 'Backspace outside text fields';
    //badKeys.single['13'] = 'Enter outside text fields';
    //badKeys.single['116'] = 'F5 (Refresh)';
    //badKeys.single['122'] = 'F11 (Full Screen)';
    //badKeys.alt = new Object();
    //badKeys.alt['37'] = 'Alt+Left Cursor';
    //badKeys.alt['39'] = 'Alt+Right Cursor';
    //badKeys.ctrl = new Object();
    //badKeys.ctrl['78'] = 'Ctrl+N';
    //badKeys.ctrl['79'] = 'Ctrl+O';
    //badKeys.ctrl['86'] = 'Ctrl+V';
    //badKeys.shift = new Object();
    //badKeys.shift['45'] = 'shift+Ins';

    // Find out if we need to disable this key combination
    var badKeyType = 'single';

    if (this.ctrlKey)
    {
        badKeyType = 'ctrl';
    }
    else if (this.altKey)
    {
        badKeyType = 'alt';
    }
    else if (this.shiftKey)
    {
        badKeyType = 'shift';
    }

    //Only onkeydown event
    if (evtType == 0)
    {
        if (checkKeyCode(badKeyType, this.keyCode))
        {
            return cancelKey(evt, this.keyCode, this.target, getKeyText(badKeyType, this.keyCode));
        }
    }
    else
    {
        if (!isCharInString(validChars, keyCode))
        {
            return cancelKey(evt, this.keyCode, this.target, String.fromCharCode(this.keyCode));
        }
    }

    function checkKeyCode(type, code)
    {
        if (badKeys[type][code])
        {
            return true;
        }
        else
        {
            return false;    
        }
    }

    function getKeyText(type, code)
    {
        return badKeys[type][code];
    }

    function cancelKey(evt, keyCode, target, keyText)
    {
        if (keyCode == 8 || keyCode == 13)
        {
            // Don’t want to disable Backspace or Enter in text fields
            if (target.type == 'text' || target.type == 'textarea')
            {
                return true;
            }
        }

        if (evt.preventDefault)
        {
            evt.preventDefault();
            evt.stopPropagation();
        }
        else
        {
            evt.keyCode = 0;
            evt.returnValue = false;
        }

        return false;
    }
}

function ReplacePhoneChars(phoneNumber)
{
    var invalidChars = new RegExp("[\\(\\) ]+", 'g');
    var result = phoneNumber.replace(invalidChars, '');
    
    invalidChars = new RegExp("\\-+", 'g');
    result = result.replace(invalidChars, '');
    
    invalidChars = new RegExp("[\\[]+", 'g');
    result = result.replace(invalidChars, '');
    
    invalidChars = new RegExp("[\\]]+", 'g');
    result = result.replace(invalidChars, '');
    
    return result;
}

function CheckPhone(obj, cadError)
{
   //var phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
   //var phoneDiplomaticFormat = /\[1\][ ]((\(\d{3}\))|(\d{3}))[ ]?\d{3}-?\d{4 }/;
   var phoneRe = /^((\+\d{1,3}(-|\s)?\(?\d\)?(-|\s)?\d{1,3})|(\(?\d{2,3}\)?))(-|\s)?(\d{3,5})(-|\s)?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
   var phoneDiplomaticFormat = /\[1\]\s*((\(\d{3}\))|(\d{3}))\s*\d{3}-?\d{4}/;
   var bResult = true;
   if (obj.value != '')
   { 
      	if (!phoneRe.test(obj.value))
      	{
      	    //verifying if the string match with the diplomatic format (only for US "[1] (999) 999-99999")
      	    if (!phoneDiplomaticFormat.test(obj.value))
      	        bResult=false;
      	}
      	if (!bResult)
      	{
      	    alert(cadError);
	        SetFocus(obj.id);
	        obj.select();
	    }
	    else
	    {
	        obj.value = ReplacePhoneChars(obj.value);
	    }
   }
   return bResult;
}

function CheckFieldLength(id, maxChars, viewMessage, message)
{
    var obj = document.getElementById(id);
    var len = obj.value.length;

    if (len > maxChars)
    {
        obj.value = obj.value.substring(0, maxChars);
        
        if (viewMessage) alert(message);
    }
}

function IsCoordinate(e)
{
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    
	if (clientBrowser() == 0)
    {
        if (e.shiftKey)
        if (code != 9 && code != 35 && code != 36 && code != 37 && code != 39 && code != 69 && code != 78 && code != 83 && code != 87) 
        return false;

        if (e.ctrlKey)
        if (code == 17 || code == 67 || code == 86)
            return true;
    }
    else
    {
        if ((e.modifiers & Event.SHIFT_MASK) > 0)
        if (code != 9 && code != 35 && code != 36 && code != 37 && code != 39 && code != 69 && code != 78 && code != 83 && code != 87) 
        return false;

        if ((e.modifiers & Event.CONTROL_MASK) > 0)
        if (code == 17 || code == 67 || code == 86)
            return true;    
    
    }
    switch(code)
        {
            case 13: /*"Enter"*/
            return true
            break;
            case 8: /*"Back"*/
            return true
            break;            
            case 9: /*"Tab"*/
            return true
            break;
            case 17: /*"Tab"*/
            return true
            break;
            case 46: /*"Del"*/
            return true
            break;
            case 35: /*"End"*/
            return true
            case 36: /*"Home"*/
            return true
            case 37: /*"Arrow Left"*/
            return true
            break;
            case 38: /*"Arrow Up"*/
            return true
            break;
            case 39: /*"Arrow Right"*/
            return true
            break;
            case 40: /*"Arrow Down"*/
            return true
            break;
            case 110: /*" . "*/
            return true
            break; 
            case 190: /*" . "*/
            return true
            break;            
        }            

    
    var ValidChars = "0123456789 EWNS";
    var IsCoordinateChar=false;

    for (i = 0; i < ValidChars.length; i++) 
        { 
            if (code == ValidChars.charCodeAt(i) || code == (ValidChars.charCodeAt(i) + 48)) 
            {
            IsCoordinateChar = true;
            }
        }
    if (IsCoordinateChar == false)
    {
        if (e.preventDefault) {
            e.preventDefault();
            e.stopPropagation();
        } else {
            e.keyCode = 0;
            e.returnValue = false;
        }
    }                   
    return IsCoordinateChar;
}

function CheckCoordinate(obj, cadError, coordinateType)
{
   if ( nowFieldOnBlur !='' &&  nowFieldOnBlur != obj.id) return;
   nowFieldOnBlur=obj.id;
   
   var coordinateRe = null;
   if (coordinateType == 1)
    coordinateRe = /^-*\d+\.\d{1,5} [EW]$/
   else
    coordinateRe = /^-*\d+\.\d{1,5} [NS]$/;
   
   if (obj.value != '' && !coordinateRe.test(obj.value))
   {
      	alert(cadError);
	    SetFocus(obj.id);
	    obj.select();
	    return false;
   }
   nowFieldOnBlur='';
   return true;
}

function isCharInString(cad, vchar)
{
    for(n=0; n<cad.length; n++)
    {
        if(cad.charAt(n) == String.fromCharCode(vchar))
        {
            return true;
        }
    }
    
    return false;	
}

function isAlphaNumeric(eventObject, eventType)
{
    var validChars = "ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzÁÉÍÓÚÀÈÌÒÌÙÄËÏÖÜÂÊÎÔÛáéíóúàèìòìäëïöüâêîôû" + "-'_." + '" ' + "1234567890";
    var keysNotAllowed = new Object();
    keysNotAllowed.single = new Object();
    //badKeys.single['8'] = 'Backspace outside text fields';
    keysNotAllowed.single['13'] = 'Enter outside text fields';
    //badKeys.single['116'] = 'F5 (Refresh)';
    //badKeys.single['122'] = 'F11 (Full Screen)';
    keysNotAllowed.alt = new Object();
    //badKeys.alt['37'] = 'Alt+Left Cursor';
    //badKeys.alt['39'] = 'Alt+Right Cursor';
    keysNotAllowed.ctrl = new Object();
    //badKeys.ctrl['78'] = 'Ctrl+N';
    //badKeys.ctrl['79'] = 'Ctrl+O';
    keysNotAllowed.ctrl['86'] = 'Ctrl+V';
    keysNotAllowed.shift = new Object();
    keysNotAllowed.shift['45'] = 'shift+Ins';

    return isValidEvent(eventObject, eventType, keysNotAllowed, validChars)
}

function isInteger(eventObject, eventType)
{
    var validChars = "1234567890";
    var keysNotAllowed = new Object();
    keysNotAllowed.single = new Object();
    //badKeys.single['8'] = 'Backspace outside text fields';
    keysNotAllowed.single['13'] = 'Enter outside text fields';
    //badKeys.single['116'] = 'F5 (Refresh)';
    //badKeys.single['122'] = 'F11 (Full Screen)';
    keysNotAllowed.alt = new Object();
    //badKeys.alt['37'] = 'Alt+Left Cursor';
    //badKeys.alt['39'] = 'Alt+Right Cursor';
    keysNotAllowed.ctrl = new Object();
    //badKeys.ctrl['78'] = 'Ctrl+N';
    //badKeys.ctrl['79'] = 'Ctrl+O';
    keysNotAllowed.ctrl['86'] = 'Ctrl+V';
    keysNotAllowed.shift = new Object();
    keysNotAllowed.shift['45'] = 'shift+Ins';

    return isValidEvent(eventObject, eventType, keysNotAllowed, validChars)
}

/*
HTMLEncode - Encode HTML special characters.
Copyright (c) 2006 Thomas Peri, http://www.tumuski.com/

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The Software shall be used for Good, not Evil.

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/**
 * HTML-Encode the supplied input
 * 
 * Parameters:
 *
 * (String)  source    The text to be encoded.
 * 
 * (boolean) display   The output is intended for display.
 *
 *                     If true:
 *                     * Tabs will be expanded to the number of spaces 
 *                       indicated by the 'tabs' argument.
 *                     * Line breaks will be converted to <br />.
 *
 *                     If false:
 *                     * Tabs and linebreaks get turned into &#____;
 *                       entities just like all other control characters.
 *
 * (integer) tabs      The number of spaces to expand tabs to.  (Ignored 
 *                     when the 'display' parameter evaluates to false.)
 *
 * v 0.3 - January 4, 2006
 */
function htmlEncode(source, display, tabs)
{
	function special(source)
	{
		var result = '';
		for (var i = 0; i < source.length; i++)
		{
			var c = source.charAt(i);
			if (c < ' ' || c > '~')
			{
				c = '&#' + c.charCodeAt() + ';';
			}
			result += c;
		}
		return result;
	}
	
	function format(source)
	{
		// Use only integer part of tabs, and default to 4
		tabs = (tabs >= 0) ? Math.floor(tabs) : 4;
		
		// split along line breaks
		var lines = source.split(/\r\n|\r|\n/);
		
		// expand tabs
		for (var i = 0; i < lines.length; i++)
		{
			var line = lines[i];
			var newLine = '';
			for (var p = 0; p < line.length; p++)
			{
				var c = line.charAt(p);
				if (c === '\t')
				{
					var spaces = tabs - (newLine.length % tabs);
					for (var s = 0; s < spaces; s++)
					{
						newLine += ' ';
					}
				}
				else
				{
					newLine += c;
				}
			}
			// If a line starts or ends with a space, it evaporates in html
			// unless it's an nbsp.
			newLine = newLine.replace(/(^ )|( $)/g, '&nbsp;');
			lines[i] = newLine;
		}
		
		// re-join lines
		var result = lines.join('<br />');
		
		// break up contiguous blocks of spaces with non-breaking spaces
		result = result.replace(/  /g, ' &nbsp;');
		
		// tada!
		return result;
	}

	var result = source;
	
	// ampersands (&)
	result = result.replace(/\&/g,'&amp;');

	// less-thans (<)
	result = result.replace(/\</g,'&lt;');

	// greater-thans (>)
	result = result.replace(/\>/g,'&gt;');
	
	if (display)
	{
		// format for display
		result = format(result);
	}
	else
	{
		// Replace quotes if it isn't for display,
		// since it's probably going in an html attribute.
		result = result.replace(new RegExp('"','g'), '&quot;');
	}

	// special characters
	//result = special(result);
	
	// tada!
	return result;
}

function htmlDecode(s)
{
	var out = "";
	if (s==null) return;

	var l = s.length;
	for (var i=0; i<l; i++)
	{
		var ch = s.charAt(i);
		
		if (ch == '&') 
		{
			var semicolonIndex = s.indexOf(';', i+1);
			
            if (semicolonIndex > 0) 
            {
				var entity = s.substring(i + 1, semicolonIndex);
				if (entity.length > 1 && entity.charAt(0) == '#') 
				{
					if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X')
						ch = String.fromCharCode(eval('0'+entity.substring(1)));
					else
						ch = String.fromCharCode(eval(entity.substring(1)));
				}
		        else 
			    {
					switch (entity)
					{
						case 'quot': ch = String.fromCharCode(0x0022); break;
						case 'amp': ch = String.fromCharCode(0x0026); break;
						case 'lt': ch = String.fromCharCode(0x003c); break;
						case 'gt': ch = String.fromCharCode(0x003e); break;
						case 'nbsp': ch = String.fromCharCode(0x00a0); break;
						case 'iexcl': ch = String.fromCharCode(0x00a1); break;
						case 'cent': ch = String.fromCharCode(0x00a2); break;
						case 'pound': ch = String.fromCharCode(0x00a3); break;
						case 'curren': ch = String.fromCharCode(0x00a4); break;
						case 'yen': ch = String.fromCharCode(0x00a5); break;
						case 'brvbar': ch = String.fromCharCode(0x00a6); break;
						case 'sect': ch = String.fromCharCode(0x00a7); break;
						case 'uml': ch = String.fromCharCode(0x00a8); break;
						case 'copy': ch = String.fromCharCode(0x00a9); break;
						case 'ordf': ch = String.fromCharCode(0x00aa); break;
						case 'laquo': ch = String.fromCharCode(0x00ab); break;
						case 'not': ch = String.fromCharCode(0x00ac); break;
						case 'shy': ch = String.fromCharCode(0x00ad); break;
						case 'reg': ch = String.fromCharCode(0x00ae); break;
						case 'macr': ch = String.fromCharCode(0x00af); break;
						case 'deg': ch = String.fromCharCode(0x00b0); break;
						case 'plusmn': ch = String.fromCharCode(0x00b1); break;
						case 'sup2': ch = String.fromCharCode(0x00b2); break;
						case 'sup3': ch = String.fromCharCode(0x00b3); break;
						case 'acute': ch = String.fromCharCode(0x00b4); break;
						case 'micro': ch = String.fromCharCode(0x00b5); break;
						case 'para': ch = String.fromCharCode(0x00b6); break;
						case 'middot': ch = String.fromCharCode(0x00b7); break;
						case 'cedil': ch = String.fromCharCode(0x00b8); break;
						case 'sup1': ch = String.fromCharCode(0x00b9); break;
						case 'ordm': ch = String.fromCharCode(0x00ba); break;
						case 'raquo': ch = String.fromCharCode(0x00bb); break;
						case 'frac14': ch = String.fromCharCode(0x00bc); break;
						case 'frac12': ch = String.fromCharCode(0x00bd); break;
						case 'frac34': ch = String.fromCharCode(0x00be); break;
						case 'iquest': ch = String.fromCharCode(0x00bf); break;
						case 'Agrave': ch = String.fromCharCode(0x00c0); break;
						case 'Aacute': ch = String.fromCharCode(0x00c1); break;
						case 'Acirc': ch = String.fromCharCode(0x00c2); break;
						case 'Atilde': ch = String.fromCharCode(0x00c3); break;
						case 'Auml': ch = String.fromCharCode(0x00c4); break;
						case 'Aring': ch = String.fromCharCode(0x00c5); break;
						case 'AElig': ch = String.fromCharCode(0x00c6); break;
						case 'Ccedil': ch = String.fromCharCode(0x00c7); break;
						case 'Egrave': ch = String.fromCharCode(0x00c8); break;
						case 'Eacute': ch = String.fromCharCode(0x00c9); break;
						case 'Ecirc': ch = String.fromCharCode(0x00ca); break;
						case 'Euml': ch = String.fromCharCode(0x00cb); break;
						case 'Igrave': ch = String.fromCharCode(0x00cc); break;
						case 'Iacute': ch = String.fromCharCode(0x00cd); break;
						case 'Icirc': ch = String.fromCharCode(0x00ce); break;
						case 'Iuml': ch = String.fromCharCode(0x00cf); break;
						case 'ETH': ch = String.fromCharCode(0x00d0); break;
						case 'Ntilde': ch = String.fromCharCode(0x00d1); break;
						case 'Ograve': ch = String.fromCharCode(0x00d2); break;
						case 'Oacute': ch = String.fromCharCode(0x00d3); break;
						case 'Ocirc': ch = String.fromCharCode(0x00d4); break;
						case 'Otilde': ch = String.fromCharCode(0x00d5); break;
						case 'Ouml': ch = String.fromCharCode(0x00d6); break;
						case 'times': ch = String.fromCharCode(0x00d7); break;
						case 'Oslash': ch = String.fromCharCode(0x00d8); break;
						case 'Ugrave': ch = String.fromCharCode(0x00d9); break;
						case 'Uacute': ch = String.fromCharCode(0x00da); break;
						case 'Ucirc': ch = String.fromCharCode(0x00db); break;
						case 'Uuml': ch = String.fromCharCode(0x00dc); break;
						case 'Yacute': ch = String.fromCharCode(0x00dd); break;
						case 'THORN': ch = String.fromCharCode(0x00de); break;
						case 'szlig': ch = String.fromCharCode(0x00df); break;
						case 'agrave': ch = String.fromCharCode(0x00e0); break;
						case 'aacute': ch = String.fromCharCode(0x00e1); break;
						case 'acirc': ch = String.fromCharCode(0x00e2); break;
						case 'atilde': ch = String.fromCharCode(0x00e3); break;
						case 'auml': ch = String.fromCharCode(0x00e4); break;
						case 'aring': ch = String.fromCharCode(0x00e5); break;
						case 'aelig': ch = String.fromCharCode(0x00e6); break;
						case 'ccedil': ch = String.fromCharCode(0x00e7); break;
						case 'egrave': ch = String.fromCharCode(0x00e8); break;
						case 'eacute': ch = String.fromCharCode(0x00e9); break;
						case 'ecirc': ch = String.fromCharCode(0x00ea); break;
						case 'euml': ch = String.fromCharCode(0x00eb); break;
						case 'igrave': ch = String.fromCharCode(0x00ec); break;
						case 'iacute': ch = String.fromCharCode(0x00ed); break;
						case 'icirc': ch = String.fromCharCode(0x00ee); break;
						case 'iuml': ch = String.fromCharCode(0x00ef); break;
						case 'eth': ch = String.fromCharCode(0x00f0); break;
						case 'ntilde': ch = String.fromCharCode(0x00f1); break;
						case 'ograve': ch = String.fromCharCode(0x00f2); break;
						case 'oacute': ch = String.fromCharCode(0x00f3); break;
						case 'ocirc': ch = String.fromCharCode(0x00f4); break;
						case 'otilde': ch = String.fromCharCode(0x00f5); break;
						case 'ouml': ch = String.fromCharCode(0x00f6); break;
						case 'divide': ch = String.fromCharCode(0x00f7); break;
						case 'oslash': ch = String.fromCharCode(0x00f8); break;
						case 'ugrave': ch = String.fromCharCode(0x00f9); break;
						case 'uacute': ch = String.fromCharCode(0x00fa); break;
						case 'ucirc': ch = String.fromCharCode(0x00fb); break;
						case 'uuml': ch = String.fromCharCode(0x00fc); break;
						case 'yacute': ch = String.fromCharCode(0x00fd); break;
						case 'thorn': ch = String.fromCharCode(0x00fe); break;
						case 'yuml': ch = String.fromCharCode(0x00ff); break;
						case 'OElig': ch = String.fromCharCode(0x0152); break;
						case 'oelig': ch = String.fromCharCode(0x0153); break;
						case 'Scaron': ch = String.fromCharCode(0x0160); break;
						case 'scaron': ch = String.fromCharCode(0x0161); break;
						case 'Yuml': ch = String.fromCharCode(0x0178); break;
						case 'fnof': ch = String.fromCharCode(0x0192); break;
						case 'circ': ch = String.fromCharCode(0x02c6); break;
						case 'tilde': ch = String.fromCharCode(0x02dc); break;
						case 'Alpha': ch = String.fromCharCode(0x0391); break;
						case 'Beta': ch = String.fromCharCode(0x0392); break;
						case 'Gamma': ch = String.fromCharCode(0x0393); break;
						case 'Delta': ch = String.fromCharCode(0x0394); break;
						case 'Epsilon': ch = String.fromCharCode(0x0395); break;
						case 'Zeta': ch = String.fromCharCode(0x0396); break;
						case 'Eta': ch = String.fromCharCode(0x0397); break;
						case 'Theta': ch = String.fromCharCode(0x0398); break;
						case 'Iota': ch = String.fromCharCode(0x0399); break;
						case 'Kappa': ch = String.fromCharCode(0x039a); break;
						case 'Lambda': ch = String.fromCharCode(0x039b); break;
						case 'Mu': ch = String.fromCharCode(0x039c); break;
						case 'Nu': ch = String.fromCharCode(0x039d); break;
						case 'Xi': ch = String.fromCharCode(0x039e); break;
						case 'Omicron': ch = String.fromCharCode(0x039f); break;
						case 'Pi': ch = String.fromCharCode(0x03a0); break;
						case 'Rho': ch = String.fromCharCode(0x03a1); break;
						case 'Sigma': ch = String.fromCharCode(0x03a3); break;
						case 'Tau': ch = String.fromCharCode(0x03a4); break;
						case 'Upsilon': ch = String.fromCharCode(0x03a5); break;
						case 'Phi': ch = String.fromCharCode(0x03a6); break;
						case 'Chi': ch = String.fromCharCode(0x03a7); break;
						case 'Psi': ch = String.fromCharCode(0x03a8); break;
						case 'Omega': ch = String.fromCharCode(0x03a9); break;
						case 'alpha': ch = String.fromCharCode(0x03b1); break;
						case 'beta': ch = String.fromCharCode(0x03b2); break;
						case 'gamma': ch = String.fromCharCode(0x03b3); break;
						case 'delta': ch = String.fromCharCode(0x03b4); break;
						case 'epsilon': ch = String.fromCharCode(0x03b5); break;
						case 'zeta': ch = String.fromCharCode(0x03b6); break;
						case 'eta': ch = String.fromCharCode(0x03b7); break;
						case 'theta': ch = String.fromCharCode(0x03b8); break;
						case 'iota': ch = String.fromCharCode(0x03b9); break;
						case 'kappa': ch = String.fromCharCode(0x03ba); break;
						case 'lambda': ch = String.fromCharCode(0x03bb); break;
						case 'mu': ch = String.fromCharCode(0x03bc); break;
						case 'nu': ch = String.fromCharCode(0x03bd); break;
						case 'xi': ch = String.fromCharCode(0x03be); break;
						case 'omicron': ch = String.fromCharCode(0x03bf); break;
						case 'pi': ch = String.fromCharCode(0x03c0); break;
						case 'rho': ch = String.fromCharCode(0x03c1); break;
						case 'sigmaf': ch = String.fromCharCode(0x03c2); break;
						case 'sigma': ch = String.fromCharCode(0x03c3); break;
						case 'tau': ch = String.fromCharCode(0x03c4); break;
						case 'upsilon': ch = String.fromCharCode(0x03c5); break;
						case 'phi': ch = String.fromCharCode(0x03c6); break;
						case 'chi': ch = String.fromCharCode(0x03c7); break;
						case 'psi': ch = String.fromCharCode(0x03c8); break;
						case 'omega': ch = String.fromCharCode(0x03c9); break;
						case 'thetasym': ch = String.fromCharCode(0x03d1); break;
						case 'upsih': ch = String.fromCharCode(0x03d2); break;
						case 'piv': ch = String.fromCharCode(0x03d6); break;
						case 'ensp': ch = String.fromCharCode(0x2002); break;
						case 'emsp': ch = String.fromCharCode(0x2003); break;
						case 'thinsp': ch = String.fromCharCode(0x2009); break;
						case 'zwnj': ch = String.fromCharCode(0x200c); break;
						case 'zwj': ch = String.fromCharCode(0x200d); break;
						case 'lrm': ch = String.fromCharCode(0x200e); break;
						case 'rlm': ch = String.fromCharCode(0x200f); break;
						case 'ndash': ch = String.fromCharCode(0x2013); break;
						case 'mdash': ch = String.fromCharCode(0x2014); break;
						case 'lsquo': ch = String.fromCharCode(0x2018); break;
						case 'rsquo': ch = String.fromCharCode(0x2019); break;
						case 'sbquo': ch = String.fromCharCode(0x201a); break;
						case 'ldquo': ch = String.fromCharCode(0x201c); break;
						case 'rdquo': ch = String.fromCharCode(0x201d); break;
						case 'bdquo': ch = String.fromCharCode(0x201e); break;
						case 'dagger': ch = String.fromCharCode(0x2020); break;
						case 'Dagger': ch = String.fromCharCode(0x2021); break;
						case 'bull': ch = String.fromCharCode(0x2022); break;
						case 'hellip': ch = String.fromCharCode(0x2026); break;
						case 'permil': ch = String.fromCharCode(0x2030); break;
						case 'prime': ch = String.fromCharCode(0x2032); break;
						case 'Prime': ch = String.fromCharCode(0x2033); break;
						case 'lsaquo': ch = String.fromCharCode(0x2039); break;
						case 'rsaquo': ch = String.fromCharCode(0x203a); break;
						case 'oline': ch = String.fromCharCode(0x203e); break;
						case 'frasl': ch = String.fromCharCode(0x2044); break;
						case 'euro': ch = String.fromCharCode(0x20ac); break;
						case 'image': ch = String.fromCharCode(0x2111); break;
						case 'weierp': ch = String.fromCharCode(0x2118); break;
						case 'real': ch = String.fromCharCode(0x211c); break;
						case 'trade': ch = String.fromCharCode(0x2122); break;
						case 'alefsym': ch = String.fromCharCode(0x2135); break;
						case 'larr': ch = String.fromCharCode(0x2190); break;
						case 'uarr': ch = String.fromCharCode(0x2191); break;
						case 'rarr': ch = String.fromCharCode(0x2192); break;
						case 'darr': ch = String.fromCharCode(0x2193); break;
						case 'harr': ch = String.fromCharCode(0x2194); break;
						case 'crarr': ch = String.fromCharCode(0x21b5); break;
						case 'lArr': ch = String.fromCharCode(0x21d0); break;
						case 'uArr': ch = String.fromCharCode(0x21d1); break;
						case 'rArr': ch = String.fromCharCode(0x21d2); break;
						case 'dArr': ch = String.fromCharCode(0x21d3); break;
						case 'hArr': ch = String.fromCharCode(0x21d4); break;
						case 'forall': ch = String.fromCharCode(0x2200); break;
						case 'part': ch = String.fromCharCode(0x2202); break;
						case 'exist': ch = String.fromCharCode(0x2203); break;
						case 'empty': ch = String.fromCharCode(0x2205); break;
						case 'nabla': ch = String.fromCharCode(0x2207); break;
						case 'isin': ch = String.fromCharCode(0x2208); break;
						case 'notin': ch = String.fromCharCode(0x2209); break;
						case 'ni': ch = String.fromCharCode(0x220b); break;
						case 'prod': ch = String.fromCharCode(0x220f); break;
						case 'sum': ch = String.fromCharCode(0x2211); break;
						case 'minus': ch = String.fromCharCode(0x2212); break;
						case 'lowast': ch = String.fromCharCode(0x2217); break;
						case 'radic': ch = String.fromCharCode(0x221a); break;
						case 'prop': ch = String.fromCharCode(0x221d); break;
						case 'infin': ch = String.fromCharCode(0x221e); break;
						case 'ang': ch = String.fromCharCode(0x2220); break;
						case 'and': ch = String.fromCharCode(0x2227); break;
						case 'or': ch = String.fromCharCode(0x2228); break;
						case 'cap': ch = String.fromCharCode(0x2229); break;
						case 'cup': ch = String.fromCharCode(0x222a); break;
						case 'int': ch = String.fromCharCode(0x222b); break;
						case 'there4': ch = String.fromCharCode(0x2234); break;
						case 'sim': ch = String.fromCharCode(0x223c); break;
						case 'cong': ch = String.fromCharCode(0x2245); break;
						case 'asymp': ch = String.fromCharCode(0x2248); break;
						case 'ne': ch = String.fromCharCode(0x2260); break;
						case 'equiv': ch = String.fromCharCode(0x2261); break;
						case 'le': ch = String.fromCharCode(0x2264); break;
						case 'ge': ch = String.fromCharCode(0x2265); break;
						case 'sub': ch = String.fromCharCode(0x2282); break;
						case 'sup': ch = String.fromCharCode(0x2283); break;
						case 'nsub': ch = String.fromCharCode(0x2284); break;
						case 'sube': ch = String.fromCharCode(0x2286); break;
						case 'supe': ch = String.fromCharCode(0x2287); break;
						case 'oplus': ch = String.fromCharCode(0x2295); break;
						case 'otimes': ch = String.fromCharCode(0x2297); break;
						case 'perp': ch = String.fromCharCode(0x22a5); break;
						case 'sdot': ch = String.fromCharCode(0x22c5); break;
						case 'lceil': ch = String.fromCharCode(0x2308); break;
						case 'rceil': ch = String.fromCharCode(0x2309); break;
						case 'lfloor': ch = String.fromCharCode(0x230a); break;
						case 'rfloor': ch = String.fromCharCode(0x230b); break;
						case 'lang': ch = String.fromCharCode(0x2329); break;
						case 'rang': ch = String.fromCharCode(0x232a); break;
						case 'loz': ch = String.fromCharCode(0x25ca); break;
						case 'spades': ch = String.fromCharCode(0x2660); break;
						case 'clubs': ch = String.fromCharCode(0x2663); break;
						case 'hearts': ch = String.fromCharCode(0x2665); break;
						case 'diams': ch = String.fromCharCode(0x2666); break;
						default: ch = ''; break;
					}
				}
				i = semicolonIndex; 
			}
		}
		
		out += ch;
	}

	return out;	
}

function eventTrigger (e) {
    if (! e)
        e = event;
    return e.target || e.srcElement;
}

function replaceChars(strInit, strSearch, strReplace)
{
    temp = "" + strInit;

    while (temp.indexOf(strSearch)>-1)
    {
        pos= temp.indexOf(strSearch);
        temp = "" + (temp.substring(0, pos) + strReplace + 
        temp.substring((pos + strSearch.length), temp.length));
    }
    return temp;
}

function GetControlValue(container, controlId)
{
   var result = 'undefined';
   
   var hidControl = container.getElementById(controlId);
   result = hidControl.value;
   if (result == 'undefined')
      result = hidControl.defaultValue;
      
   return result;
}

function disableCtxMenu(element)
{
    element.oncontextmenu = new Function('return false');
}

var treetable_rowstate = new Array();
var treetable_callbacks = new Array();

function treetable_hideRow(rowId) {
  el = document.getElementById(rowId);
  el.style.display = "none";
}

function treetable_showRow(rowId) {
  el = document.getElementById(rowId);
  el.style.display = "";
}

function treetable_hasChildren(rowId) {
  res = document.getElementById(rowId + '_0');
  return (res != null);
}

function treetable_getRowChildren(rowId) {
  el = document.getElementById(rowId);
  var arr = new Array();
  i = 0;
  while (true) {
    childRowId = rowId + '_' + i;
    childEl = document.getElementById(childRowId);
    if (childEl) {
      arr[i] = childRowId;
    } else {
      break;
    }
    i++;
  }
  return (arr);
}

function treetable_toggleRow(rowId, state, force)
{
    var rowChildren;
    var i;
    // open or close all children rows depend on current state
    force = (force == null) ? 1 : force; 
    if (state == null)
        row_state = ((treetable_rowstate[rowId]) ? (treetable_rowstate[rowId]) : 1) * -1;
    else
        row_state = state;
    rowChildren = treetable_getRowChildren(rowId);
    if (rowChildren.length == 0) 
        return (false);
    for (i = 0; i < rowChildren.length; i++)
    {
        if (row_state == -1)
        {
            treetable_hideRow(rowChildren[i]);
            treetable_toggleRow(rowChildren[i], row_state, -1);
        }
        else
        {
            if (force == 1 || treetable_rowstate[rowId] != -1)
            {
                treetable_showRow(rowChildren[i]);
                treetable_toggleRow(rowChildren[i], row_state, -1);
            }
        }
    }
    if (force == 1)
    {
        treetable_rowstate[rowId] = row_state;
        treetable_fireEventRowStateChanged(rowId, row_state);
    }
    return (false);
}

function treetable_fireEventRowStateChanged(rowId, state) {
  if (treetable_callbacks['eventRowStateChanged']) {
    callback = treetable_callbacks['eventRowStateChanged'] + "('" + rowId + "', " + state + ");";
    eval(callback);
  }
}

function treetable_collapseAll(tableId) {
    table = document.getElementById(tableId);
    if (table)
    {
        rowChildren = table.getElementsByTagName('tr');
        for (i = 0; i < rowChildren.length; i++) {
            var row = rowChildren[i];
            if (index = row.id.indexOf('_')) {
                // do not hide root elements
                posFin = row.id.lastIndexOf('_') ;
                isParent = (row.id.substring(posFin - 4,  posFin ) == 'SQst');
                if ( isParent ) 
                { 
                    if (document.getElementById('img' + row.name) != null)
                    {
                        var image = document.getElementById('img' + row.name);
                        image.setAttribute('src',document.getElementById('img_plus').src);
                        image.setAttribute('alt',document.getElementById('img_plus').alt);
                    }
                }
                if(index != row.id.lastIndexOf('_') && 
                !(treetable_hasChildren(row.id)) && !(isParent) ) {
                    row.style.display = 'none';  
                }
                if (treetable_hasChildren(row.id)) {
                    treetable_rowstate[row.id] = -1; 
                    treetable_fireEventRowStateChanged(row.id, -1); 
                }
            }
        }
    }
    return (false);
}    

function treetable_expandAll(tableId)
{
    table = document.getElementById(tableId);
    rowChildren = table.getElementsByTagName('tr');
    for (i = 0; i < rowChildren.length; i++)
    {
        var row = rowChildren[i];
        if (index = row.id.indexOf('_'))
        {
            posFin = row.id.lastIndexOf('_') ;
            isParent = (row.id.substring(posFin - 4,  posFin ) == 'SQst');
            if ( isParent ) 
            {
                if (document.getElementById('img' + row.name) != null)
                {
                    var image = document.getElementById('img' + row.name);
                    image.setAttribute('src',document.getElementById('img_minus').src);
                    image.setAttribute('alt',document.getElementById('img_minus').alt);
                }
            }
            row.style.display = '';
            if (treetable_hasChildren(row.id)) {
            treetable_rowstate[row.id] = 1;
            treetable_fireEventRowStateChanged(row.id, 1);
            }
        }
    }
    return (false);
}

function ValidColumnName(objectId, columnName)
{
    if (!columnName.match(/^([a-zA-Z_])([a-zA-Z_0-9]+)$/))
    {
        var object = document.getElementById(objectId);
        object.value = '';
    }	
}
function validateDigitsBeforeDecimals(controlId, validationMessage, maxNumberOfDigits)
{
    //This function valid the number of digits before the point of decimal
    //This function must receive a valid decimal number without miles separators, only with decimal point or comma. It can be executed after the decimal format validation
    var result = true;
    var ValidChars = "-0123456789";
    var counter = 0;
    var number = document.getElementById(controlId).value;
    var numberLength = number.length;
    var digitsCounter = 0;
    for(counter=0; counter<numberLength; counter++)
    {
        var oneDigit = number.substr(counter,1);
        if (ValidChars.indexOf(oneDigit)>-1)
        {
            digitsCounter++;
        }
        else
            break;
    }
    if (digitsCounter > maxNumberOfDigits)
        result = false;
    if (!result)
        alert(validationMessage);
    return result;
}

function isIntegerForID(eventObject, eventType)
{
    var validChars = "0123456789 ,";
    var keysNotAllowed = new Object();
    keysNotAllowed.single = new Object();
    keysNotAllowed.single['13'] = 'Enter outside text fields';
    keysNotAllowed.alt = new Object();
    keysNotAllowed.ctrl = new Object();
    keysNotAllowed.ctrl['86'] = 'Ctrl+V';
    keysNotAllowed.shift = new Object();
    keysNotAllowed.shift['45'] = 'shift+Ins';

    return isValidEvent(eventObject, eventType, keysNotAllowed, validChars)
}

///////////////////////////////////////////
//Translation functions
///////////////////////////////////////////
function showEditVoicePage(page, hidControlId, id, textControlId, title)
{
    var hidAudioValue = GetControlValue(document, hidControlId);
    
    popupWindow_showWindow('popupWnd', FormatPopupPageURL(page + hidAudioValue + '&langId=' + id + '&textControlId=' + textControlId), 530, 296, title);
}

function showVoicePage(page, hidControlId)
{
    var hidAudioValue = GetControlValue(document, hidControlId);
    
    popupWindow_showWindow('popupWnd', FormatPopupPageURL(page + hidAudioValue), 365, 165, '');
}

function setTranslationValues(translationId, hidTranslationId, hasChangedId)
{
    if(document.getElementById(translationId).value != document.getElementById(hidTranslationId).value)
    {
        document.getElementById(hasChangedId).value = 'true';
    }

    document.getElementById(hidTranslationId).value = document.getElementById(translationId).value;
}

function setLinkToAudioRecording(audioFileName, txtControlId, lnkAudioControlId, imgAudioControlId, hidAudioControlId)
{
    var lnkAudio = document.getElementById(lnkAudioControlId);
    var imgAudio = document.getElementById(imgAudioControlId);
    var hidAudio = document.getElementById(hidAudioControlId);

    if (imgAudio != null)
    {
        if (audioFileName == '')
        {
            imgAudio.style.display = 'none';
        }    
        else
        {
            imgAudio.style.display = '';    
        }
    }

    hidAudio.value = audioFileName;
    
    return false;
}

function TurnOnOffPreview(numberOfLines, isChecked, id_txtParentText, id_txtText, isSentFromPopup)
{
    var currentWnd = isSentFromPopup == true ? window.parent : window;
    var ctrlname = id_txtParentText + 'Preview';
    
    if (currentWnd.document.getElementById(ctrlname) == null)
    {
        currentWnd = window;
    }
    
    var ctrl_txtParentTextp = currentWnd.document.getElementById(ctrlname);
    var ctrl_txtParentText = currentWnd.document.getElementById(id_txtParentText);
    var pdivline = (numberOfLines * 20);

    if (isChecked.toString().toLowerCase() == "true")
    {
        ctrl_txtParentTextp.style.display = 'block';
        ctrl_txtParentTextp.style.backgroundColor = 'threedlightshadow';
        ctrl_txtParentTextp.style.borderColor = 'inactivecaption';
        ctrl_txtParentTextp.style.borderWidth = '1px';
        ctrl_txtParentTextp.style.borderStyle = 'solid';        
        
        ctrl_txtParentTextp.innerHTML = document.getElementById(id_txtText).value;
        ctrl_txtParentTextp.style.height = '' + pdivline + 'px';
        
        if (!isSentFromPopup)
        {
            ctrl_txtParentTextp.onclick = function()
                                          {
                                              ctrl_txtParentTextp.style.display = 'none';
                                              ctrl_txtParentText.style.display = '';
                                              SetFocus(ctrl_txtParentText.id);
                                          };
        }
        
        ctrl_txtParentText.style.display = 'none';
    }
    else
    {
        ctrl_txtParentTextp.style.display = 'none';
        ctrl_txtParentTextp.innerHTML = '';        
        
        ctrl_txtParentText.style.display = 'block';
    }

    ctrl_txtParentText.value = document.getElementById(id_txtText).value;
    
    return false;
}

function SendChunksToServerInfo()
{
    this.respGuid = '';
    this.colTag = '';
    this.translationKey = '';
    this.dataColumnKey = '';
    this.languages = '';
    this.translations = '';
    this.audioFiles = '';
    this.allowHtml = '';
    this.id_defaultText = '';
    this.id_CheckAllowHTML = '';
    this.id_AllowHTML = '';
    this.id_Languages = '';
    this.id_Translations = '';
    this.id_AudioFiles = '';
    this.id_txtParentText = '';
    this.id_LnkAudio = '';
    this.id_ImgAudio = '';
    this.numberOfLines = '';
}

function SendChunksToServer(paramInfo, isSentFromPopup)
{
    var chunkSize = 1024;
    var numOfChunks = 0;
    var numOfChunk = 0;
    var chkObj = document.getElementById(paramInfo.id_CheckAllowHTML);

    if (paramInfo.allowHtml.toLowerCase() == 'true')
    {
        if (chkObj.checked)
        {
            paramInfo.translations = htmlEncode(paramInfo.translations);
        }
    }

    numOfChunks = Math.ceil(paramInfo.translations.length / chunkSize);
    numOfChunks = (numOfChunks == 0 ? 1 : numOfChunks);

    for(i = 1; i <= numOfChunks; i++)
    {
        numOfChunk++;
        var o = document.getElementById(paramInfo.id_CheckAllowHTML);
        //Slicing the translation details
        var chunkedTranslation = paramInfo.translations.slice(chunkSize * (numOfChunk - 1), chunkSize * numOfChunk);
        var postData = new Array();
                
        postData.push('action=1');
        postData.push('respGuid=' + paramInfo.respGuid);
        postData.push('colTag=' + paramInfo.colTag);
        postData.push('translationKey=' + paramInfo.translationKey);
        postData.push('languages=' + paramInfo.languages);
        postData.push('chunkedTranslation=' + chunkedTranslation);
        postData.push('audioFiles=' + paramInfo.audioFiles);
        postData.push('isPlainText=' + (paramInfo.allowHtml.toLowerCase() == 'true' ? !o.checked : true));
        postData.push('numOfChunks=' + numOfChunks);
        postData.push('numOfChunk=' + numOfChunk);        
        postData.push('controlClientId=' + paramInfo.id_txtParentText);
        
        CallServerWebMethod('TranslationPopupWebMethods.aspx', isSentFromPopup == true ? false : true, SaveTranslationDetailCallBack, postData);
    }

    function SaveTranslationDetailCallBack(result)
    {
        if (result == 'True')
        {
            var currentWnd = isSentFromPopup == true ? window.parent : window;
            
            var ctrl_AllowHTML = currentWnd.document.getElementById(paramInfo.id_AllowHTML);
            ctrl_AllowHTML.value = document.getElementById(paramInfo.id_CheckAllowHTML).checked;

            var ctrl_Languages = currentWnd.document.getElementById(paramInfo.id_Languages);
            ctrl_Languages.value = paramInfo.languages;
        
            var ctrl_Translations = currentWnd.document.getElementById(paramInfo.id_Translations);
            ctrl_Translations.value = paramInfo.translations;
        
            var ctrl_AudioFiles = currentWnd.document.getElementById(paramInfo.id_AudioFiles);
            ctrl_AudioFiles.value = paramInfo.audioFiles;

            var defaultText = document.getElementById(paramInfo.id_defaultText).value;
            
            try
            {
                TurnOnOffPreview(paramInfo.numberOfLines, ctrl_AllowHTML.value, paramInfo.id_txtParentText, paramInfo.id_defaultText, isSentFromPopup);
            }
            catch(err)
            {
            //Handle errors here
            }
                    
            if (!isSentFromPopup)
            {    
                setLinkToAudioRecording(paramInfo.audioFiles, paramInfo.id_txtParentText, paramInfo.id_LnkAudio, paramInfo.id_ImgAudio, paramInfo.id_AudioFiles);
            }

            currentWnd.closePopup();
            
            currentWnd.CallServerRules(paramInfo.dataColumnKey, paramInfo.translationKey, paramInfo.respGuid, paramInfo.id_txtParentText, defaultText);
        }
    }
}
///////////////////////////////////////////
//End of Translation functions
///////////////////////////////////////////

//Firefox compatibility functions ------------------------------------
if(window.Event)
{
    Event.prototype.__defineSetter__("returnValue",function(b){
        if(!b)this.preventDefault();
        return b;
    });
    Event.prototype.__defineSetter__("cancelBubble",function(b){
        if(b)this.stopPropagation();
        return b;
    });
    Event.prototype.__defineGetter__("srcElement",function(){
        var node=this.target;
        while(node.nodeType!=1)node=node.parentNode;
        return node;
    });
    Event.prototype.__defineGetter__("fromElement",function(){
        var node;
        if(this.type=="mouseover")
        node=this.relatedTarget;
        else if(this.type=="mouseout")
        node=this.target;
        if(!node)return;
        while(node.nodeType!=1)node=node.parentNode;
        return node;
    });
    Event.prototype.__defineGetter__("toElement",function(){
        var node;
        if(this.type=="mouseout")
        node=this.relatedTarget;
        else if(this.type=="mouseover")
        node=this.target;
        if(!node)return;
        while(node.nodeType!=1)node=node.parentNode;
        return node;
    });
    Event.prototype.__defineGetter__("offsetX",function(){
        return this.layerX;
        });
    Event.prototype.__defineGetter__("offsetY",function(){
        return this.layerY;
    });
}


if(window.Node){
    Node.prototype.replaceNode=function(Node){
        this.parentNode.replaceChild(Node,this);
    }
    Node.prototype.removeNode=function(removeChildren){
        if(removeChildren)
            return this.parentNode.removeChild(this);
        else{
            var range=document.createRange();
            range.selectNodeContents(this);
            return this.parentNode.replaceChild(range.extractContents(),this);
        }
    }
    Node.prototype.swapNode=function(Node){
        var nextSibling=this.nextSibling;
        var parentNode=this.parentNode;
        node.parentNode.replaceChild(this,Node);
        parentNode.insertBefore(node,nextSibling);
    }
}

if(window.HTMLElement){
    HTMLElement.prototype.__defineGetter__("all",function(){
        var a=this.getElementsByTagName("*");
        var node=this;
        a.tags=function(sTagName){
        return node.getElementsByTagName(sTagName);
        }
        return a;
    });
    HTMLElement.prototype.__defineGetter__("parentElement",function(){
        if(this.parentNode==this.ownerDocument)return null;
        return this.parentNode;
    });
//    HTMLElement.prototype.__defineGetter__("children",function(){
//        var tmp=[];
//        var j=0;
//        var n;
//        for(var i=0;i n=this.childNodes[i];
//        if(n.nodeType==1){
//        tmp[j++]=n;
//        if(n.name){
//        if(!tmp[n.name])
//        tmp[n.name]=[];
//        tmp[n.name][tmp[n.name].length]=n;
//        }
//        if(n.id)
//        tmp[n.id]=n;
//        }
//        }
//        return tmp;
//    });
    
        //added  --
        HTMLElement.prototype.__defineGetter__("children",function () { return(this.childNodes); });
        HTMLElement.prototype.__defineSetter__("children",function (child) { this.childNodes = child; });
        //---------
        
    HTMLElement.prototype.__defineGetter__("currentStyle", function(){
        return this.ownerDocument.defaultView.getComputedStyle(this,null);
    });
    HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df=r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df,this);
        return sHTML;
    });
//    HTMLElement.prototype.__defineGetter__("outerHTML",function(){
//        var attr;
//        var attrs=this.attributes;
//        var str="<"+this.tagName;
//        for(var i=0;i attr=attrs[i];
//        if(attr.specified)
//        str+=" "+attr.name+'="'+attr.value+'"';
//        }
//        if(!this.canHaveChildren)
//            return str+">";
//        return str+">"+this.innerHTML+"";
//        });
    HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){
    switch(this.tagName.toLowerCase()){
    case "area":
    case "base":
    case "basefont":
    case "col":
    case "frame":
    case "hr":
    case "img":
    case "br":
    case "input":
    case "isindex":
    case "link":
    case "meta":
    case "param":
    return false;
    }
    return true;
    });

    HTMLElement.prototype.__defineSetter__("innerText",function(sText){
    var parsedText=document.createTextNode(sText);
    this.innerHTML=parsedText;
    return parsedText;
    });
    HTMLElement.prototype.__defineGetter__("innerText",function(){
    var r=this.ownerDocument.createRange();
    r.selectNodeContents(this);
    return r.toString();
    });
    HTMLElement.prototype.__defineSetter__("outerText",function(sText){
    var parsedText=document.createTextNode(sText);
    this.outerHTML=parsedText;
    return parsedText;
    });
    HTMLElement.prototype.__defineGetter__("outerText",function(){
        var r=this.ownerDocument.createRange();
        r.selectNodeContents(this);
        return r.toString();
    });
    HTMLElement.prototype.attachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        fHandler._ieEmuEventHandler=function(e){
        window.event=e;
        return fHandler();
        }
        this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
    }
    HTMLElement.prototype.detachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        if(typeof(fHandler._ieEmuEventHandler)=="function")
        this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        else
        this.removeEventListener(shortTypeName,fHandler,true);
    }
    HTMLElement.prototype.contains=function(Node){// 是否包含某节点
        do if(Node==this)return true;
        while(Node=Node.parentNode);
        return false;
    }
    HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){
        switch(where){
        case "beforeBegin":
        this.parentNode.insertBefore(parsedNode,this);
        break;
        case "afterBegin":
        this.insertBefore(parsedNode,this.firstChild);
        break;
        case "beforeEnd":
        this.appendChild(parsedNode);
        break;
        case "afterEnd":
        if(this.nextSibling)
        this.parentNode.insertBefore(parsedNode,this.nextSibling);
        else
        this.parentNode.appendChild(parsedNode);
        break;
        }
    }
    HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML=r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where,parsedHTML);
    }
    HTMLElement.prototype.insertAdjacentText=function(where,txtStr){
        var parsedText=document.createTextNode(txtStr);
        this.insertAdjacentElement(where,parsedText);
    }
    HTMLElement.prototype.attachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        fHandler._ieEmuEventHandler=function(e){
        window.event=e;
        return fHandler();
        }
        this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
    }
    HTMLElement.prototype.detachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        if(typeof(fHandler._ieEmuEventHandler)=="function")
        this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        else
        this.removeEventListener(shortTypeName,fHandler,true);
    }
}
        
//-----------------------------------------------------------------------------------------------------
