/// <reference path="jquery-1.4.4-vsdoc.js" />
// svcr-functions.js - requires jquery.js 1.5+
// created by Mindfly Web Studio
// created: Feb 09, 2011
// modified: Jul 20, 2011

var bsTimer = null;

$(document).ready(function() {
    bannerSlide();
    boxBlur();
});

function homeBannerRotator() {
}

function bannerSlide() {
    // set up banner for rotation and start timer
    if ($('#rotator li').length > 1) {
        $('#rotator').addClass('active');
        $('#rotator li:last-child').addClass('current');
        bsTimer = setTimeout('autoSlide();', 5000);
    } else {
        $('#rotator button').remove();
    }
    // add click event to banner buttons
    $('#rotator button').click(function() {
        if ($('#rotator .upcoming').length < 1) {
            clearTimeout(bsTimer);
            var i = -1;
            var f = false;
            if ($(this).hasClass('before')) {
                i = 1;
                f = true;
            }
            var c = $('#rotator li').index($('#rotator .current'));
            c += i;
            if (c < 0) c = ($('#rotator li').length - 1);
            if (c > ($('#rotator li').length - 1)) c = 0;
            bannerSlideAnimate(c, f);
        }
    });
}

function autoSlide() {
    var c = $('#rotator li').index($('#rotator .current'));
    c = c - 1;
    if (c < 0) c = ($('#rotator li').length - 1);
    bannerSlideAnimate(c);
}

function bannerSlideAnimate(c, f) {
    if (!f) {
        f = false;
    }
    $('#rotator li:eq(' + c + ')').addClass('upcoming');
    if (f) $('#rotator .upcoming').css({ left: '-930px' });
    $('#rotator .upcoming').animate({ left: 0 }, 1000, 'swing', function() {
        $('#rotator .current').attr('style', '').removeClass('current');
        $('#rotator .upcoming').attr('style', '').addClass('current').removeClass('upcoming');
        bsTimer = setTimeout('autoSlide();', 10000);
    });
}

function boxBlur() {
	if($('label[id*="txt_email"] input[id*="txt_email"]').length > 0) {
		var n = $('label[id*="txt_email"] input[id*="txt_email"]');
		n.live('focus', function() { if ($(this).attr('value') == "Your E-mail Address") $(this).attr('value', '');});
		n.live('blur', function() { if ($(this).attr('value') == "") $(this).attr('value', 'Your E-mail Address');});
	}
}
