﻿$(document).ready(function () {
    var current_page = window.location.href.split('/')[window.location.href.split('/').length - 1].split('.')[0];
    var selectId = current_page.split('_')[0];
    var perfix = window.location.href.split('/')[window.location.href.split('/').length - 2];
    if ((perfix == 'image') || (perfix == 'view_image')) {
        $('#a_image').css({
            'color': '#0344aa',
            'background': "url('../page/img/menu_hover.jpg') repeat-x top left"
        });
    }
    else if (perfix == 'contact') {
        $('#a_contact').css({
            'color': '#0344aa',
            'background': "url('../page/img/menu_hover.jpg') repeat-x top left"
        });
    }
    else {
        $.post("../page/get_parentId.ashx", { id_current: selectId, perfix: perfix }, function (result) {
            var parentId = result;
            $('#a_' + parentId).css({
                'color': '#0344aa',
                'background': "url('../page/img/menu_hover.jpg') repeat-x top left"
            });
            $('#a_' + parentId).parent('li').find('.ul_sub_menu').show();
        });
    }
    //---top menu----
    var current_id;
    $('.ul_top_menu li.li_item').find('a.item_left').hover(function () {
        current_id = $(this).attr('data_show');
        $('a.item_left').css({
            'color': '#FFF',
            'background-image': 'none'
        });
        $(this).css({
            'color': '#0344aa',
            'background': "url('../page/img/menu_hover.jpg') repeat-x top left"
        });
        $('a.item_left_select').css({
            'color': '#FFF',
            'background-image': 'none'
        });
        $('.ul_sub_menu').hide();
        $('ul#' + current_id).show();
    }, function () { });
    //---lazy load----
    $("a.small_product img").lazyload({
        placeholder: "../page/img/loading.jpg",
        effect: "fadeIn"
    });
    //---contact.aspx---
    $('.td_right').hover(function () {
        $(this).find('em').css('color', 'red');
        $(this).parent('tr').find('td').css('background-color', '#F4F4F4');
    }, function () {
        $(this).parent('tr').find('td').css('background-color', 'Transparent');
        $(this).find('em').css('color', '#A0A0A0');
    });
    //----last news---
    $(".ul_last_new").carouFredSel({
        items: 1,
        direction: "left",
        scroll: {
            items: 1,
            //effect          : "easeOutBounce",
            duration: 500
            //pauseOnHover    : true
        }
    });
    $(".ul_link_web").carouFredSel({
        items: 7,
        direction: "left",
        scroll: {
            items: 7,
            //effect          : "easeOutBounce",
            duration: 1000
            //pauseOnHover    : true
        },
        //prev: ".prev2",
        //next: ".next2",
        pagination: "#ulPadding2"
    });
    //----nivo_slide---
    $('#slider').nivoSlider({
        effect: 'random', //Specify sets like: 'fold,fade,sliceDown,random'
        slices: 10,
        animSpeed: 800, //Slide transition speed
        pauseTime: 3000,
        startSlide: 0, //Set starting Slide (0 index)
        directionNav: true, //Next & Prev
        directionNavHide: false, //Only show on hover
        controlNav: true, //1,2,3...
        controlNavThumbs: false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav: true, //Use left & right arrows
        pauseOnHover: true, //Stop animation while hovering
        manualAdvance: false, //Force manual transitions
        captionOpacity: 0.8, //Universal caption opacity
        beforeChange: function () { },
        afterChange: function () { },
        slideshowEnd: function () { }, //Triggers after all slides have been shown
        lastSlide: function () { }, //Triggers when last slide is shown
        afterLoad: function () { } //Triggers when slider has loaded
    });
    //---light box----        
    //$('.ul_list_image li a').lightBox();
    //---gallery image---
    var old_height = 0;
    $('#ul_list_image li a span').css({ 'height': '13px' });
    $('#ul_list_image li a').hover(function () {
        $(this).find('span').animate({ 'height': '50px' }, 300);
    }, function () {
        $(this).find('span').animate({ 'height': '13px' }, 500);
    });
    //---ty gia vang & chung khoan---
    $("#currency").genCurrency({ ClassName: "tblCurrency" });
    $("#goldprice").genGoldPrice({ ClassName: "tblGoldPrices" });
    //--tin thinh phat---
    $('#new_privater li:gt(1)').hide();
    $('#a_show').click(function () {
        $('#a_hide').show();
        $(this).hide();
        $('#new_privater li').slideDown();
    });
    $('#a_hide').click(function () {
        $('#a_show').show();
        $(this).hide();
        $('#new_privater li:gt(1)').slideUp();
    });
});


