	jQuery(document).ready(function(){
		var triggers = jQuery("a[rel='#slim1']").overlay({mask:{color:'#000', effect: 'apple'}, closeOnClick: true});
		var triggers2 = jQuery("a[rel='#slim4']").overlay({mask:{color:'#000', effect: 'apple'}, closeOnClick: true});
	jQuery(".affiliates3 a").click(function() {
  			jQuery('.blogadentro').load('http://www.jorgerieraflores.com/wp/index.php #post');
	});

	
	jQuery('li.productsl').mouseenter(function(){
		jQuery('li.productsl ul').fadeIn();
	});
	jQuery('li.productsl').mouseleave(function(){
		jQuery('li.productsl ul').fadeOut();
	});
	jQuery(".portafolio-scroll .items a").fancybox({
 'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
 }
 }); 
jQuery('#click1port').click(function(){
	jQuery("#porta1click").trigger('click');
}); 
	jQuery(".portafolio-scroll2 .items a").fancybox({
 'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
 }
 }); 
jQuery('#click2port').click(function(){
	jQuery("#porta2click").trigger('click');
}); 
	jQuery(".portafolio-scroll3 .items a").fancybox({
 'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
 }
 }); 
jQuery('#click3port').click(function(){
	jQuery("#porta3click").trigger('click');
}); 
	jQuery(".portafolio-scroll4 .items a").fancybox({
 'transitionIn' : 'none',
 'transitionOut' : 'none',
 'titlePosition' : 'over',
 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
 }
 }); 
jQuery('#click4port').click(function(){
	jQuery("#porta4click").trigger('click');
}); 
	jQuery.fn.supersized.options = {  
		startwidth: 1024,  
		startheight: 700,
		minsize: .50,
		slideshow: 0
	};
	jQuery('img#supersize').supersized();
	jQuery("#enviar2").click(function(){
		jQuery(".error").removeClass('error');
		jQuery('.noexito').hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?jQuery/;

		var emailFromVal = jQuery("#email3").val();
		if(emailFromVal == '') {
			jQuery("#email3").addClass('error');
			hasError = true;
		} else if(!emailReg.test(emailFromVal)) {
			jQuery("#email3").addClass('error');
			hasError = true;
		}

		var nameVal = jQuery("#nombre_completo").val();
		if(nameVal == '') {
			jQuery("#nombre_completo").addClass('error');
			hasError = true;
		}

		var messageVal = jQuery("#mensaje").val();
		if(messageVal == '') {
			jQuery("#mensaje").addClass('error');
			hasError = true;
		}
		var telVal = jQuery("#telefono").val();
		if(telVal == '') {
			jQuery("#telefono").addClass('error');
			hasError = true;
		}


		if(hasError == false) {
			jQuery(this).hide();
			jQuery("#psubmit").append('<img src="/img/load.gif" alt="Loading" id="loading" style="margin:20px 0 0 120px;"/>');

			jQuery.post("/sendemail.php",
				{ email: emailFromVal, name: nameVal, mensaje: messageVal, telefono :telVal },
					function(data){
						jQuery("#formulario2").slideUp("normal", function() {
							jQuery("#formulario2").after('<div class="exito"><p>Thanks for writing, I will contact you as soon as possible.</p></div>');
						});
					}
				 );
		} else {
			jQuery('#formulario2').after('<div class="noexito"><p>Sorry, there are some errors in the form.</p></div>');
		}

		return false;
	});
	
});
