var j = jQuery.noConflict();

j(document).ready(function() {
        if (j.browser.msie) {
            if (j.browser.version >= 7) {
                //codigo para ie7
            } else {
                //codigo para ie6
                DD_belatedPNG.fix('#column1');
            }
        }

	j('<a href="#top">back to top</a>').insertAfter('div.chapter p');
	j('<a id="top" name="top"></a>').prependTo('body');
	j('<ol id="notes"></ol>').insertAfter('div.chapter');
	j('span.footnote').each(function(index){
		j(this)
			.before('<a href="#foot-note-'+(index+1)+'"id="context-'+(index+1)+'"class="context"<sup>['+(index+1)+']</sup></a>')
			.appendTo('#notes')
			.append('&nbsp;<a href="#context-'+(index+1)+'">(context)</a>')
			.wrap('<li id="foot-note-'+(index+1)+'"></li>');
	});
	
	//Acordeón 
	j('.acordion .container .content').hide();
	j('.acordion .container .content:first').show();
	j('.acordion .container .header:first').addClass('headActive');
	
	/*Esta elem estará debajo del h2*/
	j('<span class="bg"></span>').insertBefore('.acordion .container .headActive h2.title');
	
	j('.acordion .container .header').click(function(){
		var checkElement = j(this).next();
		if((checkElement.is('div')) && (checkElement.is(':visible'))) {
			return false;
		}
		if((checkElement.is('div')) && (!checkElement.is(':visible'))) {
			//j('.acordion .container .content:visible').slideUp('normal');
			j('.acordion .container .content:visible').hide('slow');
			checkElement.show('slow');
			
			j('.acordion .container .headActive span.bg').remove();
			
			j('.acordion .container .header').removeClass('headActive');
			j(this).addClass('headActive');
			j('<span class="bg"></span>').insertBefore('.acordion .container .headActive h2.title');
			
			return false;
		}
		
	});	
	
	/*j('.acordion a:not([href])').remove();
	j(".acordion .container.rounded").each(function (i) {
        j(this).contents().insertBefore(this);
		j(this).remove();
      });
	j('.acordion .header').click(function() {
		j(this).next().slideToggle('slow');
		return false;
	}).next().hide();*/

	//j('.acordion').accordion({ header: 'div.header' });
	
	/*menu*/
	//#menu table td:first-child{padding-left:0}
	j('#menu table td:first-child').css('padding-left', 0);
	//j('#menu img').replaceWith('&nbsp;');
	//var anteUltimo = j('#menu table td').length - 2;
	//alert(anteUltimo);
	//j('#menu table td')[anteUltimo].css('background', 'none');
	
	j('#menu table td:last-child').css('background', 'none');
	j("#menu table td:nth-child(7)").css('background', 'none');
	//j('#menu table td')[4].css('background', 'none');
	j('#menu table td img').remove();
	//j('#menu table:last-child').remove();
	
	
	
	/*Toggle genérico*/
	j('div.toggle .more-info, tr.toggle .more-info').hide();
	//j('div.toggle .more-info:empty').remove();
	j('.toggle').toggle(
			function(){
				//j(this).find(".more-info").slideDown('slow');
				j(this).find(".more-info").show('slow');
			}, 
			function(){
				//j(this).find(".more-info").slideUp('slow');
				j(this).find(".more-info").hide('slow');
			}
		);
	/*j('div.toggle h3, tr.toggle h3').toggle(
			function(){
				j(this).next().slideDown('slow');
			}, 
			function(){
				j(this).next().slideUp('slow');
			}
		);*/
	
	
    /*j("tr.toggle").click(function (){
      j(this).children('p').slideToggle("slow");
    });*/


		
	/*Mostrar más info al hacer click en un títuto*/
	j('.text .more-info').hide();
	j('h3.toggle').toggle(
		function(){
			j(this).next().next().slideDown('slow');
		},
		function(){
			j(this).next().next().slideUp('slow');
		}
	);
	
	/*imagenes contacto*/
	if(j('.imagenes-homeMN li').length > 2){
			j('.imagenes-homeMN').width(146); 
	}

	
	/*lineas separadoras en bloque contactos */
	j('table.contactos-m td.imgProfesionalTd').parent().after('<tr class="separador"><td colspan="2"></td></tr>');
	
	j('.menlosm #main').css('height', j('.menlosm #content-inner').height() + 100);
	
	toggle();
	
	/*Areas de practica*/
	j('#areasPractica ul.imagenes li').hover(
		function(){
			j(this).addClass('active');
		},
		function(){
			j(this).removeClass('active');
		}
	);
	
});

function MM_openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);
}


/*toggle para indice de newsletter*/
function toggle(){
	j('.toggle_container').hide();
 	j('p.trigger').click(function(){
		j(this).toggleClass('active').next().slideToggle('slow');
	});
}


