/*
 * Funciones jQuery
 * Por David Cowgill
 *
 * Copyright (c) 2010 App Themes (http://appthemes.com)
 *
 * Built for use with the jQuery library
 * http://jquery.com
 *
 * Version 1.2
 *
 * Left .js uncompressed so it's easier to customize
 */

// <![CDATA[

/* Featured listings slider */
jQuery(document).ready(function() {
    jQuery(".slider").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        visible: 5,
        auto: 2800,
        speed: 1100,
        easing: "easeOutQuint" // for different types of easing, see easing.js
    });
});


/* Tab Control home main */
jQuery(function () {
    var tabContainers = jQuery('div.tabcontrol > div');
    tabContainers.hide().filter(':first').show();
    jQuery('div.tabcontrol ul.tabnavig a').click(function () {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        jQuery('div.tabcontrol ul.tabnavig a').removeClass('selected');
        jQuery(this).addClass('selected');
        return false;
    }).filter(':first').click();
});

/* Tab Control sidebar */
jQuery(function () {
    var tabContainers = jQuery('div.tabprice > div');
    tabContainers.hide().filter(':first').show();
    jQuery('div.tabprice ul.tabnavig a').click(function () {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        jQuery('div.tabprice ul.tabnavig a').removeClass('selected');
        jQuery(this).addClass('selected');
        return false;
    }).filter(':first').click();
});

/* Category nav drop down */
function toggle_slide(id_name) {
    jQuery('#'+id_name).slideToggle('fast');// open/close slide menu
}

/* Category nav drop down */
function selected_slide(id_name, form_id_place, form_name_place, id_cat) { // checked slide variable
    var ObjectForm = document.getElementById(id_name); // init slide
    var Element = ObjectForm.parentNode.getElementsByTagName("li"); // init slide element
    for (i = 0; i < Element.length; i++) { // choose slide element
        ElementHref = Element[i].parentNode.getElementsByTagName("a"); // init Tag A
        attribute = ElementHref[i].getAttribute("rel"); // init ID element
        Element[i].removeAttribute("class"); // delete checked old slide menu selected
        if (id_cat == attribute) {  // init selecte element
            save_slide(form_id_place, form_name_place, attribute, ElementHref[i].innerHTML); // save data
            Element[i].setAttribute("class", "active"); // checked slide menu selected element
        }
    }
    toggle_slide(id_name); // close slide menu
}

/* Category nav drop down */
function save_slide(id_place, name_place, var_id, var_name) {
    document.getElementById(id_place).value = var_id; // write ID element
    document.getElementById(name_place).innerHTML = var_name; // write name Element
    return 0;
}

/* initialize the form validation */
jQuery(document).ready(
    function(){
        jQuery("#mainform").validate({
            errorClass: "invalid"
        });
    }
);

// ]]>
