// idea & code by RGdesign.org - 2008

/* playing with ul */
$(document).ready(function() {
	/* 2 cols */
	$("ul.librerias li:even").attr("class", "evenList");
	$("ul.librerias li:odd").attr("class", "oddList");
	
	/* apply icons */
	$('.listado a, .listado2 a').each(function(){
		if($(this).text() == "Uruguay"){
			$(this).attr("class", "icon_uruguay");
			}
		if($(this).text() == "Argentina"){
			$(this).attr("class", "icon_argentina");
			}
	});
	
});

/* colored tags */
$(document).ready(function() {
	$('.etiquetas a').each(function(){
		size = $(this).css("font-size");
		keywords = ["#0082D6", "#DD0067", "#0039A5", "#DF0100", "#A02D94", "#E25685", "#0596A9"];
		var key = keywords[Math.floor(Math.random()*keywords.length)];
		$(this).css("color", key);
		$(this).hover(
				function(){
					var key = keywords[Math.floor(Math.random()*keywords.length)];
					$(this).css("color", key);
				},
				function(){
					var key = keywords[Math.floor(Math.random()*keywords.length)];
					$(this).css("color", key);
				}
			);
	});
});

/* ChangeImgOver */
$(document).ready(function() {
	jQuery.fn.ChangeImgOver = function(){
		
		return this.each(function() {			
			$(this).hover(
				function(){
					imgsrc = $(this).attr("src");
					matches = imgsrc.match(/_over/);
					if (!matches) {
						imgsrcON = imgsrc.replace(/.gif$/ig,"_over.gif");
						$(this).attr("src", imgsrcON);
					}
				},
				function(){
					$(this).attr("src", imgsrc);
				}
			);
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.gif$/ig,"_over.gif");
			$("<img>").attr("src", rollON);
		});
	}

});
$(document).ready(function() {
	jQuery.fn.ChangeImgOver2 = function(){
		return this.each(function() {			
			$(this).hover(
				function(){
					imgsrc = $(this).children("img").attr("src")
					matches = imgsrc.match(/_over/);
					if (!matches) {
						imgsrcON = imgsrc.replace(/.gif$/ig,"_over.gif");
						$(this).children("img").attr("src", imgsrcON);
					}
				},
				function(){
					$(this).children("img").attr("src", imgsrc);
				}
			);
			rollsrc = $(this).children("img").attr("src");
			rollON = rollsrc.replace(/.gif$/ig,"_over.gif");
			$("<img>").attr("src", rollON);
		});
	}

});


/* form */

jQuery(document).ready(function() {
	function selectAllText(textbox) {
		$(textbox).focus();
		$(textbox).select();
	}
	$('.txtInput').click(function(){
		selectAllText('#txtInput');
		$('#out').html('<br /><br />Ahora copia y pega la URL donde quieras!!');
		return false;
	});
	
	$('#txtInput').click(function() {
		selectAllText(this);
		$('#out').html('<br /><br />Ahora copia y pega la URL donde quieras!!');
		return false;
	});
	$('#txtInput').blur(function() {
		$('#out').html('');
		return false;
	});
	
	$('.enableForm').click(function(){
		$("input[type='text']:first", document.forms[1]).focus();
	});

	$('input[type="text"], textarea').focus(function() {
		if($(this).attr('id') != 'txtInput'){
			if (this.value == this.defaultValue){ 
				this.value = '';
			}
			if(this.value != this.defaultValue){
				this.select();
			}
		}
	});
	$('input[type="text"], textarea').blur(function() {
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
		
	});
});	
/* fades */
jQuery(document).ready(function() {
	jQuery.fn.fadeLink = function(start,end){
		return this.each(function() {			
			$(this).hover(
				function(){$(this).animate({"opacity":end}, 250);},
				function(){$(this).animate({"opacity":start}, 250);}
			);
			$(this).css({"opacity":start});
		});
	}
});
jQuery(document).ready(function() {
	jQuery.fn.fadeLinkTo = function(start,end,obj){
		return this.each(function() {			
			$(this).hover(
				function(){$(obj).animate({"opacity":end}, 250);},
				function(){$(obj).animate({"opacity":start}, 250);}
			);
			$(obj).css({"opacity":start});
		});
	}
});

/* fades css assigns */
$(function() {
	$('#form .row').fadeLink(0.7,1);
	$('#form button').fadeLink(0.7,1);

	$('#footerRounded').fadeLink(0.7,1);
	
	//$('.novedad').fadeLink(0.7,1);
	$('.postCat').fadeLink(0.8,1);
	$('.autoresPageBox').fadeLink(0.7,1);
	
	//$('#mainMenu a span img').fadeLink(0.7,0.9);
	//$('#autores li').fadeLink(0.8,1);

	$('#autores li a').ChangeImgOver2();
	
	$('.subPageList li').fadeLink(0.7,1);
	
	//$('#slider').fadeLink(0.7,1);
	$('#incoming .hide a').fadeLink(0.7,1);
	/*
	$(".bt_contacto").click(function () {
    	$("#contactHide").animate({"height": "toggle"}, "slow");
    });
	*/
	$(".siteMapPageList ul li ul li").each(function(){
		$(this).children('ul').hide();
		$(this).click(function(){
			last = $(this).children('ul').attr('id');
			if(last != 'current'){
				$('#current').slideUp(400);
				$('#current').removeAttr('id');
			}
			current = $(this).children('ul');
			current.attr('id','current');
			current.slideToggle(400);
			return false;
		});
	});
	$(".siteMapPubList ul li").each(function(){
		$(this).children('.t').hide();
		$(this).click(function(){
			last = $(this).children('.t').attr('id');
			if(last != 'current'){
				$('#current').slideUp(400);
				$('#current').removeAttr('id');
			}
			current = $(this).children('.t');
			current.attr('id','current');
			current.slideToggle(400);
			return false;
		});
	});

	$(".siteMapPubList .d a").each(function(){
		$(this).click(function(){
			window.open($(this).attr('href'), '_self');
		});
	});

	
});

/* imageBox */

$(document).ready(function(){
	$.fn.colorbox.settings.transition = "fade";
	$.fn.colorbox.settings.bgOpacity = "0.97";
	$.fn.colorbox.settings.contentCurrent = "Im&aacute;gen {current} de {total}";
	$.fn.colorbox.settings.initialWidth = 200;
	$.fn.colorbox.settings.initialHeight = 200;
	
	$(".cpModal").colorbox();
	
	/* this way i use the href on the .cpModalFlash css links and take only the v parameter to include it on the flash.php */
	$(".cpModalFlash").each(function(){
		url = $(this).attr("href");
		v = url.slice(url.indexOf('watch?v=') + 8, url.length)
		$(this).colorbox({contentAjax:"colorbox/flash.php?id=" +v});
	});
	
	$(".subPageList a").each(function(){
		$(this).attr('rel','nofollow');
		$(this).colorbox({contentCurrent: "P&aacute;gina {current} de {total}"});
	});
	

	$(".siteMapPageList ul li ul li ul li a").each(function(){
		$(this).attr('rel','nofollow');
		$(this).colorbox({contentCurrent: "P&aacute;gina {current} de {total}"});
	});
	$(".popup").each(function(){
		$(this).attr('rel','nofollow');
		$(this).colorbox({contentCurrent: "P&aacute;gina {current} de {total}"});
	});
	
	$(".cpModalOut").colorbox({contentAjax:"colorbox/ajax.php",iframe:true});

});



function nomailspam(name,domain) {
    	document.location = "mailto:" + name + "@" + domain;
}
    
//-->