$(function(){

$("#accordion").accordion({ 
	header: "h3",
	autoHeight: false,
	navigation: true});
});

function mycarousel_initCallback(carousel) {

	carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	
	jQuery('.jcarousel-control a').bind('click', function() {
       	carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
		jQuery('a[id|=offerLink]').removeClass('active');
		jQuery(this).addClass('active');
  		    return false;
	});
	jQuery('.jcarousel-scroll select').bind('change', function() {
    	carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
		return false;
  	});
};
		
function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
	jQuery('a[id|=offerLink]').removeClass('active');
	jQuery('#offerLink-'+idx).addClass('active');	
};

$(document).ready(function() {
	$('#mycarousel').jcarousel({
		auto: 5,
		scroll: 1,
		wrap: 'both',
		animation: 'slow',
		initCallback: mycarousel_initCallback,
		itemVisibleInCallback: {
				onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation
		}
	});
	
	$('#clients').jcarousel({
		auto: 3,
		scroll: 1,
		wrap: 'both',
		initCallback: mycarousel_initCallback,
		itemVisibleInCallback: {
				onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation
		}
	});
	
	
	$("#buttonToggle").click(function() {
		$("#effect").toggle('blind','','');
		return false;
	});
	$("#buttonClose").click(function() {
		$("#effect").toggle('blind','','');
		return false;
	});
	
	$('#tooltips a').tooltip({ 
	    track: true, 
	    delay: 0, 
	  	opacity: 1, 
		fixPNG: false, 
	    showURL: false, 
	    showBody: "# ", 
	    fade: 0
	});
	
	$(".shadowBoxProjectNavigation").fadeTo(0, 0.5);
	
	$(".shadowBoxProjectNavigation").hover(
		function () {                       
    		$(this).css({'z-index' : '100'});
			$(this).children(".hover").show();
			$(this).fadeTo(0, 1);
		},
		function () {
		 	$(this).css({'z-index' : '-1'});
			$(this).children(".hover").hide();
			$(this).fadeTo("fast", 0.5);
		}
	);
	
	$(".references").fadeTransition({
		pauseTime: 7000, 
		transitionTime: 2000 
	});
	
	$('.references img').hover(
	   	function () {
			$(this).fadeTo("fast", 0);                       
		},
		function () {
			$(this).fadeTo("fast", 1);  
		}
	);
	
	$('#link16').click(function(){
		$('#dialog').dialog('open');
		return false;
	});
	
	$('#link85').click(function(){
		$('#dialog').dialog('open');
		return false;
	});
	
	$('#dialog').dialog({
		autoOpen: false,
		modal: true,
		resizable: false,
		width: 800
	});
	
	$('#pagePeel').hover(
	   	function () {
		$("#pagePeel").stop()
			.animate({
				width: '600px',
				height: '445px',
				opacity: '0'
			}, 500);
		},
		function () {
		$("#pagePeel").stop()
			.animate({
				width: '50px',
				height: '50px',
				opacity: '1'
			}, 500);
		}
	);
	
	$("#effect").css({'display' : 'none'});
	
});
