// validate first name
function validateFirstName(firstName)
{
	if (!firstName.value.match("[a-zA-Z]*") && firstName.value.length > 0)
//	if (firstName.value == "9")
	{
		alert("Invalid First Name!");
		firstName.value = "";
		firstName.focus();
	}
}
function validateTimeToCall(ttc)
{
	if (!ttc.value.match("[a-zA-z]+([ ':-][a-zA-Z]+)*") && ttc.value.length > 0)
	{
		alert("Something strange about your input!");
		ttc.value = "";
		ttc.focus();
	}
}
function validatePhone(phone)
{
	if (!phone.value.match("+ [1-9]\\d{2}-[1-9]\\d{2}-\\d{4}") && phone.value.length > 0)
	{
		alert("Invalid Phone Number!");
		phone.value = "";
		phone.focus();
	}
}
function validateEmail(email)
{
	if (!email.value.match("^.+\@.+\..+$") && email.value.length > 0)
//	if (firstName.value == "9")
	{
		alert("Invalid Email!");
		email.value = "";
		email.focus();
	}
}
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
    var i = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function show(itemID)
{
	document.getElementById(itemID).style.display = '';
}
function hide(itemID)
{
	document.getElementById(itemID).style.display = 'none';
}
function showYouTube()
{
	hide('pms_image');
	show('pms_U2B');
	show('scStart');
	hide('learn_more');
}
function forgetIt()
{
	show('scStart');
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	hide('dpsc7');
	hide('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
}
function step1() // contact method
{
	show('study_content');
	opacity('study_content',0,100,500);
	hide('scStart');
	show('dpsc1');
}
function step2() // contact person
{
	hide('dpsc1');
	show('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	hide('dpsc7');
	hide('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
}
function step3() // show researcher phone
{
	hide('dpsc1');
	hide('dpsc2');
	show('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	hide('dpsc7');
	hide('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
}
function step4() // time zone of person interested
{
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	show('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	hide('dpsc7');
	hide('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
	// alert("Any information you submit on this web page is only used for the purpose of contacting you about study participation. It is not sold, shared with anyone else, or used for research or purposes.");
}
function step5() // best time to call
{
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	show('dpsc5');
	document.form1.time_to_call.focus();
	hide('dpsc6');
	hide('dpsc7');
	hide('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
}
function step6() // first name of person to call
{
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	show('dpsc6');
	document.form1.first_name.focus();
	hide('dpsc7');
	hide('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
}
function step7() // phone number of person to call
{
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	show('dpsc7');
	document.form1.phone_number.focus();
	hide('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
}
function step8() // time zone of e-mailer who is interested
{
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	hide('dpsc7');
	show('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
	// alert("Any information you submit on this web page is only used for the purpose of contacting you about study participation. It is not sold, shared with anyone else, or used for research or purposes.");
}
function step9() // first name of person interested
{
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	hide('dpsc7');
	hide('dpsc8');
	document.form2.first_name.focus();
	show('dpsc9');
	hide('dpsc10');
	hide('dpsc11');
}
function step10() // email address of person interested
{
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	hide('dpsc7');
	hide('dpsc8');
	hide('dpsc9');
	document.form2.user_email.focus();
	show('dpsc10');
	hide('dpsc11');
}
function step11() // submit graphics
{
	hide('dpsc1');
	hide('dpsc2');
	hide('dpsc3');
	hide('dpsc4');
	hide('dpsc5');
	hide('dpsc6');
	hide('dpsc7');
	hide('dpsc8');
	hide('dpsc9');
	hide('dpsc10');
	show('dpsc11');
}
function validateMethod(smele)
{
	if (smele.value == 1) {
		step2();
	}
	if (smele.value == 2) {
		step8();
	}
}
function validatePerson(smele)
{
	if (smele.value == 1) {
		step3();
	}
	if (smele.value == 2) {
		step4();
	}
}

function validateForm1(form1)
{
	if(form1.participant_timezone.value == "") {
		step4();
		alert("What time zone are you in?");
		return false;
	}
	if(form1.time_to_call.value === null || form1.time_to_call.value === "") {
		step5();
		alert("What is the best time to call you?");
		return false;
	}
	if(form1.first_name.value === null || form1.first_name.value === "") {
		step6();
		alert("Please tell us your first name!");
		return false;
	}
	if(form1.phone_number.value === null || form1.phone_number.value === "") {
		step7();
		alert("What is your phone number?");
		return false;
	}
	hide('study_content');
	step11();
}
function validateForm2(form2)
{
	if(form2.first_name.value === null || form2.first_name.value === "") {
		step8();
		alert("Please tell us your first name!");
		return false;
	}
	if(form2.user_email.value === null || form2.user_email.value === "") {
		step9();
		alert("What is your email address?");
		return false;
	}
	hide('study_content');
	step11();
}
