<!-- Begin
// *************************
// Check Date..
function isValidDate(dateStr, dateEliment)
{
var datePat = /^(\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/;

var matchArray = dateStr.match(datePat);
if (matchArray == null)
{
 alert("Date is not in \"yyyy/mm/dd/ format.");
 dateEliment.focus();
 return false;
}
month = matchArray[3];
day   = matchArray[4];
year  = matchArray[1];

if (month < 1 || month > 12)
{
  alert("Month must be between 1 and 12.");
  dateEliment.focus();
return false;
}
if (day < 1 || day > 31)
{
  alert("Day must be between 1 and 31.");
  dateEliment.focus();
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31)
{
  alert("Month "+month+" doesn't have 31 days!");
  dateEliment.focus();
  return false
}
if (month == 2)
{
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
  alert("February " + year + " doesn't have " + day + " days!");
  dateEliment.focus();
  return false;
}
}
return true;
}
// *************************

// *************************
// Check Spaces..
function CheckSpace(theEliment)
{
 sVal = theEliment.value;
 while (sVal.substring(0,1) == ' ')
	sVal = sVal.substring(1);
 while (sVal.substring(sVal.length-1,sVal.length) == ' ')
	sVal = sVal.substring(0,sVal.length-1);
	theEliment.value = sVal;
 if(sVal =='')
 {
   alert('System does not accept spaces.');
   theEliment.focus();
   return (false);
 }
 return (true);
}
// *************************

// *************************
// Check Null Values...
function NullCheck(theEliment,theMsg)
{
 if(theEliment.value=="")
  {
    alert(theMsg);
    theEliment.focus();
    return (false);
  }
 return (true);
}
// *************************

// *************************
// Check Min Length...
function MinCheck(theEliment,theMsg, theMin)
{
 if(theEliment.value.length < theMin)
  {
    alert(theMsg);
    theEliment.focus();
    return (false);
  }
 return (true);
}
// *************************

// *************************
// Check Max Length...
function MaxCheck(theEliment,theMsg, theMax)
{
 if(theEliment.value.length > theMax)
  {
    alert(theMsg);
    theEliment.focus();
    return (false);
  }
 return (true);
}
// *************************

// *************************
// Check Min value
function MinVal(theEliment,theMsg, theMin)
{
 if(theEliment.value < theMin)
  {
    alert(theMsg);
    theEliment.focus();
    return (false);
  }
 return (true);
}
// *************************

// *************************
// Check Max Length...
function MaxVal(theEliment,theMsg, theMax)
{
 if(theEliment.value > theMax)
  {
    alert(theMsg);
    theEliment.focus();
    return (false);
  }
 return (true);
}
// *************************

// *************************
// Pattern Check..
function CharCheck(theEliment, theCharSet, theMsg)
{
  var checkOK  = theCharSet;
  var checkStr = theEliment.value;
  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;
      alert('Character \"' + ch + theMsg);
      break;
    }
  }
  if (!allValid)
  {
    theEliment.select();
    return (false);
  }
  return (true);
}
// *************************


// *************************
// Sumbit Only Once..
function submitonce(theform, theEliment)
{
 	if (document.all||document.getElementById){
    		for (i=0;i<theform.length;i++){
        		if(theform.elements[i].type == 'submit')
        		{
        		   theform.elements[i].disabled=true;
        		}
    		}
  	}
}
// *************************

// *************************
// Check Phone Number
function intPhoneNo(theEliment)
{
   refno=/^[+]{1}\d[0-9]{1,10}$/;
   if(!refno.test(theEliment.value))
   {
      alert('Phone Number is not in International Format(+9472666890).');
      theEliment.select();
      return (false);
   }
  return (true);
}
// *************************

// *************************
// Check Pattern
function paternCheck(theEliment, thePattern, theMsg)
{
   if(!thePattern.test(theEliment.value))
   {
      alert(theMsg);
      theEliment.select();
      return (false);
   }
  return (true);
}
// *************************

// *************************
// Count Character
function CountChar(theEliment, theTarget)
{
	theTarget.value = theEliment.value.length;
}
// *************************

// *************************
// Restric Lenth
function RestrictLenth(theEliment,theMsg, theMax)
{
 if(theEliment.value.length > theMax)
  {
    alert(theMsg);
    theEliment.value = theEliment.value.substring(0,theMax)
    theEliment.focus();
    return (false);
  }
 return (true);   
}
// *************************

// *************************
// Restric Lenth
function SelectedIndex(theEliment,theMsg)
{
 if(theEliment.selectedIndex < 1)
  {
    alert(theMsg);
    theEliment.focus();
    return (false);
  }
 return (true);   
}
// *************************

// Function Equal Check
function equalChk(FirstEliment, SecondEliment, Msg) 
{
    if(FirstEliment.value != SecondEliment.value) 
	{
	  alert(Msg);
	  SecondEliment.select()
	  return false;
	}
  return (true);
}

// Function Check Box
function checked(FirstEliment, Msg) 
{
    if(!FirstEliment.checked) 
	{
	  alert(Msg);
	  FirstEliment.focus()
	  return false;
	}
  return (true);
}
// ************************

// ************************
// Open Window..
function Open(sUrl, sName, iWidth, iHight)
{
  iX = (window.screen.width/2) - (iWidth/2);
  iY = (window.screen.height/2) - (iHight/2);
  window.open(sUrl,sName,"width=iWidth,height=iHight,menu=no,status=no,resizable=no,top=iY,left=iX");
}
// ************************

function SelectVal(theEliment, VarText)
{
        cmblen = theEliment.options.length;
        for (i=0; i<cmblen; i++){
                 var org = theEliment.options[i].value
                 if( org != VarText)
                 {
                   continue;
                 }
                 else
                 return i;
        }
}

//Past Day Check..
function PastDayCheck(sYear, sMonth, sDay, sEnYear, sEnMonth, sENDay, oEliment, sMsg)
{
	var dateToday	= new Date(sYear, sMonth, sDay);
	var dateEntered = new Date(sEnYear, sEnMonth, sENDay);
	if(dateEntered > dateToday)
	{
	   return true;
	}
	else
	{
		alert(sMsg);
		oEliment.focus()
		return false;
	}
}
//  End -->