$(function(){
    $(".image img").each(function(){
        $(this).wrap("<div class='image-styler' style='background: transparent url("
            +$(this).attr("src")
            +") top left no-repeat;height:"
            +$(this).height()
            +"px;' />");
        $(this).css("visibility", "hidden");
    });
    $("blockquote").wrap("<div class='blockquote-wrapper'></div>");
    $("blockquote p:has('cite')").addClass("cite");
});


$(document).ready(function() {

$('table#cuaList tr:first').addClass('result-title');
  
$('body').removeClass('no-js');

var fullCol = $('#full-page').length;
if (fullCol > 0) {
  $('.inner-content').css({'width':'680px','padding-left':'10px'});
};


// adds class to tables with no border attr set
$('.inner-content table').each(function(){
   var getBdr = $(this).attr('border');
   if(getBdr == '0' || getBdr == ''){
     $(this).addClass('no_bdr');
   }
 });


// set default values for global search
$('#queries_site_search_query').attr('value', 'keyword');
var searchBox = $('#queries_site_search_query');
var searchVal = "keyword";

// Search input actions
searchBox.focus(function(){
	if($(this).attr("value") == searchVal) $(this).attr("value", "");
});
searchBox.blur(function(){
	if($(this).attr("value") == "") $(this).attr("value", searchVal);
});

  if ($.browser.msie) {
    $("p,a,td,th,div").removeAttr("filter");
 };
  
  if(!$('#prod_extras #product-4').length) {
     $('#prod_extras h2').hide();
  };

if($('.main-nav li a.current').length == 0) {
    $('#content-container').css('padding-top','0px');
};
  
  // expand main content spac eif right col is emtpy
  if($('#rightcol > div').is(':visible')){
       // nothing
  } else {
      $('#rightcol').hide();
      if($('.third-nav').length){
              if ($('.third-nav').is(':visible')) {
                      $('.inner-content').css('width','800px');
              } else {
                      $('.inner-content').addClass('full-col');
              };
      } else {
           $('.inner-content').addClass('full-col');
      };
  };

if ($('#social_links.Yes').length) {
	var socialScript = document.createElement('script');
	socialScript.type = 'text/javascript';
	socialScript.src = 'http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4e5335130dfdc1b3';

	$("#social_links").append(socialScript);
};

  // removed additonal bullet from WYWIWYG
  $('.inner-content ul li ul').parents('li').css({'background':'none','display':'block'});
  
$('select').customStyle();

targetExternal();


});/* end ready functions */


$('#online-banking').click(function(){
  window.open('https://webbanker.cua.com.au/webbanker/lb/','','width=800,height=550');
  return false;
});


/* Tabs */
function initTabs() {

	$('.pane').each(function(){
			if($(this).children().length < 1) {
	 			$(this).remove();
 			} else {
		 	    var thisIndex = $(this).index();
			    $(this).attr('id','tab-'+thisIndex);
			    var thisTitle = $(this).find('h2')[0];
			    var thisTxt = $(thisTitle).text();	
			    $('<li><a href="#tab-'+thisIndex+'">' + thisTxt + '</a></li>').appendTo('#tabs ul');
 			};
	});
	/* if tabs has a cookie set, load appropriate tab */
	if($.cookie('tabsCookie')) {
		var thisVal = $.cookie('tabsCookie');
                $('.pane').hide();
		$(thisVal).show();
                $('#tabs li a[href*="'+thisVal+'"]').addClass('current');
	} else {
	    $('#tabs li:first a').addClass('current');
	    $('.pane:first').show();
	};

         $('#tabs_container').fadeIn('slow', function() {
             //$('.loading').hide();
         });

/* change tab when clicked - set cookie */
$('#tabs li a').click(function(){
    var thisHref = $(this).attr('href');

  var substr = thisHref.split('#');
  thisHref = '#' + substr[1];

   $('.pane').hide();
   $(thisHref).show();
   $('#tabs li a').removeClass('current');
   $(this).addClass('current');

   $.cookie('tabsCookie', thisHref);
   return false;
});


};

function targetExternal(){
  $("a[href^='http://']").not("a[href^='http://cua-web01.squiz.net']").not("a[href^='http://cua.com.au']").not("a[href^='http://www.cua.com.au']").not("a[href^='http://www4.cua.com.au']").attr("target", "_blank").attr("rel", "external");
};

function HideIE6() {
        document.getElementById('ie6notice').style.display = "none";
        document.getElementById('greyout').style.display = "none";
        document.getElementById('product-type').style.visibility = "visible";
        document.getElementById('product').style.visibility = "visible";
    } 



