var commonURL = "http://www.epsilen.com";

function resizeIframe(){
    var iFramesize;
    var iLeftMenuHeight = 0;
    if(navigator.userAgent.toLowerCase().indexOf("msie 6.0") != -1)
        iFramesize = document.body.scrollHeight;
    else if(navigator.userAgent.toLowerCase().indexOf("msie 7.0") != -1)
        iFramesize = document.body.scrollHeight + 30;
    else if(navigator.userAgent.toLowerCase().indexOf("firefox") != -1)
        iFramesize = document.body.scrollHeight + 10;
    else if(navigator.userAgent.toLowerCase().indexOf("safari") != -1)
        iFramesize = document.body.scrollHeight;
    else if(navigator.userAgent.toLowerCase().indexOf("navigator") != -1)
        iFramesize = document.body.scrollHeight;
    else
        iFramesize = document.body.scrollHeight;
        
    if(iFramesize < 700)
        iFramesize = 710;
    
    if(parent.document.getElementById('divLeftMenuContainer') != null)
    {
        iLeftMenuHeight = parent.document.getElementById('divLeftMenuContainer').scrollHeight - 100;
    }
    
    if(iLeftMenuHeight > iFramesize)
        iFramesize = iLeftMenuHeight;
    
    if(parent.document.getElementById('frameMain')!=null)
    {
        parent.document.getElementById('frameMain').style.height = iFramesize + "px";
    }
    parent.document.title = document.title;
    hideMasterAjaxLoader();
    return true;
}

function resizeIframeEpsilenMail()
{
    if(parent.document.getElementById('frameMails') == 'undefined' || parent.document.getElementById('frameMails') == null)return;
    var iFramesize;
    if(navigator.userAgent.toLowerCase().indexOf("msie 6.0") != -1)
        iFramesize = document.body.scrollHeight + 10;
    else if(navigator.userAgent.toLowerCase().indexOf("msie 7.0") != -1)
        iFramesize = document.body.scrollHeight + 30;
    else if(navigator.userAgent.toLowerCase().indexOf("firefox") != -1)
        iFramesize = document.body.scrollHeight + 10;
    else if(navigator.userAgent.toLowerCase().indexOf("safari") != -1)
        iFramesize = document.body.scrollHeight;
    else if(navigator.userAgent.toLowerCase().indexOf("navigator") != -1)
        iFramesize = document.body.scrollHeight;
    else
        iFramesize = document.body.scrollHeight;
        
    if(iFramesize < 500)
        iFramesize = 510;    
//     if(iFramesize > 700)
//        iFramesize = 700;

    parent.document.getElementById('frameMails').style.height = (iFramesize +20 ) + "px";

    parent.document.title = document.title;
    hideMasterAjaxLoader();
    return true;
}

function resizeIframeCalender(){

    if(parent.document.getElementById('frameMain') == 'undefined' || parent.document.getElementById('frameMain') == null)return;
    var iFramesize;
    if(navigator.userAgent.toLowerCase().indexOf("msie 6.0") != -1)
        iFramesize = document.body.scrollHeight;
    else if(navigator.userAgent.toLowerCase().indexOf("msie 7.0") != -1)
        iFramesize = document.body.scrollHeight + 30;
    else if(navigator.userAgent.toLowerCase().indexOf("firefox") != -1)
        iFramesize = document.body.scrollHeight + 10;
    else if(navigator.userAgent.toLowerCase().indexOf("safari") != -1)
        iFramesize = document.body.scrollHeight;
    else if(navigator.userAgent.toLowerCase().indexOf("navigator") != -1)
        iFramesize = document.body.scrollHeight;
    else
        iFramesize = document.body.scrollHeight;
    parent.document.getElementById('frameMain').style.height = (iFramesize + 170) + "px";
    parent.document.title = document.title;
    hideMasterAjaxLoader();
    return true;
}


function resizeIframeLanding(){    

}


/* resize frame funcion without loader */
function resizeIframeAdmin()
{
    var iFramesize;
    if(navigator.userAgent.toLowerCase().indexOf("msie 6.0") != -1)
        iFramesize = document.body.scrollHeight;
    else if(navigator.userAgent.toLowerCase().indexOf("msie 7.0") != -1)
        iFramesize = document.body.scrollHeight + 10;
    else if(navigator.userAgent.toLowerCase().indexOf("firefox") != -1)
        iFramesize = document.body.scrollHeight;
    else if(navigator.userAgent.toLowerCase().indexOf("safari") != -1)
        iFramesize = document.body.scrollHeight;
    else if(navigator.userAgent.toLowerCase().indexOf("navigator") != -1)
        iFramesize = document.body.scrollHeight;
    else
        iFramesize = document.body.scrollHeight;
   
    parent.document.getElementById('frameMain').style.height = iFramesize + "px";
    parent.document.title = document.title;
    return true;
}

function openPopupWindowWithStatus(url, name, height, width, status)
{
    var iWidth = width;
    var iHeight = height + 25;
    var iLeft = (screen.width - iWidth) / 2;
    var iTop = (screen.height - iHeight) / 2;
    
    var objWin = window.open(url, name, 'resizable=1, status='+ status +', toolbar=0, scrollbars=1, width=' + iWidth + ', height=' + iHeight + ', ' + 'left=' + iLeft + ', top=' + iTop);
    if(objWin == null) 
    { 
        alert('Could not open new window.\n\nYou may be blocking pop-ups.'); 
        return false;
    }
    else
    {
        objWin.focus();
        return false;
    }
}
 
function openPopupWindow(url, name, height, width, openParams)
{
    var iWidth = width;
    var iHeight = height + 25;
    var iLeft = (screen.width - iWidth) / 2;
    var iTop = (screen.height - iHeight) / 2;
    
    var objWin = window.open(url, name, 'resizable=1, status=0, toolbar=0, scrollbars=1, width=' + iWidth + ', height=' + iHeight + ', ' + 'left=' + iLeft + ', top=' + iTop);
    if(objWin == null) 
    { 
        alert('Could not open new window.\n\nYou may be blocking pop-ups.'); 
        return false;
    }
    else
    {
        objWin.focus();
        return false;
    }
}

function openPopupWindowwithObject(url, name, height, width, openParams)
{
    var iWidth = width;
    var iHeight = height;
    var iLeft = (screen.width - iWidth) / 2;
    var iTop = (screen.height - iHeight) / 2;
    
    var objWin = window.open(url, name, 'resizable=1, status=0, toolbar=0, scrollbars=1, width=' + iWidth + ', height=' + iHeight + ', ' + 'left=' + iLeft + ', top=' + iTop);
    if(objWin == null) 
    { 
        alert('Could not open new window.\n\nYou may be blocking pop-ups.'); 
        return false;
    }
    else
    {
        objWin.focus();
        return objWin;
    }
}


function showMasterAjaxLoader(){
    var wleft = (screen.width - 100) / 2;
    var wtop = (screen.height - 100) / 2;
    var objAjaxLoader = document.getElementById("dvAjaxLoader");
    objAjaxLoader.style.display = "";
    objAjaxLoader.style.left = wleft + "px";
    objAjaxLoader.style.top = wtop + "px";
}

function hideMasterAjaxLoader(){
    if(parent.document.getElementById("dvAjaxLoader")!=null)
    {
        parent.document.getElementById("dvAjaxLoader").style.display = "none";
    }
}

/*Function is used to validate date.
Just pass STRING in date formate.and it will check. */
function validateDate(strDate, format) {
    if(format != null && format != "undefined")
    {
        return isDate(strDate, format);
    }
    else
    {
        return isDate(strDate, "M/d/yyyy");
    }
}

/*Date 17-Dec-2008
Function is used to validate date in format 'mm/dd/yyyy'.
Just pass STRING in date formate and it will check the date. */
function validateDateWithFormat(strDate, format){
    return validateDate(strDate, format)
}

/*Function used to trim string, Basically usefull while removeing space and then checking. */
function Trim(strValue)
{
    var ichar, icount;
    ichar = strValue.length - 1;
    icount = -1;
    while (strValue.charAt(ichar) == ' ' && ichar > icount)
        --ichar;
    if (ichar!=(strValue.length-1))
        strValue = strValue.slice(0,ichar+1);
    ichar = 0;
    icount = strValue.length - 1;
    while (strValue.charAt(ichar)==' ' && ichar < icount)
        ++ichar;
    if (ichar!=0)
        strValue = strValue.slice(ichar,strValue.length);
    return strValue;
}
 
function validateEmail(emailValue, isCheckEDU)
{
    var strDomain = emailValue.substring(emailValue.lastIndexOf(".") + 1);
    if(isCheckEDU && strDomain.toUpperCase() != "EDU")
        return false;
    return echeck(emailValue);
}

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}
	 if (str.indexOf(at,(lat+1))!=-1){
	    return false
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
	    return false
	 }
	 if (str.indexOf(" ")!=-1){
	    return false
	 }
	 return true					
}

function randomPassword(length)
{
   chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ";
   pass = "";
   for(x=0;x<length;x++)
   {
      i = Math.floor(Math.random() * 62);
      pass += chars.charAt(i);
   }
   return pass;
}

/************* Cookie Operations *******************/
function createCookie(name, value, days, isMins) {
    var expires = "";
	if(isMins && days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*60*1000));
		expires = "; expires="+ date.toGMTString();
	}
	if (days) 
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+ date.toGMTString();
	}
	document.cookie = name +"="+ value + expires +"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

/************* Close Cookie Operations *******************/

function isAlphaNumeric(keyWord)
{
    /* allow ONLY alphanumeric keys, no symbols or punctuation
     this can be altered for any "checkOK" string you desire */
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567899 _@!#$^.: %&+,.:*'-";//Added ' in valid character
    var checkStr = keyWord;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
        {
            if (ch == checkOK.charAt(j))
                break;
        }       
        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
    }

    if (!allValid)
    {
        return (false);
    }
    return true;
}


function validateSearch(searchKeyword, callback)
{
    var errString ='';
    searchKeyword=Trim(searchKeyword);
     if (searchKeyword.indexOf("<")>=0 || searchKeyword.indexOf(">")>=0)
     {            
        errString='Please enter valid characters, < and > are not allowed.<br/>';
     }
     else
     {
        if(searchKeyword=='')
        {
            errString+='Please enter a value to search for <br/>';
        }
        else
        {
            if(searchKeyword.length <2)
            {
                errString+='Please enter at least 2 characters for search<br/>';
            }
            else
            {
            //***************Commented below 5 lines due to Issue No. 5271 On 17th Apr 2009 By Rohit VYas*************************************
            //            if(!isAlphaNumeric(searchKeyword))
            //            {
            //                //errString+='Please enter only Alpha-Numeric characters<br/>';
            //                errString+='Following characters are allowed in search: <br/>A-Z, a-z, 0-9 and <br/> special characters _ @ ! # $ ^ . : % & + , . : * -\'';
            //            }
            //*****************************************************************************************************************************************
            
                if(searchKeyword.indexOf(" ")>=0)
                {
                    var splsearchKeyword = searchKeyword.split(" ");
                    var inValidKeyword=0;
                    for(var i=0;i<splsearchKeyword.length;i++)
                    {
                        if(splsearchKeyword[i].length==1)
                        {
                            inValidKeyword+=1;
                        }
                    }
                    if(inValidKeyword>=3)
                    {
                        errString+='Invalid search keyword.<br/>';
                    }
                }
                else
                {
                    var regExpString = "|the|of|to|and|a|in|is|it|you|that|he|was|for|on|are|as|be|at|or|had|by|but|how|an|if|so|has|did|am|b|c|d|e|f|g|h|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|";
                    if(regExpString.indexOf('|'+searchKeyword+'|')>=0)
                    {
                        errString+='Please refine your search to be more specific. Single letter searches or searches that contain common words (e.g., is, and, am, are, but, the, for, etc.) generally  return many unwanted results.';
                    }
                }  
            }
        }
      }
   
    if(errString == '')
        return true;
    else
    {
        var objDialog = new DPJsDialog();
        objDialog.init('400px');
        if(callback)
        {
            objDialog.show('Error!', errString, '200px', callback);
        }
        else
            objDialog.show('Error!', errString);
        return false;
    }
}


function validateMemberSearch(searchKeyword)
{
    var errString ='';
    searchKeyword=Trim(searchKeyword);
    if(searchKeyword=='')
    {
        errString+='Please enter a value to search for <br/>';
    }
    else
    {
        if(searchKeyword.length <2)
        {
            errString+='Please enter at least 2 characters for search<br/>';
        }
        else
        {
            if(!isAlphaNumericMemberSearch(searchKeyword))
            {
                errString+='Please enter only Alpha-Numeric characters<br/>';
            }
        
            if(searchKeyword.indexOf(" ")>=0)
            {
                var splsearchKeyword = searchKeyword.split(" ");
                var inValidKeyword=0;
                for(var i=0;i<splsearchKeyword.length;i++)
                {
                    if(splsearchKeyword[i].length==1)
                    {
                        inValidKeyword+=1;
                    }
                }
                if(inValidKeyword>=3)
                {
                    errString+='Invalid search keyword.<br/>';
                }
            }
            else
            {
                var regExpString = "|the|of|to|and|a|in|is|it|you|that|he|was|for|on|are|as|be|at|or|had|by|but|how|an|if|so|has|did|am|b|c|d|e|f|g|h|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|";
                if(regExpString.indexOf('|'+searchKeyword+'|')>=0)
                {
                    errString+='Please refine your search to be more specific. Single letter searches or searches that contain common words (e.g., is, and, am, are, but, the, for, etc.) generally  return many unwanted results.';
                }
            }  
        }
    }
   
    if(errString == '')
        return true;
    else
    {
        var objDialog = new DPJsDialog();
        objDialog.init('400px');
        objDialog.show('Error!', errString);
        return false;
    }
}

function isAlphaNumericMemberSearch(keyWord)
{
    /* allow ONLY alphanumeric keys, no symbols or punctuation
     this can be altered for any "checkOK" string you desire */
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567899 _@%&_+,.:*'-";
    var checkStr = keyWord;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
        {
            if (ch == checkOK.charAt(j))
                break;
        }       
        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
    }
    if (!allValid)
    {
        return (false);
    }
    return true;
}

function validateSearchAndShowAlert(searchKeyword)
{
    var errString ='';
    searchKeyword=Trim(searchKeyword);
    if(searchKeyword=='')
    {
        errString+='Search Keyword is required\n';
    }
    else
    {
        if(searchKeyword.length <2)
        {
            errString+='Please enter at least 2 characters for search\n';
        }
        else
        {
        
            if(searchKeyword.indexOf(" ")>=0)
            {
                var splsearchKeyword = searchKeyword.split(" ");
                var inValidKeyword=0;
                for(var i=0;i<splsearchKeyword.length;i++)
                {
                    if(splsearchKeyword[i].length==1)
                    {
                        inValidKeyword+=1;
                    }
                }
                if(inValidKeyword>=3)
                {
                    errString+='Invalid search keyword.\n';
                }
            }
            else
            {
                var regExpString = "|the|of|to|and|a|in|is|it|you|that|he|was|for|on|are|as|be|at|or|had|by|but|how|an|if|so|has|did|am|b|c|d|e|f|g|h|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|";
                if(regExpString.indexOf('|'+searchKeyword+'|')>=0)
                {
                    errString+='Please refine your search to be more specific. Single letter searches or searches that contain common words (e.g., is, and, am, are, but, the, for, etc.) generally  return many unwanted results.\n';
                }
            }  
        }
    }
   
    if(errString == '')
        return true;
    else
    {
        alert(errString);
        return false;
    }
}

/* Function used for search pages where on enter key press search results will be reflected with the validation.
This function gets that control where search text entered "ctrlKeyPress",postBackControlID  which postback is called
and event e. */
function SearchOnEnter(ctrlKeyPress, postBackControlID, e)
{
    var key;
    if(window.event)
    {
        key = window.event.keyCode;
    }
    else
    {
        key = e.which;
    }
    var searchText = document.getElementById(ctrlKeyPress.id).value;    
       
    if(key==13)
    {
        if(validateSearch(searchText)==false)
        { 
            return false;
        }
       else
        {   
            javascript:__doPostBack(postBackControlID,'');
            return false;
        }
    }
}


/* Function used for search pages where on enter key press search results will be reflected with the validation.
This function gets that control where search text entered "ctrlKeyPress",postBackControlID  which postback is called
and event e. */
function SearchMemberOnEnter(ctrlKeyPress, postBackControlID, e)
{
    var key;
    if(window.event)
    {
        key = window.event.keyCode;
    }
    else
    {
        key = e.which;
    }
    var searchText = document.getElementById(ctrlKeyPress.id).value;    
       
    if(key==13)
    {
       if(validateMemberSearch(searchText)==false)
        { 
            return false;
        }
       else
        {   
            javascript:__doPostBack(postBackControlID,'');
            return false;
        }
    }
}

function AllowStar(keyWord)
{
    /* allow ONLY alphanumeric keys, no symbols or punctuation
     this can be altered for any "checkOK" string you desire */
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567899 *+-_";
    var checkStr = keyWord;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
        {
            if (ch == checkOK.charAt(j))
                break;
        }       
        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
    }

    if (!allValid)
    {
        return (false);
    }
    return true;
}

function validateWikiForumBlogSearch(searchKeyword, callback)
{
    var errString ='';
    searchKeyword=Trim(searchKeyword);
    if(searchKeyword=='')
    {
        errString+='Please enter a value to search for <br/>';
    }
    else
    {
        if(searchKeyword.length <3)
        {
            errString+='Please enter at least 3 characters for search<br/>';
        }
        else
        {
            if(!AllowStar(searchKeyword))
            {
                errString+='Please enter only Alpha-Numeric characters<br/>';
            }
        
            if(searchKeyword.indexOf(" ")>=0)
            {
                var splsearchKeyword = searchKeyword.split(" ");
                var inValidKeyword=0;
                for(var i=0;i<splsearchKeyword.length;i++)
                {
                    if(splsearchKeyword[i].length==1)
                    {
                        inValidKeyword+=1;
                    }
                }
                if(inValidKeyword>=3)
                {
                    errString+='Invalid search keyword.<br/>';
                }
            }
            else
            {
                var regExpString = "|the|of|to|a|in|is|it|you|that|he|was|for|on|are|as|be|at|had|by|but|how|an|if|so|has|did|am|b|c|d|e|f|g|h|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|";
                if(regExpString.indexOf('|'+searchKeyword+'|')>=0)
                {
                    errString+='Please refine your search to be more specific. Single letter searches or searches that contain common words (e.g., is, and, am, are, but, the, for, etc.) generally  return many unwanted results.';
                }
            }  
        }
    }
   
    if(errString == '')
        return true;
    else
    {
        var objDialog = new DPJsDialog();
        objDialog.init('400px');
        if(callback)
        {
            objDialog.show('Error!', errString, '200px', callback);
        }
        else
            objDialog.show('Error!', errString);
        return false;
    }
}

///<Author>Pravesh Chourasia</Author>
/// <DateCreated>Jan-07-2009</DateCreated>
///Summary
/*This function is used to validate "Full text search" .It takes following 3 parameters:
1.searchKeyword (Text entered by user)
2.minCharacters (Minimum no. of characters that are allowed for search (e.g. 2,3,4 etc.))
3.requiredErrorMessage ((yes/no) : if value is 'yes', then it returns error message. If value is 'no' , it returns 'true' in case of success otherwise it gives error alert message and returns false*/    
///
function validateFulltextSearch(searchKeyword,minCharacters,requiredErrorMessage)
{
    minCharacters = parseInt(minCharacters);
    var regExpStringForAllowedOperators = "|and|or|not|and not|near|-|+|*|~|;|||&|!|~!|&!|and!|+!||!|or!|-!|(|)|on|in|the|";
    var regExpStringForSpecialCharacters = "*,+,|,-,~,;,\",(,),&,!";
    var splsearchCharacters = regExpStringForSpecialCharacters.split(",");
    var RegExPatternForInteger =/^\d+$/;
    var errString ='';
    searchKeyword=Trim(searchKeyword);
    
    if(searchKeyword=='')
    {
        errString='Please enter a value for search';
    }
    else
    {
        if(searchKeyword.length <minCharacters)
        {
            errString='Please enter at least '+minCharacters + ' characters for search';
        }
        else
        {           
            //Manish Malviya (06/Jan/2009) For check "<" and ">" sign and show message, avoid Potentially dangerous request Error            
            if (searchKeyword.indexOf("<")>=0)
            {            
                errString='Please enter valid characters, < and > are not allowed.';
                return errString;
            }
            //Manish Malviya (06/Jan/2009) For check "<" and ">" sign and show message            
            if (searchKeyword.indexOf(">")>=0)
            {
                errString='Please enter valid characters, < and > are not allowed.';
                return errString;
            }
            
            if (searchKeyword.match(RegExPatternForInteger)) 
            {
                errString='Please enter only Alpha-Numeric characters';
            } 
            if(searchKeyword.indexOf(" ")>=0)
            {
                var splsearchKeyword = searchKeyword.split(" ");
                for(var i=0;i<splsearchKeyword.length;i++)
                {
                    var inValidKeyword=0;
                    if(Trim(splsearchKeyword[i]).length==0)
                    {
                        continue;
                    }
                    if(regExpStringForAllowedOperators.indexOf('|'+splsearchKeyword[i].toLowerCase()+'|')>=0)
                    {
                        continue;
                    }
                    for(var j=0;j<splsearchCharacters.length;j++)
                    {
                        var totOccurance= splsearchKeyword[i].split(splsearchCharacters[j]).length-1;
                        if(totOccurance>0)
                        {
                            inValidKeyword+=totOccurance;
                        }
                    }
                    if((splsearchKeyword[i].length-inValidKeyword)<minCharacters)
                    {
                        errString='Please enter at least '+minCharacters + ' characters for search';
                    }
                }
            }
            else
            {
                var inValidKeyword=0;
                for(var j=0;j<splsearchCharacters.length;j++)
                {
                    var totOccurance= searchKeyword.split(splsearchCharacters[j]).length-1;
                    if(totOccurance>0)
                    {
                        inValidKeyword+=totOccurance;
                    }
                }
                if((searchKeyword.length-inValidKeyword)<minCharacters)
                {
                    errString='Please enter at least '+minCharacters + ' characters for search';
                }
                var regExpString = "|the|of|to|and|a|in|is|it|you|that|he|was|for|on|are|as|be|at|or|had|by|but|how|an|if|so|has|did|am|b|c|d|e|f|g|h|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|";
                if(regExpString.indexOf('|'+searchKeyword+'|')>=0)
                {
                    errString='Please refine your search to be more specific. Single letter searches or searches that contain common words (e.g., is, and, am, are, but, the, for, etc.) generally  return many unwanted results.';
                }
            }  
        }
    }

    if (requiredErrorMessage.toLowerCase()=="yes")
    {        
        return errString;    
    }
    else
    {
        if(errString == '')
            return true;
        else
        {            
            var objDialog = new DPJsDialog();
            objDialog.init('400px');
            objDialog.show('Error!', errString);
            return false;
        }
    }
}

///<Author>Manish Malviya</Author>
/// <DateCreated>16-Feb-2009</DateCreated>
///Summary
/*This function is used to validate keywords for all language. */
///
function validateSearchForAllLanguage(searchKeyword, callback)
{
    var errString ='';
    searchKeyword=Trim(searchKeyword);
    if(searchKeyword=='')
    {
        errString+='Please enter a value to search for <br/>';
    }
    else
    {
        if(searchKeyword.length <2)
        {
            errString+='Please enter at least 2 characters for search<br/>';
        }
        else
        {
            
            if(searchKeyword.indexOf(" ")>=0)
            {
                var splsearchKeyword = searchKeyword.split(" ");
                var inValidKeyword=0;
                for(var i=0;i<splsearchKeyword.length;i++)
                {
                    if(splsearchKeyword[i].length==1)
                    {
                        inValidKeyword+=1;
                    }
                }
                if(inValidKeyword>=3)
                {
                    errString+='Invalid search keyword.<br/>';
                }
            }
            else
            {
                var regExpString = "|the|of|to|and|a|in|is|it|you|that|he|was|for|on|are|as|be|at|or|had|by|but|how|an|if|so|has|did|am|b|c|d|e|f|g|h|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|";
                if(regExpString.indexOf('|'+searchKeyword+'|')>=0)
                {
                    errString+='Please refine your search to be more specific. Single letter searches or searches that contain common words (e.g., is, and, am, are, but, the, for, etc.) generally  return many unwanted results.';
                }
            }  
        }
    }
   
    if(errString == '')
        return true;
    else
    {
        var objDialog = new DPJsDialog();
        objDialog.init('400px');
        if(callback)
        {
            objDialog.show('Error!', errString, '200px', callback);
        }
        else
            objDialog.show('Error!', errString);
        return false;
    }
}

/*<Remarks>
///<Author>Umesh Badrecha</Author>
/// <DateCreated>11/Dec/2008</DateCreated>
/// <LastUpdatedDate>__/__/____</LastUpdatedDate>
/// <LastUpdatedBy>Updated By Name</LastUpdatedBy>
/// <CodeReviewDate>__/__/____</CodeReviewDate>
/// <CodeReviewBy>Reviewed By Name</CodeReviewBy>
/// </remarks>
/// <summary>
/// Used to show left menu selected
/// </summary> */
function selectChildToolBySysName(parentSysName, childSysName)
{
   var parentToolID;
   var ToolID;
   var pageURL;
   var menuList = window.parent.document.getElementsByTagName("h3");         
   for(var i=0; i<menuList.length; i++)
   {
        var ctrl = menuList[i];
        if(ctrl.getAttribute("systemname") == parentSysName )
        {  
            parentToolID = ctrl.getAttribute("ToolID");
            menuList = window.parent.document.getElementsByTagName("a");
            for(var j=0; j<menuList.length; j++)
            {
                ctrl = menuList[j];
                if(ctrl.getAttribute("systemname") == childSysName)
                {  
                    ToolID = ctrl.getAttribute("ToolID");
                    pageURL = ctrl.getAttribute("URL");
                    window.parent.selectToolByToolID(parentSysName, childSysName, pageURL);
                    return false;
                }   
            }
        }   
   }
   return false;
}
/************************************************************************/

/* For getting Top and Left position */
function GetTopLeft(elm)
{
    var x, y = 0;
    x = elm.offsetLeft;
    y = elm.offsetTop;
    elm = elm.offsetParent;

    /*use while loop to check if elm is null
     if not then add current elm�s offsetLeft to x
    offsetTop to y and set elm to its offsetParent */
    while(elm != null)
     {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
     }
    return {Top:y, Left: x};
}

/* For Public site ToolTip */
function ShowPublicTooltip(obj)
{
    var objDimension = GetTopLeft(obj);
    var objTooltipContainer = document.getElementById('dvToolTip');
    objTooltipContainer.style.left = (objDimension.Left+150) + "px";
    objTooltipContainer.style.top = (objDimension.Top +30) + "px";
    var toolTip = obj.getAttribute('ToolTip');
    if(toolTip !="")
    {
        objTooltipContainer.innerHTML = obj.getAttribute('ToolTip');
        objTooltipContainer.style.display='';
    }
}

function HidePublicTooltip()
{
    var objTooltipContainer = document.getElementById('dvToolTip');
    objTooltipContainer.innerHTML='';
    objTooltipContainer.style.display='none';
}
    
/* Select Menu Item of Public site */
var personalpublic_selected_class = 'selected';
function ShowPublicMenuItemSelected(menuID)
{
    if(document.getElementById(menuID))
    {
        document.getElementById(menuID).className = personalpublic_selected_class;
    }
}


/* Session Timer */
function InitializeSession(overrideTimeout)
{
    try 
    {
        if(window.opener)
        {   
            if(window.opener.document.getElementById('dvSessionAlarm'))
            {
                if(window.opener["SetSessionWarning"])
                    window.opener.SetSessionWarning(overrideTimeout);
            }        
            else if(window.opener.parent.document.getElementById('dvSessionAlarm'))
            {
                if(window.opener.parent["SetSessionWarning"])
                    window.opener.parent.SetSessionWarning(overrideTimeout);
            }
            else if(window.opener.parent.parent.document.getElementById('dvSessionAlarm'))
            {
                if(window.opener.parent.parent["SetSessionWarning"])
                    window.opener.parent.parent.SetSessionWarning(overrideTimeout);
            }
            return;
        }
        if(parent.document)
        {
            if(parent.document.getElementById('dvSessionAlarm'))
            {
                if(parent["SetSessionWarning"])
                parent.SetSessionWarning(overrideTimeout);
            }
            else
            {
                if(parent.parent.document.getElementById('dvSessionAlarm'))
                {
                    if(parent.parent["SetSessionWarning"])
                    parent.parent.SetSessionWarning(overrideTimeout);
                }
            }
        }
    }
    catch(e){}        
}

var sTimeout;
function ClearSessionTimer()
{
    if(window.opener)
    {   
        if(window.opener.document.getElementById('dvSessionAlarm'))
        {
            window.opener.document.getElementById('dvSessionAlarm').innerHTML='';
            window.opener.document.getElementById('dvSessionAlarm').style.display='none';
        }        
        else if(window.opener.parent.document.getElementById('dvSessionAlarm'))
        {
            window.opener.parent.document.getElementById('dvSessionAlarm').innerHTML='';
            window.opener.parent.document.getElementById('dvSessionAlarm').style.display='none';            
        }
        else if(window.opener.parent.parent.document.getElementById('dvSessionAlarm'))
        {
            window.opener.parent.parent.document.getElementById('dvSessionAlarm').innerHTML='';
            window.opener.parent.parent.document.getElementById('dvSessionAlarm').style.display='none';            
        }
        return;
    }
    
    if(parent.document)
    {
        if(parent.document.getElementById('dvSessionAlarm'))
        {
            parent.document.getElementById('dvSessionAlarm').innerHTML='';
            parent.document.getElementById('dvSessionAlarm').style.display='none';
        }
        else if(parent.parent.document.getElementById('dvSessionAlarm'))
        {
            parent.parent.document.getElementById('dvSessionAlarm').innerHTML='';
            parent.parent.document.getElementById('dvSessionAlarm').style.display='none';            
        }
    }
}

var cntDownDate = '';
var SessiontimeOutURL='';
function SessionTimer(timeOutURL)
{
    try
    {
        var sessionTimerDiv = '<div id="dvSessionTimer" class="LNBTooltip" style="font-size:12px;">';
        sessionTimerDiv += '<table width="100%" style="height:100px;">';
	    sessionTimerDiv += '<tr><td align="center" valign="bottom" style="font-weight:bold;color:red">Your session will be expired after</td></tr>';
	    sessionTimerDiv += '<tr><td align="center" valign="top" style="font-size:16px;font-weight:bold;color:red"><span id="spnSessionTick"> 05 : 00 </span></td></tr>';
	    sessionTimerDiv += '<tr><td align="center" valign="top"><span id="spnSessionTick">Please click on any of the left menu tools to keep your session alive.</span></td></tr>';
        sessionTimerDiv += '</table></div>';
        
        if(window.opener)
        {
            if(window.opener.document.getElementById('dvSessionAlarm'))
            {
                window.opener.document.getElementById('dvSessionAlarm').innerHTML=sessionTimerDiv;
                window.opener.document.getElementById('dvSessionAlarm').style.display='';
                setTimeout('StartCountDown()', 1000);
                SessiontimeOutURL=timeOutURL;            
            }        
            else if(window.opener.parent.document.getElementById('dvSessionAlarm'))
            {
                if(window.opener.parent.document.getElementById('dvSessionAlarm').innerHTML == "")
                {
                    window.opener.parent.document.getElementById('dvSessionAlarm').innerHTML = sessionTimerDiv;
                    window.opener.parent.document.getElementById('dvSessionAlarm').style.display='';
                    setTimeout('StartCountDown()', 1000);
                    SessiontimeOutURL=timeOutURL;
                }
            }
            else if(window.opener.parent.parent.document.getElementById('dvSessionAlarm'))
            {
                if(window.opener.parent.parent.document.getElementById('dvSessionAlarm').innerHTML == "")
                {
                    window.opener.parent.parent.document.getElementById('dvSessionAlarm').innerHTML = sessionTimerDiv;
                    window.opener.parent.parent.document.getElementById('dvSessionAlarm').style.display='';
                    setTimeout('StartCountDown()', 1000);
                    SessiontimeOutURL=timeOutURL;
                }
            }
            return;    
        }
        
        if(parent.document.getElementById('dvSessionAlarm'))
        {
            if(parent.document.getElementById('dvSessionAlarm').innerHTML == "")
            {
                parent.document.getElementById('dvSessionAlarm').innerHTML = sessionTimerDiv;
                parent.document.getElementById('dvSessionAlarm').style.display='';
                setTimeout('StartCountDown()', 1000);
                SessiontimeOutURL=timeOutURL;
            }
        }
        else
        {
            if(parent.parent.document.getElementById('dvSessionAlarm').innerHTML == "")
            {
                parent.parent.document.getElementById('dvSessionAlarm').innerHTML = sessionTimerDiv;
                parent.parent.document.getElementById('dvSessionAlarm').style.display='';
                setTimeout('StartCountDown()', 1000);
                SessiontimeOutURL=timeOutURL;
            }
        }
    }
    catch(e){}    
}

function StartCountDown()
{
    cntDownDate = new Date('01/01/2009 00:05:00');
    CountDown();
}

function CountDown()
{
    if(cntDownDate!='')
    {
        var min = cntDownDate.getMinutes();
        var sec = cntDownDate.getSeconds()-1;
        if(sec<0)
        {
            sec=59;
            min=min-1;
        }
        cntDownDate= new Date( '01/01/2009 00:' + min + ":" + sec);
        if(window.opener)
        {
            if(window.opener.document.getElementById('dvSessionAlarm'))
            {
                var timerObject = window.opener.document.getElementById('spnSessionTick');
                timerObject.innerHTML = ' ' + (min<=9?'0'+cntDownDate.getMinutes():cntDownDate.getMinutes() ) + ' : ' + (sec<=9?'0'+cntDownDate.getSeconds():cntDownDate.getSeconds());
                if(min <= 0 && sec==0)
                {
                    window.opener.location.href=SessiontimeOutURL;
                    window.close();
                    return;
                }
                else
                {
                    sTimeout=setTimeout('CountDown()', 1000);
                } 
            }
            else if(window.opener.parent.document.getElementById('dvSessionAlarm'))
            {
                var timerObject = window.opener.parent.document.getElementById('spnSessionTick');
                timerObject.innerHTML = ' ' + (min<=9?'0'+cntDownDate.getMinutes():cntDownDate.getMinutes() ) + ' : ' + (sec<=9?'0'+cntDownDate.getSeconds():cntDownDate.getSeconds());
                if(min <= 0 && sec==0)
                {
                    window.opener.parent.window.location.href=SessiontimeOutURL;
                    window.close();
                    return;
                }
                else
                {
                    sTimeout=setTimeout('CountDown()', 1000);
                } 
            }
            else if(window.opener.parent.parent.document.getElementById('dvSessionAlarm'))
            {
                var timerObject = window.opener.parent.parent.document.getElementById('spnSessionTick');
                timerObject.innerHTML = ' ' + (min<=9?'0'+cntDownDate.getMinutes():cntDownDate.getMinutes() ) + ' : ' + (sec<=9?'0'+cntDownDate.getSeconds():cntDownDate.getSeconds());
                if(min <= 0 && sec==0)
                {
                    window.opener.parent.parent.window.location.href=SessiontimeOutURL;
                    window.close();
                    return;
                }
                else
                {
                    sTimeout=setTimeout('CountDown()', 1000);
                } 
            }
            return;
        }
        
        if(parent.document.getElementById('spnSessionTick'))
        {
            var timerObject = parent.document.getElementById('spnSessionTick');
            timerObject.innerHTML = ' ' + (min<=9?'0'+cntDownDate.getMinutes():cntDownDate.getMinutes() ) + ' : ' + (sec<=9?'0'+cntDownDate.getSeconds():cntDownDate.getSeconds());
            if(min <= 0 && sec==0)
            {
                parent.window.location.href=SessiontimeOutURL;
                return;
            }
            else
            {
                sTimeout=setTimeout('CountDown()', 1000);
            }        
        }
        else if(parent.parent.document.getElementById('spnSessionTick'))
        {
            var timerObject = parent.parent.document.getElementById('spnSessionTick');
            timerObject.innerHTML = ' ' + (min<=9?'0'+cntDownDate.getMinutes():cntDownDate.getMinutes() ) + ' : ' + (sec<=9?'0'+cntDownDate.getSeconds():cntDownDate.getSeconds());
        
            if(min <= 0 && sec==0)
            {
                parent.parent.window.location.href=SessiontimeOutURL;
                return;
            }
            else
            {
                sTimeout=setTimeout('CountDown()', 1000);
            }            
        }
    }
}

/* NameBlock UC */
function onMissingNameBlockImage(ctrl, extArray)
{
    var extUsedCount=extArray.split(',');
    ctrl.src = "../Images/noMembers.jpg";
}

window.onscroll = onWindowScroll;
function onWindowScroll()
{
    var arrSelect = document.getElementsByTagName("select");
    for(var iCount = 0; iCount < arrSelect.length; iCount++)
    {
        if(arrSelect[iCount].id != "GotoInterfaceUC1_ddlGotoInterface")
        {
            arrSelect[iCount].style.display = "none";
            arrSelect[iCount].style.display = "";
        }
    }
}

/* Common JS Error Handler 
window.onerror=function(msg, url, line){

    if(msg.indexOf('Permission denied')>=0)
    {
       // window.location.reload();
        return true;
    }
    
    if(msg.indexOf('Access is denied')>=0)
    {
       // window.location.reload();
        return true;
    }
    
 alert('Client side error occured: ' + msg + '\n at line no.: ' + line + '\n URL: ' + url);
}*/

function checkAbsolutePosition(cuteEditorID)
{
    var strHTML = "";
    if(document.getElementById(cuteEditorID))
        strHTML = document.getElementById(cuteEditorID).getHTML().toLowerCase();
    if(strHTML.indexOf("position:absolute") == -1 && strHTML.indexOf("position: absolute") == -1 && strHTML.indexOf("position :absolute") == -1 && strHTML.indexOf("position : absolute") == -1)
        return true;
    else
        return confirm("The HTML content you have entered contains \"Absolute Position\" attributes and may not render properly. Do you wish to continue?");
}

function deleteConfirmation()
{
    return confirm(lDeleteConfirmMessage);
}

function validateEmailAddress(email) 
 {
     var reg = /^[A-Za-z0-9](([_\.\-\']?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/;
            var email = email
            while(email.indexOf("\r\n") != -1)
            {
                email = email.replace("\r\n",",")
            }
            while(email.indexOf("\n") != -1)
            {
                email = email.replace("\n",",")
            }
            while(email.indexOf(" ") != -1)
            {
                email = email.replace(" ",",")
            }
            while(email.indexOf(",,") != -1)
            {
                email = email.replace(",,",",")
            }
            
            var address = email.split(",");
            var invalidEmail="";
            for(i=0; i<address.length; i++)
            {
                if(reg.test(address[i]) == false) 
                {
                    invalidEmail = invalidEmail + address[i] + ", ";
                }
            }
            invalidEmail = invalidEmail.substr(0,invalidEmail.length-2);
            if(invalidEmail != "")
            {
                return false;
            }  
            else
            {   
                return true;
            }
}

//This function is used to check decimal values
//You can specify digits for number before and after "."(Decimal place)
function CheckDecimalValue(valToCheck, NumberofDigitsBeforeDecimal, NumberofDigitsAfterDecimal) {
    var IsValid = true;
    if (valToCheck == "") {
        IsValid = false;
    }
    else {
        if (isNaN(valToCheck)) {
            IsValid = false;
        }
        else {
            var val = valToCheck;
            if (val.indexOf(".") > -1) {
                if (val.length - (val.indexOf(".") + 1) > NumberofDigitsAfterDecimal) {
                    IsValid = false;
                }
                else {
                    if ((val.length - (val.length - (val.indexOf("."))) > NumberofDigitsBeforeDecimal) || val < 0.00) {
                        IsValid = false;
                    }
                    else
                        IsValid = true;
                }
            }
            else {
                if (parseInt(val) >= 0) {
                    if ((val.length > NumberofDigitsBeforeDecimal) || val < 0.00) {
                        IsValid = false;
                    } else
                        IsValid = true;
                }
                else
                    IsValid = false;
            }
        }
    }
    return IsValid;
}

// For EDSTEPS Logo customization
 function loadEpsilenLogo()
 {
 //alert(parent.logoURL);
    if(parent.document.getElementById('imgEpsilenLogo'))
    {
        if(parent.logoURL!='')
           parent.document.getElementById('imgEpsilenLogo').src = parent.logoURL;
    }
 }      

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}