jQuery.noConflict()

jQuery(document).ready(init);
function init(){
	
	

	// ENLACES EXTERNOS
	jQuery(".aExterno").attr("target", "_blank");
	jQuery(".pdf").attr("target", "_blank");
	
	// MENU PRINCIPAL
	jQuery("#mainMenu .mGroup").hover(showSubmenu, hideSubmenu);

	// DESPLEGABLE Preguntas Frecuentes
	jQuery(".faq h3").css("cursor", "pointer");
	jQuery(".faq h3").next().hide();
	jQuery(".faq h3").hover(questColorOver, questColorOut);
	jQuery(".faq h3").click(showAnswer);
	
	// DESPLEGABLE CFDs
	jQuery("#comisiones h3.enlace").css("cursor", "pointer");
	jQuery("#comisiones h4.enlace").css("cursor", "pointer");
	jQuery("#comisiones #despliegaCfds").stop().hover(showCfds, hideCfds);

	// FORMULARIOS SIDEBAR
	var cssCloseArrow = {
	 'position' : 'absolute',
	 'top' : '-10px',
	 'right' : '-60px',
	 'width' : '36px',
	 'height' : '35px',
	 'z-index' : '9900',
	 'background-image' : 'url(img/icn_flecha_cierraForm.png)',
	 'cursor' : 'pointer',
	 'overflow' : 'visible'
	}
	jQuery("#forms").removeClass("oculto").append('<div id="closeForm"></div>');
	jQuery("#forms form").append('<div id="closeArrow"></div>');
	jQuery("#forms form #closeArrow").css(cssCloseArrow);
	jQuery("#forms").hide().css("opacity", 0);
	jQuery("#forms #closeForm").hide().css("opacity", 0);
	jQuery("#forms form").hide().css("opacity", 0);
	jQuery("#sMod3-a a").stop().click(showFormCall);
	jQuery("#sMod3-b a").stop().click(showFormEmail);
	jQuery("#d2 a").stop().click(showFormGuia);
	jQuery("#forms #closeForm").stop().click(hideForm);
	jQuery("#forms #closeArrow").stop().click(hideForm);
	jQuery(document).keypress(scape);
}


// FUNCIONES MENU PRINCIPAL
function showSubmenu(){
	jQuery(this).find("p").addClass("selected");
	jQuery(this).find("ul").stop().removeClass("oculto");
}
function hideSubmenu(){
	jQuery(this).find("p").removeClass("selected");
	jQuery(this).find("ul").stop().addClass("oculto");
}


// FUNCIONES DESPLEGABLE Preguntas Frecuentes
function questColorOver(){
	jQuery(this).addClass("selected");
}

function questColorOut(){
	if( jQuery(this).next().css("display") != "block" ){
		jQuery(this).removeClass("selected")
	}
}

function showAnswer(){
	jQuery(".faq h3").removeClass("selected");//.css("color", "#3168df");
	var indice = jQuery(".faq h3").index( jQuery(this) )
	jQuery(".faq h3:not(:eq("+indice+"))").next().slideUp(450);
	jQuery(this).next().slideDown(450);
	jQuery(this).addClass("selected");
}


// FUNCIONES DESPLEGABLE CFDS
function showCfds(){
	jQuery(this).find("div").slideDown(300);
}
function hideCfds(){
	jQuery(this).find("div").hide();
}

// FORMULARIOS SIDEBAR
function showFormCall(){
	jQuery(this).addClass("selected");
	jQuery("#forms").show().animate({"opacity": 1}, 400);
	jQuery("#forms #closeForm").show().animate({"opacity": 0.7}, 400);
	jQuery("#call_back").show().animate({"opacity": 1}, 600);
	return false;
}

function showFormEmail(){
	jQuery(this).addClass("selected");
	jQuery("#forms").show().animate({"opacity": 1}, 400);
	jQuery("#forms #closeForm").show().animate({"opacity": 0.7}, 400);
	jQuery("#email_back").show().animate({"opacity": 1}, 600);
	return false;
}

function showFormGuia(){
	jQuery(this).addClass("selected");
	jQuery("#forms").show().animate({"opacity": 1}, 400);
	jQuery("#forms #closeForm").show().animate({"opacity": 0.7}, 400);
	jQuery("#guia_back").show().animate({"opacity": 1}, 600);
	return false;
}

function showFormSeminario(val){
	jQuery("#seminario_seminario").val(val);
	jQuery(this).addClass("selected");
	jQuery("#forms").show().animate({"opacity": 1}, 400);
	jQuery("#forms #closeForm").show().animate({"opacity": 0.7}, 400);
	jQuery("#seminario_back").show().animate({"opacity": 1}, 600);
	return false;
}

function scape(e){
	if(e.keyCode==27){
		hideForm();
	}
}

function hideForm(){
	jQuery("#sMod3 li a").removeClass("selected");
	jQuery("#forms form").animate({"opacity": 0}, 300).hide();
	jQuery("#forms #closeForm").animate({"opacity": 0}, 300).hide();
	jQuery("#forms").animate({"opacity": 0}, 300).hide();
}

function openWindow(url) {
	window.open(url);
}

function openAlert(msg) {
	alert(msg);
}

//-------------------------------
// script de google-analytics
//-------------------------------
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-5928098-1']);
_gaq.push(['_trackPageview']);
(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();



