
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;
    
   
    if(Trim(openParams)=='')
    {       
        objWin = window.open(url, name, 'resizable=1, status=0, toolbar=0, scrollbars=1, width=' + iWidth + ', height=' + iHeight + ', ' + 'left=' + iLeft + ', top=' + iTop);
    }
    else
    {
        objWin = window.open(url, name, 'resizable=1,directories=1,location=1,toolbar=1,menubar=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
    {
        /*Just in case width and height are ignored 
        objWin.resizeTo(iWidth, iHeight);
        Just in case left and top are ignored
        objWin.moveTo(iLeft, iTop);*/
        objWin.focus();
        return false;
    }
}



/*Date 16-April-2009
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) 
{
    var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    if ((strDate.match(RegExPattern)) && (strDate !='')) 
    {
        /*Date is Valid, now check it for format (mm/dd/yyyy)*/
        var arrDate = strDate.split("/");
        return((arrDate.length==3)&&(arrDate[0].length<=2)&&(arrDate[1].length<=2)&&(arrDate[2].length==4));
    } 
    else 
    {
        /*Date is not in correct formate.*/
        return false;
    } 
}

/*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 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;
            }
}