/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


$(document).ready(function(){
    
    $("#header>ul>li").each(function(){
        $(this).children('a').wrap('<span>','</span>')
    })
    $("#header>ul>li").hover(function(){
        $(this).addClass('active')
    },function(){
        $(this).removeClass('active')
    });
    
    $('#slides-text-area div').html($('div','#slides .slide:first-child').html()).animate({
        'top':'0px'
    },400,'easeInOutCirc');
   
    $("#video-gallery-slides").carouFredSel({
        auto: false
    });
    $("#video-gallery ul li a").click(function(){
        $("#video-gallery ul li").removeClass('active');
        $(this).parent().addClass('active');
    })
    
    $("#news-images").carouFredSel({
        auto: false,
        direction:'up'
    });

    $("#slides").carouFredSel({     
        auto : {
            duration	: 600,
            pauseDuration: 3000,
            fx:'crossfade',
            pauseOnHover: true,
            onBefore: function(oldItems, newItems) {
                $('#slides-text-area div').animate({
                    'opacity':'0'
                },400,'easeInOutCirc');
            },
            onAfter	: function(oldItems, newItems) {
                $('#slides-text-area div').html($('div',newItems).html()).animate({
                    'opacity':'1'
                },400,'easeInOutCirc');
            }
        },
        scroll : {
            fx          : "crossfade",            
            duration	: 600,            
            onBefore: function(oldItems, newItems) {
                $('#slides-text-area div').animate({
                    'opacity':'0'
                },400,'easeInOutCirc');                    
            },
            onAfter	: function(oldItems, newItems) {
                $('#slides-text-area div').html($('div',newItems).html()).animate({
                    'opacity':'1'
                },400,'easeInOutCirc');
            }
        },
        prev	: {	
            button	: "#next",
            key		: "left"
        },
        next	: { 
            button	: "#prev",
            key		: "right"
        }
        
    });
    
    $("#featured-slides ul").carouFredSel({     
        auto: false,
        width: 780,
        height: 300,
        prev	: {	
            button	: "#prev-page",
            key		: "left"
        },
        next	: { 
            button	: "#next-page",
            key		: "right"
        }
        
    });
    $("#int-slides ul").carouFredSel({     
        auto: false,
        width: 885,
        height: 81,
        prev	: {	
            button	: "#prev-int",
            key		: "left"
        },
        next	: { 
            button	: "#next-int",
            key		: "right"
        }
        
    });
    
    $('#prev,#next').css('opacity','0.8');
    
    //    $('#prev-page').mouseover(function(){        
    //        $(this).stop().animate({
    //            'backgroundPositionX':"100%"
    //        },300,'easeOutQuad')
    //    })
    //    .mouseout(function(){
    //        $(this).stop().animate({
    //            'backgroundPositionX':"0%"
    //        },300,'easeOutQuad')        
    //    })
    //    
    //    $('#next-page').mouseover(function(){        
    //        $(this).stop().animate({
    //            'backgroundPositionX':"0%"
    //        },300,'easeOutQuad')
    //    })
    //    .mouseout(function(){
    //        $(this).stop().animate({
    //            'backgroundPositionX':"100%"
    //        },300,'easeOutQuad')        
    //    })
    
    $("#content-body.contact").salah_slider({
        height:282,
        parent_extra_hw:0,
        generate_slider:false,
        slides_cont:'#contacts .warp',
        children:'.slide',
        dir:'up',
        slider:'#contact-slider',
        slider_sub:'li',
        //        next:'#next-int',
        //        prev:'#prev-int',
        speed:1200,
        easing:'easeInOutSine',
        flexible:false
    });

    $("#content-body.contact #contacts").css('height','282px');
    $("#contact-slider li").click(function(){
        //    alert($("#contact-slider li").index(this)+1);
        var slide_pos = $("#contact-slider li").index(this)+1
        if(slide_pos==1){
            $('#section-header').text('Contact us')
            $("#contacts span.arrow").animate({
                'top':0
            },1200)
        }
        if(slide_pos==2){
            $('#section-header').text('Write to us')
            $("#contacts span.arrow").animate({
                'top':345
            },1200)
        }
        if(slide_pos==3){
            $('#section-header').text('We are social')
            $("#contacts span.arrow").animate({
                'top':685
            },1200)
        }
    })
            
    $("#partners div").salah_slider({
        width:'900',
        parent_extra_hw:0,
        generate_slider:false,
        slides_cont:'div',
        children:'p',
        dir:'left',
        interval:6000,
        speed:1200,
        easing:'easeInOutSine',
        flexible:false
    });
    $("#partners div p a").each(function(){
        var img=$(this).children('img');
        var img_width = $(img).width();
        $(img).css({
            'left':((170-img_width)/2)+'px',
            'top':'-140px'
        });
    })
            
    $("#partners div p a img").hover(function(){
        $(this).stop().animate({
            'top':'0px'
        },800,'easeOutElastic')
    },function(){
        $(this).stop().animate({
            'top':'-140px'
        },1500,'easeOutElastic')                
    })
    
    $("#gallery-page .content li a").colorbox({
        rel:'gallery'
    });
    $("#gallery-page.video .content li a").colorbox({
        iframe:true, 
        innerWidth:'560', 
        innerHeight:'315'
    });
    $("#gallery-page.video .content li a").append('<img src="theme/standard/images/big-video-overlay.png" class="video-overlay" alt="" />');
    $("#video a").colorbox({
        iframe:true, 
        innerWidth:'560', 
        innerHeight:'315'
    });
    
})

