// JavaScript Document

 
var homepageSpeed=3000;
var headshotSpeed=10000;
 

var intRotator = 0;
function resetPanels() {
    $('#homepagecounter').val(-1);
    showPanel(1);
    rotate_start();
}
function nextPanel() {
    var n = Number($('#homepagecounter').val());
    if (n == 3)
        showPanel(1);
    else {
        showPanel(n + 1);
    }
}
function rotate_start() {
    intRotator = setInterval(nextPanel, homepageSpeed);
}
function rotate_stop() {
    clearInterval(intRotator);
}
function clickPanel(pNum) {
    showPanel(pNum);
    rotate_stop();
}
function showPanel(pNum) {
    if ($('#homepagecounter').val() != pNum) {

        //Reset counter
        $('#homepagecounter').val(pNum);

        // Reset panels/buttons
        $('#triple-panels > div').hide();
        $('#triple-buttons > a').removeClass('selected');

        // Show selected panel
        if (pNum == 2) {
            $('#triple-panels div.news').show();
            $('#triple-buttons a.news').addClass('selected');
        } else if (pNum == 3) {
            $('#triple-panels div.testimonial').show();
            $('#triple-buttons a.testimonial').addClass('selected');
        } else {
            $('#triple-panels div.stay-connected').show();
            $('#triple-buttons a.stay-connected').addClass('selected');
        }
    }
}
/* BEGIN HEADSHOT ROTATOR */
function searchForm(q) {
    if (q == '') {
        alert('Please enter a search term');
    }
    else {
        alert('Search:' + q);
        window.location = "search.html";
    }
}

/* BEGIN HEADSHOT ROTATOR */
var intHeadshotCount = 0;
var intHeadshotCurrent = 0;
var intHeadshotTotal = 0;

function resetHeadshot(){
    if ($('#rotator-splash').size() > 0) {

        // Apply Click Links
        $('#rotator-links > a').each(function(i) {
            $(this).click(function() {
                clickHeadshot(i);
            });
        });

        // Reset Headshot Counters
        intHeadshotTotal = $('#rotator-splash > div').size() - 1;
        intHeadshotCurrent = 0;

        // Show First Headshot
        showHeadshot();

        // Start Rotator
        startHeadshotRotate();
    }
}
function startHeadshotRotate() {
    intHeadshotCount = setInterval(nextHeadshot, headshotSpeed);
}
function stopHeadshotRotate() {
    clearInterval(intHeadshotCount);
}
function clickHeadshot(pNum) {
    intHeadshotCurrent = pNum;
    showHeadshot();
    stopHeadshotRotate();
}
function nextHeadshot() {
    intHeadshotCurrent += 1;
    if (intHeadshotCurrent > intHeadshotTotal) intHeadshotCurrent = 0;
    showHeadshot();
}
function showHeadshot() {
    $('#rotator-splash > div').hide();
    $('#rotator-splash > div:eq(' + intHeadshotCurrent + ')').fadeIn("slow");
}

function submitCommunity() {
    //alert('submitCommunity()\nUser: ' + strUser + "\nPass: " + strPass);
    var strUser = $('#txtUsername').val();
    var strPass = $('#pwdPassword').val();
    var url = "__FormPost.aspx?u=" + strUser + "&p=" + strPass + "&title=Wilson%20Heirgood%20Client%20Community&action=https://secure.clientcommunity.com/default.aspx?strLookFor=wha";
    window.location = url;
}
// Live Help
function validate() {
    alert('called');
    return false;
}