$(document).ready(function() {
	$("loginForm").click(function(){
		return validateForm();
	});
});

// validate form [LoginForm]
function validateForm( ) {
	var theForm = document.LoginForm;
	var ok  = true;
	var msg = "";
	// validate j_username
	if ( theForm.j_username.value.length > 20 ) {
			theForm.j_username.focus();
			ok = false;
			msg = msg + "The member number or user ID must be 20 characters or less. Please reenter.\n";
	}
	// validate j_username
	if ( theForm.j_username.value.length == 0 ) {
			theForm.j_username.focus();
			ok = false;
			msg = msg + "Please enter your member number or user ID\n";
	}
	// validate j_username
	var rexp = new RegExp("[^A-Za-z0-9_]", "g");
	if (rexp.test(theForm.j_username.value.replace(/^\s+/g, '').replace(/\s+$/g, '')) ){
			theForm.j_username.focus();
			ok = false;
			msg = msg + "Only alphanumeric characters are allowed in your member number or user ID\n";
	}
	// validate loginPassword
	if ( theForm.j_password.value.length == 0 ) {
			theForm.j_password.focus();
			ok = false;
			msg = msg + "Please enter your password\n";
	}

	if (!ok) alert( msg );
	return ok;
};


// Start: Slider 
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1500, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 6000 );
});
//END: Slider 


