// idea & code by RGdesign.org - 2009

/* -------- */

$(document).ready(function(){
	$('body').pngFix( { blankgif:'images/blank.gif' } );
	
	// ----------------- //
	// ChangeImgOver
	jQuery.fn.ChangeImgOver = function(obj){
		return this.each(function() {			
			$(this).hover(
				function(){
					if(obj){
						element = $(obj);
						}else{
						element = $(this);
					}
					imgsrc = element.attr("src");
					matches = imgsrc.match(/_over/);
					if (!matches) {
						imgsrcON = imgsrc.replace(/.gif$/ig,"_hover.gif");
						
						element.attr("src", imgsrcON);
					}
				},
				function(){
					if(obj){
						element = $(obj);
						}else{
						element = $(this);
					}
					element.attr("src", imgsrc);
				}
			);
			if(obj){
				element = $(obj);
				}else{
				element = $(this);
			}
			rollsrc = element.attr("src");
			rollON = rollsrc.replace(/.gif$/ig,"_hover.gif");
			$("<img>").attr("src", rollON);
		});
	}
	$('.imgHover').ChangeImgOver();
	$('#creditosT').ChangeImgOver('#creditosI');
	$('#creditosI').hover(function(){
		$('#creditosT').addClass('over');
		},function(){
			$('#creditosT').removeClass('over');
		});
	// ----------------- //
	
	// ----------------- //
	// General forms focus/blur, etc
	$('input[type="text"], input[type="password"]').focus(function(){if(this.value==this.defaultValue){this.value='';}if(this.value!=this.defaultValue){this.select();}});
	$('input[type="text"], input[type="password"]').blur(function(){if($.trim(this.value)==''){this.value=(this.defaultValue?this.defaultValue:'');	}
	});
	$('#mascota').click(function(){
		$("input[type='text']:first", document.forms[1]).focus();
	});
	// ----------------- //
	
	// ----------------- //
	// fadeLink fn
	jQuery.fn.fadeLink = function(start,end,vel){
		return this.each(function() {			
			$(this).hover(
				function(){$(this).animate({"opacity":end}, vel);},
				function(){$(this).animate({"opacity":start}, vel);}
			);
			$(this).css({"opacity":start});
		});
	}
	// ----------------- //
	/* ejemplo de uso fadeLink(alpha inicial/rollout, alpha rollover, velocidad) */
	$('#header .bt_registrame').fadeLink(1,.8,100);
	
	$('.bigmore').hover(
		function(){
			$(this).css('background-position', '0 -34px');
		},
		function(){
			$(this).css('background-position', '0 0');
		});
});
/* -------- */