$(document).ready(function() {
	$(function () {
		$.each(
		$('.loading'),
			function( intIndex, objValue ){
				var img = new Image();
				$(img).load(function () {
					$(this).hide();
					$(objValue).removeClass('loading').append(this);
					$(this).fadeIn();
				}).error(function () {
				}).attr('src', $(this).attr('load'));
			}
		);
	});

	$('.qDefaultValue').bind('focus', function() {
		if ($('.qDefaultValue').val() == this.defaultValue) {
			$('.qDefaultValue').val('');
		}
	});

	$('.qDefaultValue').bind('blur', function() {
		if ($('.qDefaultValue').val() == '') {
			$('.qDefaultValue').val(this.defaultValue);
		}
	});

	$('.userDefaultValue').bind('focus', function() {
		if ($('.userDefaultValue').val() == this.defaultValue) {
			$('.userDefaultValue').val('');
		}
	});

	$('.userDefaultValue').bind('blur', function() {
		if ($('.userDefaultValue').val() == '') {
			$('.userDefaultValue').val(this.defaultValue);
		}
	});

	$('.passwordDefaultValue').bind('focus', function() {
		if ($('.passwordDefaultValue').val() == this.defaultValue) {
			$('.passwordDefaultValue').val('');
		}
	});

	$('.passwordDefaultValue').bind('blur', function() {
		if ($('.passwordDefaultValue').val() == '') {
			$('.passwordDefaultValue').val(this.defaultValue);
		}
	});

	$('#qButton').bind('click', function() {
		$('#frmBuscar').submit();
	});

	$('#loginButton').bind('click', function() {
		$('#frmIngreso').submit();
	});

	$('#emailUsuario, #passwordUsuario').keyup(function(e) {
		if (e.keyCode == 13) {
			$('#frmIngreso').submit();
		}
	});


	$("a.registrarse").fancybox({
		'width'				: 750,
		'height'			: 150,
        'autoScale'     	: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
});

/*
Open Centered Popup Window Script-(c) DHTMLShock (www.dhtmlshock.com)
To add more shock to your site, visit www.DHTMLShock.com
*/

function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}
