﻿var g_player = null;
var g_firstTime = true;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function playerReady(obj) {
    var id = obj['id'];
    g_player = document[id];
    if (g_player == null) {
        g_player = document.getElementById('playerContent');
    }
    loadVideo();
    g_firstTime = false;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function loadVideo() {
    g_player.sendEvent('PLAY', true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function onClickActVideoPict() {
    document.getElementById("ActVideoPict").style.display = 'none';
    document.getElementById("ActVideo").style.display = '';
    loadVideo();
}

var errFound = false;

function ValidEmail(item) {
    if (!ValidLength(item, 5)) return false;
    if (item.indexOf('@', 0) == -1) return false;
    return true;
}
function ValidLength(item, len) {
    return (item.length >= len);
}
function error(elem, text) {
    if (errFound) return;
    window.alert(text);
    elem.select();
    elem.focus();
    errFound = true;
}
function ValidateAct() {
    errFound = false;
    if (!ValidLength(document.form.parent_first.value, 1)) {
        error(document.form.parent_first, "Please Enter Parent's First Name ");
    }
    if (!ValidLength(document.form.parent_last.value, 1)) {
        error(document.form.parent_last, "Please Enter Parent's Last Name ");
    }
    if (!ValidEmail(document.form.parent_email.value, 1)) {
        error(document.form.parent_email, "Please Enter Parent's Email Address");
    }
    if (!ValidLength(document.form.parent_zip.value, 1)) {
        error(document.form.parent_zip, "Please Enter Parent's Zip Code ");
    }
    if (document.form.parent_day.value == "") {
        error(document.form.parent_zip, "Please Enter Parent's Birthday");
    }
    if (document.form.parent_month.value == "") {
        error(document.form.parent_zip, "Please Enter Parent's Birthday");
    }
    if (document.form.parent_year.value == "") {
        error(document.form.parent_zip, "Please Enter Parent's Birthday");
    }
    var currentTime = new Date();
    if (parseInt(document.form.parent_year.value) > currentTime.getFullYear() - 13) {
        error(document.form.parent_zip, "You must be at least 13 Years of Age to Register.");
    }
    if (!ValidLength(document.form.child_first.value, 1)) {
        error(document.form.child_first, "Please Enter Child's First Name ");
    }
    if (!ValidLength(document.form.child_age.value, 1)) {
        error(document.form.child_age, "Please Enter Child's Age ");
    }
    if (!ValidLength(document.form.child_hometown.value, 1)) {
        error(document.form.child_hometown, "Please Enter Child's Hometown ");
    }
    if (document.form.terms.checked == false) {
        error(document.form.terms, "You must agree to the Terms of Use");
    }
    return !errFound;
}
 
