jQuery(function() {
$siteurl = "http://loadtraining.com";
$themeurl = $siteurl+"/wp-content/themes/loadtraining";
jQuery.easing.def = 'easeInOutQuint'; //Define defualt easing method


$('.home #free_dvd img').stop().animate({opacity:0},0,//Initial tab pop-up animation for homepage only
  function () {$(this).animate({marginTop:'-48px'},0,function(){$(this).animate({opacity:1},250,
  function(){$(this).animate({marginTop:'-116px'}, 1000);})});});
$("#close-video").click(//click on X to close form
  function (e) {
e.preventDefault();
closeit ();
  }
);


$("#free_dvd img").hover(//tab hover
  function () {// $('#free_dvd img').stop().show(250).css('margin-top','-48px').animate({marginTop:'-116px'}, 1000);
$('#free_dvd img').stop().animate({opacity:0},0, function () {$(this).animate({marginTop:'-48px'},0,function(){$(this).animate({opacity:1},250, function(){$(this).animate({marginTop:'-116px'}, 1000);})});});
  }, 
  function () {
$('#free_dvd img').stop().animate({marginTop:'-48px'}, 1000, function () {$(this).animate({opacity:0},250,function(){$(this).animate({marginTop:'0px'}, 0, function(){$(this).animate({opacity:1},0);})});});
  }
);
$('#animation img#truck').fadeIn(1000);
$('#animation #truck').animate({left:'230px'},2000, function(){$('#animation #dd').fadeIn(500,
function () {$('.home #free_dvd img').wait(2000).animate({marginTop:'-48px'}, 1000,
  function () {$(this).animate({opacity:0},250,function(){$(this).animate({marginTop:'0px'}, 0,
  function(){$(this).animate({opacity:1},0);})});});
});});


$("#content #videoform input#name_2").focus();

$("#free_dvd img").click(      //tab click
function (e) {
e.preventDefault();
mailform();
});

$(".freedvd").click(
function (e) {
e.preventDefault();
mailform();
})


//general single reveal
$(".reveal").click(
  function (e) {
e.preventDefault();
if($(".revealed").is(':hidden')){$(".revealed").slideDown(550);}
  })


//refund policy

$("#policy1").click(
  function (e) {
e.preventDefault();
if($("#refund1").is(':hidden')){$("#refund1").slideDown(250);}
  })
$("#policy2").click(
  function (e) {
e.preventDefault();
if($("#refund2").is(':hidden')){$("#refund2").slideDown(250);}
  })
$("#policy3").click(
  function (e) {
e.preventDefault();
if($("#refund3").is(':hidden')){$("#refund3").slideDown(250);}
  })
$("#policy4").click(
  function (e) {
e.preventDefault();
if($("#refund4").is(':hidden')){$("#refund4").slideDown(250);}
  })
$("#policy5").click(
  function (e) {
e.preventDefault();
if($("#refund5").is(':hidden')){$("#refund5").slideDown(250);}
  })
$("#policy6").click(
  function (e) {
e.preventDefault();
if($("#refund6").is(':hidden')){$("#refund6").slideDown(250);}
  })
$("#policy7").click(
  function (e) {
e.preventDefault();
if($("#refund7").is(':hidden')){$("#refund7").slideDown(250);}
  })
$("#policy8").click(
  function (e) {
e.preventDefault();
if($("#refund7").is(':hidden')){$("#refund8").slideDown(250);}
  })

$('#playera').click(
function (e) {
e.preventDefault();
showclip(1);
})
$('#playerb').click(
function (e) {
e.preventDefault();
showclip(2);
})
$('#playerc').click(
function (e) {
e.preventDefault();
showclip(3);
})
$('#playerd').click(
function (e) {
e.preventDefault();
showclip(4);
})

function showclip(clip) {
$clip = clip;
$('#clipholder').html("<object id=\"flowplayer\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"340\" height=\"226\"><param name=\"movie\" value=\""+$themeurl+"/video/flowplayer-3.2.2-0.swf\" /><param name=\"flashvars\" value=\'config={\"clip\":\""+$themeurl+"/video/video"+$clip+".flv\"}\' /><embed type=\"application/x-shockwave-flash\" width=\"340\" height=\"226\" src=\""+$themeurl+"/video/flowplayer-3.2.2-0.swf\" flashvars=\'config={\"clip\":\""+$themeurl+"/video/video"+$clip+".flv\"}\'/></object><br clear=\"all\" />");


}


//FORMS



$('#comments_2').focus(function() {$(this).animate({height: 48},650);});

$('#comments_c').focus(function() {$(this).animate({height: 144},650);});

$('#contact_form_1').submit(function (e) {//side-bar form
e.preventDefault();   var name_1 = $("#name_1").val();       if (name_1 == "") {     $("#name_1L").css('color','#cc6633');     $("input#name_1").focus();     return false;   }  

var tele_1 = $("#tele_1").val();       if (tele_1 == "") {     $("#tele_1L").css('color','#cc6633');     $("input#tele_1").focus();     return false;   }     var email_1 = $("#email_1").val();       if (email_1 == "") {     $("#email_1L").css('color','#cc6633');     $("input#email_1").focus();     return false;   }       
if /*(himonf == himon)*/ (1==1) {
$("#contact_form_1 input").attr('disabled', 'true');
$("#contact_form_1 textarea").attr('disabled', 'true');
$('#submit_1').attr('disabled', 'true');
$('#sfields').html("<h4>Submitting form. Please wait.</h4>").slideDown(400);
var dataString = 'name_1='+ name_1 + '&email_1=' + email_1 + '&tele_1=' + tele_1;
$.ajax({
type: "POST",
url: $siteurl+"/post_sform.php",
data: dataString,
success: function() {

$( 'html, body' ).animate( { scrollTop: 0 }, 'slow' );
$('#sfields').html("<h4>Thank You!</h4>").fadeIn(850, mailform(name_1,email_1,tele_1) );
/*$('#msg').html("<h2>Your message has been sent.</h2>")
.append("<p>I will contact you soon. Thank you!</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='images/check.png' />");


});*/
}
});
return false;
}
else {
$('#sfields').html("<h4>We are sorry, there was an error.</h4><p>Please refresh the page and try again.</p>")
return false;}
}
);


$('#videoform_2').submit(function (e) {//main video mail form
e.preventDefault();
var name_2 = $("#name_2").val();       if (name_2 == "") {     $("#name_2L").css('color','#cc6633');     $("input#name_2").focus();     return false;   }  

var tele_2 = $("#tele_2").val();       if (tele_2 == "") {     $("#tele_2L").css('color','#cc6633');     $("input#tele_2").focus();     return false;   } var email_2 = $("#email_2").val();       if (email_2 == "") {     $("#email_2L").css('color','#cc6633');     $("input#email_2").focus();     return false;   }
var address_2 = $("#address_2").val();       if (address_2 == "") {     $("#address_2L").css('color','#cc6633');     $("input#address_2").focus();     return false;   }  

var city_2 = $("#city_2").val();       if (city_2 == "") {     $("#city_2L").css('color','#cc6633');     $("input#city_2").focus();     return false;   } var state_2 = $("#state_2").val();       if (state_2 == "") {    $("#city_2L").css('color','#cc6633');
 $("input#state_2").focus();     return false;   }

var zip_2 = $("#zip_2").val();       if (zip_2 == "") {    $("#city_2L").css('color','#cc6633');
 $("input#zip_2").focus();     return false;   }

var himon;
var himonf = $("#himon").val().toLowerCase();
switch ($("#simgnum").val()) {
case '0' : himon = "working"; break;
case '1' : himon = "wheat"; break;
case '2' : himon = "upstairs"; break;
case '3' : himon = "craft"; break;
case '4' : himon = "sunlight"; break;
case '5' : himon = "heading"; break;
case '6' : himon = "sharpen"; break;
case '7' : himon = "campfire"; break;
  }
if (himonf == himon) {

$("#videoform_2").attr('disabled', 'true');
var comments_2 = $("#comments_2").val();

var dataString = 'name_2='+ name_2 + '&email_2=' + email_2 + '&tele_2=' + tele_2 + '&address_2=' + address_2 + '&city_2=' + city_2 + '&state_2=' + state_2 + '&zip_2=' + zip_2 + '&comments_2=' + comments_2;
$('#vfields').html("<h4>Submitting form. Please wait.</h4>").slideDown(400);
$.ajax({
type: "POST",
url: $siteurl+"/post_vform.php",
data: dataString,
success: function() {
$('#videoform_2').html("<h4>Thank You! Form submitted.</h4>");
$('#referform').slideDown(600);
$("#referrer").val (name_2);
$("#referrer_e").val (email_2);
$("#referform").attr('disabled', 'false');
//$("#referform textarea").attr('disabled', 'false');
/*$('#msg').html("<h2>Your message has been sent.</h2>")
.append("<p>I will contact you soon. Thank you!</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='images/check.png' />");


});*/
}
});
return false;
}
else {
$('#himonchigaimasu').show(200);
 $("#slabel").css('color','#cc6633');
$('#himon').focus();
return false;}
}
);





if (!$.browser.msie){
	$('#videoform_').submit(function () {//main video mail form

var first_name = $("#first_name").val();
if (first_name == "") {$("#first_nameL").css('color','#cc6633');
$("input#first_name").focus();return false;}

var last_name = $("#last_name").val();
if (last_name == "") {$("#last_nameL").css('color','#cc6633');
$("input#last_name").focus();return false;}

var phone = $("#phone").val();
if (phone == "") {$("#phoneL").css('color','#cc6633');
$("input#phone").focus();return false;}

var email = $("#email").val();
if (email == "") {$("#emailL").css('color','#cc6633');
$("input#email").focus();return false;}

var street = $("#street").val();
if (street == "") {$("#streetL").css('color','#cc6633');
$("input#street").focus();return false;} 

var city = $("#city").val();
if (city == "") {$("#cityL").css('color','#cc6633');
$("input#city").focus();return false;}

var state = $("#state").val();
if (state == "") {$("#stateL").css('color','#cc6633');
$("input#state").focus();return false;}

var zip = $("#zip").val();
if (zip == "") {$("#zipL").css('color','#cc6633');
$("input#zip").focus();return false;}

var oid = $("#oid").val();
var debug = $("#debug").val();
var debugEmail = $("#debugEmail").val();
var retURL = $("#retURL").val();
var _00N70000001i956 = $("#00N70000001i956").val();
var company = $("#company").val();
var lead_source = $("#lead_source").val();


var himon;
var himonf = $("#himon").val().toLowerCase();
switch ($("#simgnum").val()) {
case '0' : himon = "working"; break;
case '1' : himon = "wheat"; break;
case '2' : himon = "upstairs"; break;
case '3' : himon = "craft"; break;
case '4' : himon = "sunlight"; break;
case '5' : himon = "heading"; break;
case '6' : himon = "sharpen"; break;
case '7' : himon = "campfire"; break;
  }
if (himonf == himon) {
$("#videoform_").attr('disabled', 'true');
return true;
	}
else {
$('#himonchigaimasu').show(200);
 $("#slabel").css('color','#cc6633');
$('#himon').focus();
return false;}
}
);


}





$('#contact_form').submit(function (e) {//contact form
e.preventDefault();
var name_c = $("#name_c").val();       if (name_c == "") {     $("#name_cL").css('color','#cc6633');     $("input#name_c").focus();     return false;   }  

var tele_c = $("#tele_c").val();        var email_c = $("#email_c").val();       if (email_c == "") {     $("#email_cL").css('color','#cc6633');     $("input#email_c").focus();     return false;   }

var comments_c = $("#comments_c").val();
if (comments_c == "") {     $("#comments_cL").css('color','#cc6633');     $("textarea#comments_c").focus();     return false;   }

var himon_c;
var himonf_c = $("#himon_c").val().toLowerCase();
switch ($("#simgnum_c").val()) {
case '0' : himon_c = "working"; break;
case '1' : himon_c = "wheat"; break;
case '2' : himon_c = "upstairs"; break;
case '3' : himon_c = "craft"; break;
case '4' : himon_c = "sunlight"; break;
case '5' : himon_c = "heading"; break;
case '6' : himon_c = "sharpen"; break;
case '7' : himon_c = "campfire"; break;
  }
if (himonf_c == himon_c) {

$("#contact_form").attr('disabled', 'true');


var dataString = 'name_c='+ name_c + '&email_c=' + email_c + '&tele_c=' + tele_c + '&comments_c=' + comments_c;
$('#cfields').html("<h4>Submitting form. Please wait.</h4>").slideDown(400);
$.ajax({
type: "POST",
url: $siteurl+"/post_cform.php",
data: dataString,
success: function() {
$('#contact_form').html("<h4>Thank You! Message sent.</h4>");
}
});
return false;
}
else {
$('#himonchigaimasu_c').show(200);
 $("#clabel").css('color','#cc6633');
$('#himon_c').focus();
return false;}
}
);




$('#submitrefer').click(function (e) {
e.preventDefault(); rformed ();})


$('#referform').submit(function (e) {
e.preventDefault(); rformed ();
 })


function rformed () {//referral form
/*var himon;
var himonf = $("#himon").val().toLowerCase();
switch ($("#simgnum").val()) {
case '1' : himon = "animate"; break;
case '2' : himon = "robot"; break;
case '3' : himon = "sushi"; break;
case '4' : himon = "colors"; break;
case '5' : himon = "rhythm"; break;
case '6' : himon = "raster"; break;
case '7' : himon = "vector"; break;
case '8' : himon = "pixel"; break;
  }*/
if /*(himonf == himon)*/ (1==1) {
$("#referform input").attr('disabled', 'true');
$("#referform textarea").attr('disabled', 'true');
$('#submitrefer').attr('disabled', 'true');

var name_r = $("#name_r").val();
var email_r = $("#email_r").val();
var referrer = $("#referrer").val();
var referrer_e = $("#referrer_e").val();

$('#rfields').html("<h4>Submitting form. Please wait.</h4>").slideDown(400);

var dataString = 'name_r='+ name_r + '&email_r=' + email_r + '&referrer=' + referrer + '&referrer_e=' + referrer_e;
$.ajax({
type: "POST",
url: $siteurl+"/post_rform.php",
data: dataString,
success: function() {
$('#referform').html("<h4>Thank You! Friend referred.</h4>").wait(2500).animate({opacity:1},0,
  function () {
closeit ();});
/*$('#msg').html("<h2>Your message has been sent.</h2>")
.append("<p>I will contact you soon. Thank you!</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='images/check.png' />");


});*/
}
});
return false;
}
else {
$('#rfields').html("<h4>We are sorry, there was an error.</h4><p>Please refresh the page and try again.</p>")
return false;}
}


});

$.fn.wait = function(time, type) {//delay function
time = time || 1000;
type = type || "fx";
return this.queue(type, function() {
var self = this;
setTimeout(function() {
$(self).dequeue();
}, time);
});
};

jQuery.extend( jQuery.easing,//defualt easing script
{
easeInOutQuint: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
return c/2*((t-=2)*t*t*t*t + 2) + b;
}
});

function mailform(name,email,tele) {//form to mail video function
$( 'html, body' ).animate( { scrollTop: 0 }, 'slow' );
$('#ddsb').slideUp();
$("#videoform").stop().fadeIn(600);
$("#fade").show();
$("#fade").stop().fadeTo(0, 0);
//$("#fade").css("background-color", "#ccc");
$("#fade").stop().fadeTo(700, .60);

$('#name_2').val(name);
$('#email_2').val(email);
$('#tele_2').val(tele);
if ($('#name_2').val() == '') {$('#vf_space #name_2').focus();}
else {$('#vf_space #address_2').focus();}
}

function closeit () {//close form pop-in function

$("#vf_space #videoform").stop().fadeOut(600);
$("#fade").stop().fadeOut(700);
$('#ddsb').slideDown();
//location.reload();

}

function showmap (map) {//change map hover for calendar

if (map == 'defualt') {$('#calmap img').stop().fadeOut(800);}
else {
if ($('#calmap #'+map).is(':hidden')) {
$('#calmap img').stop().hide();
$('.classdesc').stop().hide();
$('#calmap #'+map).stop().show(); 
$('#desc_'+map).stop().show(); }
}

}

