/*
 *
 * Copyright (c) 2006 Sam Collett (http://www.noth.es)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 *  21 Junio 2007
 *  
 */
 
 // on page load call TB_init

/*
 * Convierte todos los enlaces externos de forma sencilla, para su 
 * uso accesible
 *
 * @name     linksAcesibles
 * @author   Queli (http://www.noth.es)
 * @example  // en la primera linea dentro del document ready pondremos $().linksAcesibles();
 *
 */
jQuery.fn.ALLinksAcesibles = function(b)
{ 
    //alert('hola');
	$("h1").click( function() { window.open('/','_self');return false; } );
	if(arguments.length == 0){
		
	  if(typeof arguments[0] != "boolean" || arguments[0])
	  $('a').each(function(i){
	  	var href =$(this).attr('href');
		//alert(href);
		//para enlaces externos 
	  	var RegExPattern ='^(ht|f)tp(s?)';
			if(href.match(RegExPattern))
			{
				//alert('hola');
				$(this).attr('target','_blank');
				//para explorer 6
				$(this).addClass('external');
				return;
			}
		//hack para el ie6, colocar las clases para los iconos
		var RegExPattern ='(.pdf)$';
			if(href.match(RegExPattern))
			{
				//alert($(this).attr('href'));
				//para explorer 6
				$(this).addClass('pdf');
			}
		var RegExPattern ='^(mailto:)';
			if(href.match(RegExPattern))
			{
				//para explorer 6
				$(this).addClass('mailto');
			}
		var RegExPattern ='(.zip)$';
			if(href.match(RegExPattern))
			{
				//para explorer 6
				$(this).addClass('zip');
			}				
	  });
	}
	else
	{
		return this;
	}
	
	  
};
/*
 * Removes an option (by value or index) from a select box (or series of select boxes)
 *
 * @name     removeOption
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  jQuery("#myselect").removeOption("Value"); // remove by value
 *           jQuery("#myselect").removeOption(0); // remove by index
 *
 */
jQuery.fn.linkAccesible = function()
{
	
	if(arguments.length >= 0) 
	{
		this.attr('target','_blank');
		return this;
	}
	else
	{
		return this;
	}
};

$(document).ready(function() {
	$().ALLinksAcesibles();
});