$(document).ready(function() {
	$(".png, #wrapper.overlay, h1#logo, h1#logoHome").ifixpng();
	$("h1#logo").click(function(){
		window.location.href = $(this).parent().find("a").attr('href'); 
	});
	$("#txtHolder").jScrollPane({ scrollbarWidth: 10, scrollbarMargin: 10, showArrows: true });
	$("a#btnRefGreen").toggle(function(){
		$(".intro").hide();
		$(".references").fadeIn();
		$("#txtHolder").jScrollPane({ scrollbarWidth: 10, scrollbarMargin: 10, showArrows: true });
		$(this).addClass("hover");
	},function(){
		$(".references").hide();
		$(".intro").fadeIn();
		$("#txtHolder").jScrollPane({ scrollbarWidth: 10, scrollbarMargin: 10, showArrows: true });
		$(this).removeClass("hover");
	});
	$("ul#targets li h3").each(function(){
		$(this).parent().bind("click", function(){
			window.location.href = $(this).find("a").attr('href'); 
		});
		$(this).parent().hover(function(){
			JT_show($(this).find("a").attr('rel'),$(this).find("a").attr('id'),$(this).find("a").attr('name'));
		},function(){
			$('#JT').remove();
		});
	});
	
	$("ul#icoVideos li a").click(function(){
		var flvURL = $(this).attr('href');
		var tempo = $(this).attr('rel');
		$(this).parent().parent().find("a").removeClass("hover");
		$(this).addClass("hover");
		if(tempo){
			$("#playerVideos").html("").flash({ src: 'swf/playerVideo.swf', width: 320, height: 240, wmode: 'transparent', flashvars: { xml: ['flv/' + flvURL].join(' '), tempo: [tempo].join(' ')}}, { version: 8 });	
		}else{
			$("#playerVideos").html("").flash({ src: 'swf/playerVideo.swf', width: 320, height: 240, wmode: 'transparent', flashvars: { xml: ['flv/' + flvURL].join(' ')}}, { version: 8 });
		}
		return false;
	});
	
	
	$(".copy").click(function(){
		$(this).focus().select();
	});
});

/* Accordion Why´s page */
jQuery.fn.accordionWhy = function(options) {
    // options
    var SLIDE_DOWN_SPEED = 'slow';
    var SLIDE_UP_SPEED = 'fast';
    var startClosed = options && options.start && options.start == 'closed';
    var on = options && options.on && (typeof options.on == 'number' && options.on > 0) ? options.on - 1 : 0;
    return this.each(function() {
        jQuery(this).addClass('accordion'); // use to activate styling
        jQuery(this).find('ul').hide();
		jQuery(this).find('p').click(function() {
            var current = jQuery(this.parentNode).find('ul:visible');
            var next = jQuery(this).find('+ul');
            if (current[0] != next[0]) {
                current.slideUp(SLIDE_UP_SPEED);
            } 
            if (next.is(':visible')) {
                next.slideUp(SLIDE_UP_SPEED);
            } else {
                next.slideDown(SLIDE_DOWN_SPEED);
            }
        });
        if (!startClosed) {
            jQuery(this).find('ul:eq(' + on + ')').slideDown(SLIDE_DOWN_SPEED);
        }
    });
};
