//tevabien-home.js

$(document).ready(function(event) {

	//homeAdsCarousel 28 sep 2009: init
	$("#homeAdsCarouselScrollRight").click(function(event) {
		scrollHomeAdsCarousel(-1);
		$(this).blur();
		event.preventDefault();
	}); // end homeAdsCarouselScrollRight
	$("#homeAdsCarouselScrollLeft").click(function(event) {
		scrollHomeAdsCarousel(1);
		$(this).blur();
		event.preventDefault();
	}); // end homeAdsCarouselScrollLeft
	//end homeAdsCarousel init	

}); // end jQuery $(document).ready


function showVideo(idVideo) {
	var popup = window.open("", "Video", "menubar=no,width=550,height=450,scrollbars=1,toolbar=no,location=no");
	popup.document.write('<html><body><div align="center"><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/' + idVideo +  '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + idVideo + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></div></body></html>');
}

//homeAdsCarousel 28 sep 2009
function scrollHomeAdsCarousel(direction) {
	//direction = 1 or -1

	var howManyAds = 3;
	var viewerWidth = 364;

	var allAdsWidth = howManyAds * viewerWidth;

	var thePosition = $('#homeAdsCarouselViews').position();
	var theOffset = thePosition.left; //(obtener);

	var theNewOffset = theOffset + (viewerWidth * direction);

	if (theNewOffset > 0) {
		theNewOffset = -allAdsWidth + viewerWidth;
	}

	if (theNewOffset <= -allAdsWidth) {
		theNewOffset = 0;
	}

	$('#homeAdsCarouselViews').animate({ left: theNewOffset }, 500);
}
