function formExampleValues(selectorForm) {
	$(selectorForm+' :input').example(function() {
		return $(this).attr('title');
	});
}
function formReloadExampleValues(selectorForm) {
	$(selectorForm).trigger("reload");
}
function preloadImages(images) {
	var $div = $(document.createElement("div"));
	$div.css({
		height:'1px',
		overflow:'hidden'
	});
	var src;
	var $img;
	for(var i = 0; i < images.length; i++) {
		src = images[i];
		$img = $(document.createElement("img"));
		$img.attr("src", src);
		$img.appendTo($div);
	}
	$("#header").after($div);
}
function accordionConHash(selector) {
	$(selector).accordion();
	$(".ui-accordion-header").each(function(i) {
		if('#'+(i+1) == document.location.hash) {
			$(".ui-accordion").accordion("activate",i);
		}
	});
}
function colorBox(selector, selectorHandle) {
	$(selector).colorbox();
	if((selectorHandle != null) && ($(selectorHandle).lenght > 0)) {
		$(selectorHandle).click(function(){
			$(this)./*  AGREGAR RUTA HASTA EL HANDLE  */click();
			return false;
		});
	}
}
function bindMostrarVentana(selectorTrigger, selectorVentana, width, height) {
	$(selectorTrigger).click(function(){
		 mostrarVentana(selectorVentana, width, height);
		 return false;
	});
}
function mostrarVentana(selector, width, height) {
	if(width == null) {
		width = 650;
	}
	if(height == null) {
		height = 430;
	}
	$.fn.colorbox({
		width:width+"px", 
		height:height+"px",
		display:"block",
		href:selector,
		opacity:0.8,
		open:true,
		inline:true
	});
}
function formularioSetFocuses(selectorForm) {
	setFocusBlur($(selectorForm+" :input"));
}
function setFocusBlur($obj) {
	setElementOnFocus($obj);
	setElementOnBlur($obj);
}
function setElementOnFocus($obj) {
	$obj.focus(function() {
		$(this).addClass("focus");
		$(this).parents("div:first").prevAll("label:first").eq(0).addClass("focus");
	});
}
function setElementOnBlur($obj) {
	$obj.blur(function() {
		$(this).removeClass("focus");
		$(this).parents("div:first").prevAll("label:first").eq(0).removeClass("focus");
	});
}
function setOnsubmit($form, onsubmit) {
	if(typeOf(onsubmit) == "function") {
		$form.submit(onsubmit);
	}
}
function attachSubmitToForm($elem, $form, callback) {
	$elem.click(function(){ 
		$form.submit();
		if(typeOf(callback) == "function") {
			return callback();
		}
	});
}
function scrollToSelector(selector, callback, duration, over) {
	if(typeOf(callback) != "function") {
		callback = function(){};
	}
	if(duration == null) {
		duration = 600;
	}
	if(over == null) {
		over = 0;
	}
	$.scrollTo($(selector), {
		duration: duration,
		axis: "y",
		onAfter: callback,
		over: over
	});
}
function efectoFoco(selector1, selector2, tiempo) {
	var over = function() { 
				var $img = $(this).find(selector2);
				$img.dequeue();
				$img.animate({opacity:"1"},tiempo); 
			};
	var out = function() {
				var $img = $(this).find(selector2);
				$img.dequeue();
				$img.animate({opacity:"0.5"},tiempo); 
			};
	$(selector1).hover(over, out);
}
function fixPng() {
	$(function() {
		if($.browser.msie && ($.browser.version.substr(0,1) < 7)){
			$("*").ifixpng();
		}
	});
}
function isSwf(filename) {
	var isValid = false;
	if(filename !== undefined) {
		extnRx = new RegExp('\.swf'.toUpperCase()+'$');
		if (extnRx.exec(filename.toUpperCase())) {
			isValid = true;
		}
	}
	return isValid;
}
function embedBannerGrupo(banners, width, height, vinculo) {
	/* De la forma:
	<div class="banner">
		<div id="banner-{$idBanner}">
		</div>
	</div>
	*/
	var i, banner;
	for(i in banners) {
		banner = banners[i];
		if(isSwf(banner.archivo) && ($("#banner-"+banner.id).length == 1)) {
			swfobject.embedSWF('images/banners/'+banner.archivo, 'banner-'+banner.id, width, height, '6', null, "href="+vinculo);
		}
	}
}


function formToMail(selector, action, callback, validateCallback, errorCallback) {
	var $form = $(selector);
	$form.attr("action",action);
	$form.submit(function() {
								var that = this;
								if (validar(that,validateCallback)) {
									$form.ajaxSubmit({
										type:"POST",
										success:function(resp){ callback(resp, that) },
										error:errorCallback
									});
								}
							});	
}



