jQuery.fn.morePages = function() {
	document.createElement('abbr');	
	if ($(this).length > 0){
		$(this).css('cursor','pointer').find('select').hide();
		$(this).append('<acronym title="ir para outras p&aacute;ginas">&hellip;</acronym>')
		
		$(this).each(function(){ 			   			  
			$(this).click(function() {
				$(this).find('acronym').hide();
				$(this).find('select').show();			  
			});
			
			$(this).find('select').blur(function () {										  	
				$(this).hide();
				$(this).next().show();
		   });			
		});
		
	}
};


jQuery.fn.buildBox = function() {
					
	if ($(this).length > 0){
		
		var targetLists = $("#list-dist ul");
		var targetItem = $("#list-dist");
		
		if ($("#list-dist-content".length == 0)){
			
			$(targetItem).append(			
			$("<div/>", {"id": "list-dist-content"}).append(
				
					$("<h2/>", {
						"class" : "list-title font1",
						text: ""
					}),
					$("<a/>", {
						"class" : "pngf close-this",
						text: "Fechar",
						click: function(){
							$("#list-dist-content").fadeOut(100, function(){
								targetLists.fadeIn();											  
							})
							$("#list-dist-placeholder").empty();
							$(this).parents("#list-dist").find(".column > .location").removeClass("activeCon");
							$("#list-dist").removeClass("activeList");
						}
	
					}),
					$("<div/>", {
						"id": "list-dist-placeholder"
					})
				).css("display","none")
			)
		};
		
		$(this).click(function() {
			var aTitle = $(this).attr("title");
			var aHref = $(this).attr("href");
			$("#list-dist").addClass("activeList");
			$(this).parents(".column").find(".location").addClass("activeCon");
			targetLists.fadeOut(100, function() {
				$("#list-dist-content").fadeIn();
			});
			$("#list-dist-content .list-title").text(aTitle);
			$("#list-dist-placeholder").load("/"+aHref+" #distribuidores");
	
			return false;
	
		});						
		
	}
};

jQuery.fn.quickShow = function(el) {
	var aHref1 = $(this).attr("href");
		
	$liveVantagens = $("<div/>", {
			"id":	"vantagens-overlay",
			css:	{"display":"none"}	
			}).append(
				$("<span/>",{
					"id":	"arrow-overlay"
				}),
				$("<div/>", {
					"id":	"vantagens-overlay-spc"	   
				}).load(aHref1+" #vantagens-list h1")
			)
	
	$(this).hover(
	  function () {
		$liveVantagens.stop(true, true).fadeIn();
		$liveVantagens.appendTo($(this))
		$(this).addClass('active');
		$('#coin-slider').trigger('mouseover');
	  }, 
	  function () {
		$liveVantagens.stop(true, true).fadeOut();
		$(this).removeClass('active');
	  }
	);
	
		
};

$(document).ready(function() {

    $('.morePages').morePages();
    //$("#nav li a[href*='vantagens.aspx'] ").quickShow();

    $('#toPrint').click(function() {
        window.print();
        return false;
    });


    // LOGIN && Register
    $('.AreaReservada').removeClass('hide');

    if ($(this).find("input[id*='hError']")) {
        var hError = $(this).find("input[id*='hError']").val();
        
        if (hError == undefined || hError == '') {
            $('.Login').hide();
            $('.Register').hide();
        }

        if (hError == 'Login') {
            $('.Login').show();
            $('.Register').hide();
        }

        if (hError == 'Register') {
            $('.Login').hide();
            $('.Register').show();
        }
    }

    $('.toggleLogin').click(function(event) {
        $('.Register').slideUp();
        $('.Login').slideToggle();
        event.stopPropagation();
        return false;
    });

    $('.toggleRegister').click(function(event) {
        $('.Login').slideUp();
        $('.Register').slideToggle();
        event.stopPropagation();
        return false;
    });

    $('.Login').click(function(event) {
        event.stopPropagation();
        //return false;
    });

    $('.Register').click(function(event) {
        event.stopPropagation();
        //return false;
    });

    $('body').click(function(event) {
        $('.Login').slideUp();
        $('.Register').slideUp();
        event.stopPropagation();
    });




    // HIGHLIGHT HP FOR IE 
    if (jQuery.browser.msie) {
        $("#highlights .item").hover(
		  function() {
		      $(this).addClass("hover");
		  },
		  function() {
		      $(this).removeClass("hover");
		  }
		);
    }

});
