 $(function() {  
$('#coin-slider').coinslider({ width: 517, height: 273, navigation: false, delay: 6000, effect:'straight', sDelay: 10, hoverPause: false});
 });


//contact form has id of 'thisform'

//runs the onload and clears the textarea onclick, note the textarea is just the message box, 
window.onload = function() {
var textarea = document.getElementById("message");
textarea.onclick=function(){
	textarea.value="";
}

//clears all fields onclick of type "text" and "textarea"
var inputs = document.getElementsByTagName("input");
for (var i = 0 ; i < inputs.length ; i++ ) {
 if (inputs[i].type=="text"||inputs[i].type=="textarea") {
  inputs[i].onfocus = function() {
   if(this.value==this.defaultValue) this.value = '';
  }
  inputs[i].onblur = function() {
   if(this.value=='') this.value = this.defaultValue;
  }
 }
}
}

//end onload

//function if null or default value then alert
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
	else if (value=="Your Name                             " || value=="Your Email                             " || value=="Your Message")
	  {
		alert(alerttxt);return false;
	  }
  else
    {
    return true;
    }
  }
}


//validate question
function validate_question(field)
{
	with(field)
		if (value=="blue" || value=="BLUE")
	{
		return true;
	}
	else
	{
		return false;
	}	
}
//validate email - couldnt get this to work, maybe wont work as there is a default value of Your Email
/*
function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}*/

//validate radio buttons
function validate_radio(myForm){
if ((!myForm.vote[0].checked) && (!myForm.vote[1].checked) && (!myForm.vote[2].checked))
{
//alert("Please vote")
var voteerror = document.getElementById('vote_error');  // get the element with id 'vote_error' (the label with the error message)
  voteerror.style.visibility = 'visible';  //make it visible
return false}
}


//validate fields
function validate_form(thisform)
{
with (thisform)
  {
 if (validate_required(email,"Email must be filled out!")==false)
 {email.focus();return false;}
  else if (validate_required(name,"Name must be filled out!")==false)
  {name.focus();return false;}
  else if (validate_required(message,"The message is blank!")==false)
  {message.focus();return false;}
   else if (validate_required(question,"Please answer the question")==false)
  {question.focus();return false;}	
   else if (validate_question(question)==false)
  {question.focus();return false;}	
//   else if (validate_email(email, "Not a valid email address")==false)
//  {email.focus();return false;}	
  }
}