/**
 * @author adrian marte
 */
// Drop Down
$(function() {
    $('#nav').droppy();

/* Block Toggle */

	$(".toggle h2").nextAll().toggle();
	$(".toggle h2").click(function(){
		$(this).nextAll().toggle();
	})


    // Scroller  
    // initialize scrollable  
    $("div.scrollable").find("#items a").remove();
    $("div.scrollable").scrollable({ 
             
        // items are auto-scrolled in 2 second interval 
        interval: 12000, 
        loop: true,  
        speed: 1200, 
	size: 1,
	items: '#items',   
        hoverClass: 'hover',
         
        // when seek starts make items little transparent 
        onBeforeSeek: function() { 
            this.getItems().fadeTo(600, 0.5);
        }, 
         
        // when seek ends resume items to full transparency 
        onSeek: function() { 
            this.getItems().fadeTo(600, 1);
        } 
    }).autoscroll({
        autoplay: true,
        autopause:true,
        interval:10000
    }).circular();     
     


    /* Image Scroller (Dia Show) in Main Content Area */
	// Copy all raw-image tags to scroller div
	$('#dia-images * img').each(function() {
		$("#dia-container").append($(this));
	});
	
	$('#dia-container img').each(function() {
	 	$(this).jScale({w:$(this).parent().width()});
	});

        if($('#dia-container').length == 1) {
		$('#dia-container').cycle({ 
			delay:  5000, 
			speed:  1500
		});
	}


	/* Corners */
/*	
	$('.sideblock').corner({
		tl: { radius: 8 },
		tr: { radius: 8 },
		bl: { radius: 8 },
		br: { radius: 8 },
		antiAlias: true,
		autoPad: false,
		validTags: ["div"] }); 

	$('#ft').corner({
		tl: { radius: 8 },
		tr: { radius: 8 },
		bl: { radius: 8 },
		br: { radius: 8 },
		antiAlias: true,
		autoPad: false,
		validTags: ["div"] }); 
		
	$('#hd').corner({
		tl: { radius: 8 },
		tr: { radius: 8 },
		bl: { radius: 8 },
		br: { radius: 8 },
		antiAlias: true,
		autoPad: false,
		validTags: ["abbr"] }); 
		
		
	$('#scroller_container').corner({
		tl: { radius: 8 },
		tr: { radius: 8 },
		bl: { radius: 8 },
		br: { radius: 8 },
		antiAlias: true,
		autoPad: true,
		validTags: ["div"] }); 
*/		
		
	/* Scale images in Main Content area */
	resizeWindow();

	$(window).bind("resize", resizeWindow);
	function resizeWindow( e ) {
		$('.csc-textpic-border * img').each(function() {
	  		$(this).jScale({w:$(this).parent().width()});
		});
		$('.yui-u .sideblock:not(.special) .csc-textpic-image img').each(function() {
	  		$(this).jScale({w:$(this).parents('.sideblock').width()});
		});
		$('#dia-container img').each(function() {
	 		$(this).jScale({w:$(this).parent().width()});
		});
	}
	

});