/*
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><SCRIPT LANGUAGE=JavaScript>
*/

//**********************************************************************************
//       Check wether only the characters specified are there in the string
// Accepts the string and the character to be checked (it is a string)
//                                        A     -> for all alphabets (no case specification)
//                                        N     -> for all numbers
//                                        a - z     -> for all the lower case chars
//                                        other just specify it
//**********************************************************************************
function checkAllowedChars(strToCheck, allowedChars)
{
     var acLen     = allowedChars.length;
     var stcLen     = strToCheck.length;
     strToCheck     = strToCheck.toLowerCase();
     var i;
     var j;
     var rightCount = 0;
     for(i = 0; i < acLen; i++)
     {
          switch(allowedChars.charAt(i))
          {
          case 'A':
               for(j = 0; j< stcLen; j++)
               {
                    rightCount += strToCheck.charAt(j) >= 'a' && strToCheck.charAt(j) <= 'z';
               }
               break;
          case 'N':
               for(j = 0; j< stcLen; j++)
               {
                    rightCount += strToCheck.charAt(j) >= '0' && strToCheck.charAt(j) <= '9';
               }
               break;
          default:
               for(j = -1; -1 != (j = strToCheck.indexOf(allowedChars.charAt(i), j+1)); rightCount++);
               break;
          }
     }
     if(rightCount == stcLen)
     {
          return true;
     }
     return false;
}

//**********************************************************************************
//       Check wether the characters specified are not there in the string
// Accepts the string and the character to be checked (it is a string)
//                                        A     -> for all alphabets (no case specification)
//                                        N     -> for all numbers
//                                        a - z     -> for all the lower case chars
//                                        other just specify it
//**********************************************************************************
function checkNotAllowedChars(strToCheck, unAllowedChars)
{
     var acLen     = unAllowedChars.length;
     var stcLen     = strToCheck.length;
     strToCheck     = strToCheck.toLowerCase();
     var i;
     var j;
     var rightCount = 0;
     for(i = 0; i < acLen; i++)
     {
          switch(unAllowedChars.charAt(i))
          {
          case 'A':
               for(j = 0; j< stcLen; j++)
               {
                    if(strToCheck.charAt(j) >= 'a' && strToCheck.charAt(j) <= 'z')
                    {
                         return false;
                    }
               }
               break;

          case 'N':
               for(j = 0; j< stcLen; j++)
               {
                    if(strToCheck.charAt(j) >= '0' && strToCheck.charAt(j) <= '9')
                    {
                         return false;
                    }
               }
               break;

          default:
               if(strToCheck.indexOf(unAllowedChars.charAt(i)) != -1)
               {
                    return false;
               }
               break;
          }
     }
     return true;
}

//3 ---------------------------------------------------------------------------------------------------
//     to check begining space
//     parameters  (formname,indx,fieldname)
//     indx is the elements no eg: elements[indx]
//-----------------------------------------------------------------------------------------------------

function chkbeginspace(formname,indx,fieldname) {
     field = eval("document." + formname + ".elements[" + indx + "]");
        if (field.value.charAt(0) == ' ') {
             alert("First character of " + fieldname + " cannot be space");
             field.focus();
          return false;
        }
     else {
          return true;
     }
}


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function trimSpace(frmElement)
{

     var stringToTrim = frmElement.value;
     var len = stringToTrim.length;
     var front;
     var back;
     for(front = 0; front < len && (stringToTrim.charAt(front) == ' ' || stringToTrim.charAt(front) == '\n' || stringToTrim.charAt(front) == '\r' || stringToTrim.charAt(front) == '\t'); front++);
     for(back = len; back > 0 && back > front && (stringToTrim.charAt(back - 1) == ' ' || stringToTrim.charAt(back - 1) == '\n' || stringToTrim.charAt(back - 1) == '\r' || stringToTrim.charAt(back - 1) == '\t'); back--);

     frmElement.value = stringToTrim.substring(front, back);
}

function noChkBoxSelected(frmElement)
{
     var i;
     if(frmElement[1])
     {
          var len = frmElement.length;
          for(i = 0; i < len; i++)
               if(frmElement[i].checked)
                    break;

          if(i < len)
               return false;
          else
               return true;
     }
     else
          return !(frmElement.checked);
}

function findSelectedButton(btns)
{
     if(!btns[1])
          return btns.checked? 0: -1;

     for(i = 0; i < btns.length; i++)
     {
          if(btns[i].checked)
               return i;
     }

     return -1;
}

function setButton(btns, idx, val)
{
     idx = parseInt(idx, 10);
     if(!isNaN(idx))
          if(!btns[1])
               btns.checked = val;
          else
               btns[idx].checked = val;
}

function checkRedundantValues(frmElement)
{
     if(frmElement[1])
     {
          var cpy = new Array();
          for(i = 0; i < (frmElement.length - 1); i++)
               if(frmElement[i].value != '')
                    for(j = i+1; j < frmElement.length; j++)
                         if(frmElement[i].value == frmElement[j].value)
                              cpy[cpy.length] = i;
          if(cpy.length)
               return cpy;
     }
     return null;
}

//**********************************************************************************//
//                      Counts the Number of Occurance of a character                    //
// Accepts the string and the character                                                            //
//**********************************************************************************//
function countOccurance(str, charecter)
{
     var j;
     var count;
     for(j = -1, count = 0; -1 != (j = str.indexOf(charecter, j+1)); count++);
     return count;
}

function checkEmailNew(emailFieldRef, mandatory)
{
     //lrTrim(emailFieldRef);
     var email = eval(emailFieldRef + '.value');
     if((mandatory && !(email.length))
      || (email.length && !(checkAllowedChars(email, 'AN@-_.<>')
         && countOccurance(email, '@') == 1
         && email.indexOf('@') != 0
         && email.lastIndexOf('@') != (email.length - 1)
         && countOccurance(email, '<') <= 1
         && countOccurance(email, '>') <= 1
         && ((email.lastIndexOf('>') == (email.length - 1) && email.indexOf('<') != -1)
             || (email.indexOf('>') == -1) && email.indexOf('<') == -1)
         && countOccurance(email, '.') >= 1
         && email.indexOf('.') != 0
         && email.lastIndexOf('.') != (email.length - 1))))
     {
          alert('E-mail is Not Valid.');
          eval(emailFieldRef + '.focus()');
          return false;
     }
     afterAt = email.substring(email.indexOf('@') + 1);
     if(!(afterAt.indexOf('.') != 0 && afterAt.lastIndexOf('.') != (afterAt.length - 1)))
     {
          alert('E-mail is Not Valid.');
          eval(emailFieldRef + '.focus()');
          return false;
     }
     beforeAt = email.substring(0, email.indexOf('@'));
     if(!(beforeAt.indexOf('_') != 0 && beforeAt.indexOf('-') != 0 && beforeAt.indexOf('.') != 0 && beforeAt.lastIndexOf('.') != (beforeAt.length - 1)))
     {
          alert('E-mail is Not Valid.');
          eval(emailFieldRef + '.focus()');
          return false;
     }

     return true;
}

function CheckEmail(stremail)
{
  var err;
  var str=stremail;
  var ValidChars = "0123456789.";
  var validdom   = "0123456789";
  var illegalchars="#$!%^&*();:<>+/\?|";
  var i;
  var c;
  var l;
  var n;
  var at="@";
  var dot=".";
  var lat=str.indexOf(at);
  var lstr=str.length;
  var ldot=str.indexOf(dot);

    i=0;
   c = str.charAt(i);

   if (ValidChars.indexOf(c) !=-1)
   { return false; }

   l=str.indexOf(dot)+1;
   n=str.charAt(l);

   if(n=="")
   { return false; }

   for(i=l;i<lstr;i++)
   {
     l=str.charAt(i);

         if (validdom.indexOf(l)!=-1)
         { return false; }
   }

           clen=illegalchars.length;
         for(j=0;j<clen;j++)
        {
                c=illegalchars.charAt(j);
                if(str.indexOf(c)>0)
                {
                 return false;
                }
        }

  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 ;
}


/*
 * checkDateString(dateString, dateFormat, seperator)
 *
 * dateString     (string)     The string that is to validated.
 * dateFormat     (string)     The format in which the date is expected to be present in dateString. {dmy for ddmmyyyy, ymd for yyyymmdd}
 * seperator     (string)     The seperator that seperates the day, month & year from each other. Its possible values are - and /
 *
 * Returns Value:
 *  true if the date that you give is correct. Else it returns false.
 */

function checkDateString(dateString, dateFormat, seperator)
{
     var dmy = new Array();
     var day, month, year;

     dateFormat.toLowerCase();
     if(!checkAllowedChars(dateFormat, 'dmy'))
     {
          alert('checkDateString: Function usage error.\n\nInvalid date format.');
          return false;
     }

     if(seperator.length != 1 || (!checkAllowedChars(seperator, '/-')))
     {
          alert('checkDateString: Function usage error.\n\nInvalid seperator.');
          return false;
     }


     if(!checkAllowedChars(dateString, 'N' + seperator))
          return false;

     dmy = dateString.split(seperator);
     if(dmy.length == 3)
     {
          i = 0;
          while(dateFormat.length > 0)
          {
               fmtLen = countOccurance(dateFormat, dateFormat.charAt(0));

               switch(dateFormat.charAt(0))
               {
               case 'd':
                    day = dmy[i];
                    break

               case 'm':
                    month = dmy[i];
                    break

               case 'y':
                    year = dmy[i];
                    break
               }
               dateFormat = dateFormat.substring(fmtLen);
               i++;
          }

          if(!(day.length > 0 && month.length > 0 && year.length > 0))
               return false;

          return _checkDate(day, month, year);
     }
     return false;
}
/*
 * checkDate(day, month, year)
 *
 * As you expect day, month and year are the strings that contains the corresponding values.
 *
 * Returns Value:
 *  true if the date that you give is correct. Else it returns false.
 */

function checkDate(day, month, year)
{
     if(!checkAllowedChars(day + month + year, 'N'))
          return false;

     if((day.length <= 0) || (month.length <= 0) || (year.length <= 0))
          return false;

     return _checkDate(day, month, year);
}

function _checkDate(day, month, year)
{
     year *= 1;
     if(year <= 0)
          return false;

     month *= 1;
     if(!((month > 0) && (month < 13)))
          return false;

     var daysInMonth = new Array();
     daysInMonth[ 0] = 31;                         //Jan
     daysInMonth[ 1] = isLeap(year) == true? 29: 28;     //Feb
     daysInMonth[ 2] = 31;                         //Mar
     daysInMonth[ 3] = 30;                         //Apr
     daysInMonth[ 4] = 31;                         //May
     daysInMonth[ 5] = 30;                         //Jun
     daysInMonth[ 6] = 31;                         //Jul
     daysInMonth[ 7] = 31;                         //Aug
     daysInMonth[ 8] = 30;                         //Sep
     daysInMonth[ 9] = 31;                         //Oct
     daysInMonth[10] = 30;                         //Nov
     daysInMonth[11] = 31;                         //Dec

     day *= 1;
     if(!((day > 0) && (day <= daysInMonth[month - 1])))
          return false;

     return true;
}

function isLeap(year)
{
     if((year % 4) == 0)
     {
          if((year % 100) == 0)
          {
               if((year % 400) == 0)
                    return true;
               else
                    return false;
          }
          return true;
     }
     return false;
}


/*
 * checkDropDown(dropDown, alertMsg, moveNext)
 *
 * dropDown          (object)     The reference to the dropdown object.
 * alertMsg          (string)     The message to be alerted on finding error. If it is null('') then the message will not be displayed in case of an error.
 * moveNext          (boolean)     Says whether to move to the next option on error.
 *
 * Returns Value:
 *  true if there was no error. Else it returns false.
 *
 * Remark
 *  The options that are not to be allowed to select by the user should be given the value null ('').
 */

function checkDropDown(dropDown, alertMsg, moveNext)
{
     if(dropDown.options[dropDown.selectedIndex].value == '')
     {
          if(alertMsg != '')
               alert(alertMsg);

          if(moveNext)
               cddMoveForward(dropDown)

          return false;
     }
     return true;
}

function cddMoveBack(dropDown)
{
     var i;
     for(i = dropDown.selectedIndex - 1; i >= 0 && dropDown.options[i].value == ''; i--);
     if(i < 0)
          dropDown.options[dropDown.selectedIndex].selected = false;
     else
          dropDown.options[i].selected = true;
}

function cddMoveForward(dropDown)
{
     var i;
     for(i = dropDown.selectedIndex + 1; i < dropDown.options.length && dropDown.options[i].value == ''; i++);
     if(i >= dropDown.options.length)
          cddMoveBack(dropDown);
     else
          dropDown.options[i].selected = true;
}


/*
 * formFocus(frm)
 *
 * frm          (object)     The reference to the form object to be focused.
 *
 * Remark
 *  Passes the focus to the first element in the given form.
 */

function formFocus(frm)
{
     var fieldLen;
     if(frm != null && frm.elements)
     {
          fieldLen = frm.elements.length;
          var eleType;
          for(i = 0; i < fieldLen; i++)
          {
               eleType = frm.elements[i].type;
               if(eleType == 'select-multiple' || eleType == 'select-one' || eleType == 'text' || eleType == 'textarea' || eleType == 'checkbox' || eleType == 'radio')
               {
                    frm.elements[i].focus();
                    break;
               }
          }
     }
}

// Function to check whether an element is null or contain initial spaces.
function spaceCheck(formname, fieldname) {
        anyspacing = true;
        itemlength = eval("document." + formname + "." + fieldname + ".value.length");
        itemvalue = eval("document." + formname + "." + fieldname + ".value");
        for(i = 0; i < itemlength; i++) {
                if(itemvalue.charAt(i) != ' ') {
                        anyspacing = false;
                        break;
                }
        }
       eval("document." + formname + "." + fieldname + ".focus()");
        return anyspacing;
}

//---------------------------------------------------------------------------------------------------
//     to check space
//     parameters  (formname,fieldname)
//-----------------------------------------------------------------------------------------------------

function chkspace(formname,fieldname,msgname) {
     field = eval("document." + formname +"."+ fieldname);
        if (field.value.indexOf(' ') >= 0) {
             alert(msgname + " cannot contain space");
             field.focus();
             return false;
        }
        else {
             return true;
        }
}

function isEmpty(formname, fieldname) {
        itemvalue = eval('document.' + formname + '.' + fieldname + '.value');
        if(itemvalue.length <= 0) {
                return true;
        }
        icount = 0;
        for(i=0;i<itemvalue.length;++i) {
                if(itemvalue.charAt(i) != ' ') {
                        ++icount;
                }
        }
        if(icount > 0) {
                return false;
        }
        else {
                return true;
        }
}

function openWindow(type, page) {
     windowFeatures = "";
     if (type == 'showContent') {
          window_width = 640;
          window_height = 320;
          window_top = (screen.availHeight-window_height)/2
          window_left = (screen.availWidth-window_width)/2
          windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
          windowFeatures += window_top
          windowFeatures += ",left="
          windowFeatures += window_left
          windowFeatures += ",scrollbars=1"
     }

     window.open(page,type,windowFeatures)
}

function openWindowDownload(type, page, width, height)
{
     windowFeatures = "";
      window_width = width;
      window_height = height;
      window_top = (screen.availHeight-window_height)/2
      window_left = (screen.availWidth-window_width)/2
      windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
      windowFeatures += window_top
      windowFeatures += ",left="
      windowFeatures += window_left
      windowFeatures += ",scrollbars=0"

      window.open(page,type,windowFeatures) 
}

function openWindowCustom(type, page, width, height) {
     windowFeatures = "";
     if (type == 'showContent') {
          window_width = width;
          window_height = height;
          window_top = (screen.availHeight-window_height)/2
          window_left = (screen.availWidth-window_width)/2
          windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
          windowFeatures += window_top
          windowFeatures += ",left="
          windowFeatures += window_left
          windowFeatures += ",scrollbars=1"
     }
     else{
          window_width = width;
          window_height = height;
          window_top = (screen.availHeight-window_height)/2
          window_left = (screen.availWidth-window_width)/2
          windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
          windowFeatures += window_top
          windowFeatures += ",left="
          windowFeatures += window_left
          windowFeatures += ",scrollbars=1"
     }

     window.open(page,type,windowFeatures)
}

// function for home page section
function openWindowHome(type, page, width, height) {
     windowFeatures = "";
     if (type == 'showContent') {
          window_width = width;
          window_height = height;
          window_top = (screen.availHeight-window_height)/2
          window_left = (screen.availWidth-window_width)/2
          windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
          windowFeatures += window_top
          windowFeatures += ",left="
          windowFeatures += window_left
          windowFeatures += ",scrollbars=0"
     }
     window.open(page,type,windowFeatures)
}


function openSearchWindow(type, page, top, left) {
     windowFeatures = "";
          window_width = 620;
          window_height = 350;
          window_top = top;
          window_left = left;
          windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
          windowFeatures += window_top
          windowFeatures += ",left="
          windowFeatures += window_left
          windowFeatures += ",scrollbars=1,status=1"
          window.open(page,type,windowFeatures)
}


//----------
//to find element number after giving its name
function find_element(formname,  element_name, i)  {
     with(formname)  {
     //alert(elements[i].name);
          if (elements[i].name == element_name){
               return i;
          }
          else {
               return -1;
          }
     }
     return true;
}

//**********************************************************************************
// Check whether the provided data contain only numeric values.
// Accepts the form name, field name and display name.
//**********************************************************************************
function isNumeric(formname, fieldname, displayname)
{
        itemvalue = eval("document." + formname + "." + fieldname + ".value");
        if(itemvalue.length <= 0)
        {
                alert("Please enter a numeric value in \"" + displayname + "\"");
                eval("document." + formname + "." + fieldname + ".focus()");
                return false;
        }
        if(parseInt(itemvalue) <= 0)
        {
                alert("Please enter a numeric value greater than zero in \"" + displayname + "\"");
                eval("document." + formname + "." + fieldname + ".focus()");
                return false;
        }
        if(itemvalue.indexOf(' ') >= 0)
        {
                alert("Only numbers are allowed in \"" + displayname + "\"");
                eval("document." + formname + "." + fieldname + ".focus()");
                return false;
        }
        if(isNaN(itemvalue))
        {
                alert("Only numbers are allowed in \"" + displayname + "\"");
                eval("document." + formname + "." + fieldname + ".focus()");
                return false;
        }
        return true;
}

    function isNoBeginingSpaces(formname, fieldname, displayname)
{
        itemname = eval("document." + formname + "." + fieldname + ".value");
        if(itemname.charAt(0) == ' ')
        {
                alert("First character of \"" + displayname + "\" cannot be space");
                eval("document." + formname + "." + fieldname + ".focus()");
                return false;
        }
        else
        {
                return true;
        }
}


//**********************************************************************************
// Check whether any data is entered for processing.
// Accepts the form name, field name and the number non-empty items.
//**********************************************************************************
function isEmptySet(formname, fieldname, itemvalue)
{
        if(itemvalue > 0)
        {
                return true;
        }
        else
        {
                alert("No data available for processing.");
                eval("document." + formname + "." + fieldname + ".focus()");
                return false;
        }
}


//**********************************************************************************
// Check for blank spaces in a varible.  Used in validation for variables like file
// URLs, where no spaces are permitted.
// Accepts the form name, field name and display name.
//**********************************************************************************
function isNotSpaces(formname, fieldname, displayname)
{
        itemname = eval("document." + formname + "." + fieldname + ".value");
        if(itemname.indexOf(' ') >= 0)
        {
                alert("\"" + displayname + "\" cannot contain spaces");
                eval("document." + formname + "." + fieldname + ".focus()");
                return false;
        }
        else
        {
                return true;
        }
}


function OpenCustomWindow(turl, wd, ht, toolbar) {
        var windowFeatures =  '';

                window_width = wd;
                window_height = ht;
                window_top = (screen.availHeight-window_height)/2
                window_left = (screen.availWidth-window_width)/2
                windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
                windowFeatures += window_top
                windowFeatures += ",left="
                windowFeatures += window_left
                windowFeatures += ',status=1'
                windowFeatures += ',scrollbars=yes'
                if(toolbar == "y")
                {
                         windowFeatures += ',toolbar=yes'
                }
                else
                {
                         windowFeatures += ',toolbar=no'
                }
window.open(turl,"newwin",windowFeatures);

}

function OpenWindow(wintype, turl, wd, ht) {
        var windowFeatures =  '';
        if(wintype == 'tablename') {
                window_width = 450;
                window_height = 300;
                window_top = (screen.availHeight-window_height)/2
                window_left = (screen.availWidth-window_width)/2
                windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
                windowFeatures += window_top
                windowFeatures += ",left="
                windowFeatures += window_left
                windowFeatures += ',status=1'
                windowFeatures += ',scrollbars=yes'
        }
        if (wintype == 'general') {
          window_width = wd;
          window_height = ht;
          window_top = (screen.availHeight-window_height)/2
          window_left = (screen.availWidth-window_width)/2
          windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
          windowFeatures += window_top
          windowFeatures += ",left="
          windowFeatures += window_left
          windowFeatures += ',scrollbars=yes'
     }
        if (wintype == 'invoice') {
          window_width = wd;
          window_height = ht;
          window_top = (screen.availHeight-window_height)/2
          window_left = (screen.availWidth-window_width)/2
          windowFeatures += "width=" + window_width + ",height=" + window_height + ",top="
          windowFeatures += window_top
          windowFeatures += ",left="
          windowFeatures += window_left
          windowFeatures += ',scrollbars=yes,menubar=yes'
     }
window.open(turl,wintype,windowFeatures);
}


//***************************************
//FUNCTION TO CHECK THE DATE
//PARAMETERS ARE DAY, MONTH, MONTH NAME AND YEAR
//*************************************
function isDateN(d, m, mname, y) {
        if(d.length <= 0 || m.length <= 0 || y.length <= 0)  {
                alert("Please enter a valid date");
                return false;
        }


        a = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
      if(m == 2) {
                leapyear = (((y%4 == 0) && !(y%100 == 0)) || (y%400 == 0))?true:false;
                if(leapyear && d > 29) {
                        alert("There are only 29 days in February " + y + ". Please choose a valid date");
                        return false;
                }
                if(!leapyear && d > 28) {
                        alert("There are only 28 days in February " + y + ". Please choose a valid date");
                        return false;
                }
        }

        else if (d > a[m-1]){
                alert("There are only " + a[m-1] + " days in " + mname + ". Please choose a valid date");
                return false;
        }
   return true;

}

//******************************************
//Function to print the date as a dropdown
//First 3 Parameters are day, Month and Year Name
//Last 3 Parameters are value of day, month and year to be selected
//******************************************
function printDate(fday, fmonth, fyear, day1, month1, year1) {

        document.write('<TD ALIGN="LEFT"><FONT CLASS="mother_link_list"><SELECT NAME="' + fday + '" WIDTH="3" SIZE="1" CLASS="mother_link_list">');
        document.write('<OPTION VALUE="">Day</OPTION>');
        for(var i=1;i<=31;i++) {
            if (i == day1) {
                document.write('<OPTION VALUE="' + i + '" SELECTED="SELECTED">' + i + '</OPTION>');
            }else {
               document.write('<OPTION VALUE="' + i + '" >' + i + '</OPTION>');
            }
        }
        document.write('</SELECT></FONT><FONT CLASS="mother_link_list"><SELECT NAME="' + fmonth + '" WIDTH="5" SIZE="1" CLASS="mother_link_list">');
        document.write('<OPTION VALUE="">Month</OPTION>');
        var mon = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
        for(i=1;i<=12;i++) {
            if (i == month1) {
                document.write('<OPTION VALUE="' + i + '" SELECTED="SELECTED">' + mon[i-1] + '</OPTION>');
            }else {
                document.write('<OPTION VALUE="' + i + '">' + mon[i-1] + '</OPTION>');
            }

        }
        document.write('</SELECT></FONT><FONT CLASS="mother_link_list"><SELECT NAME="' + fyear + '" SIZE="1" WIDTH="5" CLASS="mother_link_list">');
        document.write('<OPTION VALUE="">Year</OPTION>');
        for(i=2003;i<=2020;i++) {
            if (i == year1) {
                document.write('<OPTION VALUE="' + i + '" SELECTED="SELECTED">' + i + '</OPTION>');
            }else {
                document.write('<OPTION VALUE="' + i + '">' + i + '</OPTION>');
            }

        }
        document.write('</SELECT></FONT></TD>');
}
//-----------
/*Please don't delete this line </SCRIPT></HEAD><BODY STYLE="background-color:black;color:gray">
<FORM name=form1 onSubmit="alert(checkDateString(document.form1.dateInput.value, document.form1.dateFormat.value, document.form1.seperator.options[document.form1.seperator.selectedIndex].value)); return false"><TABLE><TR><TD ALIGN=RIGHT>Date:</TD><TD ALIGN=LEFT><INPUT STYLE="background-color:black;color:gray;border:1 solid" TYPE=TEXT name=dateInput></TD></TR><TR><TD ALIGN=RIGHT>Date Format:</TD><TD ALIGN=LEFT><INPUT STYLE="background-color:black;color:gray;border:1 solid" TYPE=TEXT name=dateFormat></TD></TR><TR><TD ALIGN=RIGHT>Seperator:</TD><TD ALIGN=LEFT><SELECT STYLE="background-color:black;color:gray;border:1 solid" NAME=seperator SIZE=1><OPTION VALUE='/'>/</OPTION><OPTION VALUE='-'>-</OPTION></SELECT></TD></TR><TR><TD ALIGN=CENTER COLSPAN=2><INPUT STYLE="background-color:black;color:gray;border:1 solid" TYPE=submit onMouseOver="this.style.backgroundColor='#555555';this.style.color='#bbbbbb'" onMouseOut="this.style.backgroundColor='black';this.style.color='gray'"></TD></TR></TABLE></FORM>
</BODY></HTML>*/


function CheckEmail(stremail)
{ 
  var err;
  var str=stremail;
  var ValidChars = "0123456789.";
  var validdom   = "0123456789";
  var illegalchars="#$!%^&*();:<>+/\?|";
  var i;
  var c;
  var l;
  var n;
  var at="@";
  var dot=".";
  var lat=str.indexOf(at);
  var lstr=str.length;
  var ldot=str.indexOf(dot);
  
    i=0;
   c = str.charAt(i); 
  
   if (ValidChars.indexOf(c) !=-1) 
   { return false; }
 
   l=str.indexOf(dot)+1;
   n=str.charAt(l);
  
   if(n=="")
   { return false; }
   
   for(i=l;i<lstr;i++)
   {
     l=str.charAt(i); 
		 
	 if (validdom.indexOf(l)!=-1) 
	 { return false; }
   }
   
   	clen=illegalchars.length;
 	for(j=0;j<clen;j++)
	{
		c=illegalchars.charAt(j);
		if(str.indexOf(c)>0)
		{
		 return false;	
		}
	}
   
  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 ;        
}


  //----------------------------------Start AJAX code-----------------------------
/******************************************************************************/
//function name :createRequestObject
/******************************************************************************/
   function createRequestObject(){//function start
      var xmlhttp=false;
      try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");  }
      catch(e){//first catch start brace
          try{
              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          }catch(e){//start sec catch
              xmlhttp=false;
          }    //end sec catch
      }//first catch end brace
      if(!xmlhttp && typeof XMLHttpRequest !='undefined'){
        xmlhttp=new XMLHttpRequest();
      }return xmlhttp;
    }//function end
//----------------------------------End AJAX code-----------------------------


/*==========================================================================# 
# * Function for adding a Filter to an Input Field                          # 
# * @param  : [filterType  ] Type of filter 0=>Alpha, 1=>Num, 2=>AlphaNum   # 
# * @param  : [evt         ] The Event Object                               # 
# * @param  : [allowDecimal] To allow Decimal Point set this to true        # 
# * @param  : [allowCustom ] Custom Characters that are to be allowed       # 
#==========================================================================*/ 
function filterInput(filterType, evt, allowDecimal, allowCustom){ 
    var keyCode, Char, inputField, filter = ''; 
    var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 
    var num   = '0123456789'; 
    // Get the Key Code of the Key pressed if possible else - allow 
    if(window.event){ 
        keyCode = window.event.keyCode; 
        evt = window.event; 
    }else if (evt)keyCode = evt.which; 
    else return true; 
    // Setup the allowed Character Set 
    if(filterType == 0) filter = alpha; 
    else if(filterType == 1) filter = num; 
    else if(filterType == 2) filter = alpha + num; 
    if(allowCustom)filter += allowCustom; 
    if(filter == '')return true; 
    // Get the Element that triggered the Event 
    inputField = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget; 
    // If the Key Pressed is a CTRL key like Esc, Enter etc - allow 
    if((keyCode==null) || (keyCode==0) || (keyCode==8) || (keyCode==9) || (keyCode==13) || (keyCode==27) )return true; 
    // Get the Pressed Character 
    Char = String.fromCharCode(keyCode); 
    // If the Character is a number - allow 
    if((filter.indexOf(Char) > -1)) return true; 
    // Else if Decimal Point is allowed and the Character is '.' - allow 
    else if(filterType == 1 && allowDecimal && (Char == '.') && inputField.value.indexOf('.') == -1)return true; 
    else return false; 
}
    
//country array
var arrCountry = new Object();

arrCountry['AL']='Albania';
arrCountry['DZ']='Algeria';
arrCountry['AD']='Andorra';
arrCountry['AO']='Angola';
arrCountry['AI']='Anguilla';
arrCountry['AG']='Antigua and Barbuda';
arrCountry['AR']='Argentina';
arrCountry['AM']='Armenia';
arrCountry['AW']='Aruba';
arrCountry['AU']='Australia';
arrCountry['AT']='Austria';
arrCountry['AZ']='Azerbaijan Republic';
arrCountry['BS']='Bahamas';
arrCountry['BH']='Bahrain';
arrCountry['BB']='Barbados';
arrCountry['BE']='Belgium';
arrCountry['BZ']='Belize';
arrCountry['BJ']='Benin';
arrCountry['BM']='Bermuda';
arrCountry['BT']='Bhutan';
arrCountry['BO']='Bolivia';
arrCountry['BA']='Bosnia and Herzegovina';
arrCountry['BW']='Botswana';
arrCountry['BR']='Brazil';
arrCountry['BN']='Bangladesh';
arrCountry['VG']='British Virgin Islands';
arrCountry['BN']='Brunei';
arrCountry['BG']='Bulgaria';
arrCountry['BF']='Burkina Faso';
arrCountry['BI']='Burundi';
arrCountry['KH']='Cambodia';
arrCountry['CA']='Canada';
arrCountry['CV']='Cape Verde';
arrCountry['KY']='Cayman Islands';
arrCountry['TD']='Chad';
arrCountry['CL']='Chile';
arrCountry['C2']='China';
arrCountry['CO']='Colombia';
arrCountry['KM']='Comoros';
arrCountry['CK']='Cook Islands';
arrCountry['CR']='Costa Rica';
arrCountry['HR']='Croatia';
arrCountry['CY']='Cyprus';
arrCountry['CZ']='Czech Republic';
arrCountry['CD']='Democratic Republic of the Congo';
arrCountry['DK']='Denmark';
arrCountry['DJ']='Djibouti';
arrCountry['DM']='Dominica';
arrCountry['DO']='Dominican Republic';
arrCountry['EC']='Ecuador';
arrCountry['SV']='El Salvador';
arrCountry['ER']='Eritrea';
arrCountry['EE']='Estonia';
arrCountry['ET']='Ethiopia';
arrCountry['FK']='Falkland Islands';
arrCountry['FO']='Faroe Islands';
arrCountry['FM']='Federated States of Micronesia';
arrCountry['FJ']='Fiji';
arrCountry['FI']='Finland';
arrCountry['FR']='France';
arrCountry['GF']='French Guiana';
arrCountry['PF']='French Polynesia';
arrCountry['GA']='Gabon Republic';
arrCountry['GM']='Gambia';
arrCountry['DE']='Germany';
arrCountry['GI']='Gibraltar';
arrCountry['GR']='Greece';
arrCountry['GL']='Greenland';
arrCountry['GD']='Grenada';
arrCountry['GP']='Guadeloupe';
arrCountry['GT']='Guatemala';
arrCountry['GN']='Guinea';
arrCountry['GW']='Guinea Bissau';
arrCountry['GY']='Guyana';
arrCountry['HN']='Honduras';
arrCountry['HK']='Hong Kong';
arrCountry['HU']='Hungary';
arrCountry['IS']='Iceland';
arrCountry['IN']='India';
arrCountry['ID']='Indonesia';
arrCountry['IE']='Ireland';
arrCountry['IR']='Iran';
arrCountry['IL']='Israel';
arrCountry['IT']='Italy';
arrCountry['JM']='Jamaica';
arrCountry['JP']='Japan';
arrCountry['JO']='Jordan';
arrCountry['KZ']='Kazakhstan';
arrCountry['KE']='Kenya';
arrCountry['KI']='Kiribati';
arrCountry['KW']='Kuwait';
arrCountry['KG']='Kyrgyzstan';
arrCountry['LA']='Laos';
arrCountry['LV']='Latvia';
arrCountry['LS']='Lesotho';
arrCountry['LI']='Liechtenstein';
arrCountry['LT']='Lithuania';
arrCountry['LU']='Luxembourg';
arrCountry['MG']='Madagascar';
arrCountry['MW']='Malawi';
arrCountry['MY']='Malaysia';
arrCountry['MV']='Maldives';
arrCountry['ML']='Mali';
arrCountry['MT']='Malta';
arrCountry['MH']='Marshall Islands';
arrCountry['MQ']='Martinique';
arrCountry['MR']='Mauritania';
arrCountry['MU']='Mauritius';
arrCountry['YT']='Mayotte';
arrCountry['MX']='Mexico';
arrCountry['MN']='Mongolia';
arrCountry['MS']='Montserrat';
arrCountry['MA']='Morocco';
arrCountry['MZ']='Mozambique';
arrCountry['NA']='Namibia';
arrCountry['NR']='Nauru';
arrCountry['NP']='Nepal';
arrCountry['NL']='Netherlands';
arrCountry['AN']='Netherlands Antilles';
arrCountry['NC']='New Caledonia';
arrCountry['NZ']='New Zealand';
arrCountry['NI']='Nicaragua';
arrCountry['NE']='Niger';
arrCountry['NU']='Niue';
arrCountry['NF']='Norfolk Island';
arrCountry['NO']='Norway';
arrCountry['OM']='Oman';
arrCountry['PW']='Palau';
arrCountry['PK']='Pakistan';
arrCountry['PA']='Panama';
arrCountry['PG']='Papua New Guinea';
arrCountry['PE']='Peru';
arrCountry['PH']='Philippines';
arrCountry['PN']='Pitcairn Islands';
arrCountry['PL']='Poland';
arrCountry['PT']='Portugal';
arrCountry['QA']='Qatar';
arrCountry['CG']='Republic of the Congo';
arrCountry['RE']='Reunion';
arrCountry['RO']='Romania';
arrCountry['RU']='Russia';
arrCountry['RW']='Rwanda';
arrCountry['VC']='Saint Vincent and the Grenadines';
arrCountry['WS']='Samoa';
arrCountry['SM']='San Marino';
arrCountry['ST']='São Tomé and Príncipe';
arrCountry['SA']='Saudi Arabia';
arrCountry['SN']='Senegal';
arrCountry['SC']='Seychelles';
arrCountry['SL']='Sierra Leone';
arrCountry['SG']='Singapore';
arrCountry['SK']='Slovakia';
arrCountry['SI']='Slovenia';
arrCountry['SB']='Solomon Islands';
arrCountry['SO']='Somalia';
arrCountry['ZA']='South Africa';
arrCountry['KR']='South Korea';
arrCountry['ES']='Spain';
arrCountry['LK']='Sri Lanka';
arrCountry['SH']='St. Helena';
arrCountry['KN']='St. Kitts and Nevis';
arrCountry['LC']='St. Lucia';
arrCountry['PM']='St. Pierre and Miquelon';
arrCountry['SR']='Suriname';
arrCountry['SJ']='Svalbard and Jan Mayen Islands';
arrCountry['SZ']='Swaziland';
arrCountry['SE']='Sweden';
arrCountry['CH']='Switzerland';
arrCountry['TW']='Taiwan';
arrCountry['TJ']='Tajikistan';
arrCountry['TZ']='Tanzania';
arrCountry['TH']='Thailand';
arrCountry['TG']='Togo';
arrCountry['TO']='Tonga';
arrCountry['TT']='Trinidad and Tobago';
arrCountry['TN']='Tunisia';
arrCountry['TR']='Turkey';
arrCountry['TM']='Turkmenistan';
arrCountry['TC']='Turks and Caicos Islands';
arrCountry['TV']='Tuvalu';
arrCountry['UG']='Uganda';
arrCountry['UA']='Ukraine';
arrCountry['AE']='United Arab Emirates';
arrCountry['US']='United States of America';
arrCountry['GB']='United Kingdom';
arrCountry['UY']='Uruguay';
arrCountry['VU']='Vanuatu';
arrCountry['VA']='Vatican City State';
arrCountry['AE']='United Arab Emirates';
arrCountry['VE']='Venezuela';
arrCountry['VN']='Vietnam';
arrCountry['WF']='Wallis and Futuna Islands';
arrCountry['YE']='Yemen';
arrCountry['ZM']='Zambia';

