function validate(f)
{
//var i;
//var formFields=document.getElementById("application").elements;
//	for (i=0;i<formFields.length;i++)
//	{
//				formFields[i].style.background="#FFFFFF";
//	}

	if(document.getElementById("amount").value==""){document.getElementById("s1").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s1").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	if(countAlphabets(document.getElementById("first_name").value)<2 || document.getElementById("first_name").value=="First"){document.getElementById("s2").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s2").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	if(countAlphabets(document.getElementById("last_name").value)<2 || document.getElementById("last_name").value=="Last"){document.getElementById("s3").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s3").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	if(!isValidEmail(document.getElementById("email").value)){document.getElementById("s4").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s4").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	if(rs(document.getElementById("phone").value).length !=11 || isNaN(document.getElementById("phone").value) ){document.getElementById("s5").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s5").innerHTML="<img src=form/images/1.png width=19 height=16>";}

return true;
}


function check(i)
{
	if(i==1){
	if(document.getElementById("amount").value==""){document.getElementById("s1").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s1").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	}
	if(i==2){
	if(countAlphabets(document.getElementById("first_name").value)<2 || document.getElementById("first_name").value=="First"){document.getElementById("s2").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s2").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	}

	if(i==3){
	if(countAlphabets(document.getElementById("last_name").value)<2 || document.getElementById("last_name").value=="Last"){document.getElementById("s3").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s3").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	}

	if(i==4){	
	if(!isValidEmail(document.getElementById("email").value)){document.getElementById("s4").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s4").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	}

	if(i==5){
	if(rs(document.getElementById("phone").value).length !=11 || isNaN(document.getElementById("phone").value)){document.getElementById("s5").innerHTML="<img src=form/images/0.png width=14 height=14>"; return false;}else{document.getElementById("s5").innerHTML="<img src=form/images/1.png width=19 height=16>";}
	}



}



function isValidEmail(emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(2([0-4]\d|5[0-5])|1?\d{1,2})(\.(2([0-4]\d|5[0-5])|1?\d{1,2})){3} \])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}

function popUp(URL, w,h)
{
var day = new Date();
var id = day.getTime();
eval("window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + w + ",height=" + h + ",left = 340,top = 362');");
}

function countWords(s)
{
var trimmed = s.replace(/^\s+|\s+$/g, '');
c=trimmed.split(" ");
return c.length;
}

function xx(o, x, obj)
{
	if (o.value.length == x)
		eval(obj).focus();
}

function emptyIt(o,s)
{
	if (o.value == s)
		o.value="";
}

function checkABA(s) 
{
   var i, n, t;
   t = "";
   for (i = 0; i < s.length; i++)
   {
       c = parseInt(s.charAt(i), 10);
       if (c >= 0 && c <= 9)t = t + c;
   }
   if (t.length != 9)return false;
   n = 0;
   for (i = 0; i < t.length; i += 3)
       {
       n += parseInt(t.charAt(i),     10) * 3

         +  parseInt(t.charAt(i + 1), 10) * 7

         +  parseInt(t.charAt(i + 2), 10);
      }
   if(n != 0 && n % 10 == 0)return true;
   else return false;
}


function isValidDate(dateStr) 
{
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	var matchArray = dateStr.match(datePat);
	if (matchArray == null) 
	{
		return false;
	}
	month = matchArray[1];
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) 
	{
		return false;
	}
	if (day < 1 || day > 31)
	{
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	{
		return false
	}
	if (month == 2) 
	{
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) 
		{
		return false;
		}
	}
return true;
}


function rs(string) {
 return string.split(' ').join('');
}


function containsAlphabets(checkString) {
        var tempString="";
        var regExp = /^[A-Za-z ]$/;
        if(checkString != null && checkString != "")
        {
          for(var i = 0; i < checkString.length; i++)
          { 
            if (!checkString.charAt(i).match(regExp))
            {
              return false;
            }
          }
        }
        else
        {
          return false;
        }
        return true;
}

function countAlphabets(checkString) {
        var regExp = /^[A-Za-z]$/;
	var count=0;
        if(checkString != null && checkString != "")
        {
          for(var i = 0; i < checkString.length; i++)
          { 
            if (checkString.charAt(i).match(regExp))
            {
              count++;
            }
		
          }
        }
        else
        {
          return 0;
        }
        return count;
}


function fixNum(el){ 
	el.value = el.value.replace(/\D/g, ''); 
} 



function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}
                  

