function creaVideo(url)
{
	var html = '<object width="560" height="340">\
					<param id="movieparam" name="movie" value="' + url + '"></param>\
					<param name="allowFullScreen" value="true"></param>\
					<param name="allowscriptaccess" value="always"></param>\
					<embed src="' + url + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed>\
				</object>';
	return html;
}

function showProduct (url)
{
	$('#indicator').removeClass('hidden');
	$('#productInfo .foto, #productInfo .datos').addClass('hidden');
	$.ajax({
		   type: "GET",
		   url: url,
		   data: "",
		   dataType: 'html',
		   success: function(html){
		   		var parte = $('#productInfo', html).html();
		   		if (parte){
		   			$('#productInfo').html(parte);
		   		} else {
		   			window.location = url;
		   		}
			},
			complete: function() { $('#indicator').addClass('hidden'); }
	 });
	 return false;
}


function showMediumPicture(i)
{
	$('#videoPlayer a').addClass('hidden');
	$('#videoPlayer a:eq(' + i + ')').removeClass('hidden');
	var largesrc = $('#videoPlayer a:eq(' + i + ')').attr('href');
	$('.maximizar').attr('href', largesrc);
}


$(document).ready(function() {
	if ($('#videoList').get(0))
	{
		if($('#picturesTable table').get(0))
		{
			$('#picturesTable table tr').each(function(i) {
				var smallsrc = $('img:first', this).attr('src');
				var mediumsrc = $('img:last', this).attr('src');
				var largesrc = $('a', this).attr('href');
				
				if (i == 0){
					clase = '';
					$('.maximizar').attr('href', largesrc);
				} else
					clase = 'hidden';
				
				$('#videoPlayer').append('<a class="' + clase + ' lightbox" href="' + largesrc + '"><img src="' + mediumsrc + '" width="560" height="340" /></a>');
				
	
				$('#mycarousel').append('<li><a href="#" onclick="showMediumPicture(\'' + i + '\'); return false"><img class="reflect" src="' + smallsrc + '" width="120" height="90" /></a></li>');
				
				$('a.lightbox').lightBox(lightboxOptions);
			});
		}
    	$('#videoList ul').jcarousel({});
    }else if ($('#productsList').get(0))
	{
    	$('#productsList ul').jcarousel({scroll:5});
    }
    
    if ($('#slider').get(0))
    {
	    // $('#slider div').cycle();
	    if ($('#page-blog').get(0)) 
	    {
	    	$('#slider div').cycle({ 
			    fx:      'custom', 
			    cssBefore: {  
			        left: 115,  
			        top:  115,  
			        width: 0,  
			        height: 0,  
			        opacity: 1, 
			        zIndex: 1 
			    }, 
			    animOut: {  
			        opacity: 0  
			    }, 
			    animIn: {  
			        left: 0,  
			        top: 0,  
			        width: 610,  
			        height: 191  
			    }, 
			    cssAfter: {  
			        zIndex: 0 
			    }, 
			    delay: -3000 
			});
	    } else {
		    $('#slider div').cycle({
			    fx:      'scrollRight',
			    timeout:  5000 ,
		   	 easing:  'backinout' 
			});
		}
		
		
    }
});