/**
 * 
 */
$(function() {
    var tt = [];
    var boxidx = 0;
    var fadti = 600;
    /*
    $('div.mainbox').each(function(){
        boxidx++;
        $(this).attr({'id':'boxnbr'+boxidx});
    });
	*/
    /* $('#boxnbr1').fadeIn(fadti*2,
        function(){
            $('#boxnbr2').fadeIn(fadti,
                function(){
           		$('#boxnbr3').show();
                    $('#boxnbr3').fadeIn(fadti,
                        function(){
							initCarousel();
                            $('#boxnbr4').fadeIn(fadti,
                                function(){
                                    // animateAcordeon();
                            });
                    });
            });
    }); */
    // $('#accordion').show().accordion();
    
    var idx=-1;
    /**
     * 
     */
	function initCarousel()
	{
        $('#carroussel').bxSlider({
            mode : 'horizontal',
            speed : 500,
            controls : false,
            auto : true,
            randomStart : true,
            pause : 2500
        });
	};
	/**
	 * 
	 */
    function animateAcordeon()
    {
        idx++;
        var t=setTimeout(animateAcordeon,5000);
        $('#accordion').accordion( "activate" , idx );
        if (idx >= 6) idx = -1;
    };
    /**
     * 
     */
    function slideBoxes()
    {
    	$('.mainbox').each(function(){
    		// init
    		var sldbx = [];
    		var cntr = 0;
    		$('.slidebox', $(this)).hide().each(function(){ 
    			var url = $(this).attr('url');
    			if (url != '') {
    				$(this).css({'cursor':'pointer'}).click(function(){ window.location=url; });
    			}
    			sldbx.push( $(this) );
    		});
    		// sliding
    		function sliding() {
    			var ti;
    			for(var y=0; y < sldbx.length; y++) $(sldbx[y]).hide();
    			$(sldbx[cntr]).fadeIn(3000, function(){ ti=setTimeout(sliding,5000); });
    			cntr++;
    			if (cntr >= sldbx.length) cntr=0;
    		};
    		sliding();
    	});
    };
    /**
     * 
     */
    function changeLayout() {
        $('#pageContent > div[text=editclass], div.content').css({'float':'right'});
    };

    // initialization
    changeLayout();
    slideBoxes();
    initCarousel();
});







