//checking for a valid image file extensions
function checkFile(field)
{
		var path,extn,dotposn
		path=trimText(field)
		dotposn=path.lastIndexOf(".")
		if (dotposn==-1)
		{
			alert("Invalid file selected for image. Only the following types of files are allowed for images...\n*.gif, *.jpg, *.jpeg,*.tif,*.tiff,*.bmp,*.ico")
 			return false
		}
		else 
		{
			extn=path.substring(dotposn,path.length).toLowerCase()
			if (!(extn==".jpg" || extn==".jpeg" || extn==".gif" || extn==".ico" || extn==".tif" || extn==".tiff" || extn==".bmp" || extn==".png"))
			{
				alert("Invalid file selected for image. Only the following types of files are allowed for images...\n*.gif, *.jpg, *.jpeg,*.tif,*.tiff,*.bmp,*.ico,*.png")
				return false
			}
		}
		return true
}

//checking for a valid image file extensions
function checkPricelistFile(field)
{
		var path,extn,dotposn
		path=trimText(field)
		dotposn=path.lastIndexOf(".")
		if (dotposn==-1)
		{
			alert("Invalid file selected for pricelist upload. Only the following types of files are allowed ...\n*.pdf, *.xls, *.txt, *.doc, *.rtf")
			return false
		}
		else
		{
			extn=path.substring(dotposn,path.length).toLowerCase()
			if (!(extn==".pdf" || extn==".xls" || extn==".txt" || extn==".doc" || extn==".rtf"))
			{
				alert("Invalid file selected for pricelist upload. Only the following types of files are allowed ...\n*.pdf, *.xls, *.txt, *.doc, *.rtf")
				return false
			}
		}
		return true
}

function checkEmail(strField,strFieldValue)
{
	var emailStr = strFieldValue
	/* The following pattern is used to check if the entered e-mail address fits the user@domain format.It also is used to
	separate the username from the domain.*/
	var emailPat=/^(.+)@(.+)$/
	/* The following string represents the pattern for matching all special characters.We don't want to allow special characters
	in the address.These characters include ( ) < > @ , ; : \ " . [ ]*/
	var specialChars="\\(\\)<>@,;:!\\\\\\\"\\.\\[\\]"
	/* The following string represents the range of characters allowed in a username or domainname.It really states which
	chars aren't allowed. */
	var validChars="\[^\\s" + specialChars + "\]"
	/* The following pattern applies if the "user" is a quoted string (in which case, there are no rules about which characters
	are allowed and which aren't; anything goes).E.g. "jiminy cricket"@disney.com is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")"
	/* The following pattern applies for domains that are IP addresses,rather than symbolic names.E.g. joe@[123.124.233.4] is
	a legal e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	/* The following string represents an atom (basically a series of non-special characters.) */
	var atom=validChars + '+'
	/* The following string represents one word in the typical username.For example, in john.doe@somewhere.com, john and doe
	are words.Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")"
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	/* The following pattern describes the structure of a normal symbolic domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null)
	{
		/* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */
		strField.focus()
		strField.select()
		alert("Email address is incorrect (check @ and .'s)")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	// See if "user" is valid 
	if (user.match(userPat)==null)
	{
		// user is not valid
		strField.focus()
		strField.select()
		alert("The username is invalid. Please verify")
		return false
	}
	/* if the e-mail address is at an IP address (as opposed to a symbolic host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null)
	{
	   // this is an IP address
	  for (var i=1;i<=4;i++)
	  {
	    if (IPArray[i]>255)
	    {
			strField.focus()
			strField.select()
			alert("Destination IP address is invalid!")
			return false
		}
	   }
	   return true
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null)
	{
		strField.focus()
		strField.select()
		alert("The domain name is invalid. Please verify")
	    return false
	}

	/* domain name seems valid, but now make sure that it ends in a three-letter word (like com, edu, gov) or a two-letter
	word,representing country (uk, nl), and that there's a hostname preceding the domain or country. */
	/* Now we need to break up the domain to get a count of how many atoms it consists of. */
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
	{
	   // the address must end in a two letter or three letter word.
	   strField.focus()
	   strField.select()
	   alert("The Email address must end in a three-letter domain, or two letter country.")
	   return false
	}

	// Make sure there's a host name preceding the domain.
	if (len<2)
	{
	   var errStr="This Email address is missing a hostname!"
	   strField.focus()
	   strField.select()
	   alert(errStr)
	   return false
	}
	// If we've gotten this far, everything's valid!
	return true;
}

//checking for a valid URL 
function checkURL(theField,strURL)
{
	if( strURL != '')
	{
		var i,len,f,test;
		len=strURL.length;
		f=false;
		var st=strURL.substring((len-4),(len));
		var l=strURL.substring((len-3),(len-2));	
		var last=strURL.substring((len-6),(len-5));
		//if( ((strURL.substring(0,7)=="http://")||(strURL.substring(0,4)=="www.")) &&((st==".com/") ||(st==".com")||(st==".net")||(st==".org")||(st==".mil")||(st==".edu")||(st==".fru")) )
		if((strURL.substring(0,7) != "http://")||(strURL.substring(7,11) != "www."))
		{
			theField.focus();
			alert("Invalid URL. Please re-enter.")
			return false;
		}
		if((strURL.substring(0,7)=="http://")||(strURL.substring(7,11)=="www."))
		{
			if((strURL.substring(0,7)=="http://")&&((strURL.substring(7,9)!="ww")||(strURL.substring(7,11)!="wwww")))
			{
					return true;
			}
			else if(strURL.substring(7,11)=="www.")
				return true;
			else
			{
				theField.focus();
				alert("Invalid URL. Please re-enter.")
				return false;
			}
		}
		else if(((strURL.substring(0,7)=="http://")||(strURL.substring(7,11)=="www."))&&((l==".")&&(last==".")))
		{
			return true;
		}
		else
		{
			theField.focus();
			alert("Invalid URL. Please re-enter.")
			return false;
		}
	}
	else
		return true;
}

//Trimming a String
function  trimText(fldName)
{
	var name=fldName.value;
	while(name.charAt(0)==' ')
	{
		name=name.substring(1,name.length);
	}
	while(name.charAt((name.length)-1)==' ')
		name=name.substring(0,(name.length)-1);
	return name;
}

// Check whether string  is empty.
function isEmpty(s)
{ 
	return ((s == null) || (s.length == 0))
}

//used in the function that checks for a Valid Zip Code
function isZIPCode (s)
{  if (isEmpty(s)) 
       if (isZIPCode.arguments.length == 1) return false;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) && 
            ((s.length == 5) ||
             (s.length == 9)))
}

//checking for a valid ZIP Code
function checkZIPCode (fldName)
{   
     var normalizedZIP = putChars(fldName.value, "-")
      if (!isZIPCode(normalizedZIP, false)) 
         return false //showAlert (fldName, "ZIP field must be a 5 or 9 digit code (like 94043). Please reenter it now.");
      else 
      {  
         fldName.value = reformatZIPCode(normalizedZIP)
         return true;
      }
    
}

//Reformats the ZIP Code as a String
function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}

//puts the specified characters(second argument) into the String 
function putChars (s, chars)

{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (chars.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

//shows alert messages and puts the focus in the form element 
function showAlert(fldName, s)
{   
	alert(s)
	fldName.focus()
    fldName.select()
    return false
}

//checking for a Valid Phone Number
function checkPhone (fldName)
{   
      var normalizedPhone = putChars(fldName.value, "()- ")
       if (!isPhoneNumber(normalizedPhone, false)) 
          return false //showAlert (fldName, "Phone field must be a 10 digit number (like 4155551212). Please reenter it now.");
       else 
       {
			fldName.value = reformatPhoneNumber(normalizedPhone)
			return true;
       }
   
}

//Used in the function that checks for a valid Phone number
function isPhoneNumber (s)
{   
    return (isInteger(s) && s.length == 10)
}

//Reformats the Phone Number as a String
function reformatPhoneNumber (PhoneNo)
{   return (reformat (PhoneNo, "(", 3, ") ", 3, "-", 4))
}

//Checking for a valid number
function isInteger (s)
{   
	var i;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }
    return true;
}

//Checking for a valid Digit
function isDigit (c)
{
	return ((c >= "0") && (c <= "9"))
}

//Reformats a String into a specific Format
function reformat (s)
{   
	var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

//Checking for a Valid Time Format
function checkTime(fldName)
{
	var strHours=fldName.value;
	len=strHours.length;
	as=1;
	if(strHours=="" || len>=6)
	{
		//alert(" Please enter Hour(s) After in format HH:MM")
		return false;
	}
	else
	{
		if(len<=4)
		{
			as=checkHours(strHours);
			if(as==2)
			{
				return true;
			}
			else
			{
				//alert(" Please enter Hour(s) After in format HH:MM")
				return false;
			}
		}
		if(len==5)
		{
			as=checkMinutes(strHours);
			if(as==2)
			{
				return true;
			}
			else
			{
				//alert(" Please enter Hour(s) After in format HH:MM")
				return false;
			}

		}

	}

}

//Used in the function that checks for a valid time
function checkHours(str)
{
	str1=str;valid=1;
	for(i=1;i<=9;i++)
	{  
		for(j=0;j<=5;j++)
		{ 
			for(k=0;k<=9;k++)
			{ 
				str2=""+i+":"+j+k;
		        if(str1==str2)
				{ 
					valid=2;
				}
			}
		 }
	}
	if(valid==2) 
	{
		return 2;
	}
	else
	{
		return 1;
	}
}	

//Used in the function that checks for a valid time
function checkMinutes(str)
{
	str1=str
	valid=1; 
 	for(l=0;l<=2;l++)
	{
		if(l==2) 
			ii=3;
		else
			ii=9;
		for(i=0;i<=ii;i++)
		{ 
			for(j=0;j<=5;j++)
			{
				 for(k=0;k<=9;k++)
		   		 {
					str2=""+l+i+":"+j+k;
 			        if(str1==str2)
					{ 
						valid=2;
					}
				 }
			 }
		}
	}

	if(valid==2) 
	{
		return 2;
	}
	else
	{
		return 1;
	}

} 

//checking for a Valid character String
function isValidCharsString(theField,strval)
{
		  validCharsString=/^[a-zA-Z0-9. ]+$/;
		  if (validCharsString.test(strval)==false )
		  {
			theField.focus();
			theField.select();
			return false;
		  }
		  else
			return true
}

//checking for a Valid jobs applied for String (Employment Application)
function isValidPositionsString(theField,strval)
{
		  validCharsString=/^[a-zA-Z0-9,\- ]+$/;
		  if (validCharsString.test(strval)==false )
		  {
			theField.focus();
			theField.select();
			return false;
		  }
		  else
			return true
}

//checking for a Valid wages expected per String (Employment Application)
function isValidWageString(theField,strval)
{
		  validCharsString=/^[a-zA-Z]+$/;
		  if (validCharsString.test(strval)==false )
		  {
			theField.focus();
			theField.select();
			return false;
		  }
		  else
			return true
}

//checking for a Valid Password String
 function isValidPwdCharsString(theField,strval)
{

		  validCharsString=/^[a-zA-Z0-9_]+$/;
		  if (validCharsString.test(strval)==false )
		  {
			theField.focus();
			theField.select();
			return false;
		  }
		  else
			return true
}

//checking for a Valid Date
function isDate(dateStr,strField) 
{
    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?
    
    if (matchArray == null) {
        return false;
    }

    month = matchArray[1]; // parse date into variables
    day = matchArray[3];
    year = matchArray[5];

    if (month < 1 || month > 12) 
    { 
        alert("Month must be between 1 and 12 for " + strField);
        return false;
    }

    if (day < 1 || day > 31) 
    {
        alert("Day must be between 1 and 31 for " + strField);
        return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) 
    {
		alert("Month "+month+" doesn't have 31 days for " + strField)
        return false;
    }

    if (month == 2) 
    { // check for february 29th
        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 for " + strField);
            return false;
        }
    }
    return true; 
}

//Checking whether the selected date in greater than present date or not
function checkDate(month,date,year)
{

/*month = document.forms[0].month.options[document.forms[0].month.selectedIndex].value;
date=document.forms[0].date.options[document.forms[0].date.selectedIndex].value;
year=document.forms[0].year.options[document.forms[0].year.selectedIndex].value;*/

var workorderdate = new Date();

workorderdate.setMonth(month-1);
workorderdate.setDate(date);
workorderdate.setYear(year);

var currentdate=new Date();

if(workorderdate<currentdate)
	return false;
else
	return true;
}

//Used to delete functionality in the forms
function Delete(strConfirmationMessage,strUncheckedMessage)
{
	if(SelectAtleastOne())
	{
		var blnDelConfirm = confirm(strConfirmationMessage);

		if (blnDelConfirm == true)
			{
				document.forms[0].hdnFormAction.value = "Delete";
				document.forms[0].submit();
			}
	}

	else
	{
		alert(strUncheckedMessage);
	}
}

function SelectAtleastOne()
{
	var selCount=0;

	for(i=0; i<document.forms[0].elements.length; i++) 
	{
		if (document.forms[0].elements[i].name=="chkUser")
		{
		if (document.forms[0].elements[i].checked == true)
		{
		selCount++;
		}
		}
	}
	if(selCount==0)
		return false;
	else
		return true;
}

function FormatDateTime(datetime, FormatType)
/*
	 FomatType takes the following values
		1 - General Date = Friday, October 30, 1998
		2 - Typical Date = 10/30/98
		3 - Standard Time = 6:31 PM
		4 - Military Time = 18:31
*/
{
	var strDate = new String(datetime);

	if (strDate.toUpperCase() == "NOW") {
		var myDate = new Date();
		strDate = String(myDate);
	} else {
		var myDate = new Date(datetime);
		strDate = String(myDate);
	}


	// Get the date variable parts
	var Day = new String(strDate.substring(0,3));
	if (Day == "Sun") Day = "Sunday";
	if (Day == "Mon") Day = "Monday";
	if (Day == "Tue") Day = "Tuesday";
	if (Day == "Wed") Day = "Wednesday";
	if (Day == "Thu") Day = "Thursday";
	if (Day == "Fri") Day = "Friday";
	if (Day == "Sat") Day = "Saturday";	
	
	var Month = new String(strDate.substring(4,7)), MonthNumber = 0;
	if (Month == "Jan") { Month = "January"; MonthNumber = 1; }
	if (Month == "Feb") { Month = "February"; MonthNumber = 2; }
	if (Month == "Mar") { Month = "March"; MonthNumber = 3; }
	if (Month == "Apr") { Month = "April"; MonthNumber = 4; }
	if (Month == "May") { Month = "May"; MonthNumber = 5; }
	if (Month == "Jun") { Month = "June"; MonthNumber = 6; }
	if (Month == "Jul") { Month = "July"; MonthNumber = 7; }
	if (Month == "Aug") { Month = "August"; MonthNumber = 8; }
	if (Month == "Sep") { Month = "September"; MonthNumber = 9; }
	if (Month == "Oct") { Month = "October"; MonthNumber = 10; }
	if (Month == "Nov") { Month = "November"; MonthNumber = 11; }
	if (Month == "Dec") { Month = "December"; MonthNumber = 12; }
	
	var curPos = 11;
	var MonthDay = new String(strDate.substring(8,10));
	if (MonthDay.charAt(1) == " ") {
		MonthDay = "0" + MonthDay.charAt(0);
		curPos--;
	}	
	
	var MilitaryTime = new String(strDate.substring(curPos,curPos + 5));
	
	var Year = new String(strDate.substring(strDate.length - 4, strDate.length));	
	
	document.write(strDate + "");	

	// Format Type decision time!
	if (FormatType == 1)
		strDate = Day + ", " + Month + " " + MonthDay + ", " + Year;
	else if (FormatType == 2)
		strDate = MonthNumber + "/" + MonthDay + "/" + Year.substring(2,4);
	else if (FormatType == 3) {
		var AMPM = MilitaryTime.substring(0,2) >= 12 && MilitaryTime.substring(0,2) != "24" ? " PM" : " AM";
		if (MilitaryTime.substring(0,2) > 12)
			strDate = (MilitaryTime.substring(0,2) - 12) + ":" + MilitaryTime.substring(3,MilitaryTime.length) + AMPM;
		else {
			if (MilitaryTime.substring(0,2) < 10)
				strDate = MilitaryTime.substring(1,MilitaryTime.length) + AMPM;
			else
				strDate = MilitaryTime + AMPM;
		}
	}	
	else if (FormatType == 4)
		strDate = MilitaryTime;


	return strDate;
}

//function is used to check the price
function checkPrice(fromfield)
{
    var lowerLimit = 0;
    var uperLimit = 99999999.99;
    if(eval(fromfield).value!="")
    if ((Number(eval(fromfield).value)) || (Number(eval(fromfield).value) == 0)) 
	{              
         val =  Number(eval(fromfield).value)              
         val = Math.floor(val * 100)/100;
         eval(fromfield).value= val;                 
         if (eval(fromfield).value < lowerLimit )
		 {     
              alert('Price Cant be less than ' + lowerLimit );
              eval(fromfield).select();
              eval(fromfield).focus();
              return false
         }
         else 
		 {
              if (eval(fromfield).value > uperLimit )
			  {
                   alert('Price Cant be greater than ' + uperLimit );
                   eval(fromfield).select();
                   eval(fromfield).focus();
                   return false
              }                     
         } 
    } 
	else
	{
         alert('Price is Invalid.Please Reenter It.');
         eval(fromfield).select();
         eval(fromfield).focus();
         return false
    }
    return true;
}

//function is used to check whether values entered or not for cardno
function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		formField.select();
		result = false;
	}
	
	return result;
}

//function is used to check the crdit card validations
function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

//function is used to check the crdit card validations
function inValidCharSet(str,charset)
{
	var result = true;
	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

//function is used to check the crdit card validations
function isValidExpDate(ccmonth,formField,fieldLabel,required)
{
	var result = true;
	var formValue = formField;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result && (formField.length>0))
 	{
 		var elems = formValue.split("/");
 		
 		result = (elems.length == 2); // should be two components
 		var expired = false;
 		
 		if (result)
 		{
 			var month = parseInt(elems[0],10);
 			var year = parseInt(elems[1],10);
 			
 			if (elems[1].length == 2)
 				year += 2000;
 			
 			var now = new Date();
 			
 			var nowMonth = now.getMonth() + 1;
 			var nowYear = now.getFullYear();
 			
 			expired = (nowYear > year) || ((nowYear == year ) && (nowMonth > month));
 			
			result = allDigits(elems[0]) && (month > 0) && (month < 13) &&
					 allDigits(elems[1]) && ((elems[1].length == 2) || (elems[1].length == 4));
 		}
 		
  		if (!result)
 		{
 			alert('Please enter a date in the format MM/YY for the "' + fieldLabel +'" field.');
 			ccmonth.focus();
		}
		else if (expired)
		{
 			result = false;
 			alert('The date for "' + fieldLabel +'" has expired.');
			ccmonth.focus();
		}
	} 
	return result;
}

//function is used to check the crdit card validations
function isValidCreditCardNumber(formField,ccType,fieldLabel,required)
{
	var result = true;
 	var ccNum = formField.value;
 	if (required && !validRequired(formField,fieldLabel))
		result = false;
 
  	if (result && (ccNum.length>0))
 	{ 
 		if (!allDigits(ccNum))
 		{
 			alert('Please enter only numbers (no dashes or spaces) for the "' + fieldLabel +'" field.');
			formField.focus();
			formField.select();
			result = false;
		}	

		if (result)
 		{ 
 			
 			if (!LuhnCheck(ccNum) || !validateCCNum(ccType,ccNum))
 			{
 				alert('Please enter a valid card number for the "' + fieldLabel +'" field.');
				formField.focus();
				formField.select();
				result = false;
			}	
		} 

	} 
	return result;
}

function LuhnCheck(str) 
{
  var result = true;

  var sum = 0; 
  var mul = 1; 
  var strLen = str.length;
  
  for (i = 0; i < strLen; i++) 
  {
    var digit = str.substring(strLen-i-1,strLen-i);
    var tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }
  if ((sum % 10) != 0)
    result = false;
    
  return result;
}

function GetRadioValue(rArray)
{
	for (var i=0;i<rArray.length;i++)
	{
		if (rArray[i].checked)
			return rArray[i].value;
	}
	
	return null;
}

//function is used to check the crdit card validations
function validateCCNum(cardType,cardNum)
{
	var result = false;
	cardType=cardType.value;
	cardType = cardType.toUpperCase();
	
	var cardLen = cardNum.length;
	var firstdig = cardNum.substring(0,1);
	var seconddig = cardNum.substring(1,2);
	var first4digs = cardNum.substring(0,4);

	switch (cardType)
	{
		case "VISA":
			result = ((cardLen == 16) || (cardLen == 13)) && (firstdig == "4");
			break;
			//4154831564554123
		case "AMEX":
			var validNums = "47";
			result = (cardLen == 15) && (firstdig == "3") && (validNums.indexOf(seconddig)>=0);
			break;
			//347220405670890
		case "MASTERCARD":
			var validNums = "12345";
			result = (cardLen == 16) && (firstdig == "5") && (validNums.indexOf(seconddig)>=0);
			break;
			//5450784604506801
		case "DISCOVER":
			result = (cardLen == 16) && (first4digs == "6011");
			break;
			//6011456021048705
		case "DINERS":
			var validNums = "068";
			result = (cardLen == 14) && (firstdig == "3") && (validNums.indexOf(seconddig)>=0);
			break;
			//30684722040560
	}
	return result;
}

//function is used to check the crdit card validations
function validCCForm(ccType,ccNum,ccMonth,ccYear,ccNameOnCard)
{
	var ccTypeField=ccType;
	var ccNumField=ccNum;
	var ccmonth=ccMonth;
	var ccyear=ccYear;
	var ccExpField=ccmonth.value+"/"+ccyear.value;
	if(isValidCreditCardNumber(ccNumField,ccTypeField,"Credit Card Number",true))
	{
		if (isEmpty(trimText(ccNameOnCard)))
		{
			showAlert(ccNameOnCard,"Name cannot be empty. Please enter it.");
			return;
		}	
		if(isValidExpDate(ccmonth,ccExpField,"Expiration Date",true))
		{
			return true;
		}
	}
	else
	{
		return false;
	}
}