function isEmail(elm) 
	{
	var str=elm.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=true
	else
		testresults=false
	return (testresults)
	}
	
/*********************************************************************************************/


// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


/*********************************************************************************************/

function Agree(checkObj)
	{
		if (!checkObj.checked)
		{
			//alert('Please tick the check box to continue')
			return false;
		}
			
		else
		{
			return true;
		}
	}

/*********************************************************************************************/

function popUp2(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=no,width=596,height=600,left = 312,top = 30');");
	}
	
/*********************************************************************************************/	
	
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*********************************************************************************************/	

/* I block this function by errors woth Mastercrad cards
function ccCardNumber(cardNumber) 
{
  var cardTotal=0;
  var dnum=0;
  var test=0;
  if (cardNumber.length < 13) { return (false); }
  else
    {
    for ( i = cardNumber.length; i >= 1 ;  i--)	{
	  test=test+1;
	  num = cardNumber.charAt(i-1);
	  if ((test % 2) != 0) cardTotal=cardTotal+parseInt(num)
	  else {
		dnum=parseInt(num)*2;
		if (dnum >= 10) cardTotal=cardTotal+1+dnum-10
		else cardTotal=cardTotal+dnum;
		}
    }
  if ((cardTotal % 10) != 0){ return (false); }else{ return(true); }
  }
}
*/

function ccCardNumber(cardNumber) 
{
  var cardTotal=0;
  var dnum=0;
  var test=0;
  if (cardNumber.length < 13) 
  	{ return (false); }
  else
    { return IsNumeric(cardNumber); }
}




/*********************************************************************************************/	

function IsNumeric(inputText) {
  var okChars = "0123456789.";
  var isNumber=true;
  var cChar;

  for (i = 0; i < inputText.length && isNumber == true; i++) {
    cChar = inputText.charAt(i);
    if (okChars.indexOf(cChar) == -1) {
      isNumber = false;
      }
    }
  return isNumber;
}
	
/**********************************************************************************************/
/* Functions for ste 4 of horse */

function countCheck1() 
	{
	var checkbox_choices = 0;
	
	// Loop from zero to the one minus the number of checkbox button selections
	for (counter = 0; counter < document.forms.quoteform.check1.length; counter++)
	{
	
	// If a checkbox has been selected it will return true
	// (If not it will return false)
	if (document.forms.quoteform.check1[counter].checked)
	{ checkbox_choices = checkbox_choices + 1; }
	
	}
	return checkbox_choices;	
	}
	
function countCheck2() 
	{
	var checkbox_choices = 0;
	
	// Loop from zero to the one minus the number of checkbox button selections
	for (counter = 0; counter < document.forms.quoteform.check2.length; counter++)
	{
	
	// If a checkbox has been selected it will return true
	// (If not it will return false)
	if (document.forms.quoteform.check2[counter].checked)
	{ checkbox_choices = checkbox_choices + 1; }
	
	}
	return checkbox_choices;	
	}	
	
function countCheck3() 
	{/*
	var checkbox_choices = 0;
	
	// Loop from zero to the one minus the number of checkbox button selections
	for (counter = 0; counter < document.forms.form2.check3.length; counter++)
	{
	
	// If a checkbox has been selected it will return true
	// (If not it will return false)
	if (document.forms.form2.check3[counter].checked)
	{ checkbox_choices = checkbox_choices + 1; }
	
	}
	return checkbox_choices;	
*/
	if (document.forms.quoteform.check3.checked == true)
		return 1;
	else
		return 0;
	}
	
function countCheck4() 
	{
	var checkbox_choices = 0;
	
	// Loop from zero to the one minus the number of checkbox button selections
	for (counter = 0; counter < document.forms.quoteform.check4.length; counter++)
	{
	
	// If a checkbox has been selected it will return true
	// (If not it will return false)
	if (document.forms.quoteform.check4[counter].checked)
	{ checkbox_choices = checkbox_choices + 1; }
	
	}
	return checkbox_choices;	
	}		

function validarCheck(){
   
  var i=0;var cCheck=0;
  var objInput = document.forms.quoteform.getElementsByTagName("input");
  var lObj = (objInput!=null)? objInput.length : 0;
  
 for(i=0;i<lObj;i++){    
    if ((objInput[i].type=="checkbox")&&(objInput[i].checked)) cCheck++;   
 }
 
 return (cCheck);
}

/**********************************************************************************************/

function DisableVet()
	{
	if (document.forms.quoteform.NoVet.checked) 
		{
		document.forms.quoteform.VetName.disabled = true;
		document.forms.quoteform.VetAddress.disabled = true;
		document.forms.quoteform.VetContact.disabled = true;
		document.forms.quoteform.VetName.value = "";
		document.forms.quoteform.VetAddress.value = "";
		document.forms.quoteform.VetContact.value = "";
		}
	else 
		{
		document.forms.quoteform.VetName.disabled = false;
		document.forms.quoteform.VetAddress.disabled = false;
		document.forms.quoteform.VetContact.disabled = false;
		}
	}
	
/**********************************************************************************************/	
	
	
function confirmDelete(filename,prompt)
	{
	if(confirm(prompt))
		location= filename;
	}
	
/**********************************************************************************************/	

function isIllegalwithNumsNoAlpa(field){
		var legalChars = false;
		var aIllegalChars = new Array(",",".","=","+","#","~","<",">","/","\\","{","}","[","]","%","!","£","€","^","&","(",")","-","'","$","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
		for (var i=0;i<aIllegalChars.length;i++){
			if (field.value.indexOf(aIllegalChars[i]) != -1){
				legalChars = false;
				break;
				}
			else legalChars = true;	
			}
	
		
	
		if (legalChars == true){
			return false;
			}
		else{
			return true;
		}
}

/**********************************************************************************************/	

// Fucntions to validate date

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
return true
}

/**********************************************************************************************/	

function checkUsername(field)
	{
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	for (var i = 0; i < field.value.length; i++) 
		{
		if (iChars.indexOf(field.value.charAt(i)) != -1) 
			{
			return false;
			}
		}
		return true;		
	}

/**********************************************************************************************/	
