//change the opacity for different browsers
function changeOpac(opacity, id) {
var object = document.getElementById(id).style; 
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
}
function blendimage(divid, imageid, imagefile, millisec) {
var speed = Math.round(millisec / 100);
var timer = 0;

//set the current image as background
document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

//make image transparent
changeOpac(0, imageid);

//make new image
document.getElementById(imageid).src = imagefile;

//fade in image
for(i = 0; i <= 100; i++) {
setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
timer++;
}
}

$(document).ready(function () {
	
//jCarousel Plugin
    $('#carouseltrabajos').jcarousel({
		vertical: true,
		scroll: 4,
		auto: 0,
		visible: 4,
		wrap: 'both',
		animation: 'fast', 
		initCallback: mycarousel_initCallback
   	});

//jCarousel Plugin
    $('#carouselgaleria').jcarousel({
		vertical: true,
		scroll: 4,
		auto: 0,
		visible: 5, 
		wrap: 'both',
		animation: 'fast', 
		initCallback: mycarousel_initCallback
   	});

//Front page Carousel - Initial Setup
$('div#slideshow-carousel a img').css({'opacity': '1.0'});
$('div#slideshow-carousel a img:first').css({'opacity': '1.0'});
$('div#slideshow-carousel li a:first').append('<span class="arrow"></span>')


//Combine jCarousel with Image Display
$('div#slideshow-carousel li a').hover(
function () {
		
	if (!$(this).has('span').length) {
		$('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '1.0'});
    		$(this).stop(true, true).children('img').css({'opacity': '1.0'});
	}		
},
function () {
		
	$('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '1.0'});
	$('div#slideshow-carousel li a').each(function () {

		if ($(this).has('span').length) $(this).children('img').css({'opacity': '1.0'});

	});
		
}
).click(function () {

      	$('span.arrow').remove();        
	$(this).append('<span class="arrow"></span>');
$('div#slideshow-main li').removeClass('active');        
$('div#slideshow-main li.' + $(this).attr('rel')).addClass('active');	
	
return false;
});


});


//Carousel Tweaking

function mycarousel_initCallback(carousel) {

// Pause autoscrolling if the user moves with the cursor over the clip.
carousel.clip.hover(function() {
	carousel.stopAuto();
}, function() {
	carousel.startAuto();
});
}


