
var nombre;
var lastobject;
var cartimeout;

var slide=0;
var slideBusqueda=0;

function getElement(id){
    try{
	var d = document;
    return d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	}catch(err){}
}

function tb_remove() {
	$("#TB_window").remove();
	$("#TB_overlay").remove();
	$("#TB_HideSelect").remove();
	$("#mask").hide();	
	
 	$("#TB_imageOff").unbind("click");
	$("#TB_closeWindowButton").unbind("click");
	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	$("#TB_load").remove();
	$("#testFrame").remove();
	
	$("body","html").css({height: "auto", width: "auto"});
	$("html").css("overflow","");
	return false;
}



function pageLoad(sender, args){

	
	try{//select all the a tag with name equal to modal
	$('a[class=thickbox2]').click(function(e) {
		//Cancel the link behavior
		tb_remove();
		e.preventDefault();
		
		$("body","html").css({height: "100%", width: "100%"});
		$("html").css("overflow","hidden");
		$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window' style='left:28%;top:32%;position:absolute;display:block;width:550px;height:255px;'></div>");
		
		
		//Get the A tag
		var id = $(this).attr('target');
		var tag = $(this).text();
		id = id.replace("../",window.location.protocol + "//" + window.location.host + "/");
		//id = id.replace("../",window.location.protocol + "//" + window.location.host + "/Elaw.rootweb/");
		var testFrame = document.createElement("IFRAME");
    	testFrame.id = "testFrame";
	    testFrame.src = id;
		
		$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle' style='float:left;'><strong>"+tag+"</strong></div><div id='TB_closeAjaxWindow' style='float:right;'><a href='#' onClick='tb_remove();' id='TB_closeWindowButton' title='Close'><img src='../files/template2008/_common/web/cerrar_divflotante.jpg'/></a></div></div><iframe frameborder='0' hspace='0' src='"+id+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:550px;height:220px;'> </iframe>");
		
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
        
		      
		//Set the popup window to center
		//$('#'+testFrame.id).css('top',  winH/2-$(id).height()/2);
		//$('#'+testFrame.id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		//$('#'+testFrame.id).fadeIn(0); 
		
	});
	}catch(err){}

	try{

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(0); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});
	}catch(err){}

	
	try{
	$(document).pngFix();
	}catch(err){}
	try{
		$('.tabs').tabs();
		}catch(err){}
	try{
		$('.input_num').numeric();
		}catch(err){}
	try{
		$('.positive-integer').numeric({ decimal: false, negative: false });
		}catch(err){}	
	try{
		$('.input').numeric();
		}catch(err){}
	
	try{
		$('.slideshow')
		.after('<div id="nav">') 
		.cycle({ 
		    fx:     'fade', 
		    speed:  'fast', 
		    timeout: 8000, 
		    pager:  '#nav',
			pagerAnchorBuilder: function(idx, slide) { 
     		   return '<a href="#">&nbsp;&nbsp;&nbsp;&nbsp;</a>'; 
    		}
		});
		}catch(err){}
		
	try{
		var sig = "Siguiente";
		var imagen = document.getElementById('top_cont').style.backgroundImage;
		
		imagen = imagen.split("/")[imagen.split("/").length-1];
		
		if(imagen == 'logo_nuevo_amway3_BRA.jpg)' || imagen == 'logo_nuevo_amway3_BRA.jpg'){
			sig = "Pr&oacute;xima";
		}
		else
		{
			sig = "Siguiente";
		}
		
		$('.allproducts_product_cont')
		.after ('<div class="nav_content_inf"><a href="#"><span class="next1" id="siguiente1">  '+sig+' >>  </span></a><div class="nav1"></div><a href="#"><span class="prev1" id="anterior1" >  << Anterior</span></a></div>') 
		.before('<div class="nav_content"><a href="#"><span class="next1" id="siguiente2">  '+sig+' >>  </span></a><div class="nav1"></div><a href="#"><span class="prev1" id="anterior2">  << Anterior </span></a></div>') 
		.cycle({ 
		    fx:     'fade', 
		    speed:  'fast', 
		    timeout: 0, 
		    pager:  '.nav1',
		    next:   '.next1', 
		    prev:   '.prev1',
		    stop:   'true',
			pagerAnchorBuilder: pagerFactory
 	});
 
    	}catch(err){}



	try{
		
		var sig = "Siguiente";
		var imagen = document.getElementById('top_cont').style.backgroundImage;
		
		imagen = imagen.split("/")[imagen.split("/").length-1];
		
		if(imagen == 'logo_nuevo_amway3_BRA.jpg)' || imagen == 'logo_nuevo_amway3_BRA.jpg'){
			sig = "Pr&oacute;xima";
		}
		else
		{
			sig = "Siguiente";
		}
		
		$('.allproducts_product_cont_Search')
		.after ('<div class="nav_content_inf"><a href="#"><span class="next1_search3" id="siguiente1">  '+sig+' >>  </span></a><div class="nav1_search3"></div><a href="#"><span class="prev1_search3" id="anterior1" >  << Anterior</span></a></div>') 
		.before('<div class="nav_content"><a href="#"><span class="next1_search3" id="siguiente2">  '+sig+' >>  </span></a><div class="nav1_search3"></div><a href="#"><span class="prev1_search3" id="anterior2">  << Anterior </span></a></div>') 
		.cycle({ 
		    fx:     'fade', 
		    speed:  'fast', 
		    timeout: 0, 
		    pager:  '.nav1_search3',
		    next:   '.next1_search3', 
		    prev:   '.prev1_search3',
		    stop:   'true',
			pagerAnchorBuilder: pagerFactory
 	});
 
    	}catch(err){}


	

	try{
		
		var sig = "Siguiente";
		var imagen = document.getElementById('top_cont').style.backgroundImage;
		
		imagen = imagen.split("/")[imagen.split("/").length-1];
		
		if(imagen == 'logo_nuevo_amway3_BRA.jpg)' || imagen == 'logo_nuevo_amway3_BRA.jpg'){
			sig = "Pr&oacute;xima";
		}
		else
		{
			sig = "Siguiente";
		}
		
		$('.info_adicional1_contenido')
		.after ('<div class="nav_content_inf"><a href="#"><span class="next1_search" id="siguiente1">  '+sig+' >>  </span></a><div class="nav1_search"></div><a href="#"><span class="prev1_search" id="anterior1" >  << Anterior</span></a></div>') 
		.before('<div class="nav_content"><a href="#"><span class="next1_search" id="siguiente2">  '+sig+' >>  </span></a><div class="nav1_search"></div><a href="#"><span class="prev1_search" id="anterior2">  << Anterior </span></a></div>') 
		.cycle({ 
		    fx:     'fade', 
		    speed:  'fast', 
		    timeout: 0, 
		    after:   onAfter,		
		    pager:  '.nav1_search',
		    next:   '.next1_search', 
		    prev:   '.prev1_search',
		    stop:   'true',
			pagerAnchorBuilder: pagerFactory
 	});
		function onAfter() {
		    $('#ContenidoRec_Rango').html((this.dir+1) + " - " + (this.dir+1));
		}
 
    	}catch(err){}

	try{
		var sig = "Siguiente";
		var imagen = document.getElementById('top_cont').style.backgroundImage;
		
		imagen = imagen.split("/")[imagen.split("/").length-1];
		
		if(imagen == 'logo_nuevo_amway3_BRA.jpg)' || imagen == 'logo_nuevo_amway3_BRA.jpg'){
			sig = "Pr&oacute;xima";
		}
		else
		{
			sig = "Siguiente";
		}
		
		$('.info_adicional2_contenido')
		.after ('<div class="nav_content_inf"><a href="#"><span class="next2_search" id="siguiente1">  '+sig+' >>  </span></a><div class="nav2_search"></div><a href="#"><span class="prev2_search" id="anterior1" >  << Anterior</span></a></div>') 
		.before('<div class="nav_content"><a href="#"><span class="next2_search" id="siguiente2">  '+sig+' >>  </span></a><div class="nav2_search"></div><a href="#"><span class="prev2_search" id="anterior2">  << Anterior </span></a></div>') 
		.cycle({ 
		    fx:     'fade', 
		    speed:  'fast', 
		    timeout: 0, 
		    after:   onAfter,		
		    pager:  '.nav2_search',
		    next:   '.next2_search', 
		    prev:   '.prev2_search',
		    stop:   'true',
			pagerAnchorBuilder: pagerFactory
 	});
		function onAfter() {
		    $('#ContenidoRec_Rango').html((this.dir+1) + " - " + (this.dir+1));
		}
 
    	}catch(err){}
		
	try{
		$('.ppage_imagenes_slideshow')
		.after('<div id="ppnav">')
		.cycle({
		    fx:     'fade', 
		    speed:  'fast', 
		    timeout: 0, 
			stop:   'true',
		    pager:  '#ppnav',
		    pagerAnchorBuilder: function(idx, slide) {
			var src = $('img',slide).attr('src'); 
			return '<li style="display:inline;"><a href="#"><img src="' + src + '" width="44" height="41" /></a></li>'; 
    			}
    });
		}catch(err){}
	    
	try{
		
		dropdowncontent.init("liga_carrito", "left-bottom", 300, "click");
		dropdowncontent.init("liga_abo", "left-bottom", 300, "click");
		getElement("contenedor_carrito").src = "../Blank.aspx";
		getElement("contenedor_ABO").src = "../Blank.aspx";
		
	}catch(err){}
	
	try{
		$('#liga_carrito').click(function() {
        	getElement("contenedor_carrito").src = "../Store/ShoppingCart.aspx";
		});
    }catch(err){}
	try{
	    $('#liga_abo').click(function() {
			getElement("contenedor_ABO").src = "../AccessControl/InfoABO.aspx";
		});
	}catch(err){}
	    

	
}



function Alert(label, contenido) {
	$.growlUI(label, contenido); 
}

function MensajeConfirmacion2(label, contenido, clientId, clientIdTexto, clientIdDecripcion) {
	$('.Mensaje_contenidoImag').html("<img src='../files/template2008/_common/web/imagenes/warning.png'>");
	$('#'+clientIdTexto).text(contenido);
	$('#'+clientIdDecripcion).text(label);
	$('#'+clientId)
    .show()
    .animate({opacity: 1.0}, 3500)
    .fadeOut('slow');
}

function MensajeConfirmacion1(label, contenido, clientId, clientIdTexto, clientIdDecripcion) {
	$('.Mensaje_contenidoImag').html("<img src='../files/template2008/_common/web/imagenes/check48.png'>");
	$('#'+clientIdTexto).text(contenido);
	$('#'+clientIdDecripcion).text(label);
	$('#'+clientId)
    .show()
    .animate({opacity: 1.0}, 3500)
    .fadeOut('slow');
}


function Ocultar(){
	try{
	//document.getElementById("panel_carrito").style.visibility = "hidden";
	HideLoading();
	}catch(err){}
}

function pagerFactory(idx, slide) {
        var s = idx > 2 ? ' style="display:none"' : '';
        return '<a href="#">'+(idx+1)+'</a>';
    }
function ShareThis(titulo) {
	var markup = '<a class="a2a_dd" href="http://www.addtoany.com/share_save"><img src="http://static.addtoany.com/buttons/favicon.png" width="16" height="16" border="0" alt="Share/Bookmark"/><span id="sharethisTitle">'+titulo+'</span></a><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>'

	$('.ppage_contenido_sub_shared').html(markup);
}

function MenuBusquedas(cont1, cont2, cont3) {
	var espacio = ' ';
	var mensaje = '<div class="menu_izq_title">Resultados:</div>';
	if(cont1 != ""){
		mensaje += '<div class="menu_izq_opciones" id="li">'+'<a href="#'+cont1.split(",")[0].split(" ")[0]+'" class="anchorLink">'+cont1.split(",")[0]+' ('+cont1.split(",")[1]+')'+'</a>'+'</div>';
	}
	if(cont2 != ""){
		mensaje += '<div class="menu_izq_opciones" id="li">'+'<a href="#'+cont2.split(",")[0].split(" ")[0]+'" class="anchorLink">'+cont2.split(",")[0]+' ('+cont2.split(",")[1]+')'+'</a>'+'</div>';
	}
	if(cont3 != ""){
		mensaje += '<div class="menu_izq_opciones" id="li">'+'<a href="#'+cont3.split(",")[0].split(" ")[0]+'" class="anchorLink">'+cont3.split(",")[0]+' ('+cont3.split(",")[1]+')'+'</a>'+'</div>';
	}
	
	$('.menu_izq1_Search').html(mensaje);
}

	
function ShowLoading(obj){
	try{
	slide = $('.allproducts_product_cont').next().children().next().children(".activeSlide").text()-1;
	slideBusqueda = $('.allproducts_product_cont_Search').next().children().next().children(".activeSlide").text()-1;
	
	clearTimeout(cartimeout);
	lastobject=obj;
	nombre = obj.value;
	obj.value="";
	
	var campos = lastobject.className.split("_").length
	
	if(campos==2)
	{
		obj.className = lastobject.className.split("_")[0]+"_loading";
	}
	else
	{
		obj.className = lastobject.className+"_loading";
	}
	}catch(err){}
}


function ActualizarPaginador(control, cantidad, total)
{
	try{
		
		if(parseInt(cantidad) > parseInt(total)){cantidad = total;}
		
		var actual = $('.'+control).text();
		var inicio = actual.split(" ")[1];
		var valor2 = $('.ddlList').val() * $('.'+control).parent().next().next().attr("class");
		
		var contenedor = $('.'+control).parent().next().next().attr("class");
		var activeSlide = "";
		if (contenedor != "")
		{
			activeSlide = $('.'+contenedor).next().children().next().children(".activeSlide").text();
		}

		if((activeSlide == "" || activeSlide == "1") && slide == "0")
		{
			$("."+control).html("&nbsp;&nbsp;&nbsp;1 - "+cantidad+" de "+total+" resultados");
		}
		else if(contenedor == "" && slide == "0")
		{
			$("."+control).html("&nbsp;&nbsp;&nbsp;1 - "+cantidad+" de "+total+" resultados");
		}
		else if(contenedor == "" && slide == "-1")
		{
			$("."+control).html("&nbsp;&nbsp;&nbsp;1 - "+cantidad+" de "+total+" resultados");
		}
		else
		{
			var num_total = $("."+control).parent().prev().children().children().next().next().text();
			num_total = num_total.split("(")[1];
			num_total = num_total.split(")")[0];
			
			var valor2 = (slide+1) * $('.ddlList').val();
			var valor1 = ((slide) * $('.ddlList').val())+1;
			
			if(parseInt(valor2) > parseInt(num_total)){valor2 = total;}
			
			if(valor1<0 || valor2 <0){
				$("."+control).html("&nbsp;&nbsp;&nbsp;1 - "+cantidad+" de "+total+" resultados");
			}
			else{
				$('.'+control).html("&nbsp;&nbsp;&nbsp;"+valor1 +" - "+ valor2 +" de "+num_total+" resultados");
			}
		}
	}catch(e){}
}


function HideLoading(){
	try{
	lastobject.value=nombre;
	lastobject.className = "input";
	}catch(err){}
}
	
function Llamada() {

}
