jQuery(document).ready(function($){

$("#faqs").accordion({
				header: 'li > h5',
				icons: { 'header': 'icon-faq', 'headerSelected': 'icon-faq-selected' },
				autoHeight: false
			});

$("#faqs li").click(function(){
	$("#faqs li").removeClass('active');
	$(this).addClass('active');
});

$("#antispam").bind('loaded.simpleCaptcha', function() {
	// do something when loaded
})
.simpleCaptcha({
	scriptPath: '/wp-content/themes/iep/captcha.php',
	numImages: 5,
	introText: '<p>Debe seleccionar la siguiente imagen: <strong class="captchaText"></strong></p>'
});

$("#form-contact,#formlateral").validate({
	errorPlacement: function(error, element) {}
});

/*
$("#close_programs").click(function(){
	if ($(this).attr('class') == 'cerrar') {
		$("#progr").slideUp();
		$(this).attr('title','Abrir')
				.text('Abrir')
				.removeClass('cerrar').addClass('abrir');
	}else{
		$("#progr").slideDown();
		$(this).attr('title','Cerrar')
				.text('Cerrar')
				.removeClass('abrir').addClass('cerrar');
	}

	return false;
});
*/

$("#menu-item-4751").click(function () {
    //$("#submenu").slideDown('slow');
    if ($("#submenu").is(':hidden')) {
	    $("#progr, #close_programs").css('display','none');
	    $("#submenu,#progr, #close_programs").slideDown('slow');
    }else{
    	$("#submenu,#progr, #close_programs").slideUp('slow');
    }
});

$("#close_programs").click(function(){
	//$("#submenu").slideUp('slow');
	$("#progr, #close_programs").slideUp('slow');
	return false;
});



// Envio del formulario de programas y contacto
$("#formlateral, #form-contact").submit(function(){

	var $this = $(this);

	if ($this.valid()) {
		$.ajax({
			type: "POST",
			url: "/wp-content/themes/iep/enviar_formulario.php",
			data: $this.serialize(),
			dataType: 'json',
			success: function(data){
				if (data.success) {
					location.href = data.redirect;
				}else{
					alert( data.msg );
				}
			}/*,
			beforeSend: function(jqXHR, settings){
				$this.children().css('visibility','hidden');
				$this.append('<p class="message" style="vertical-align:middle; min-height:640px">Enviando datos</p>');
			},
			complete: function(jqXHR, textStatus){
				$this.children('.message').remove();
				$this.children().css('visibility','visible');
			}*/
		});
	}
	return false;
});

$("#graficos li a").click(function(){

	var $this = $(this);

	$("#graficos li a").removeClass('on');

	$("#graphic img").hide('slide',500,function(){
		$(this).attr('src',$this.attr('href'))
				.attr('title',$this.text())
				.show('slide',1000);
		$this.addClass('on');
	});
	return false;
});


$("#siguiente").click(function(){
	$(".cursos").scrollTo({top:'0', left:'+='+(260*3)},1000);
	return false
})

$("#anterior").click(function(){
	$(".cursos").scrollTo({top:'0', left:'-='+(260*3)},1000);
	return false
})

// Listado Cursos
$("#secciones_programa li a").click(function(){
	var $id = $(this).attr('href');
	$(".div-cursos").hide();
	$(".cursos").scrollTo({top:'0', left:'0'},0);
	$($id).show();
	$("#secciones_programa li").removeClass('on')
	$(this).parent().addClass('on')
	$("#index li.programa").text($("div[id^=programa-]:visible .columna3").length+' programas');
	if ($("div[id^=programa-]:visible .columna3").length > 3){
		//$(".programas").css('visibility','visible');
		$(".programas").show();
	}
	else{
		//$(".programas").css('visibility','hidden');
		$(".programas").hide();
	}
	return false;
})
$("#secciones_programa li a:first").click();

// Tooltip
$(".aeen,.icde").tipTip({delay:0});


// Prettyphoto
$("a[rel^='wp-prettyPhoto']").prettyPhoto({
	animation_speed: 'fast', /* fast/slow/normal */
	slideshow: 5000, /* false OR interval time in ms */
	autoplay_slideshow: false, /* true/false */
	opacity: 0.80, /* Value between 0 and 1 */
	show_title: true, /* true/false */
	allow_resize: true, /* Resize the photos bigger than viewport. true/false */
	default_width: 500,
	default_height: 344,
	counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
	theme: 'pp_default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
	horizontal_padding: 20, /* The padding on each side of the picture */
	hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
	wmode: 'opaque', /* Set the flash wmode attribute */
	autoplay: true, /* Automatically start videos: True/False */
	modal: false, /* If set to true, only the close button will close the window */
	deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */
	overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
	keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
	changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
	callback: function(){}, /* Called when prettyPhoto is closed */
	ie6_fallback: true,
	markup: '<div class="pp_pic_holder"> \
				<div class="ppt">&nbsp;</div> \
				<div class="pp_top"> \
					<div class="pp_left"></div> \
					<div class="pp_middle"></div> \
					<div class="pp_right"></div> \
				</div> \
				<div class="pp_content_container"> \
					<div class="pp_left"> \
					<div class="pp_right"> \
						<div class="pp_content"> \
							<div class="pp_loaderIcon"></div> \
							<div class="pp_fade"> \
								<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
								<div class="pp_hoverContainer"> \
									<a class="pp_next" href="#">next</a> \
									<a class="pp_previous" href="#">previous</a> \
								</div> \
								<div id="pp_full_res"></div> \
								<div class="pp_details"> \
									<div class="pp_nav"> \
										<a href="#" class="pp_arrow_previous">Previous</a> \
										<p class="currentTextHolder">0/0</p> \
										<a href="#" class="pp_arrow_next">Next</a> \
									</div> \
									<p class="pp_description"></p> \
									{pp_social} \
									<a class="pp_close" href="#">Close</a> \
								</div> \
							</div> \
						</div> \
					</div> \
					</div> \
				</div> \
				<div class="pp_bottom"> \
					<div class="pp_left"></div> \
					<div class="pp_middle"></div> \
					<div class="pp_right"></div> \
				</div> \
			</div> \
			<div class="pp_overlay"></div>',
	gallery_markup: '<div class="pp_gallery"> \
						<a href="#" class="pp_arrow_previous">Previous</a> \
						<div> \
							<ul> \
								{gallery} \
							</ul> \
						</div> \
						<a href="#" class="pp_arrow_next">Next</a> \
					</div>',
	image_markup: '<img id="fullResImage" src="{path}" />',
	flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
	quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',
	iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',
	inline_markup: '<div class="pp_inline">{content}</div>',
	custom_markup: '',
	social_tools: '' /* html or false to disable */
});



});
