$(document).ready(function() 
{
	var isOpened = false;
	$(".biografia_content img").overlay({
		target:'#biografia_popup',
		expose:'#000000',
		closeOnClick:true,
		onClose: function(){
			$('#bio1').attr("src","");
			$('#bio2').attr("src","");
			$('#bio3').attr("src","");
			$('#bio4').attr("src","");
			$('#biografia_popup').hide();
		}
	});
	$('#news_current a').overlay({
		target:'#popup2',
		expose:'#000000',
		closeOnClick:true,
		onClose: function(){
			$('#popup2').hide();
		}
	});
	$('#news_full a').overlay({
		target:'#popup2',
		expose:'#000000',
		closeOnClick:true,
		onClose: function(){
			$('#popup2').hide();
		}
	});
	$('.tienda_item img').overlay({
		expose: '#000000',
		left:'center',
		target: '#multimedia_gallery',
		closeOnClick:true,
		closeOnEsc:true,
		onBeforeLoad: function()
		{
			$('#gallery_image').attr("src","");
			$('#gallery_image_2').attr("src","");
			$('#isOpened').val("true");
		},
		onClose: function(){
			$('#isOpened').val("false");
			$('#multimedia_gallery').css("width",400);
			$('#multimedia_gallery').css("height",400);
			$('#gallery_image').attr("src","");
			$('#gallery_image_2').attr("src","");
			$('#multimedia_gallery').hide();
		}
	});
	$('#gallery_trigger img').overlay({
		expose: '#000000',
		left:'center',
		target: '#multimedia_gallery',
		onBeforeLoad: function(){
			$('#gallery_image').attr("src","");
			$('#isOpened').val("true");
		},
		onClose: function(){
			$('#isOpened').val("false");
			$('#multimedia_gallery').css("width",400);
			$('#multimedia_gallery').css("height",400);
			$('#gallery_image').attr("src","");
			$('#multimedia_gallery').hide();
		}
	});
	$('#noticias_hidden').hide();	$('#multimedia_item0').hide();	$('#multimedia_item1').hide();	$('#multimedia_item2').hide();	$('#multimedia_item3').hide();
	$('input[name="subscription_email"]').addClass("idleField");	$('input[name="subscription_email"]').focus(function() {	    $(this).removeClass("idleField").addClass("focusField");	    if (this.value == this.defaultValue){	        this.value = '';	    }	    if(this.value != this.defaultValue){	        this.select();	    }	});
	$('input[name="subscription_email"]').blur(function() {	    $(this).removeClass("focusField").addClass("idleField");	    if ($.trim(this.value) == ''){	    	this.value = this.defaultValue;	    }	});
	$('#show_noticias').click(function() {	    $('#noticias_hidden').show();	    $('#show_noticias').hide();	});
	$('#hide_noticias').click(function() {	    $('#noticias_hidden').hide();	    $('#show_noticias').show();	});
	var get_string		= location.search.substr(1).split("&");	var get_PAGE		= "0"; 	for (var i = 0; i < get_string.lenght; i++)	{		var get_variable	= get_string[i].split("=");		if (get_variable[0] = "PAGE" )			get_PAGE		= get_variable[1];	}	/*--- wait time ----*/    $.fn.wait = function(time, type) {        time = time || 500;        type = type || "fx";        return this.queue(type, function() {            var self = this;            setTimeout(function() {                $(self).dequeue();            }, time);        });    };   
	$("#video_trigger img").overlay({
		expose: '#000000',
		target: '#video',
		closeOnClick:true,
		onClose: function ()
		{
			$("#multimedia_gallery_image").attr("src","");
			$('#video').hide();
		}
	});	});
function display_biografia(){	$('#biografia_canvas').hide('slow');	xajax_display_post_information('1','display_type_content','biografia_canvas_full');	$('#biografia_canvas_full').show('slow');}
function display_index_news(){	$('#news_current').hide('slow');	$('#news_full').wait();	$('#news_full').show('slow');}
function multimedia_display(display_type){	$('#multimedia_item0').hide(1000);	$('#multimedia_item1').hide(1000);	$('#multimedia_item2').hide(1000);	$('#multimedia_item3').hide(1000);	$('#multimedia_item'+display_type).show(500);}
function display_lyrics(album_title){	$('#change_lyrics').hide();	xajax_display_post_information(album_title,'display_type_content','change_lyrics');	$('#change_lyrics').show();	$('#print').attr('href', './?PAGE=8&LYRICS_ID='+album_title);}
function change_biografia_reconocimiento(){	$('#reconocimientos').hide(800);	xajax_display_random_content('2003','reconocimientos');	$('#reconocimientos').show(800);}
function change_biografia_sabias(){	$('#sabias').hide(800);	xajax_display_random_content('2002','sabias');	$('#sabias').show(800);}
//---- Galeria de multimedia
function hide_loader()
{
	alert("load");
	
}
function gallery_video($image_path)
{
	var browser = navigator.appVersion;
	if(browser.indexOf('MSIE 7.0')>0)
		$('#video_content').html('<object id=\"embed_video\" width=\"500\" height=\"365\"  ><param name=\"movie\" value=\"'+$image_path+'\" id=\"video_path\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed id=\"video_embed\" src=\"'+$image_path+'\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"500\" height=\"385\" wmode="transparent" ></embed></object>');
	else
		$('#video_content').html('<div class=\"video_loader\"></div><object id=\"embed_video\" width=\"500\" height=\"365\"  ><param name=\"movie\" value=\"'+$image_path+'\" id=\"video_path\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed id=\"video_embed\" src=\"'+$image_path+'\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"500\" height=\"385\" wmode="transparent" ></embed></object>');
}
function changeGalleryImage($image)
{
	$('#loader').fadeIn();
	var img = new Image();
	
	$(img).load(function() {
		$('#gallery_image').hide();
		$(img).hide();
		if($('#isOpened').val()=="true")
		{
			$('#multimedia_gallery').animate({
				width:img.width,
				left:($(window).width()-img.width)/2
			}, function(){ $('#loader').fadeOut(); }).animate({height:img.height },function(){
				$('#gallery_image').fadeIn('slow');
			});
			$('#gallery_image').attr("src","./userContent/"+$image);
		}
	}).attr("src","./userContent/"+$image);
	
	//$('#gallery_image').hide();
	$('#zip_download').hide();
}
function changeWallpaper($image)
{
	$('#loader').fadeIn();
	var img = new Image();
	
	$(img).load(function() {
		$('#gallery_image').hide();
		$(img).hide();
		if($('#isOpened').val()=="true")
		{
			$('#multimedia_gallery').animate({
				width:img.width,
				left:($(window).width()-img.width)/2
			}, function(){ $('#loader').fadeOut(); }).animate({height:img.height},function(){
				$('#gallery_image').fadeIn('slow');
			});
			$('#gallery_image').attr("src","./userContent/"+$image+".jpg");
		}
	}).attr("src","./userContent/"+$image+".jpg");
	$('#download').attr('href','./userContent/'+$image+'.zip');
	$('#zip_download').show();
}
function backBiografia()
{
	$('#biografia_popup_content').show();
	$('#gallery_image').hide();
	$('#zip_download').hide();
	$('#gallery_image').attr("src","");
}
function changeBiografia($groupid)
{
	var nombre = '';
	$('#bio_pancho').hide();
	$('#bio_tono').hide();
	$('#bio_javier').hide();
	$('#biografia_popup_content').show();
	$('#gallery_image').hide();
	$('#zip_download').hide();
	
	if($groupid == 1998)
		nombre = 'pancho';
	else if($groupid == 1999)
		nombre = 'tono';
	else
		nombre = 'javier';	
	
	$('#bio1').attr("src","./userContent/CMS/th_"+nombre+"1.jpg");
	$('#bio2').attr("src","./userContent/CMS/th_"+nombre+"2.jpg");
	$('#bio3').attr("src","./userContent/CMS/th_"+nombre+"3.jpg");
	$('#bio4').attr("src","./userContent/CMS/th_"+nombre+"4.jpg");
	$('#bio_'+nombre).show();
	$('#bio_info').val(nombre);
	
	
}
function changeBiografiaImage($image)
{
	$('#gallery_image').attr("src","./userContent/CMS/"+$image);
	$('#biografia_popup_images img').overlay({
		target: '#multimedia_gallery',
		expose: '#000000',
		closeOnClick:true,
		onClose: function(){
			$('#gallery_image').attr("src","");
			$('#multimedia_gallery').hide();
		}
	});
}
function changeCalendarContent($id)
{
	xajax_changeBiografia($id,"popup2_content");
}
function change_shoppingcart_ammount($item)
{
	xajax_change_shoppingcart_ammount($item,$('#cant_'+$item).val());
}
function change_shoppingcart_link($item)
{
	var talla = $('#size_'+$item).val();
	$("#add_item_"+$item).attr("href","./?ACTION=ADD&SIZE="+talla+"&ITEM="+$item);
}
function change_shoppingcart_size($item)
{
	var total_items = $('#'+$('#size_'+$item).val()+"_"+$item).val();
	var i=0;
	var str = '';
	for(i=1;i<=total_items;i++)
		str += '<option>'+i+'</option>';
	$('#cant_'+$item).html(str);
	xajax_change_shoppingcart_size($item,$('#size_'+$item).val());
}
function submit_order()
{
	$('#paypal_button').hide();
	$('#paypal_text').html('<p>Estamos comunic&aacute;ndonos con PayPal, por favor espere un minuto.</p>');
	xajax_submit_order();
}
function change_shopping_image($image,$text)
{
	$('#loader').fadeIn();
	$('#product_name').html($text);
	var img = new Image();
	$(img).load(function() {
		$('#gallery_image').hide();
		$(img).hide();
		$('#multimedia_gallery').animate({
			width:img.width,
			left:($(window).width()-img.width)/2
		}, function(){ $('#loader').fadeOut(); }).animate({height:img.height },function(){
			$('#gallery_image').fadeIn('slow');
		});
		$('#gallery_image').attr("src","./userContent/"+$image);
		
	}).attr("src","./userContent/"+$image);
	
}
function change_shopping_image_2($image,$image2,$text)
{
	$('#loader').fadeIn();
	$('#product_name').html($text);
	if($image=='')
		$image = 'thumbnail-G.jpg';
	var img = new Image();
	var img2 = new Image();
	var gallery_api = $('.tienda_item img').data("overlay");
	$(img).load(function() {
		$('#gallery_image').hide();
		$(img).hide();
		if($('#isOpened').val()=="true")
		{
			$('#multimedia_gallery').animate({
				width:img.width,
				left:($(window).width()-img.width)/2
			}, function(){ $('#loader').fadeOut(); }).animate({height:img.height },function(){
				$('#gallery_image').fadeIn('slow');
			});
			$('#gallery_image').attr("src","./userContent/"+$image);
		}
	}).attr("src","./userContent/"+$image);
	if($image2=='')
	{
		$('#second_image').hide();
	}else{
		$(img2).load(function() {
			$('#gallery_image_2').hide();
			$(img2).hide();
			$('#gallery_image_2').attr("src","./userContent/"+$image2);
			
		}).attr("src","./userContent/"+$image2);
	}
}
function change_image_next($i)
{
	var ancho, alto;
	var img;
	if($i==1)
		img = '';
	else
		img = '_2';
	
	ancho = $('#gallery_image'+img).width();
	alto = $('#gallery_image'+img).height();
	$('#gallery_image_2').hide();
	$('#gallery_image').hide();
	$('#loader').fadeIn();
	$('#multimedia_gallery').animate({
		width:ancho,
		left:($(window).width()-ancho)/2
	}, function(){ $('#loader').fadeOut(); }).animate({height:alto },function(){
		$('#gallery_image'+img).fadeIn('slow');
		$('#gallery_image'+img).show();
	});
}
