function PrintIframe(pIframe)  
	{
		setTimeout(
			function() {
					f = document.getElementById(pIframe);
					f.focus();
					print();								
				}
			, 4000);
	}

function RecargarCarrito(reference)
{
	CargarContenido('#Carrito', '/ventas/carrito_vista.asp?Cantidad=1&Reference=' + reference + '&Contenido=Productos&Operation=Insert', 'Cargando...');
	$('#Carrito').show();
}

function RecargarCarrito(reference, cantidad)
{
	CargarContenido('#Carrito', '/ventas/carrito_vista.asp?Cantidad=' + cantidad + '&Reference=' + reference + '&Contenido=Productos&Operation=Insert', 'Cargando...');
	$('#Carrito').show();
}

function EliminarCarrito(url, mensaje) {
	if ( confirm(mensaje) )
	Enviar(url);
}


function AgregarFavoritos(Contenido, Reference) {
	CargarAlerta('/includes/formularios.asp?Contenido=' + Contenido + '&Reference=' + Reference + '&Formulario=Favoritos');
}	

function VerProIcon(Objeto)
{
	if ($(Objeto).next().css('display') == 'none')
	{
		$(Objeto).children('img').attr('src', '/images/ProIcoVerMas2.png');
		$(Objeto).next().animate({ width: 'show' }, 100); 		
	}
	else
	{
		$(Objeto).next().animate({ width: 'hide' }, 100);			
		setTimeout(function() {$(Objeto).children('img').attr('src', '/images/ProIcoVerMas.png');}, 100);
	}
}

function CreateTabs(Objeto, ObjetoImagen) {
    $("." + Objeto + "_content").hide();
    //$("ul." + Objeto + "s li:first").addClass("active").show();
    //$("." + Objeto + "_content:first").show();
    $("ul." + Objeto + "s li").click(function() {
        $("ul." + Objeto + "s li").removeClass("active");
        $(this).addClass("active");
        $("." + Objeto + "_content").hide();
        var activeTab = $(this).find("a").attr("href");
		if(ObjetoImagen) {
			$('#'+ObjetoImagen).attr("src", $(this).find("a").attr("rel"));	
		}
        $(activeTab).fadeIn();
        return false;
    });
}

function insertObject(sHTML) {
	if(navigator.appName.indexOf('Microsoft')!=-1) {
		var obj=dialogArguments.oUtil.obj;
	} else {
		var obj=window.opener.oUtil.obj;
	}
	obj.insertHTML(sHTML);
}

function MesNumero(Mes) {

	switch (Mes) {
		case 'Enero': Mes = '01'; break;
		case 'Febrero': Mes = '02'; break;
		case 'Marzo': Mes = '03'; break;				
		case 'Abril': Mes = '04'; break;		
		case 'Mayo': Mes = '05'; break;		
		case 'Junio': Mes = '06'; break;
		case 'Julio': Mes = '07'; break;		
		case 'Agosto': Mes = '08'; break;		
		case 'Septiembre': Mes = '09'; break;				
		case 'Octubre': Mes = '10'; break;
		case 'Noviembre': Mes = '11'; break;		
		case 'Diciembre': Mes = '12'; break;				
	} 

	return Mes;	
}			

/*********************************************************************************************************************************/
try {

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[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}('(9($){$.1f.1q=9(1X){b 3=$.2i({},$.1f.1q.2c,1X);I g.E(9(){b 4={f:0,t:\'\',U:0,o:\'\',N:m,1k:m,1N:m};b 5=$(g);5.1S(\'7:4\',4);5.e(\'2h\',\'2g\');5.1n(\'1q\');b d=5.2j();d.E(9(){b j=$(g);b 1p=\'\';6(!j.K(\'B\')){6(j.K(\'a\')){j.1n(\'7-2k\');1p=j}j=j.1g(\'B:1s\')}b 1c=j.w();6(1c==0)1c=j.s(\'w\');b 1d=j.x();6(1d==0)1d=j.s(\'x\');6(1c>5.w()){5.w(1c)}6(1d>5.x()){5.x(1d)}6(1p!=\'\'){1p.e(\'P\',\'1h\')}j.e(\'P\',\'1h\');4.U++});6(3.1a>0){6(3.1a>=4.U)3.1a=4.U-1;4.f=3.1a}6($(d[4.f]).K(\'B\')){4.t=$(d[4.f])}n{4.t=$(d[4.f]).1g(\'B:1s\')}6($(d[4.f]).K(\'a\')){$(d[4.f]).e(\'P\',\'1w\')}5.e(\'W\',\'V(\'+4.t.s(\'D\')+\') R-Y\');2b(b i=0;i<3.h;i++){b G=X.27(5.w()/3.h);6(i==3.h-1){5.J($(\'<C z="7-c"></C>\').e({21:(G*i)+\'13\',w:(5.w()-(G*i))+\'13\'}))}n{5.J($(\'<C z="7-c"></C>\').e({21:(G*i)+\'13\',w:G+\'13\'}))}}5.J($(\'<C z="7-H"><p></p></C>\').e({P:\'1h\',y:3.1Y}));6(4.t.s(\'16\')!=\'\'){$(\'.7-H p\',5).1y(4.t.s(\'16\'));$(\'.7-H\',5).1x(3.q)}b l=0;6(!3.1i&&d.1j>1){l=1v(9(){F(5,d,3,m)},3.1m)}6(3.T){5.J(\'<C z="7-T"><a z="7-2a">2f</a><a z="7-29">2m</a></C>\');6(3.2d){$(\'.7-T\',5).24();5.25(9(){$(\'.7-T\',5).2l()},9(){$(\'.7-T\',5).24()})}$(\'a.7-2a\',5).1J(\'1I\',9(){6(4.N)I m;S(l);l=\'\';4.f-=2;F(5,d,3,\'1C\')});$(\'a.7-29\',5).1J(\'1I\',9(){6(4.N)I m;S(l);l=\'\';F(5,d,3,\'1A\')})}6(3.M){b 1b=$(\'<C z="7-M"></C>\');5.J(1b);2b(b i=0;i<d.1j;i++){6(3.20){b j=d.1B(i);6(!j.K(\'B\')){j=j.1g(\'B:1s\')}6(3.1Q){1b.J(\'<a z="7-1l" 11="\'+i+\'"><B D="\'+j.s(\'11\')+\'" 28="" /></a>\')}n{1b.J(\'<a z="7-1l" 11="\'+i+\'"><B D="\'+j.s(\'D\').2n(3.1R,3.1P)+\'" 28="" /></a>\')}}n{1b.J(\'<a z="7-1l" 11="\'+i+\'">\'+i+\'</a>\')}}$(\'.7-M a:1B(\'+4.f+\')\',5).1n(\'1o\');$(\'.7-M a\',5).1J(\'1I\',9(){6(4.N)I m;6($(g).2e(\'1o\'))I m;S(l);l=\'\';5.e(\'W\',\'V(\'+4.t.s(\'D\')+\') R-Y\');4.f=$(g).s(\'11\')-1;F(5,d,3,\'1l\')})}6(3.1M){$(2q).2A(9(1L){6(1L.1Z==\'2C\'){6(4.N)I m;S(l);l=\'\';4.f-=2;F(5,d,3,\'1C\')}6(1L.1Z==\'2D\'){6(4.N)I m;S(l);l=\'\';F(5,d,3,\'1A\')}})}6(3.1T){5.25(9(){4.1k=Q;S(l);l=\'\'},9(){4.1k=m;6(l==\'\'&&!3.1i){l=1v(9(){F(5,d,3,m)},3.1m)}})}5.2E(\'7:Z\',9(){4.N=m;$(d).E(9(){6($(g).K(\'a\')){$(g).e(\'P\',\'1h\')}});6($(d[4.f]).K(\'a\')){$(d[4.f]).e(\'P\',\'1w\')}6(l==\'\'&&!4.1k&&!3.1i){l=1v(9(){F(5,d,3,m)},3.1m)}3.1U.1z(g)})});9 F(5,d,3,19){b 4=5.1S(\'7:4\');6((!4||4.1N)&&!19)I m;3.1W.1z(g);6(!19){5.e(\'W\',\'V(\'+4.t.s(\'D\')+\') R-Y\')}n{6(19==\'1C\'){5.e(\'W\',\'V(\'+4.t.s(\'D\')+\') R-Y\')}6(19==\'1A\'){5.e(\'W\',\'V(\'+4.t.s(\'D\')+\') R-Y\')}}4.f++;6(4.f==4.U){4.f=0;3.1V.1z(g)}6(4.f<0)4.f=(4.U-1);6($(d[4.f]).K(\'B\')){4.t=$(d[4.f])}n{4.t=$(d[4.f]).1g(\'B:1s\')}6(3.M){$(\'.7-M a\',5).2F(\'1o\');$(\'.7-M a:1B(\'+4.f+\')\',5).1n(\'1o\')}6(4.t.s(\'16\')!=\'\'){6($(\'.7-H\',5).e(\'P\')==\'1w\'){$(\'.7-H p\',5).22(3.q,9(){$(g).1y(4.t.s(\'16\'));$(g).1x(3.q)})}n{$(\'.7-H p\',5).1y(4.t.s(\'16\'))}$(\'.7-H\',5).1x(3.q)}n{$(\'.7-H\',5).22(3.q)}b i=0;$(\'.7-c\',5).E(9(){b G=X.27(5.w()/3.h);$(g).e({x:\'O\',y:\'0\',W:\'V(\'+4.t.s(\'D\')+\') R-Y -\'+((G+(i*G))-G)+\'13 0%\'});i++});6(3.k==\'1t\'){b 10=2G 2B("1K","14","1F","17","1E","12","1D","1r");4.o=10[X.26(X.1t()*(10.1j+1))];6(4.o==2y)4.o=\'1r\'}6(3.k.2o(\',\')!=-1){b 10=3.k.2r(\',\');4.o=$.2z(10[X.26(X.1t()*10.1j)])}4.N=Q;6(3.k==\'2p\'||3.k==\'1K\'||4.o==\'1K\'||3.k==\'14\'||4.o==\'14\'){b u=0;b i=0;b h=$(\'.7-c\',5);6(3.k==\'14\'||4.o==\'14\')h=$(\'.7-c\',5).1e();h.E(9(){b c=$(g);c.e(\'1G\',\'O\');6(i==3.h-1){L(9(){c.A({x:\'r%\',y:\'1.0\'},3.q,\'\',9(){5.18(\'7:Z\')})},(r+u))}n{L(9(){c.A({x:\'r%\',y:\'1.0\'},3.q)},(r+u))}u+=1u;i++})}n 6(3.k==\'2t\'||3.k==\'1F\'||4.o==\'1F\'||3.k==\'17\'||4.o==\'17\'){b u=0;b i=0;b h=$(\'.7-c\',5);6(3.k==\'17\'||4.o==\'17\')h=$(\'.7-c\',5).1e();h.E(9(){b c=$(g);c.e(\'23\',\'O\');6(i==3.h-1){L(9(){c.A({x:\'r%\',y:\'1.0\'},3.q,\'\',9(){5.18(\'7:Z\')})},(r+u))}n{L(9(){c.A({x:\'r%\',y:\'1.0\'},3.q)},(r+u))}u+=1u;i++})}n 6(3.k==\'1E\'||3.k==\'2u\'||4.o==\'1E\'||3.k==\'12\'||4.o==\'12\'){b u=0;b i=0;b v=0;b h=$(\'.7-c\',5);6(3.k==\'12\'||4.o==\'12\')h=$(\'.7-c\',5).1e();h.E(9(){b c=$(g);6(i==0){c.e(\'1G\',\'O\');i++}n{c.e(\'23\',\'O\');i=0}6(v==3.h-1){L(9(){c.A({x:\'r%\',y:\'1.0\'},3.q,\'\',9(){5.18(\'7:Z\')})},(r+u))}n{L(9(){c.A({x:\'r%\',y:\'1.0\'},3.q)},(r+u))}u+=1u;v++})}n 6(3.k==\'1D\'||4.o==\'1D\'){b u=0;b i=0;$(\'.7-c\',5).E(9(){b c=$(g);b 1H=c.w();c.e({1G:\'O\',x:\'r%\',w:\'O\'});6(i==3.h-1){L(9(){c.A({w:1H,y:\'1.0\'},3.q,\'\',9(){5.18(\'7:Z\')})},(r+u))}n{L(9(){c.A({w:1H,y:\'1.0\'},3.q)},(r+u))}u+=1u;i++})}n 6(3.k==\'1r\'||4.o==\'1r\'){b i=0;$(\'.7-c\',5).E(9(){$(g).e(\'x\',\'r%\');6(i==3.h-1){$(g).A({y:\'1.0\'},(3.q*2),\'\',9(){5.18(\'7:Z\')})}n{$(g).A({y:\'1.0\'},(3.q*2))}i++})}}};$.1f.1q.2c={k:\'1t\',h:15,q:2x,1m:2w,1a:0,T:Q,2d:Q,M:Q,20:m,1Q:m,1R:\'.1O\',1P:\'2v.1O\',1M:Q,1T:Q,1i:m,1Y:0.8,1W:9(){},1U:9(){},1V:9(){}};$.1f.1e=[].1e})(2s);',62,167,'|||settings|vars|slider|if|nivo||function||var|slice|kids|css|currentSlide|this|slices||child|effect|timer|false|else|randAnim||animSpeed|100|attr|currentImage|timeBuff||width|height|opacity|class|animate|img|div|src|each|nivoRun|sliceWidth|caption|return|append|is|setTimeout|controlNav|running|0px|display|true|no|clearInterval|directionNav|totalSlides|url|background|Math|repeat|animFinished|anims|rel|sliceUpDownLeft|px|sliceDownLeft||title|sliceUpLeft|trigger|nudge|startSlide|nivoControl|childWidth|childHeight|reverse|fn|find|none|manualAdvance|length|paused|control|pauseTime|addClass|active|link|nivoSlider|fade|first|random|50|setInterval|block|fadeIn|html|call|next|eq|prev|fold|sliceUpDown|sliceUpRight|top|origWidth|click|live|sliceDownRight|event|keyboardNav|stop|jpg|controlNavThumbsReplace|controlNavThumbsFromRel|controlNavThumbsSearch|data|pauseOnHover|afterChange|slideshowEnd|beforeChange|options|captionOpacity|keyCode|controlNavThumbs|left|fadeOut|bottom|hide|hover|floor|round|alt|nextNav|prevNav|for|defaults|directionNavHide|hasClass|Prev|relative|position|extend|children|imageLink|show|Next|replace|indexOf|sliceDown|window|split|jQuery|sliceUp|sliceUpDownRight|_thumb|3000|500|undefined|trim|keypress|Array|37|39|bind|removeClass|new'.split('|'),0,{}))
	
} catch(err) {
	
}



/*********************************************************************************************************************************/

var Auxiliar = false;


function EnviarFormularioGETGEN(WebURL) {
	elForm = buscarobjeto('FormAdmin');
	Resultado = $('#FormAdmin').validationEngine({returnIsValid:true});
	if (!Resultado) {
		$.validationEngine.submitValidation();			
	} else {
		elForm.redirect.value = WebURL;
		document.location.href = WebURL + '?' + getAllValues();
	}
}


function EnviarFormularioGETURL(WebURL) {
	Enviar(WebURL + '?' + getAllValues());
}


function IngresoTexto(Objeto, Texto) {
    if (Objeto.value == Texto) {
        Objeto.value = '';
    }
}

function SalidaTexto(Objeto, Texto) {
    if (Objeto.value == '') {
        Objeto.value = Texto;
    }
}

function showMenu(id_menu, p_Table, p_PK, p_elDIV, p_elDIVMostrar, p_Reference, p_Column) {
    var my_menu = document.getElementById(id_menu);
    if (my_menu.style.display == "none" || my_menu.style.display == "") {
        my_menu.style.display = "block";
        if (!Auxiliar)
        {
			CargarObjetoBuscador(p_Table, p_PK, p_elDIV, p_elDIVMostrar, p_Reference, p_Column);
			Auxiliar = true;
        }
    } else {
        my_menu.style.display = "none";
    }
}

function CargarObjetoBuscador(p_Table, p_PK, p_elDIV, p_elDIVMostrar, p_Reference, p_Column) {
	url_page = '/myadmin/reportes/objetos/buscador.asp?Table=' + p_Table + '&PK=' + p_PK + '&Reference=' +  p_Reference + '&Column=' + p_Column;

	$.ajax({
		url: url_page,
		cache: false,
		type: 'POST',
		beforeSend: function(data){ 
			$('#'+p_elDIV).html('<div style=\'margin:10px;\'><img src=\'/images/wait2.gif\' align=\'absmiddle\'></div>');
			$('#'+p_elDIVMostrar).show();				
		},  
		error: function(data){ 		
			$('#'+p_elDIV).html('<img src=\'/images/icon_alert.gif\' align=\'absmiddle\'> <span class=\'textor\'> <strong>Se ha producido un error</strong>. Por favor, intente nuevamente.</span>');
			$('#'+p_elDIVMostrar).show();
		},  
		success: function(html){
			$('#'+p_elDIV).html(html);
			$('#'+p_elDIVMostrar).show();
		}
	});
}

function swapImage(idStatus) {
    if (idStatus == 0) {
        document.arrow_profile.src = "/images/arrow_hover.png";
    } else if (idStatus == 1) {
        document.arrow_profile.src = "/images/arrow_select.png";
    } else if (idStatus == 2) {
        document.arrow_profile.src = "/images/arrow.png";
    }
}

function CargarFormulario(Objeto, Pagina)
{
    $.ajax({
        url: Pagina,
        cache: false,
        beforeSend: function(data) {
            $('#' + Objeto).html('<div><img src=\'/images/wait2.gif\'></div>');
        },
        success: function(html) {
            $('#' + Objeto).html(html);
        }
    });
}

/*********************************************************************************************************************************/

function Zoom()
{
	(function($){
	
	$.fn.zoomi = function() {
	  $(this).filter("img").each(function(){
		if(!this.z) {
		  $(this).zoom1().mouseover(function(){$(this).zoom2().show();});
		  $(this.z).mouseout(function(){$(this).hide();}); }
	  });
	 return this;
	}
	
	$.fn.zoom1 = function() {
	  $(this).each(function(){
		var e = this;
		$(e).css({'position':'absolute','z-index':'8'}).after('<img class="'+e.className+'">');
		e.z = e.nextSibling;
		$(e.z).removeClass("zoomi").addClass("zoom2").attr("src",e.alt || e.src)
		.css({'position':'relative','z-index':'10'});
		$(e.z).hide();
	  });
	  return this;
	}
	
	$.fn.zoom2 = function() {
	  var s = [];
	  this.each(function(){
		var e = this;
		if(!e.z) e = $(e).zoom1()[0]; s.push(e.z);
		if(!e.z.complete) return;
		if(!e.z.width) {
			$(e.z).show();
			e.z.width = e.z.width;
			$(e.z).hide();
		}
		var PosicionIzquierda = - e.z.width * 0.5 - 5 + e.width * 0.5;
		var PosicionTop = - e.z.height * 0.5 - 5 + e.height * 0.5;
		$(e.z).css({
			left:PosicionIzquierda +'px'
			,top:PosicionTop+'px'
		});
	  });
	  return this.pushStack(s);
	}
	
	$.fn.offsetLeft = function() {
	  var e = this[0];
	  if(!e.offsetParent) return e.offsetLeft;
	  return e.offsetLeft + $(e.offsetParent).offsetLeft(); }
	
	$.fn.offsetTop = function() {
	  var e = this[0];
	  if(!e.offsetParent) return e.offsetTop;
	  return e.offsetTop + $(e.offsetParent).offsetTop(); }
	
	$(function(){ $('img.zoomi').zoomi(); });
	
	})(jQuery);
}



/*********************************************************************************************************************************/

var QueryLoader = {
	overlay: "",
	loadBar: "",
	preloader: "",
	items: new Array(),
	doneStatus: 0,
	doneNow: 0,
	selectorPreload: "body",
	ieLoadFixTime: 2000,
	ieTimeout: "",
		
	init: function() {
		if (navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/) == "MSIE 6.0,6.0") {
			//break if IE6			
			return false;
		}
		if (QueryLoader.selectorPreload == "body") {
			QueryLoader.spawnLoader();
			QueryLoader.getImages(QueryLoader.selectorPreload);
			QueryLoader.createPreloading();
		} else {
			$(document).ready(function() {
				QueryLoader.spawnLoader();
				QueryLoader.getImages(QueryLoader.selectorPreload);
				QueryLoader.createPreloading();
			});
		}
		
		//help IE drown if it is trying to die :)
		QueryLoader.ieTimeout = setTimeout("QueryLoader.ieLoadFix()", QueryLoader.ieLoadFixTime);
	},
	
	ieLoadFix: function() {
		var ie = navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/);
		//if (ie[0].match("MSIE")) {
		if (ie) {
			while ((100 / QueryLoader.doneStatus) * QueryLoader.doneNow < 100) {
				QueryLoader.imgCallback();
			}
		}
	},
	
	imgCallback: function() {
		QueryLoader.doneNow ++;
		QueryLoader.animateLoader();
	},
	
	getImages: function(selector) {
		var everything = $(selector).find("*:not(script)").each(function() {
			var url = "";
			
			if ($(this).css("background-image") != "none") {
				var url = $(this).css("background-image");
			} else if (typeof($(this).attr("src")) != "undefined" && $(this).attr("tagName").toLowerCase() == "img") {
				var url = $(this).attr("src");
			}
			
			url = url.replace("url(\"", "");
			url = url.replace("url(", "");
			url = url.replace("\")", "");
			url = url.replace(")", "");
			
			if (url.length > 0) {
				QueryLoader.items.push(url);
			}
		});
	},
	
	createPreloading: function() {
		QueryLoader.preloader = $("<div></div>").appendTo(QueryLoader.selectorPreload);
		$(QueryLoader.preloader).css({
			height: 	"0px",
			width:		"0px",
			overflow:	"hidden"
		});
		
		var length = QueryLoader.items.length; 
		QueryLoader.doneStatus = length;
		
		for (var i = 0; i < length; i++) {
			var imgLoad = $("<img></img>");
			$(imgLoad).attr("src", QueryLoader.items[i]);
			$(imgLoad).unbind("load");
			$(imgLoad).bind("load", function() {
				QueryLoader.imgCallback();
			});
			$(imgLoad).appendTo($(QueryLoader.preloader));
		}
	},

	spawnLoader: function() {
		if (QueryLoader.selectorPreload == "body") {
			var height = $(window).height();
			var width = $(window).width();
			var position = "fixed";
		} else {
			var height = $(QueryLoader.selectorPreload).outerHeight();
			var width = $(QueryLoader.selectorPreload).outerWidth();
			var position = "absolute";
		}
		var left = $(QueryLoader.selectorPreload).offset()['left'];
		var top = $(QueryLoader.selectorPreload).offset()['top'];
		
		QueryLoader.overlay = $("<div></div>").appendTo($(QueryLoader.selectorPreload));
		$(QueryLoader.overlay).addClass("QOverlay");
		$(QueryLoader.overlay).css({
			position: position,
			top: top,
			left: left,
			width: width + "px",
			height: height + "px"
		});
		
		QueryLoader.loadBar = $("<div></div>").appendTo($(QueryLoader.overlay));
		$(QueryLoader.loadBar).addClass("QLoader");
		
		$(QueryLoader.loadBar).css({
			position: "relative",
			top: "50%",
			width: "0%"
		});
	},
	
	animateLoader: function() {
		var perc = (110 / QueryLoader.doneStatus) * QueryLoader.doneNow;
		//$('#buscador').val(perc);
		if (perc > 100) {
			$(QueryLoader.loadBar).stop().animate({
				width: perc + "%"
			}, 500, "linear", function() { 
				QueryLoader.doneLoad();
			});
		} else {
			$(QueryLoader.loadBar).stop().animate({
				width: perc + "%"
			}, 500, "linear", function() { });
		}
	},
	
	doneLoad: function() {
		//prevent IE from calling the fix
		clearTimeout(QueryLoader.ieTimeout);

		$(QueryLoader.overlay).remove();

		//determine the height of the preloader for the effect
		if (QueryLoader.selectorPreload == "body") {
			var height = $(window).height();
		} else {
			var height = $(QueryLoader.selectorPreload).outerHeight();
		}
		
		//The end animation, adjust to your likings
		$(QueryLoader.loadBar).animate({
			height: height + "px",
			top: 0
		}, 500, "linear", function() {
			$(QueryLoader.overlay).fadeOut(800);
			$(QueryLoader.preloader).remove();
		});
	}
}

/*********************************************************************************************************************************/

function AgregarOpcion(optionValue, optionText, optionContainer)
{
	var oOption = document.createElement('OPTION');
	oOption.value = optionValue;
	oOption.innerHTML = optionText;
	optionContainer.appendChild(oOption); 
}

function Descargar(Archivo)
{
	document.location.href = '/includes/download.asp?Archivo=' + Archivo
}

function CargarNuevoCombo(p_Combo, p_Nombre, p_Seleccionar, p_Relations, p_CampoValor, p_CampoNombre, p_elDIV, p_OnChange) {
	url_page = '/includes/RSComboDependiente.asp?Combo='+ p_Combo +'&Nombre='+ p_Nombre +'&Relations='+ p_Relations +'&Seleccionar='+ p_Seleccionar + '&CampoValor='+ p_CampoValor +'&CampoNombre='+ p_CampoNombre +'&OnChange=' + p_OnChange;
	$.ajax({
		url: url_page,
		cache: false,
		beforeSend: function(data){ 
			$('#'+p_elDIV).html('<select><option>Cargando...</option></select>');
		},  
		success: function(html){
			$('#'+p_elDIV).html(html);
		}
	});
}

function EnviarFormularioAJAX(p_Formulario, p_elDIV) {
	url_page = '/includes/formularios.asp';
	$.ajax({
		url: url_page,
		cache: false,
		data: getFormValues(p_Formulario),
		type: 'POST',
		beforeSend: function(data){ 
			$('#'+p_elDIV).html('<div align=\'center\' style=\'margin:20px;\'><img src=\'/images/wait.gif\'></div>');
		},  
		error: function(data){ 		
			$('#'+p_elDIV).html('<div align=\'center\' style=\'margin:20px;\'><img src=\'/images/icon_alert.gif\'><br><span class=\'textor\'>- <strong>Se ha producido un error</strong> -<br> Por favor, intente nuevamente.</span></div>');
		},  
		success: function(html){
			$('#'+p_elDIV).html('<div align=\'center\' style=\'margin:20px;\'><img src=\'/images/check_big.png\'><div class=\'textoc\'>' + html + '</div></div>');
		}
	});
}

function FavoritoEliminar(p_Contenido, p_elDIV) {
	url_page = '/includes/formularios.asp';
	$.ajax({
		url: url_page,
		cache: false,
		data: 'Formulario=FavoritosDel&Contenido=' + p_Contenido,
		type: 'POST',
		beforeSend: function(data){ 
			$('#'+p_elDIV).html('<div align=\'center\' style=\'margin:11px;\'><img src=\'/images/wait2.gif\'></div>');
		},  
		error: function(data){ 		
			$('#'+p_elDIV).html('<div align=\'center\' style=\'margin:11px;\'><img src=\'/images/icon_alert.gif\'><span class=\'textor\'>- <strong>Se ha producido un error</strong> -<br> Por favor, intente nuevamente.</span></div>');
		},  
		success: function(html){
			//$('#'+p_elDIV).hide();
			//VerPanel(p_elDIV, 'Slide');
			$('#'+p_elDIV).fadeOut('fast');
		}
	});
}

function EnviarFormularioAJAXPersonalizado(p_Formulario, p_elDIV) {
	url_page = '/includes/formularios.asp';
	$.ajax({
		url: url_page,
		cache: false,
		data: getFormValues(p_Formulario),
		type: 'POST',
		beforeSend: function(data){ 
			$('#'+p_elDIV).html('<div align=\'center\' style=\'margin:20px;\'><img src=\'/images/wait.gif\'></div>');
		},  
		error: function(data){ 		
			$('#'+p_elDIV).html('<div align=\'center\' style=\'margin:20px;\'>- <strong>Se ha producido un error</strong> -<br> Por favor, intente nuevamente.</span></div>');
		},  
		success: function(html){
			$('#'+p_elDIV).html(html);
		}
	});
}

function EnviarFormularioGET(p_Formulario) {
	p_Formulario = buscarobjeto(p_Formulario);
	document.location.href = '?' + getFormValues(p_Formulario);
}

function getFormValues(form) {
     var str = "";
     $(':input', form).each(function(i) {
          if ((this.type == 'radio') || (this.type == 'checkbox')) {
               if (this.checked) {
                    str += this.name + "=" + escape(this.value) + "&";
               }
          } else {
               str += this.name + "=" + escape(this.value) + "&";
          }
     });
     str = str.substr(0, str.length-1);
     return str;
};

function cambiar_estilo(objeto, nombre_estilo, estilo_restaurar) {
	if (document.getElementById(objeto)) {
		if (document.getElementById(objeto).className == nombre_estilo) {
				document.getElementById(objeto).className = estilo_restaurar;
			}
		else {
				document.getElementById(objeto).className = nombre_estilo;
		}
	}
}

function seleccionarTodos(objeto) {
	var i;
	var f = $('form');
	for(i=0;i<f.elements.length;i++)
	{
		e = f.elements[i];

		if (e.type == 'checkbox' && e.name == objeto) {
			e.checked =f.chkTodos.checked;
		}

	}
}

function seleccionarTodosTR(objeto, tr_prefijo, tr_estilo, tr_estilo_restaurar) {
	var i;
	var f = document.getElementById('FormAdmin');
	for(i=0;i<f.elements.length;i++)
	{
		e = f.elements[i];

		if (e.type == 'checkbox' && e.name == objeto) {
			e.checked = f.chkTodos.checked;

			if (e.checked) {
				document.getElementById(tr_prefijo + e.value).className = tr_estilo;
			} else {
				document.getElementById(tr_prefijo + e.value).className = tr_estilo_restaurar;
			}
		}

	}
}

function getAllValues() {
     var str = "";
     $(':input').each(function(i) {
          if ((this.type == 'radio') || (this.type == 'checkbox')) {
               if (this.checked) {
                    str += this.name + "=" + escape(this.value) + "&";
               }
          } else {
               str += this.name + "=" + escape(this.value) + "&";
          }
     });
     str = str.substr(0, str.length-1);
     return str;
};

function CargarNuevoCombo2(p_elDIV, Datos, CampoNombre, Reference, Seleccionar, Nombre) {
	url_page = '/includes/RSComboDependiente2.asp?Datos='+ Datos +'&CampoNombre='+ CampoNombre +'&Reference='+ Reference +'&Seleccionar='+ Seleccionar + '&Nombre='+Nombre;
	$.ajax({
		url: url_page,
		cache: false,
		beforeSend: function(data){ 
			$('#'+p_elDIV).html('<select><option>Cargando...</option></select>');
		},  
		success: function(html){
			$('#'+p_elDIV).html(html);
		}
	});
}

function AgregarNewsletter(pURL, pSector, pContenido, pReferencia, pHTML) {
	url_page = pURL + '?Sector='+ pSector +'&Contenido='+ pContenido +'&Referencia='+ pReferencia +'&HTML='+  pHTML;
	$.ajax({
		url: url_page,
		cache: false,
		beforeSend: function(data){ 
			//$('#'+p_elDIV).html('<select><option>Cargando...</option></select>');
		},
		error: function() {
			alert('Se ha producido un error.\nEl contenido que intenta agregar ya está asociado al Newsletter.\n\nIntente borrarlo y agregarlo nuevamente.');	
		},
		success: function(html){
			$('#' + pContenido + '_' + pReferencia).fadeOut('normal');
			window.opener.Actualizar(pContenido, pReferencia);
		}
	});
}


/*********************************************************************************************************************************/

function ProMenu(pMenuNombre)
{
	switch (pMenuNombre) {
		case 'Productos':
				if (document.getElementById('MenuCuentaP')) {
						$('.MenuProductos').show();
						$('.MenuCuenta').hide();
						document.getElementById('MenuProductosP').className = 'PestanaSeleccionada';
						document.getElementById('MenuCuentaP').className = 'Pestana';						
						DondeEstoy('SeccionVentas', pMenuNombre);
					}
			break;
		case 'Cuenta':
				if (document.getElementById('MenuCuentaP')) {		
						$('.MenuProductos').hide();
						$('.MenuCuenta').show();
						document.getElementById('MenuProductosP').className = 'Pestana';
						document.getElementById('MenuCuentaP').className = 'PestanaSeleccionada';
						DondeEstoy('SeccionVentas', pMenuNombre);
					}						
			break;					
		}
}

function DondeEstoy(pSeccion, pSector)
{
	$.ajax({url: '/includes/EstoyEnSector.asp?' + pSeccion + '=' + pSector});
}

function Enviar(pUrl)
{
	$.ajax({url: pUrl});
}

function CambiarValorBIT(objCheckbox) {
	if (objCheckbox.value == '1') {
		objCheckbox.value = '000';
	} else	{
		objCheckbox.value = '1';			
	}
}

function CargarContenido(p_elDIV, p_URL, p_Mensaje) {
	$.ajax({
		url: p_URL,
		cache: false,
		beforeSend: function(data){ 
			$(p_elDIV).html(p_Mensaje);
		},  
		success: function(html){
			$(p_elDIV).html(html);
		}
	});
}

function CargarAlerta(p_URL) {
	$.ajax({
		url: p_URL,
		cache: false,
		success: function(html){
			if (html != '') {
					alert(html);				
				}
		}
	});
}

function responder() {
	formulario = document.getElementById('Formulario');
	respuesta = $("input[@name='Respuesta']:checked").val();
	pregunta = $("input[@name='Pregunta']").val();
	examen = $("input[@name='Examen']").val();
	if(respuesta) {
		CargarContenido('#Resultado', '/contenidos/respuesta.asp?Pregunta='+ pregunta +'&Respuesta=' + respuesta + '&Examen=' + examen , 'Verificando Respuesta...');
		//$('.tdChecks').html('');
		$('.tdChecks').hide();
		$('#btnSiguiente').show();
		$('#btnResponder').hide();
		$("input[@name='RespuestaFinal']").attr('value', respuesta);
		//formulario.submit();
	} else {
		alert('Por favor, eliga una de las opciones como respuesta.');
	}
}

function responder_final() {
	formulario = document.getElementById('Formulario');
	respuesta = $("input[@name='Respuesta']:checked").val();
	pregunta = $("input[@name='Pregunta']").val();
	if(respuesta) {
		//CargarContenido('#Resultado', '/contenidos/respuesta.asp?Pregunta='+ pregunta +'&Respuesta=' + respuesta, 'Verificando Respuesta...');
		//$('.tdChecks').html('');
		//$('#btnSiguiente').show();
		//$('#btnResponder').hide();
		$("input[@name='RespuestaFinal']").attr('value', respuesta);
		formulario.submit();
	} else {
		alert('Por favor, eliga una de las opciones como respuesta.');
	}
}



/*********************************************************************************************************************************/

function Cargar(p_elDIV, url_page) {
	$.ajax({
		url: url_page,
		cache: false,
		beforeSend: function(data){ 
			$('#'+p_elDIV).html('<div class="wait"><img src="/images/wait.gif"></div>');
		},  
		success: function(html){
			$('#'+p_elDIV).html(html);
		}
	});
}

/*********************************************************************************************************************************/

function Siguiente(Objeto) {
	var $active = $(Objeto + ' .Registro');
	var $next = $active.next();
	//$active.slideUp('normal');
	//$next.slideDown('normal');
	$active.fadeOut('normal');
	$next.fadeIn('normal');
}

function Anterior(Objeto) {
	var $active = $(Objeto + ' .Registro');
	var $prev = $active.prev();
	//$active.slideUp('normal');
	//$prev.slideDown('normal');
	$active.fadeOut('normal');
	$prev.fadeIn('normal');	
}

function ResMenus() {
	$('.Ventana').slideUp('fast');
	for(i=1;i<=5;i++) {
		buscarobjeto('BotonMenu0' + i).src = '/images/2010/menu/Menu0' + i + '1.jpg';		
	}
}

/*********************************************************************************************************************************/

function VerPanel(seccion, efecto) {
	var Visible = document.getElementById(seccion).style.display;
	switch (efecto) {
		case 'Slide':
				if (Visible == 'none') {
					//Effect.SlideDown(seccion,{queue:{scope:'myscope', position:'end', limit: 1}});
					$('#'+seccion).slideDown('normal');
				} else {
					//Effect.SlideUp(seccion,{queue:{scope:'myscope', position:'end', limit: 1}});
					$('#'+seccion).slideUp('normal');				
				}
			break;
		case 'Slide2':
				if (Visible == 'none') {
					$('#'+seccion).slideUp('normal');
				} else {
					$('#'+seccion).slideDown('normal');					
				}
			break;			
		case 'SlideHL':
				if (Visible == 'none') {
					//Effect.SlideDown(seccion,{queue:{scope:'myscope', position:'end', limit: 1}});
					$('#'+seccion).animate({ width: 'show' }); 
				} else {
					//Effect.SlideUp(seccion,{queue:{scope:'myscope', position:'end', limit: 1}});
					$('#'+seccion).animate({ width: 'hide' }); 
				}
			break;			
		default:
			if(document.getElementById(seccion)) {
				if (document.getElementById(seccion).style.display == 'none') {
					document.getElementById(seccion).style.display = 'block';
				} else	{
					document.getElementById(seccion).style.display = 'none';
				}
			}
	}
}

var DondeEstaba = '';

function CambiarImagen(Objeto, Imagen1, Imagen2)
{
	Posicion = Objeto.src.indexOf(Imagen1, 1);
	/*
	if(DondeEstaba != Objeto.id) {
		$('#' + DondeEstaba).click();
		DondeEstaba = Objeto.id;
	}
	*/
	if (Posicion < 0) {
			Objeto.src = Imagen1;
		}
	else
		{
			setTimeout(
				function() {
					Objeto.src = Imagen2;
				}
			, 400);
		}
}

/*********************************************************************************************************************************/

function oShadowbox(content, player, title){
    Shadowbox.open({
        content:    content,
        player:     player,
        title:      title
    });
}


function OpenShadowbox(Titulo, Pagina, Ancho, Alto) {
	Shadowbox.open({
        title:      Titulo,
        player:     'iframe',		
        content:    Pagina,
        height:     Alto,
        width:      Ancho
    });
	//clearTimeout(TiempoEspera);	
}


function Television() {
	ow('/television.asp', 'Televisión', '531', '403');
}

/*********************************************************************************************************************************/

function MensajeOK(request) {
	$('#IngresoNewsletter').show();
	$('#IngresoNewsletter').html(request);
}
function MensajeError() {
	$('#IngresoNewsletter').show();
	$('#IngresoNewsletter').html('<strong class="textor">Ha ocurrido<br>un error!</strong><br> Por favor intente<br>nuevamente.');
}
function Suscribirse(pTipoSuscripcion) {
	Formulario = document.getElementById('FormNewsletter');
	if (ValidaNewsletter(Formulario)) {
		$.ajax({
			url: '/includes/Newsletter.asp?Email='+ $('#EmailNewsletter').val() +'&TipoSuscripcion='+ pTipoSuscripcion + '&Nombre=' + $('#NombreNewsletter').val() + '&TipoNewsletter=' + $('#TipoNewsletter').val(),
			cache: false,
			error: MensajeError,
			success: MensajeOK
		});
	}
}
function ValidaNewsletter(theform) {
	if (!ValidateRequired(theform.EmailNewsletter) )
		{ alert('El campo «« Email »» ' + sMsg );
		theform.EmailNewsletter.focus();
	return (false); }
	
	if (!ValidateEmail(theform.EmailNewsletter) )
		{ alert('El campo «« Email »» ' + sMsg );
		theform.EmailNewsletter.focus();
	return (false); }
return true;
}



/*********************************************************************************************************************************/

function buscarobjeto(pobjeto) {
	if (document.getElementById) {
		return document.getElementById(pobjeto);
	}
	else if (document.all) {
		return window.document.all[pobjeto];
	}	
}

function BuscarObjeto(pobjeto) {
	if (document.getElementById) {
		return document.getElementById(pobjeto);
	}
	else if (document.all) {
		return window.document.all[pobjeto];
	}	
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else
		countfield.value = maxlimit - field.value.length;
}


/*********************************************************************************************************************************/

function marqueeStop(){
	if (document.getElementById("marq"))
	{
		document.getElementById("marq").stop();	
	}
}

function marqueePlay(){
	if (document.getElementById("marq"))
	{
		document.getElementById("marq").start();
	}
}

function ocultar_todos(mascara) {
	document.getElementById('menu_socios').className = 'menu01';
	document.getElementById(obj + '_links').style.display = 'block';
}

function flash_banners(movie, w, h, flashvars, transparent) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ w +'" height="'+ h +'">');
	document.write ('	<param name="movie" value="'+ movie +'">');
	document.write ('	<param name="quality" value="high">');
	document.write ('	<param name="flashvars" value="'+ flashvars +'">');
	document.write ('	<param name="scale" value="exactfit">');
	document.write ('	<param name="menu" value="0">');
	document.write ('	<param name="wmode" value="'+ transparent +'">');
	document.write ('	<embed src="'+ movie +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
	document.write ('</object>');
}

function flash(movie, w, h, flashvars, transparent) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ w +'" height="'+ h +'">');
	document.write ('	<param name="movie" value="'+ movie +'">');
	document.write ('	<param name="quality" value="high">');
	document.write ('	<param name="flashvars" value="'+ flashvars +'">');
	document.write ('	<param name="menu" value="0">');
	document.write ('	<param name="scale" value="noscale">');
	document.write ('	<param name="wmode" value="'+ transparent +'">');
	document.write ('	<embed src="'+ movie +'" flashvars="'+ flashvars +'" wmode="'+ transparent +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ w +'" height="'+ h +'"></embed>');
	document.write ('</object>');
}

function o(td) {
	td.style.backgroundColor='';
}
function h(td) {
	td.style.backgroundColor='F0F0F0'; td.style.cursor="hand";
}

function hrf(url) {
	document.location.href = url;
}

function ow(page, name, w, h) {
  window.open(page,name,"resizable=0,width="+w+",height="+h+",left=10,top=10,scrollbars=no");
}

function ows(page, name, w, h) {
  window.open(page,name,"resizable=0,width="+w+",height="+h+",left=50,top=50,scrollbars=yes");
}

function hrf(url) {
	if(url != '0') {
		document.location.href = url;		
	}
}

function foco(obj) {
	if (obj) { obj.focus(); }
}

function confirmar(url, mensaje) {
	if ( confirm(mensaje) )
	document.location.href = url;
}

function clock() {

	var digital = new Date();
		var hours = digital.getHours();
		var minutes = digital.getMinutes();
		var seconds = digital.getSeconds();
		var amOrPm = "AM";
		if (hours > 11) amOrPm = "PM";
		if (hours > 12) hours = hours - 12;
		if (hours == 0) hours = 12;
		if (minutes <= 9) minutes = "0" + minutes;
		if (seconds <= 9) seconds = "0" + seconds;
		dispTime = hours + ":" + minutes + ":" + seconds + " " + amOrPm;

	var months = new Array(13);
		months[1]="Enero";
		months[2]="Febrero";
		months[3]="Marzo";
		months[4]="Abril";
		months[5]="Mayo";
		months[6]="Junio";
		months[7]="Julio";
		months[8]="Agosto";
		months[9]="Septiembre";
		months[10]="Octubre";
		months[11]="Noviembre";
		months[12]="Diciembre";

	var time = new Date();
		var lmonth=months[time.getMonth() + 1];
		var date=time.getDate();
		var year=time.getYear();
		if (year < 2000)    
		year = year + 1900;

	if(document.getElementById('pendule')) {
		document.getElementById('pendule').innerHTML = date + " de " + lmonth + " de " + year + " - " + dispTime;
		setTimeout("clock()", 1000);
	}
}

function cargar_combo(file, sql, name, value, cid, cnm, rq, sel, nuevo) {
	var scriptTag = document.getElementById('loadScript');
	var head = document.getElementsByTagName('head').item(0);
	script		= document.createElement('script');
	script.src	= file+'?cid='+cid+'&cnm='+cnm+'&sql='+sql+'&sel='+sel+'&vl='+value+'&rq='+rq+'&name='+name+'&nuevo='+nuevo;
	script.type = 'text/javascript';
	script.id	= 'loadScript';
	head.appendChild(script);
}

function CargarScript(pURL) {
	var scriptTag = document.getElementById('loadScript');
	var head = document.getElementsByTagName('head').item(0);
	script		= document.createElement('script');
	script.src	= pURL;
	script.type = 'text/javascript';
	script.id	= 'loadScript';
	head.appendChild(script);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function cargar_submenu(valor) {
	cargar_combo('/includes/rs.asp', 'sp_submenu', 'submenu', valor, 'id', 'name', '', 'Selecciones uno...', '');
}

function resize() {
	if (document.images[0]) window.resizeTo(document.images[0].width +10, document.images[0].height+35);
		self.focus();
	}

function encuesta_validar(form) {
	var f = form;
	var i;
	for(i=0;i<f.votes.length;i++) {
		if (f.votes[i].checked == true)
			return true;
	}
	alert('Debe seleccionar alguna opción!');
	return false;
}
