var GB_ANIMATION = true;

$(document).ready(function(){
	// home navigation 
	$("#navigation li:last").css("margin-right","0");
	
	// home base navigation
	$("#base li:first").css("padding-left","0");
	$("#base li:last").css("border-right","none");

	// navigation hover effect for ie
	$('.navigation li').hover(function() {
		  $(this).addClass('hover');
	}, function() {
		  $(this).removeClass('hover');
	});
	
	$('.navigation li ul li').hover(function() {
		  $(this).addClass('hover');
	}, function() {
		  $(this).removeClass('hover');
	});
	
	// greybox overlay
	$("a.greybox").click(function(){
      var t = this.title || $(this).text() || this.href;
      GB_show(t,this.href,500,544);
      return false;
    });
    
	// add <br /> after subscript
	$("sub").after("<br /><br />");
	
	// smsf sub
	$("#smsf sub:last").wrap("<div class='footnote'></div>");

	// footer styling
	$("#footer li:last").css("border-right","none");
	$("#footer li:first").css("padding-left","0");
	
	// view & hide answer for faqs question
	$(".moreinfo").hide();

	$(".view").click(function(){
		$(this).prev().slideToggle(600);
		$(this).text($(this).text() == 'Learn more »' ? 'Close' : 'Learn more »');
		return false;
	});
	
	// remove last <p> tag for last paragraph
	$(".moreinfo p:last-child").css('margin-bottom', '0'); 
	
	// remove last <ol> or <ul> bottom padding
	$(".moreinfo ol").css('padding', '0');
	$(".moreinfo ul").css('padding', '0');	
	
	$('.nav_contact-us, .nav_new-partner, .nav_smsf-loan-enquiry, .btn_enquire-now, .nav_finance-enquiry, .btn_apply-now, .btn_apply-now_finance, .btn_contact-us').popupWindow({ 
		centerScreen:1, 
		height: 600,
		scrollbars: 1,
		width: 544
	}); 
	
	init();
});

// scrolling marquee
var speed = 1; // change scroll speed with this value
/**
 * Initialize the marquee, and start the marquee by calling the marquee function.
 */
function init(){
  var el = document.getElementById("marquee_replacement");
  el.style.overflow = 'hidden';
  scrollFromBottom();
}
 
var go = 0;
var timeout = '';
/**
 * This is where the scroll action happens.
 * Recursive method until stopped.
 */
function scrollFromBottom(){
  clearTimeout(timeout);
  var el = document.getElementById("marquee_replacement");
  if(el.scrollTop >= el.scrollHeight-205){
    el.scrollTop = 0;
  };
  el.scrollTop = el.scrollTop + speed;
  if(go == 0){
    timeout = setTimeout("scrollFromBottom()",50);
  };
}
 
/**
 * Set the stop variable to be true (will stop the marquee at the next pass).
 */
function stop(){
  go = 1;
}
 
/**
 * Set the stop variable to be false and call the marquee function.
 */
function startit(){
  go = 0;
  scrollFromBottom();
}