(function(F,C){var D=function(H){var G,I=[];for(G in H){if(/string|number/.test(typeof H[G])&&H[G]!==""){I.push(G+'="'+H[G]+'"')}}return I[A]("")},E=function(I){var G,K,J=[],H;if(typeof I=="object"){for(G in I){if(typeof I[G]=="object"){H=[];for(K in I[G]){H.push([K,"=",encodeURIComponent(I[G][K])][A](""))}I[G]=H[A]("&amp;")}if(I[G]){J.push(['<param name="',G,'" value="',I[G],'" />'][A](""))}}I=J[A]("")}return I},B=false,A="join";F[C]=(function(){try{var G="0,0,0",H=navigator.plugins["Shockwave Flash"]||ActiveXObject;G=H.description||(function(){try{return(new H("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")}catch(J){}}())}catch(I){}G=G.match(/^[A-Za-z\s]*?(\d+)[\.|,](\d+)(?:\s+[d|r]|,)(\d+)/);return{available:G[1]>0,activeX:H&&!H.name,version:{major:G[1]*1,minor:G[2]*1,release:G[3]*1},hasVersion:function(K){var N=this.version,L="major",M="minor",J="release";K=(/string|number/.test(typeof K))?K.toString().split("."):K||[0,0,0];K=[K[L]||K[0]||N[L],K[M]||K[1]||N[M],K[J]||K[2]||N[J]];return(K[0]<N[L])||(K[0]==N[L]&&K[1]<N[M])||(K[0]==N[L]&&K[1]==N[M]&&K[2]<=N[J])},expressInstall:"expressInstall.swf",create:function(J){if(!F[C].available||B||!typeof J=="object"||!J.swf){return false}if(J.hasVersion&&!F[C].hasVersion(J.hasVersion)){J={swf:J.expressInstall||F[C].expressInstall,attrs:{id:J.id||"SWFObjectExprInst",name:J.name,height:Math.max(J.height||137),width:Math.max(J.width||214)},params:{flashvars:{MMredirectURL:location.href,MMplayerType:(F[C].activeX)?"ActiveX":"PlugIn",MMdoctitle:document.title.slice(0,47)+" - Flash Player Installation"}}};B=true}else{J=F.extend(true,{attrs:{id:J.id,name:J.name,height:J.height||180,width:J.width||320},params:{wmode:J.wmode||"opaque",flashvars:J.flashvars}},J)}if(F[C].activeX){J.attrs.classid=J.attrs.classid||"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";J.params.movie=J.params.movie||J.swf}else{J.attrs.type=J.attrs.classid||"application/x-shockwave-flash";J.attrs.data=J.attrs.data||J.swf}return["<object ",D(J.attrs),">",E(J.params),"</object>"][A]("")}}}());F.fn[C]=function(G){if(typeof G=="object"){this.each(function(){var I=document.createElement(C);var H=F[C].create(G);if(H){I.innerHTML=H;if(I.childNodes[0]){this.appendChild(I.childNodes[0])}}})}else{if(typeof G=="function"){this.find("object").andSelf().filter("object").each(function(){var I=this,H="jsInteractionTimeoutMs";I[H]=I[H]||0;if(I[H]<660){if(I.clientWidth||I.clientHeight){G.call(this)}else{setTimeout(function(){F(I)[C](G)},I[H]+66)}}})}}return this}}(jQuery,"flash"));


function zeroPad(num,count)
{
var numZeropad = num + '';
while(numZeropad.length < count) {
numZeropad = "0" + numZeropad;
}
return numZeropad;
}


$(function () {

var popupWidth = 1000;

if (screen && screen.width <= 1024)
{
    var popupWidth = 800;
}

if (screen && screen.width <= 1024 && $("#lowerCSS").length < 1)
{
    $('head').append('<link rel="stylesheet" id="lowerCSS" href="/style/lower_profile.css" type="text/css"></link>');
    $.cookie( "homeone.resolution", "low", { path: '/', domain: '.homeone.com.au' });

    
}
else if (screen && screen.width > 1024 && $("#lowerCSS").length > 0)
{
    $("#lowerCSS").remove();

    $.cookie( "homeone.resolution", "high", { path: '/', domain: '.homeone.com.au' });
}

$(".bookmark").click( function()
    {
        var id = $(this).attr( "rel" );

        var ids = $.cookie( "homeone.bookmark" );

	if (ids == ",") ids = "";

	if (ids)
	{
	    ids = ids.replace( "null", "" );
	}

	var dt = $.cookie( "homeone.bookmark.date" );

        if (dt)
	{

	    dt = dt.replace( "null", "" );
	}

        if (!ids || ids.indexOf( id + "," ) == -1)
        {
            $.cookie( "homeone.bookmark", ids + id + ",", { path: '/', domain: '.homeone.com.au' });

            var foo = new Date; // Generic JS date object
            var unixtime_ms = foo.getTime(); // Returns milliseconds since the epoch
            var unixtime = parseInt(unixtime_ms / 1000);
            
            $.cookie( "homeone.bookmark.date", dt + unixtime + ",", { path: '/', domain: '.homeone.com.au' });

            $("#bookmarkLink"+$(this).attr( "rel" )).hide();

            var rev = $(this).attr( "rev" );
            rev = rev.replace( /\+/g, " " );
            rev = rev.split(",");

            $("#bookmarkContent").html( "<div class='bookmarkSection"+id+" bookmarkSection'><div class='left'><a href='"+window.location+"' class='articleTitle'>"+unescape(rev[0])+"</a><br /><span class='date'>"+zeroPad(foo.getDate(), 2)+"/"+zeroPad(foo.getMonth()+1, 2)+"/"+foo.getFullYear()+"</span></div><a class='bold removeBookmark' rel='"+id+"' id='removeBookmark"+id+"' href='#RemoveBookmark'><b class='b1'></b><b class='b2'></b><b class='b3'></b><b class='b4'></b><div class='contentb'><div>X</div></div><b class='b4'></b><b class='b3'></b><b class='b2'></b><b class='b1'></b></a><br class='clear'/><br/></div>" + $("#bookmarkContent").html() );

            $(".removeBookmark").unbind( "click", removeBookmarkFunc );
            $(".removeBookmark").click( removeBookmarkFunc );

	     $(this).hide();

		var ids   = $.cookie( "homeone.bookmark" );
        	var list  = ids.split(",");
		$("#bookmarkCount").html( list.length-1 );

        }

        $("#bookmarkBox").show();

        return false;

    });

//$.cookie( "homeone.bookmark.date", "", { path: '/', domain: '.homeone.com.au' });
    removeBookmarkFunc = function()
    {
        var ids   = $.cookie( "homeone.bookmark" );
        var dates = $.cookie( "homeone.bookmark.date" );
    
        var list  = ids.split(",");
        var list2 = dates.split(",");
        

        for (var i = 0; i < list.length; i++)
        {
            if (list[i] == $(this).attr( "rel" ))
            {
                dates = dates.replace( list2[i] + ",", "" );
                break;
            }
            
        }

	if ($(this).attr("rel") == $("#bookmarkButton").attr("rel"))
{
       $("#bookmarkButton").show();
}

        ids = ids.replace( $(this).attr( "rel" ) + ",", "" );
        ids = ids.replace( "null", "" );

        dates = dates.replace( "null", "" );

	 $("#bookmarkCount").html( list.length-2 );

        if (dates == "null" || dates == null)
        {
            dates = "";
        }

        if (ids == "null" || ids == null || ids == ",")
        {
            ids = "";
        }

        $.cookie( "homeone.bookmark", ids, { path: '/', domain: '.homeone.com.au' });
        $.cookie( "homeone.bookmark.date", dates, { path: '/', domain: '.homeone.com.au' });

        $(".bookmarkSection"+$(this).attr( "rel" )).remove();

        $("#bookmarkLink"+$(this).attr( "rel" )).show();

        if (ids == "" || ids == "null" || ids == null || ids == ",")
        {
            
            $("#bookmarkBox").hide();
        }

        return false;
    }

//bookmarkSectionid
    $(".removeBookmark").click( removeBookmarkFunc );

    $( ".external").click( function()
		{
var ref = $(this).attr("href");
$.ajax({
		dataType: "json",
		url: "/link_out.php",
                    data: { "url" : ref, "id" : $(this).attr("rev") },
                    complete: function() {  },
                    success: function(data) {  }
            });


		});
   
$("#socialIcons a").bind( "click", function() { if ($(this).attr("id").indexOf("recommendButton") != -1) { return true; } if ($(this).attr("id").indexOf("smsButton") != -1) { return true; } window.open($(this).attr("href"), 'sharer','toolbar=0,status=0,width=626,height=436'); return false; } );

$(function()
{
$("#recommendButton").click( function() { if ( $("#recommendForm").css("display") == "none") { $("#recommendForm").show(); $("#recommendForm").css( "height", ($("#recommendForm").contents().find("form").attr("offsetHeight") + 20) + "px"); } else { $("#recommendForm").hide(); } return false; } );
        $("body").click(function (evt) {
            var target = evt.target;
         if($(target).attr("id") != 'recommendForm' && $(target).parents("#recommendForm").length < 1){
                $("#recommendForm").hide();
        }                
        });
}
);
 
$("#printButton").click( function() { window.print(); } );
$("#favButton").click( function() { 

if(window.sidebar){
    // Mozilla Firefox Bookmark
    window.sidebar.addPanel(document.title , window.location,"");
    return false;
  } else if(window.external){
    // IE Favorite
    window.external.AddFavorite( window.location, document.title );
    return false;
  } else if(window.opera && window.print){
    //Opera Hotlist
    obj.setAttribute('href',window.location);
    obj.setAttribute('title',document.title );
    obj.setAttribute('rel','sidebar');
    obj.click();
    return false;
  }


} );

 

 var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
    
    myWidth     -= 100;
    myHeight    -= 200;
//zoomSpeedIn: 300,
//        zoomSpeedOut: 300,
    $("a.iframe").fancybox(
    {
         zoomSpeedIn: 300,
       zoomSpeedOut: 300,
		overlayShow:   true,
		overlayOpacity: 0.8,
		fixedSize:      true,
        frameWidth: popupWidth,
        frameHeight: myHeight,
        hideOnContentClick: false,
        hideOnOverlayClick: false
    });	
	

    $( ".thumbnail" ).bind( "mouseover", function() { $( this ).attr( "class", "border thumbnailOver" ); } );
    $( ".thumbnail" ).bind( "mouseout", function() { $( this ).attr( "class", "border thumbnail" ); } );

var tabContainers2 = $('#contentBox div.tabContainer > div');
    
    $('#contentBox .tabNavigation a').click(function () {

        tabContainers2.hide().filter(this.hash).show();
        
        $('#contentBox .tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter('.selected').click();


var tabContainers3 = $('#contentBox2 div.tabContainer > div');
    
    $('#contentBox2 .tabNavigation a').click(function () {

        tabContainers3.hide().filter(this.hash).show();
        
        $('#contentBox2 .tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter('.selected').click();
    
});
