$(window).load(function() {

 // nivo slider controls
$('#slider').nivoSlider({
effect: 'random', //Specify sets like: 'random' 'sliceDown, sliceDownLeft, sliceUp, sliceUpLeft, sliceUpDown, sliceUpDownLeft, fold, fade, random, slideInRight, slideInLeft'
slices: 15,
animSpeed: 600, //Slide transition speed
pauseTime: 5000,
startSlide: 0, //Set starting Slide (0 index)
directionNav: true, //Next & Prev
directionNavHide: true, //Only show on hover
controlNav: false //1,2,3...
});

// clear input vlue control
$('input[title]').each(function() {
if($(this).val() === '') {
$(this).val($(this).attr('title'));	
}
$(this).focus(function() {
if($(this).val() == $(this).attr('title')) {
$(this).val('').addClass('focused');	
}
});
$(this).blur(function() {
if($(this).val() === '') {
$(this).val($(this).attr('title')).removeClass('focused');	
}
});
});

// student tab control
$("#student-panel, .student-content").hide(); //hides the panel and content from the user
$('#student-tab').toggle(function(){ //adding a toggle function to the #tab
$('#student-panel').stop().animate({width:"400px", opacity:1.0}, 500, function() {//sliding the #panel to 400px
$('.student-content').fadeIn('slow'); //slides the content into view.
});  
},
function(){ //when the #tab is next cliked
$('.student-content').fadeOut('slow', function() { //fade out the content 
$('#student-panel').stop().animate({width:"0", opacity:0.1}, 500); //slide the #panel back to a width of 0
});
});

// blackbelt phone# control
jQuery('#phoneno-blackbelt').scrollFollow({
//speed: 500,
offset: -42,
easing: 'easeOutBounce',
container: 'wrapper'
});

/*
var defaults = {
containerID: 'moccaUItoTop', // fading element id
containerHoverClass: 'moccaUIhover', // fading element hover class
scrollSpeed: 1200,
easingType: 'linear' 
};
*/
$().UItoTop({ easingType: 'easeOutQuart' });

// tipTip
$(".bio").tipTip({
edgeOffset: 5
});
$(".linkreg").tipTip({
edgeOffset: 5
});

$('.scroll-pane').jScrollPane({});
$('.scroll-pane-arrows').jScrollPane({
showArrows: true,
arrowScrollOnHover: true,
arrowButtonSpeed: 5
});

});  //End Ready

jQuery(function($){

// menu controls
$('#sdt_menu > li').bind('mouseenter',function(){
var $elem = $(this);
$elem.find('img')
.stop(true)
.animate({
'width':'164px',
'height':'164px',
'left':'0px'
},400,'easeOutBack')
.andSelf()
.find('.sdt_wrap')
.stop(true)
.animate({'top':'118px'},500,'easeOutBack') /*pop down box top padding*/
.andSelf()
.find('.sdt_active')
.stop(true)
.animate({'height':'164px'},300,function(){
var $sub_menu = $elem.find('.sdt_box');
if($sub_menu.length){
var left = '164px';
if($elem.parent().children().length == $elem.index()+1)
left = '-164px';
$sub_menu.show().animate({'left':left},164);
}	
});
}).bind('mouseleave',function(){
var $elem = $(this);
var $sub_menu = $elem.find('.sdt_box');
if($sub_menu.length)
$sub_menu.hide().css('left','0px');
$elem.find('.sdt_active')
.stop(true)
.animate({'height':'0px'},300)
.andSelf().find('img')
.stop(true)
.animate({
'width':'0px',
'height':'0px',
'left':'70px'},400)
.andSelf()
.find('.sdt_wrap')
.stop(true)
.animate({'top':'10px'},500); /*padding top return to*/
});

});

// initialize shadowbox
Shadowbox.init({
//displayCounter:  false,
overlayOpacity: 0.8,
slideshowDelay: 15
});

// validate email
function emailValidation(entered, alertbox) {
with (entered) {
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}}

function FormValidation(thisform) {
with (thisform) {
if (emailValidation(email,"The \"Your Email Address\" field contains an invalid email address or the field was left blank.")==false) {email.focus(); return false;};
}}
