﻿$(document).ready(function() {

    var classified_timer = function classifiedtimerEvent() {
        var clsfselected = null;
        var nextClsf = null;
        var clsfid = null;
        var cllsfselector = null;

        clsfselected = $('div.classif_values span.classif_active');
        clsfid = clsfselected.attr('value');
        if (clsfid > 0) {
            clsfselected.attr("class", "classif_nonactive");
            nextClsf = clsfselected.parent().next().children('span');
            if (nextClsf.length == 0) {
                nextClsf = $('div.classif_values > p:eq(0)').children('span');
            }
            nextClsf.attr("class", "classif_active");
            clsfid = nextClsf.attr('value');
        }
        else {
            cllsfselector = $('.classif_values > p:eq(0)').children('span');
            cllsfselector.attr('class', 'classif_active');
            clsfid = cllsfselector.attr('value');

        }
        if (clsfid > 0) {

            showClassified("div.featuredclassified_ajax", "/helperfiles/_featured_classifieds_box_ajax.aspx", clsfid);
            classif_counter--;
            if (classif_counter == 0) {
                clearInterval(classif_loaderId);
                setInterval(classified_timer, 10000);
            }
        }
    };

    var classif_counter = 1;
    var classif_loaderId = 0;
    loaderSwitch("div.featuredclassified_ajax");
    classif_loaderId = setInterval(classified_timer, 1000)

}); 
                       

    function showClassified(divclass,page,data)
    {
                   $.ajax
            ({
                    type: "GET",
                    url: page,                    
                    data: "id=" + data,
                    success: 
                        function(ret)
                        {                            
                             $(divclass).fadeOut(350,function()
                             {
                              $(divclass).html(ret).fadeIn(350);                          
                             });
                         }
             });
    }
    
