/**
 * Function to format bot protected email addresses
 */
$(function() {
	$("a[rel='e']").each(function(){
		chars = $(this).attr("href").split(",");
		mailto="";
		for(i=0,t=chars.length;i<t;i++) {
			mailto +=  String.fromCharCode(chars[i]);
		}
		if(mailto.substr(0,7) != "mailto:") {
			mailto = "mailto:"+mailto;
		}
		$(this).attr("href",mailto);
		
		chars = $(this).text().split(",");
		text="";
		for(i=0,t=chars.length;i<t;i++) {
			text +=  String.fromCharCode(chars[i]);
		}
		$(this).text(text);
	   
	});
});
/**
 * Function to preload images
 */
var preloaded = new Array();
function preload_images() {
	for (var i = 0; i < arguments.length; i++){
		preloaded[i] = document.createElement('img');
		preloaded[i].setAttribute('src',arguments[i]);
	};
};
/**
 * Function to make external links open new window (_blank isn't available in html strict)
 */
/*$(function() {
	$("a[rel='external']").attr('target','_blank');
});*/

// Check whether links are external:
// (Only works with elements that have href):
/*$.extend($.expr[':'],{
    external: function(a,i,m) {
       // if(!a.href || a.href.indexOf(location.hostname) == -1) {return false;}
		//return true;
		if(!a.href) {return false;}
        return a.hostname && a.hostname !== window.location.hostname;
    }
});*/
$(function() {
	//$('a:external').attr('target','_blank'); //make external links open new window
	//	$("a[href*='http:\/\/']:not([href*='"+location.hostname+"'])")
	$("a[href*='http:\/\/']:not([href*='www.actioncashloans.com.au']|[href*='www.actioncashloansfranchise.com.au'])").attr("target","_blank");
});

/**
 * Fix png transparency in ie6
 */
 /*var blank = new Image();
 blank.src = '/puppy/images/blank.gif';
 
 $(function() {
   var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
   if (badBrowser) {
     // get all pngs on page
     $('img[src$=.png]').each(function() {
       if (!this.complete) {
         this.onload = function() { fixPng(this) };
       } else {
         fixPng(this);
       }
     });
   }
 });
 
 function fixPng(png) {
   var src = png.src;
   if (!png.style.width) { png.style.width = $(png).width(); }
   if (!png.style.height) { png.style.height = $(png).height(); }
   png.onload = function() { };
   png.src = blank.src;
   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 }*/
