﻿function fnCancelKey(ev)
{   
    var keyPressValue;
    if(ev.which == undefined)
        keyPressValue = ev.keyCode;
    else
        keyPressValue = ev.which;
        
    if(keyPressValue==0 || keyPressValue==8 || keyPressValue==13 ){return true;}
    return false;
}
function fnGetDateObject(val)
{
    return new Date(val.split('/')[2], val.split('/')[0], val.split('/')[1]);
}
function fnToggleControl(cntId)
{ 

    var cnt = document.getElementById (cntId);
    //alert(cnt);
    if(cnt.style.display == 'none')
    {
        cnt.style.display ='block';
    }
    else if(cnt.style.display == '')
    {
        cnt.style.display ='none';
    }
    else if(cnt.style.display == 'block')
    {
        cnt.style.display ='none';
    }
    //alert( cnt.style.display);
    return true;
}

function fnIsEmpty(val)
{
    return (val.replace(/(^\s*)|(\s*$)/g,"")=='');
}
function TextEditorValidator(objifr)
{
    //alert("TextEditorINN");
    ifr = objifr;
    if (ifr)
    {
        var ifrDoc = ifr.contentWindow ? ifr.contentWindow.document : ifr.contentDocument;
        var edittd = ifrDoc.getElementById("xEditingArea");
        
        if( edittd.childNodes[0].tagName == "IFRAME")
        {
            ifr = ifrDoc.documentElement.getElementsByTagName("IFRAME")[0] ;
            ifrDoc = ifr.contentWindow ? ifr.contentWindow.document : ifr.contentDocument;
            
            var ifrbdy = ifrDoc.documentElement.getElementsByTagName('body').item(0);
            if (ifrbdy) 
            { 
              if( Trim( TrimEditor( ifrbdy.innerHTML ) ) == "" )
              {
                  //ErrorObj.addError(ErrorMessage);
                  //ErrorObj.showError();
                  return false;
              }
            }
        }
        else
        {
            if( Trim( TrimEditor( edittd.childNodes[0].value ) )  == "" )
            {
                //ErrorObj.addError(ErrorMessage);
                //ErrorObj.showError();
                return false;
            }
        }
    }
}