// JavaScript Document
(function($) {
 $.fn.textDropShadow = function(){
	 $(this).html('<span class="jq-text">'+$(this).html()+'</span><span class="jq-shadow">'+$(this).html()+'</span>');
	 return $(this);
 }
})(jQuery);

eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4($){k.9.7=5.9.7=4(a){3 b=p;2(b.j==5)b=d(b);2(!a)3 a=$(\'g\');2($(a).6()>0){3 c=b*(1/(d($(a).r("n-6"))))+\'m\';8 c}l 8\'i: o h q f s a e t\'}})(u);',31,31,'||if|var|function|String|size|pxToEm|return|prototype||||parseInt|DOM|is|body|scope|Error|constructor|Number|else|em|font|Provided|this|argument|css|not|element|jQuery'.split('|'),0,{}));

$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
				if($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if(!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm($(this)); //use ems unless px is specified or 
		// for ie6, set height since min-height isn't supported
		var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
		if ($.browser.msie && (ie6)) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return $(this);
};

var filters = {
		requerido: function(el) {return ($(el).val() != '' && $(el).val() != -1 && $(el).val() != 'undefined' || $(el).attr('value') != '');},
		email: function(el) {return /^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/.test($(el).val());},
		telefono: function(el){return /^[0-9]*$/.test($(el).val());},
		categoria: function(el){ return ($('select#mm_categoria option:selected').val());},
		contactDefault: function(el){return $(el).val() != 'Deje su mensaje.';},
		contactNameDefault: function(el){return ($(el).val() != 'su nombre de contacto' && $(el).val() != 'your contact name');},
		contactEmailDefault: function(el){return ($(el).val() != 'su correo electronico' && $(el).val() != 'your email address');},
		contactSubjectDefault: function(el){return ($(el).val() != 'el asunto de este mensaje' && $(el).val() != 'this message subject');},
		contactCommentsDefault: function(el){return ($(el).val() != 'su mensaje' && $(el).val() != 'your message');}
	};
	
$.extend({
	stop: function(e){
		if (e.preventDefault) e.preventDefault();
		if (e.stopPropagation) e.stopPropagation();
	}
});

var preloader = new Image();
preloader.src = 'images/loadingAnimation.gif';

function insertPreloader(div){
	var topPercent = 50;
	var thisHeight = div.height();
	
	var layerHeight = (topPercent*thisHeight)/100;
	var layerPadding = (thisHeight-layerHeight);
	
	div.html('<div class="center" style="height:'+(layerHeight-1)+'px; padding-top:'+layerPadding+'px"><img src="images/loadingAnimation.gif" width="24" height="24" alt="" /></div>');
}

function sameHeight(container){
	var arr = $.makeArray($(container));
	var mHeight = 0;
	for(var i=0; i < arr.length; i++){
		var height = $(arr[i]).height();
		if(height > mHeight){
			mHeight = height;	
		}
		
	}
	$(container).css({height:mHeight});
	
}


/*
 * JavaScript Pretty Date
 * Copyright (c) 2008 John Resig (jquery.com)
 * Licensed under the MIT license.
 */

// Takes an ISO time and returns a string representing how
// long ago the date represents.
$(document).ready( function(){
	$("form").bind("submit", function(e){
		if (typeof filters == 'undefined') return;
	    $(this).find("input, textarea, select").each(function(x,el){ 
	        if ($(el).attr("className") != 'undefined') { 
			$(el).removeClass("error");
	        $.each(new String($(el).attr("className")).split(" "), function(x, klass){
	            if ($.isFunction(filters[klass])){
	                if (!filters[klass](el))  $(el).addClass("error");
				}
	        });
	        }
	    });
		if ($(this).find(".error").size() > 0) {
			$.stop(e || window.event);
			jAlert("<p>Necesita completar los campos marcados</p>","El formulario no es valido");
			return false;
		}
	    return true;
	});
	
	$('ul.liRounded li a').corner("10px tl bl");
	
	$('div.paddingVerticalPublicidad:empty').remove();
	
});
