﻿
// Contacts near us... global variables

var tabid = "ct1";
var pageid = 1;
var bannerid = 4; // initiation of banner id

var rotateContactsPause = false;
var DoRotator;
var DoBannerRotator;
var bannerinterval = 3000;
var contactsinterval = 2000;

$.ajaxSetup({
  async: true
});


function RotateContacts()
{
    // rotate contacts
    last = $('ul#listticker li:last').hide().remove();
    $('ul#listticker').prepend(last);
    $('ul#listticker li:first').slideDown("slow");
    // interval = setInterval(RotateContacts, contactspause);
}

function doTimer() {
    if (!rotateContactsPause) {
        RotateContacts();
    }
    DoRotator = setTimeout("doTimer()", 3000);
}



function getcontacts() {
    $(".contact_list_block").html(contactsloading);
    $.post(contextAppPath + "/controls/contactsNearScroll.aspx?t=" + tabid + "&p=" + pageid, function(res) {
        $(".contact_list_block").html(res);
        // doTimer(contactsinterval);
    });
}

function initBinding() {


    // pause contact carousel on hover
    $(".contact_list_block").bind("mouseleave", function() {
        rotateContactsPause = false;
    });

    $(".contact_list_block").bind("mouseenter", function() {
        rotateContactsPause = true;
    });

    // Functions to get content when a contacttab clicked

    $(".contacttab").click(function() {
        $("#" + tabid).removeClass("current");
        tabid = $(this).attr("id");
        $("#" + tabid).addClass("current");
        pageid = 1;
        getcontacts();
    });
}




