IE6 = (document.all && /MSIE (5\.5|6)/.test(navigator.userAgent));

function fixIE6() {
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch (e) {
	}
}

// Hace visibles los PNG despues del filtro de transparencia IE6
if (IE6) {
	fixIE6();

	document.styleSheets[0].addRule('.png', 'visibility: hidden');
	document.styleSheets[0].addRule('.png',
			'behavior: url(/scripts/iepngfix.htc)');

	$( function() {
		setTimeout( function() {
			$('.png').each( function() {
				$(this).css('visibility', 'visible');
			});
		}, 30);
	});
}

/*
 * Simular target ="_blank" y abre los enlaces en ventana nueva, cerrar ventana
 */
$( function() {
	$('.external').click( function() {
		window.open($(this).attr('href'));
		return false;
	});
});

$( function() {
	function exclude(event) {
		var element = $(event.target);

		if (element.is('.clicable-exclude') || element.is('.clickable-exclude')) {
			return true;
		}
		if (event.target.tagName == 'A' || event.target.tagName == 'INPUT') {
			return true;
		}
	}

	$(".clicable, .clickable").click( function(event) {
		if (exclude(event)) {
			return true;
		}

		$(this).find("a").each( function() {
			var content = $(this);
			var url = content.attr("href");

			if (content.is('.external')) {
				window.open(url);
			} else {
				document.location = url;
			}

			return false;
		});
	});

	$(".clicable, .clickable").mouseover( function(event) {
		if (exclude(event)) {
			return true;
		}

		if ($(this).find("a").size() > 0) {
			$(this).css("cursor", "pointer");
		}
	});

	$(".clicable, .clickable").mouseout( function(event) {
		if (exclude(event)) {
			return true;
		}

		if ($(this).find("a").size() > 0) {
			$(this).css("cursor", "auto");
		}
	});
});

$( function() { 
	$(".canciones li:even").addClass("even");
});
$( function() { 
	$("input.submit").mouseover (function() {
		$(this).addClass("inputhover");
	});
	$("input.submit").mouseout (function() {
		$(this).removeClass("inputhover");
	});
});
/*
	border mal renderizado en ff2
*/
if (! (jQuery.browser.mozilla && jQuery.browser.version.substr(0,3)=="1.8")) {
	DD_roundies.addRule('.compra input', '10px',true);
	DD_roundies.addRule('div.advertencia', '10px',true);
	DD_roundies.addRule('.codigo div', '10px',true);
	DD_roundies.addRule('.descargar a', '10px',true);
}

// abre un popup centrado
function popup(url,talla) {
	var aw = screen.availWidth - 10;
	var w; var h;
	switch (talla){
		case "legal":
			w=520;
			h=500;
			break;
		default:
			w=928;
			h=600;
	}
	xc = (aw - w) / 2; // center
	features = 'status=no,scrollbars=yes,menubar=no,toolbar=no,location=no,directories=no,resizable=yes,copyhistory=no,width=' + w + ',height=' + h + ',' + 'left=' + xc	+ ',top=0,screenX=' + xc + ',screenY=0';

	var ventana = window.open(url, 'popup'+w, features);	
	if(ventana != undefined){
		ventana.focus();
		return true;
	}
	
	return false;
	
}

$( function() {
	$('a[class*="window"]').click( function() {
		var tipoventana = $(this).attr("rel");
		popup($(this).attr('href'),tipoventana);
		return false;
	});
	
});


$( function() {
	$('input.cancelar').click( function() {
		close();
		return false;
	});
});

$( function() {
	$('p.print a').click( function() {
		print();
		return false;
	});
});

/*
 * Simular target ="_blank" y abre los enlaces en ventana nueva
 */
$( function() {
	$('.external').click( function() {
		window.open($(this).attr('href'));
		return false;
	});
});

$( function() {
	$('#formTPV, #formPaypal').submit( function() {

		if(! $('#warning').attr('checked')) {
			$('#warning').fadeTo("fast", 0.1, function callback() {
				$(this).fadeTo("fast", 1.0);
			});
			return false;
		}

		return true;
		});
});


