ImageLoad = new Image(); 
ImageLoad.src = "/img/logo.gif";
ImageLoad2 = new Image(); 
ImageLoad2.src = "/img/whybullion_header.jpg";
ImageLoad3 = new Image(); 
ImageLoad3.src = "/img/arrow_bullet.gif";

$(document).ready(function() {
	$('.fadeThis').append('<span class="hover"></span>').each(function () {
	  var $span = $('> span.hover', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(250, 1);
	  }, function () {
	    $span.stop().fadeTo(500, 0);
	  });
	});
});

$(function() {
     $("#Bullion").click(function(){
         if ($("#BullionContent").is(":hidden")){
			$("#Bullion .collapsebutton").html("<img src='/img/collapse_button.gif' alt='Collapse' />");
             $("#BullionContent").slideDown("slow");
         }
         else{
			$("#Bullion .collapsebutton").html("<img src='/img/expand_button.gif' alt='Expand' />");
             $("#BullionContent").slideUp("slow");
         }
     });

 $("#MiningStocks").click(function(){
         if ($("#MiningStocksContent").is(":hidden")){
			$("#MiningStocks .collapsebutton").html("<img src='/img/collapse_button.gif' alt='Collapse' />");
             $("#MiningStocksContent").slideDown("slow");
         }
         else{
			$("#MiningStocks .collapsebutton").html("<img src='/img/expand_button.gif' alt='Expand' />");
             $("#MiningStocksContent").slideUp("slow");
         }
     });

 $("#ETFS").click(function(){
         if ($("#ETFSContent").is(":hidden")){
			$("#ETFS .collapsebutton").html("<img src='/img/collapse_button.gif' alt='Collapse' />");
             $("#ETFSContent").slideDown("slow");
         }
         else{
			$("#ETFS .collapsebutton").html("<img src='/img/expand_button.gif' alt='Expand' />");
             $("#ETFSContent").slideUp("slow");
         }
     });

});

$.fn.delayPopup = function(options) {
	var options = $.extend({ delaytime: 4000 }, options);
 	timer();
	function timer() {
		if($.cookie('gbi_learnmore') != 1) {
			setTimeout(showLightbox, options.delaytime);
		}
	}
	function showLightbox() {		
		$('#LearnMore').jqm({trigger: '#LearnMorePopup', overlay: 80}); 
		$('#LearnMore').jqmShow();
		$.cookie('gbi_learnmore', '1', { expires: 60, path: '/' });	
	}
};

$(function() {
	$('#LearnMoreTrigger').delayPopup({delaytime:8000});
	
    $('#slides').cycle({ 
		fx: 'fade',
        speed: 1500,
		timeout: 5000,
		pager:  '#slidenav',
		pagerAnchorBuilder: function(idx, slide) { 
	        return '<a href="#"></a>'; 
	    }
    });
    $('#goto1').click(function() { 
        $('#slides').cycle(0); 
        return false; 
    });
    $('#goto2').click(function() { 
        $('#slides').cycle(1); 
        return false; 
    });
    $('#goto3').click(function() { 
        $('#slides').cycle(2); 
        return false; 
    });
    $('#goto4').click(function() { 
        $('#slides').cycle(3); 
        return false; 
    });
});

$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) {
    $(pager).find('li').removeClass('activeLI')
        .filter('li:eq('+currSlideIndex+')').addClass('activeLI');
};

$(document).ready(function() {
	$('input[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));
		}

		$(this).focus(function() {
			if($(this).val() === $(this).attr('title')) {
				$(this).val('').addClass('focused');
			}
		});

		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title')).removeClass('focused');
			}
		});
	});
});
