/*function loadjscssfile(filename, filetype){
 if (filetype == "js"){ //if filename is a external JavaScript file
  var fileref = document.createElement("script");
  fileref.setAttribute("type","text/javascript");
  fileref.setAttribute("src", filename);
 }
 else if (filetype == "css"){ //if filename is an external CSS file
  var fileref = document.createElement("link");
  fileref.setAttribute("rel", "stylesheet");
  fileref.setAttribute("type", "text/css");
  fileref.setAttribute("href", filename);
 }
 if (typeof fileref != "undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref);
}
*/
// Carga de CSS
function applyCSS(cssCode) {
	var styleElement = document.createElement("style");
	styleElement.type = "text/css";
	if (styleElement.styleSheet) {
		styleElement.styleSheet.cssText = cssCode;
	} else {
		styleElement.appendChild(document.createTextNode(cssCode));
	}
	document.getElementsByTagName("head")[0].appendChild(styleElement);
}
/*COLUMNAS DE IGUAL TAMAŅO*/
function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}
$(document).ready(function() {
    equalHeight($(".columns"));
});
/*ACCESSIBILITY*/
$(document).ready(function(){
	$('.accessibility_content').hide();
	$('#BTNACCESSIBILITY').click(function(){
		$('.accessibility_content').slideToggle('slow');
	});
});
/*CARRUCEL PORTADA*/
function mycarousel_initCallback(carousel){
    carousel.clip.hover(function(){$('.imgteaser').slideToggle('slow');carousel.stopAuto();},
	function() {$('.imgteaser').slideToggle('slow');carousel.startAuto();});	
};
$(document).ready(function(){
if ($('#carrucel-content').length) {						   
    $('#carrucel-content').jcarousel({vertical: true,auto: 3,wrap: 'both',scroll: 1,size: 6,initCallback: mycarousel_initCallback});
}
});
/*SLIDESHOW PORTADA */
var interval = 0;
$(document).ready(function(){
if ($('#gallery').length) {
	slideShow();
	$('#gallery li').mouseenter(function() {
		clearInterval(interval);
		$('.imgteaser').css({opacity: "0.65"});	
		$('.imgteaser').slideToggle('slow');
	}).mouseleave(function() {
		interval = setInterval('gallery()',3000);
		$('.imgteaser').slideToggle('slow');
	});
}
});
function slideShow(){
	$('#gallery li').css({opacity: 0.0});
	$('#gallery li:first').css({opacity: 1.0});
	interval = setInterval('gallery()',3000);	
}
function gallery() {
	var current = ($('#gallery li.show')?  $('#gallery li.show') : $('#gallery li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery li:first') :current.next()) : $('#gallery li:first'));	
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
}
/* MARCAR ENLACES */
$(document).ready(function(){
	$('#enlace1').click(function(){

	});
});
//BLURMOTION
$(document).ready(function(){
if ($('.animate_blurmotion').length) {	
	var obj = $(".animate_blurmotion");
	var animeframe = 0;
	var myOpacity;
	
	function animation(){
		setTimeout(function(){
			if(animeframe == 0) {
				myOpacity = 0.8;
				animeframe = 1;
			}
			else if(animeframe  == 1) {
		 		myOpacity = 1;
				animeframe  = 0;
			}
			obj.animate({ opacity:myOpacity}, 700);
			animation();
			}, 700);
		}
	{animation();}  
}
});
//BLURMOTION MOUSELEAVE
$(document).ready(function(){
	if ($('.animate_blurmotion2').length) {
		$('.animate_blurmotion2').mouseenter(function(){
			$(this).animate({ opacity:0.6}, 500);
		}).mouseleave(function(){	$(this).animate({ opacity:1}, 500);});
	}
});
/* COLUMNAS DE MISMO ANCHO */
function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}
$(document).ready(function() {equalHeight($(".columnas"));});
