// alert("hello world");

overfunc = function(){
	$('#meetingbutton').attr('src', 'http://shift-work.com/wp-content/themes/wpremix3/includes/meetingbutton/web_meeting_button__over.png');
	
}

outfunc = function(){
	jQuery('#meetingbutton').attr('src', 'http://shift-work.com/wp-content/themes/wpremix3/includes/meetingbutton/web_meeting_button.png');
	
}
formdescription = '<div id="webmeetingform">	<form method="post" action="http://shift-work.com/wp-content/themes/wpremix3/includes/meetingbutton/webmeetingsignup.php" onSubmit="return validate(this)"><table><caption>Schedule a Web Meeting with Shiftwork Solutions LLC</caption><tr><td>First Name: </td><td><input type="text" maxlength="40" name="firstname" size="40" /></td></tr><tr><td>Last Name: </td><td><input type="text" maxlength="40" name="lastname" size="40" /></td></tr><tr><td>Email: </td><td><input type="text" maxlength="40" name="email" size="40" /></td></tr><tr><td>Telephone:  </td><td><input type="text" maxlength= "14" name="telephone" size="14" /></td></tr><tr><td><input type="submit" value="Signup" /></td><td><input type="button" value="Do Not Signup" onclick="closewebmeeting()" /></td></tr></table></form><p>Thank you for your interest.  We will only use this information to contact you to schedule a web meeting.</p></div>';

clickfunc = function(){
	jQuery('#meetingbutton').attr('src', 'http://shift-work.com/wp-content/themes/wpremix3/includes/meetingbutton/web_meeting_button_click.png');
	jQuery('#codescription').html(formdescription);
}


validate = function(form){
	fail = validateFirstname(form.firstname.value);
	fail += validateLastname(form.lastname.value);
	fail += validateEmail(form.email.value);
	fail += validateTelephone(form.telephone.value);
	if (fail =="") {
		return true;
	}
	else {
		alert(fail);
		return false;
	}
}

validateFirstname = function(field){
	if (field == "") {
		return "No first name entered.\n";
	}
	return "";
}

validateLastname = function(field){
	if (field == "") {
		return "No last name entered.\n";
	}
	return "";
}

validateEmail = function(field){
	if (field == "") {
		return "No email entered.\n";
	}
	else if (!((field.indexOf(".") > 0 ) &&
			(field.indexOf("@") > 0)) ||
			/[^a-zA-Z0-9.@_-]/.test(field)) {
		
			return "The email address is invalid.\n"
	}
	return "";
}

validateTelephone = function(field){
	if (field == "") {
		return "";  //	Placeholder to make this a check.
	}
	return "";
}

closewebmeeting = function(){
	alert("Closing the web meeting request form.  No contact data has been sent.");
	location.replace('http://shift-work.com/shift-schedule-issues/shift-schedules');
	return true;
}

jQuery(function(){
  jQuery('#meetingbutton').attr('src',"http://shift-work.com/wp-content/themes/wpremix3/includes/meetingbutton/web_meeting_button.png");
  jQuery('#meetingbutton').hover(overfunc,outfunc);
  jQuery('#meetingbutton').click(clickfunc);
});

