﻿$(document).ready(function () {
    $('.Btn,.cppBtn').hover(function () { $(this).addClass('BtnS'); }, function () { $(this).removeClass('BtnS'); });
    $('#BestSlider').bxSlider({ prev_image: '../App_Themes/MainTheme/Images/bxLeft.png', next_image: '../App_Themes/MainTheme/Images/bxRight.png' });
    $('.tmrItem').hover(function () { $(this).addClass('tmrItemHover'); }, function () { $(this).removeClass('tmrItemHover'); });

    var tabPanelClick = function (sender, tab) {
        $('.TabBtn').removeClass('TabBtnS');
        $(sender).addClass('TabBtnS');
        $('.TabPage').removeClass('TabPageS');
        $(tab).addClass('TabPageS');
        $('.GalleryHover').css('opacity', '0');
        $('.GalleryHoverText').css('opacity', '0');
    };
    $('#cthHonorBtn').click(function () { tabPanelClick('#cthHonorBtn', '#ctbHonor') });
    $('#cthGalleryBtn').click(function () { tabPanelClick('#cthGalleryBtn', '#ctbGallery') });
    $('#cthDescBtn').click(function () { tabPanelClick('#cthDescBtn', '#ctbDesc') });
    $('#cthNewsBtn').click(function () { tabPanelClick('#cthNewsBtn', '#ctbNews') });
    $('#ctbNews').addClass('TabPageS');

    /*------------------------------------------------------------------------------*/
    $('.GalleryPic').hover(function () {
        $(this).find('.GalleryHover').animate({ opacity: '0.5' }, 500, 'easeInOutBack');
        $(this).find('.GalleryHoverText').animate({ opacity: '1' }, 500, 'easeInOutBack');
    }, function () {
        $(this).find('.GalleryHover').animate({ opacity: '0' }, 500, 'easeInOutBack');
        $(this).find('.GalleryHoverText').animate({ opacity: '0' }, 500, 'easeInOutBack');
    });
    $('.HonorW').hover(function () { $(this).addClass('tandisS'); }, function () { $(this).removeClass('tandisS'); });
    $('.Corprate').hover(function () { $(this).addClass('op2'); }, function () { $(this).removeClass('op2'); });
    $('.CoBarItems').hover(function () { $(this).addClass('CoBarItemsHover'); }, function () { $(this).removeClass('CoBarItemsHover'); });
    $('.FooterButton').hover(function () { $(this).addClass('FooterButtonS'); }, function () { if (!($(this).hasClass('FooterButtonA'))) $(this).removeClass('FooterButtonS'); });

    $('#fbMainBut').click(function () {
        if ($('#fbMainButPointer').hasClass('fbMainButPointerS')) {
            $('#fbMainButPointer').removeClass('fbMainButPointerS');
            $('#fbMainPanel').animate({ top: '10px' }, 600);
        } else {
            $('#fbMainButPointer').addClass('fbMainButPointerS');
            $('.FooterButton').removeClass('FooterButtonA');
            $('.FooterPanel').animate({ top: '10px' }, 600);
            $('#fbMainPanel').animate({ top: '-325px' }, 600);
        }
    });

    $('.contactBtnMenu').click(function () {
        $('#bFooter').css({ 'display': 'none' });
        $('#cMain').fadeOut(100);
        $('.homeBtnMenu').removeClass('menuItemS');
        $('#cSubPage').load('../ContactPage.aspx');
        $('#cSubPage').fadeIn(100);
        $('.contactBtnMenu').addClass('menuItemS');
        
    });
    $('.homeBtnMenu').click(function () {
        $('#cSubPage').fadeOut(100);
        $('#bFooter').css({ 'display': 'none' });
        $('.homeBtnMenu').addClass('menuItemS');
        $('.contactBtnMenu').removeClass('menuItemS');
        $('#cMain').fadeIn(100);
        $('#bFooter').css({ 'display': 'block' });
    });

    var fbBtnClick = function (sender, panel, height) {
        if ($(sender).hasClass('FooterButtonA')) {
            $(sender).removeClass('FooterButtonA');
            $(panel).animate({ top: '10px' }, 600);
        } else {
            $('#fbMainButPointer').removeClass('fbMainButPointerS');
            $('#fbMainPanel').animate({ top: '10px' }, 600);
            $('.FooterButton').removeClass('FooterButtonA');
            $('.FooterButton').removeClass('FooterButtonS');
            $('.FooterPanel').animate({ top: '10px' }, 600);
            $(panel).stop().animate({ top: height }, 600);
            $(sender).addClass('FooterButtonA');
        }
    };
    $('#fbLoginBtn').click(function () { fbBtnClick(this, '#fbLoginPanel', '-290px') });
    $('#fbAgentBtn').click(function () { fbBtnClick(this, '#fbAgentPanel', '-318px') });
    $('#fbNewsBtn').click(function () { fbBtnClick(this, '#fbNewsPanel', '-360px') });
    $('#fbLangBtn').click(function () { fbBtnClick(this, '#fbLangPanel', '-160px') });

    /*---------------*/
    $('#Esfahan1').hover(function () { $('#Esfahan').css('background', 'url(../App_Themes/MainTheme/Images/Esfahan.png)'); }, function () { $('#Esfahan').css('background', ''); });
    $('#Tehran1').hover(function () { $('#Tehran').css('background-image', 'url(../App_Themes/MainTheme/Images/Tehran.png)'); }, function () { $('#Tehran').css('background-image', ''); });
    $('#Semnan1').hover(function () { $('#Semnan').css('background-image', 'url(../App_Themes/MainTheme/Images/Semnan.png)'); }, function () { $('#Semnan').css('background-image', ''); });
    $('#AzarGh1').hover(function () { $('#AzarGh').css('background-image', 'url(../App_Themes/MainTheme/Images/AzarbayejanGharbi.png)'); }, function () { $('#AzarGh').css('background-image', ''); });
    $('#Golestan1').hover(function () { $('#Golestan').css('background-image', 'url(../App_Themes/MainTheme/Images/golestan.png)'); }, function () { $('#Golestan').css('background-image', ''); });
    $('#KhRazavi1').hover(function () { $('#KhRazavi').css('background-image', 'url(../App_Themes/MainTheme/Images/KhorasanRazavi.png)'); }, function () { $('#KhRazavi').css('background-image', ''); });
    $('#AzarSh1').hover(function () { $('#AzarSh').css('background-image', 'url(../App_Themes/MainTheme/Images/AzarbayejanSharghi.png)'); }, function () { $('#AzarSh').css('background-image', ''); });
    $('#Ardebil1').hover(function () { $('#Ardebil').css('background-image', 'url(../App_Themes/MainTheme/Images/Ardebil.png)'); }, function () { $('#Ardebil').css('background-image', ''); });
    $('#Ghazvin1').hover(function () { $('#Ghazvin').css('background-image', 'url(../App_Themes/MainTheme/Images/Ghazvin.png)'); }, function () { $('#Ghazvin').css('background-image', ''); });
    $('#Markazi1').hover(function () { $('#Markazi').css('background-image', 'url(../App_Themes/MainTheme/Images/Markazi.png)'); }, function () { $('#Markazi').css('background-image', ''); });
    $('#Ghom1').hover(function () { $('#Ghom').css('background-image', 'url(../App_Themes/MainTheme/Images/Ghom.png)'); }, function () { $('#Ghom').css('background-image', ''); });
    $('#Hamedan1').hover(function () { $('#Hamedan').css('background-image', 'url(../App_Themes/MainTheme/Images/Hamedan.png)'); }, function () { $('#Hamedan').css('background-image', ''); });
    $('#Khoozestan1').hover(function () { $('#Khoozestan').css('background-image', 'url(../App_Themes/MainTheme/Images/Khoozestan.png)'); }, function () { $('#Khoozestan').css('background-image', ''); });
    $('#Ch_B1').hover(function () { $('#Ch_B').css('background-image', 'url(../App_Themes/MainTheme/Images/Ch_B.png)'); }, function () { $('#Ch_B').css('background-image', ''); });
    $('#Yazd1').hover(function () { $('#Yazd').css('background-image', 'url(../App_Themes/MainTheme/Images/Yazd.png)'); }, function () { $('#Yazd').css('background-image', ''); });
    $('#Fars1').hover(function () { $('#Fars').css('background-image', 'url(../App_Themes/MainTheme/Images/Fars.png)'); }, function () { $('#Fars').css('background-image', ''); });
    $('#Bandar1').hover(function () { $('#Bandar').css('background-image', 'url(../App_Themes/MainTheme/Images/Bandarabbas.png)'); }, function () { $('#Bandar').css('background-image', ''); });
    /*---------------*/
    $(function () { var $cn_next = $('#cn_next'); var $cn_prev = $('#cn_prev'); var $cn_list = $('#cn_list'); var $pages = $cn_list.find('.cn_page'); var cnt_pages = $pages.length; var page = 1; var $items = $cn_list.find('.cn_item'); var $cn_preview = $('#cn_preview'); var current = 1; $items.each(function (i) { var $item = $(this); $item.data('idx', i + 1); $item.bind('click', function () { var $this = $(this); $cn_list.find('.selected').removeClass('selected'); $this.addClass('selected'); var idx = $(this).data('idx'); var $current = $cn_preview.find('.cn_content:nth-child(' + current + ')'); var $next = $cn_preview.find('.cn_content:nth-child(' + idx + ')'); if (idx > current) { $current.stop().animate({ 'top': '-300px' }, 600, 'easeOutBack', function () { $(this).css({ 'top': '310px' }); }); $next.css({ 'top': '310px' }).stop().animate({ 'top': '5px' }, 600, 'easeOutBack'); } else if (idx < current) { $current.stop().animate({ 'top': '310px' }, 600, 'easeOutBack', function () { $(this).css({ 'top': '310px' }); }); $next.css({ 'top': '-300px' }).stop().animate({ 'top': '5px' }, 600, 'easeOutBack'); } current = idx; }); }); $cn_next.bind('click', function (e) { var $this = $(this); $cn_prev.removeClass('disabled'); ++page; if (page == cnt_pages) $this.addClass('disabled'); if (page > cnt_pages) { page = cnt_pages; return; } $pages.hide(); $cn_list.find('.cn_page:nth-child(' + page + ')').fadeIn(); e.preventDefault(); }); $cn_prev.bind('click', function (e) { var $this = $(this); $cn_next.removeClass('disabled'); --page; if (page == 1) $this.addClass('disabled'); if (page < 1) { page = 1; return; } $pages.hide(); $cn_list.find('.cn_page:nth-child(' + page + ')').fadeIn(); e.preventDefault(); }); });

    $('#slider').nivoSlider({effect: 'fade', slices: 15, boxCols: 8,  boxRows: 4,  animSpeed: 500,  pauseTime: 7000, startSlide: 0, directionNav: true, directionNavHide: true, controlNav: false,  keyboardNav: true,  pauseOnHover: true, manualAdvance: false, captionOpacity: 0.8, prevText: '', nextText: '', });


});

$(window).load(function () {
    $('#C').fadeIn(3000);
});
