jQuery(document).ready( function(jQuery) {
	
	jQuery("#flashCapacitadosContent").css({'display':'none'});
	
	jQuery('#boton4Join a').click( function() {
		loadCV();
		return false;
	});
	jQuery('#boton3Join a').click( function() {
		openVals();
		return false;
	});
	jQuery('#botonValores a').click( function() {
		openVals();
		return false;
	});
	
	jQuery.ajaxSetup( {
	
		beforeSend : function() {
			jQuery('#loading').fadeIn();
			jQuery('#loadingBack').show();
		},
		complete : function() {
			jQuery('#loading').fadeOut();
			jQuery('#loadingBack').hide();
		}
	});
	
	var regF = jQuery('div#register>a');
	regF.click(function() {
		if('' == jQuery('div#lbForm>div#lbFormCt').html()) {
			jQuery.ajax( {
				url : '?id=791',
				beforeSend: function() {
					jQuery('#loading').fadeIn();
					jQuery('#loadingBack').show();
				},
				success : function(html) {
					jQuery('div#lbFormCt').html(html);
					jQuery('div#lbForm').fadeIn();
				},
				complete: function() {
					jQuery('#loading').fadeOut();
					jQuery('#loadingBack').hide();
				}
			});
		}else {
			jQuery('div#lbForm').fadeIn();
		}
		return false;
	});
	
	var regClose = jQuery('div#lbForm>a.close');
	regClose.click(function() {
		jQuery('div#lbForm').fadeOut();
		return false;
	
	});
	
	var ulNavZone = jQuery('ul#navZone li a');
	ulNavZone.click(function() {
		jQuery.ajax( {
			url : '?id=794',
			data: 'doc=' + jQuery(this).attr('rel'),
			type: 'GET',
			beforeSend: function() {
				jQuery('div#dataZone').fadeOut('fast',function() {
					jQuery('img#dataZoneLoader').fadeIn('fast');
				}).empty();
			},
			success : function(html) {
				jQuery('img#dataZoneLoader').fadeOut('fast',function() {
					jQuery('div#dataZone').append(html).fadeIn('fast');
				});
			},
			complete: function(event, request){
				if(200 != event.status) {
					jQuery('img#dataZoneLoader').fadeOut('fast',function() {
						alert('Ha ocurrido un error al hacer la petición a la página');
					});
				}
			}
		});
		return false;
	});
	
	
	///////////////////////////////////////////////////////////////////
	var ulNacCapacitacion = jQuery('ul#flashZone li a');
	ulNacCapacitacion.click(function() {
			jQuery.ajax( {
				url : '805.html&width=550&height=405',
				beforeSend: function() {
					jQuery('#loading').fadeIn();
					jQuery('#loadingBack').show();
				},
				success : function(html) {
					jQuery('div#flashCapacitados').html(html);
					jQuery('div#flashCapacitadosContent').show();
					
				},
				complete: function() {
					jQuery('#loading').fadeOut();
					jQuery('#loadingBack').hide();
				}
			});
		return false;
	});
	
	
	//Lightbox de Capacitación 2010	
	//SexyLightbox.initialize();  //<<<------- Ojo Mod 27 mayo
	
});

function reloadVals() {
	openVals();
	jQuery('#regresarVal').fadeOut();
}

function openValoresList() {
	jQuery.ajax( {
		url : '?id=725',
		beforeSend : function() {
			jQuery('#contValoresAjax').fadeOut();
			jQuery('#loading').fadeIn();
			jQuery('#loadingBack').show();
		},
		success : function(html) {
			jQuery('#contValoresAjax').html(html);
			jQuery('#contValoresAjax').fadeIn();
			jQuery('#regresarVal').fadeIn();
		}
	});
}

function openValor(id) {
	if (id) {
		var uri;
		jQuery.ajax( {
			url : '?id=726&id_val=' + id,
			success : function(html) {
				jQuery('#valSingDiv').html(html);
				jQuery('#valSingDiv').fadeIn();
				jQuery('#cerrarValores').fadeIn();
			}
		});
	}
}

function closeLightValor() {
	jQuery('#valSingDiv').fadeOut();
	jQuery('#cerrarValores').fadeOut();
}

function openReglas() {
	jQuery.ajax( {
		url : '?id=727',
		success : function(html) {
			var div = jQuery('#valDiv');
			jQuery('#valCont').html(html);
			jQuery('#backLightNuest').show();
			div.fadeIn();
			jQuery('#regresarVal').fadeIn();
		}
	});
}

function openVals() {
	jQuery.ajax( {
		url : '?id=724',
		success : function(html) {
			var div = jQuery('#valDiv');
			jQuery('#valCont').html(html);
			jQuery('#backLightNuest').show();
			div.fadeIn();
		}
	});

	return false;
}

function loadCV() {
	jQuery.ajax( {
		url : '?id=723',
		success : function(html) {
			jQuery('#cvCont').html(html);
			jQuery('#cvDiv').fadeIn();
			jQuery('#backLightNuest').show();
		}
	});
}

function plantaLoad(id) {
	
	jQuery.ajax( {
		url : id + '.html',
		success : function(html) {
			alert(html);
			jQuery('#infoPlantasCont').html(html);
			jQuery('#infoPlantas').fadeIn();
		}
	});
}

var margin = 0;
function next() {
	if (margin < -1800) {
		return false;
	}
	jQuery('#plantasDiv').css('margin-left', '' + (margin - 225) + 'px');
	jQuery('#backPlantas').fadeIn();
	jQuery('#nextPlantas').fadeIn();
	margin = margin - 225;
	if (margin == -2025) {
		jQuery('#nextPlantas').fadeOut();
	}
	return false;
}

function back() {
	if (margin == 0) {
		return false;
	}
	jQuery('#plantasDiv').css('margin-left', '' + (margin + 225) + 'px');
	jQuery('#nextPlantas').fadeIn();
	margin = margin + 225;
	if (margin == 0) {
		jQuery('#backPlantas').fadeOut();
	}
	return false;
}

function closeLight() {
	jQuery('#backLightNuest').fadeOut();
	jQuery('#lightNuestAcerca').fadeOut();
	jQuery('#backLightCentro').fadeOut();
	jQuery('#lightCentroInnova').fadeOut();
	
	jQuery('#lightHistoriaFlashFy').fadeOut();
	jQuery('#lightNuest').fadeOut();
	jQuery('#lightPlantas').fadeOut();
	jQuery('#plantasButtons').fadeOut();
	jQuery('#infoPlantas').fadeOut();
	jQuery('#cvDiv').fadeOut();
	jQuery('#valDiv').fadeOut();
	jQuery('#valSingDiv').fadeOut();
	jQuery('#cerrarValores').fadeOut();
	jQuery('#regresarVal').fadeOut();
	//jQuery('#flashCapacitados').hide();
	jQuery('#flashCapacitadosContent').fadeOut();
}

function closeLightPlanta() {
	jQuery('#infoPlantas').fadeOut();
}

/**
 * Script para validar el formulario de compra
 */
function validateCV() {
	var ret = true;
	jQuery('#nombre_txt, #mail_txt, #sendto_sel, #tel_txt, #cv_file')
			.each(
					function() {
						if (jQuery(this).attr('value') == '') {
							alert('El campo ' + jQuery(this).attr('alt') + ' no puede estar vacío');
							ret = false;
						}
					});
	return ret;
}

