// JavaScript Document
var testimonials;
$(document).ready(function() {
	
	if ($('#player')) {
		$("div.test", this).hide();	
		testimonials=new Array();
		testimonials = $("div.test");
		selectTest();
	}	
});

function selectTest(jp) {
	var j = Math.floor( Math.random() * ( 3 + 1 ) );
	if (j == jp) {
		j = j+1;
	}
	for (i = 0; i < testimonials.length; i++) {
		$(testimonials[i]).hide();
	}
	if (testimonials[j] == "" || j == null) {
		$(testimonials[1]).animate({
	   opacity: 'show'
	 }, 1000);
	}
	else {
		$(testimonials[j]).animate({
	   opacity: 'show'
	 }, 1000);
	}
	var delay = setTimeout("selectTest(" + j + ")",10000)
}

function isEmail(mailfield){
 
                                        if (mailfield == ''){
 
                                                return false;
 
                                        }
 
                               
 
                                        if (mailfield.indexOf ('@',0) == -1 || mailfield.indexOf ('.',0) == -1){
 
                                                return false;
 
                                        }
 
                                        else{
 
                                                return true;
 
                                        }
 
                                }
 
                               
 
                                function checkemail(form1){
 
                               
 
                                        var Email  = form1.email.value ;
 
                               
 
                                        if (!isEmail(Email)) {
 
                                                alert('Please enter a valid email address.');
 
                                                form1.email.focus();
 
                                        return (false);
 
                                        }
 
                               
 
                                        return checkform(form1);
 
                               
 
                                }
 
                               
 
                                function checkform(form1)
 
                                {
 
                  if (form1.firstname.value == '')
 
                  {
 
                                alert('Please enter a value for the First Name field.');
 
                                form1.firstname.focus();
 
                                return (false);
 
                  }
 
                                  if (form1.lastname.value == '')
 
                  {
 
                                alert('Please enter a value for the Last Name field.');
 
                                form1.lastname.focus();
 
                                return (false);
 
                  }
 
 
 
                                if (form1.telephone.value == '')
 
                  {
 
                                alert('Please enter a value for the Telephone field.');
 
                                form1.telephone.focus();
 
                                return (false);
 
                  }
 
                  if (form1.telephone.value.length < 10)
 
                  {
 
                                alert('Please enter at least 10 characters in the Telephone field.');
 
                                form1.telephone.focus();
 
                                return (false);
 
                  }
 
               
 
                // only allow numbers to be entered
 
                var checkOK = '0123456789-() .+';
 
                var checkStr = form1.telephone.value;
 
                var allValid = true;
 
                var allNum = '';
 
                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;
 
                break;
 
                }
 
                if (ch != ',')
 
                allNum += ch;
 
                }
 
                if (!allValid)
 
                {
 
                alert('Please only use numerical characters in the Telephone field. ');
 
                form1.telephone.focus();
 
                return (false);

 
                } 
 
 
 
                                                                                                if (form1.custom1.value == '')
 
                                                                                                {
 
                                                                                                alert('Please enter a value for the Evening Phone field.');
 
                                                                                                form1.custom1.focus();
 
                                                                                                return (false);
 
                                                                                                }
 
                  return (true);
 
                }