//function to add onload events. from http://simonwillison.net/2004/May/26/addLoadEvent/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

//{addLoadEvent(blog_navbar_add);}
//
//function blog_navbar_add()
//{
//$("#blog-navbar").load("http://www.oneacrefund.org/node/87 #nice-menu-1","", function() {init_menu(); fix_milestones();});  
//}

//function to add ShareThis button
//for some reason, it crashes IE8, could only get it to work in IE6 and 7, and FF3
if ((jQuery.browser.msie && (jQuery.browser.version <= 7)) || (jQuery.browser.mozilla && (jQuery.browser.version.substr(0,3)=="1.9")))
{addLoadEvent(sharethis_add);}

function sharethis_add()
{
//$(".menu a[href='http://www.addthis.com/bookmark.php']").replaceWith($(".addthis").children("span").children("a").text("Share"));
$.getScript("https://s7.addthis.com/js/152/addthis_widget.js", function() {bindaddthis();});
}

function bindaddthis()
{
$(".menu a[href='http://www.addthis.com/bookmark.php']").bind("click", function(){return addthis_sendto();});
$(".menu a[href='http://www.addthis.com/bookmark.php']").bind("mouseout", function(){addthis_close();});
$(".menu a[href='http://www.addthis.com/bookmark.php']").bind("mouseover",function(){return addthis_open(this, '', '[URL]', '[TITLE]');});
}


//function to fix top margin of left pane of slideshow in IE6 and IE7
if ((jQuery.browser.msie && (jQuery.browser.version <= 7)))
{addLoadEvent(fix_cycle);}

function fix_cycle()
{
$("#slideshow_front_pic").css("margin-top","0px");
$("#slideshow_front_pic img:first").css("margin-top","-1px");
}

//function to fix "3-year milestones and vision" menu item in IE6 and IE8
if ((jQuery.browser.msie && (jQuery.browser.version != 7)))
{addLoadEvent(fix_milestones);}

function fix_milestones()
{
//$("#menu-586 > a").text("3-Year Milestones &amp; Vision");
$("#menu-586 > a").css("margin-right","-4px");
}

//
//function to fix dividers on menu bar - adds dividers, allows them to go away when moused over, and removes them from the active navbar item
//

//add to load events, but not in IE6
if (
   !(jQuery.browser.msie && (jQuery.browser.version < 7)) &&
   !(jQuery.browser.safari)
)
{addLoadEvent(init_menu);}

function init_menu()
{

//add handlers to all items
var nice_menu_items = $('ul.nice-menu-down > li');

for (var i = 0; i < nice_menu_items.length; i++)

{
var divider = document.createElement('p');
divider.style.cssFloat = 'left';
divider.style.styleFloat = 'left';
//divider.style.display = 'inline';
divider.style.color = 'white';
//divider.style.backgroundColor = 'white';
divider.style.fontFamily = 'Arial, sans-serif';
divider.style.fontSize = '13px';
divider.style.margin = '3px 0px 0px -1px';
divider.style.padding = '0px 0px 0px 0px';
divider.id = nice_menu_items[i].id + '_divider';

//don't add divider to first item
if (i > 0) {$(divider).text('|');}

nice_menu_items[i].onmouseover = divider_hide;
nice_menu_items[i].onmouseout = divider_show;
nice_menu_items[i].insertBefore(divider,nice_menu_items[i].firstChild);
}

//take the handler and dividers away from any already active item (i.e., the current location)

//find active link
var active_link = $("ul.nice-menu-down a[@class = 'active']");
//get parent
if (active_link[0])
{var current_item = active_link[0].parentNode;}

if (current_item)
{
var right_divider = document.getElementById(current_item.id + '_divider');
if (right_divider)
{$(right_divider).text('');}

var left_divider = $(current_item).next('li').children("p[@id *= '_divider']")[0];
if (left_divider)
{$(left_divider).text('');}
}

//remove divider from "Donate Now" item
$("#menu-770_divider").remove();
}

function divider_hide()
{
var left_divider = document.getElementById(this.id + '_divider');
if (left_divider)
{$(left_divider).css('color','#99cc66');}

var right_divider = $(this).next('li').children("p[@id *= '_divider']")[0]
if (right_divider)
{$(right_divider).css('color','#669933');}
}

function divider_show()
{
var left_divider = document.getElementById(this.id + '_divider');
if (left_divider)
{$(left_divider).css('color','white');}

var right_divider = $(this).next('li').children("p[@id *= '_divider']")[0]
if (right_divider)
{$(right_divider).css('color','white');}
}

//function to get rid of top border on top navbar item
addLoadEvent(menu_fix);

function menu_fix()
{
$("#sidebar-left li:first").css("border-top", "none");   
}

//function to add dropdown to "Family Profiles" page
addLoadEvent(profile_dropdown);

function profile_dropdown()
{
//create all the elements for the dropdown list on the "family profiles" page.    
var dropdown_div = document.createElement("td");
$(dropdown_div).css("width", "500px");
$(dropdown_div).css("height", "20px");
$(dropdown_div).css("vertical-align", "middle");
$(dropdown_div).css("margin", "0px");
$(dropdown_div).css("padding", "0px");

var go_link_text = document.createElement("p");
$(go_link_text).append(document.createTextNode("See past monthly profiles: "));
$(go_link_text).css("display","inline");
$(dropdown_div).append(go_link_text);

var dropdown = document.createElement("select");
$(dropdown).attr("name","profile_dropdown_list");
$(dropdown).attr("id","profile_dropdown_list");
$(dropdown).css("display","inline");
$(dropdown).css("font-size","13px");

var profiles_array = new Array();

//
//
// Here's where to add new profiles
//
//
profiles_array['August 2010'] = '/files/monthlyprofiles/2010August.htm';
profiles_array['July 2010'] = '/files/monthlyprofiles/2010July.htm';
profiles_array['June 2010'] = '/files/monthlyprofiles/2010June.htm';
profiles_array['May 2010'] = '/files/monthlyprofiles/2010May.htm';
profiles_array['April 2010'] = '/files/monthlyprofiles/2010April.htm';
profiles_array['March 2010'] = '/files/monthlyprofiles/2010March.htm';
profiles_array['February 2010'] = '/files/monthlyprofiles/2010February.htm';
profiles_array['January 2010'] = '/files/monthlyprofiles/2010January.htm';
profiles_array['November 2009'] = '/files/monthlyprofiles/2009November.htm';
profiles_array['October 2009'] = '/files/monthlyprofiles/2009October.htm';
profiles_array['September 2009'] = '/files/monthlyprofiles/2009September.htm';
profiles_array['August 2009'] = '/files/monthlyprofiles/2009August.htm';
profiles_array['May 2009'] = '/files/monthlyprofiles/2009May.htm';
profiles_array['April 2009'] = '/files/monthlyprofiles/2009April.htm';
profiles_array['March 2009'] = '/files/monthlyprofiles/2009March.htm';
profiles_array['February 2009'] = '/files/monthlyprofiles/2009February.htm';
profiles_array['January 2009'] = '/files/monthlyprofiles/2009January.htm';
profiles_array['November 2008'] = '/files/monthlyprofiles/2008November.htm';
profiles_array['October 2008'] = '/files/monthlyprofiles/2008October.htm';
profiles_array['September 2008'] = '/files/monthlyprofiles/2008September.htm';
profiles_array['August 2008'] = '/files/monthlyprofiles/2008August.htm';
profiles_array['July 2008'] = '/files/monthlyprofiles/2008July.htm';
profiles_array['May 2008'] = '/files/monthlyprofiles/2008May.htm';
profiles_array['April 2008'] = '/files/monthlyprofiles/2008April.htm';
profiles_array['March 2008'] = '/files/monthlyprofiles/2008March.htm';
profiles_array['February 2008'] = '/files/monthlyprofiles/2008February.htm';
profiles_array['January 2008'] = '/files/monthlyprofiles/2008January.htm';
profiles_array['December 2007'] = '/files/monthlyprofiles/2007December.htm';
profiles_array['November 2007'] = '/files/monthlyprofiles/2007November.htm';
profiles_array['October 2007'] = '/files/monthlyprofiles/2007October.htm';
profiles_array['September 2007'] = '/files/monthlyprofiles/2007September.htm';
profiles_array['August 2007'] = '/files/monthlyprofiles/2007August.htm';
profiles_array['July 2007'] = '/files/monthlyprofiles/2007July.htm';
profiles_array['June 2007'] = '/files/monthlyprofiles/2007June.htm';
profiles_array['May 2007'] = '/files/monthlyprofiles/2007May.htm';
profiles_array['April 2007'] = '/files/monthlyprofiles/2007April.htm';
profiles_array['March 2007'] = '/files/monthlyprofiles/2007March.htm';
profiles_array['February 2007'] = '/files/monthlyprofiles/2007February.htm';
profiles_array['January 2007'] = '/files/monthlyprofiles/2007January.htm';
profiles_array['December 2006'] = '/files/monthlyprofiles/2006December.htm';
profiles_array['November 2006'] = '/files/monthlyprofiles/2006November.htm';
profiles_array['October 2006'] = '/files/monthlyprofiles/2006October.htm';
profiles_array['September 2006'] = '/files/monthlyprofiles/2006September.htm';
profiles_array['August 2006'] = '/files/monthlyprofiles/2006August.htm';
profiles_array['July 2006'] = '/files/monthlyprofiles/2006July.htm';

for (var i in profiles_array)
{
var option = document.createElement("option");
$(option).append(document.createTextNode(i));
option.value = profiles_array[i];
$(dropdown).append(option);
}

$(dropdown_div).append(dropdown);

var go_link = document.createElement("a");
$(go_link).append(document.createTextNode("Go"));
$(go_link).attr("href","#");
$(go_link).bind("click", function(e) {pageTracker._trackPageview($(dropdown).val()); window.open($(dropdown).val()); return false;})

var go_link_wrap = document.createElement("p");
$(go_link_wrap).css("display","inline");
$(go_link_wrap).css("margin-left","6px");
$(go_link_wrap).append(go_link);
$(dropdown_div).append(go_link_wrap);

var dropdown_tr = document.createElement("tr");
$(dropdown_tr).css("vertical-align", "middle");
$(dropdown_tr).css("margin", "0px");
$(dropdown_tr).css("padding", "0px");
var dropdown_table = document.createElement("table");
$(dropdown_table).css("vertical-align", "middle");
$(dropdown_table).css("margin", "0px");
$(dropdown_table).css("margin-top", "-6px");
$(dropdown_table).css("padding", "0px");
//$(dropdown_table).css("float", "right");

$(dropdown_table).append(dropdown_tr);
$(dropdown_tr).append(dropdown_div);

//if the monthly profile page ever changes node number (from 11), this won't work anymore
$(dropdown_table).insertBefore('#node-11');
}

//function to set up video player on gallery page
//$.getScript("/files/photogallery/video/swfobject.js");
addLoadEvent(video_setup);

function video_setup()
{
if(document.getElementById("vid_container"))
{$.getScript("http://www.oneacrefund.org/site/files/photogallery/swfobject.js", video_setup_2);}
if(document.getElementById("vid_container_l"))
{$.getScript("http://www.oneacrefund.org/site/files/photogallery/swfobject.js", video_setup_l);}
if(document.getElementById("vid_container_kclip"))
{$.getScript("http://www.oneacrefund.org/site/files/photogallery/swfobject.js", video_setup_kclip);}
}

function video_setup_2()
{
  var so = new SWFObject('http://www.oneacrefund.org/site/files/photogallery/player.swf','mpl','300','250','9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('file','http://www.oneacrefund.org/site/files/photogallery/video/OneAcreFund_F8_512K.flv');
  so.addVariable('image','http://www.oneacrefund.org/site/files/photogallery/video/kvideo_preview.jpg');
  so.write('vid_container');
}

function video_setup_l()
{
  var so = new SWFObject('http://www.oneacrefund.org/site/files/photogallery/player.swf','mpl','400','333','9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('autostart','true');
  so.addParam('wmode','opaque');
  so.addVariable('file','http://www.oneacrefund.org/site/files/photogallery/video/OneAcreFund_F8_512K.flv');
  so.addVariable('image','http://www.oneacrefund.org/site/files/photogallery/video/kvideo_preview.jpg');
  so.write('vid_container_l');
}

function video_setup_kclip()
{
  var so = new SWFObject('http://www.oneacrefund.org/site/files/photogallery/player.swf','mpl','500','280','9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addParam('stretching','exactfit');
  so.addParam('autostart','true');
  so.addVariable('file','http://www.oneacrefund.org/site/files/photogallery/video/OneAcreFund_F8_512K.flv');
  so.addVariable('image','http://www.oneacrefund.org/site/files/photogallery/video/kvideo_preview.jpg');
  so.write('vid_container_kclip');
}

//function to set Google Analytics cookie expiry to one year
addLoadEvent(ga_timeout_oneyear);

function ga_timeout_oneyear()
{
pageTracker._setCookieTimeout("3152600"); //number of seconds in 1 year
}


//function to add the cycle plugin to the home page
addLoadEvent(load_cycle);

function load_cycle()
{
if (document.getElementById("slideshow"))
{
load_cycle_2();
}
}

function load_cycle_2()
{
 /*
 * jQuery Cycle Lite Plugin
 * http://malsup.com/jquery/cycle/lite/
 * Copyright (c) 2008 M. Alsup
 * Version: 1.0 (06/08/2008)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.3 or later
 */
;(function($) {

var ver = 'Lite-1.0';

$.fn.cycle = function(options) {
    return this.each(function() {
        options = options || {};
        
        if (this.cycleTimeout) clearTimeout(this.cycleTimeout);
        this.cycleTimeout = 0;
        this.cyclePause = 0;
        
        var $cont = $(this);
        var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
        var els = $slides.get();
        if (els.length < 2) {
            if (window.console && window.console.log)
                window.console.log('terminating; too few slides: ' + els.length);
            return; // don't bother
        }

        // support metadata plugin (v1.0 and v2.0)
        var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : 

$.meta ? $cont.data() : {});
            

        opts.before = opts.before ? [opts.before] : [];
        opts.after = opts.after ? [opts.after] : [];
        opts.after.unshift(function(){ opts.busy=0; });
            
        // allow shorthand overrides of width, height and timeout
        var cls = this.className;
        opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1]) || opts.width;
        opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1]) || opts.height;
        opts.timeout = parseInt((cls.match(/t:(\d+)/)||[])[1]) || opts.timeout;

        if ($cont.css('position') == 'static') 
            $cont.css('position', 'relative');
        if (opts.width) 
            $cont.width(opts.width);
        if (opts.height && opts.height != 'auto') 
            $cont.height(opts.height);

        var first = 0;
        $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) { 
            $(this).css('z-index', els.length-i) 
        });
        
        $(els[first]).css('opacity',1).show(); // opacity bit needed to handle reinit case
        if ($.browser.msie) els[first].style.removeAttribute('filter');
        if (opts.fit && opts.width) 
            $slides.width(opts.width);
        if (opts.fit && opts.height && opts.height != 'auto') 
            $slides.height(opts.height);
        if (opts.pause) 
            $cont.hover(function(){this.cyclePause=1;}, function(){this.cyclePause=0;});

        $.fn.cycle.transitions.fade($cont, $slides, opts);
        
        $slides.each(function() {
            var $el = $(this);
            this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
            this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
        });

        $slides.not(':eq('+first+')').css({opacity:0});
        if (opts.cssFirst)
            $($slides[first]).css(opts.cssFirst);

        if (opts.timeout) {
            // ensure that timeout and speed settings are sane
            if (opts.speed.constructor == String)
                opts.speed = {slow: 600, fast: 200}[opts.speed] || 400;
            if (!opts.sync)
                opts.speed = opts.speed / 2;
            while((opts.timeout - opts.speed) < 250)
                opts.timeout += opts.speed;
        }
        opts.speedIn = opts.speed;
        opts.speedOut = opts.speed;

 		opts.slideCount = els.length;
        opts.currSlide = first;
        opts.nextSlide = 1;

        // fire artificial events
        var e0 = $slides[first];
        if (opts.before.length)
            opts.before[0].apply(e0, [e0, e0, opts, true]);
        if (opts.after.length > 1)
            opts.after[1].apply(e0, [e0, e0, opts, true]);
        
        if (opts.click && !opts.next)
            opts.next = opts.click;
        if (opts.next)
            $(opts.next).bind('click', function(){return advance(els,opts,opts.rev?-1:1)});
        if (opts.prev)
            $(opts.prev).bind('click', function(){return advance(els,opts,opts.rev?1:-1)});

        if (opts.timeout)
            this.cycleTimeout = setTimeout(function() {
                go(els,opts,0,!opts.rev)
            }, opts.timeout + (opts.delay||0));
    });
};

function go(els, opts, manual, fwd) {
    if (opts.busy) return;
    var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
    if (p.cycleTimeout === 0 && !manual) 
        return;

    if (manual || !p.cyclePause) {
        if (opts.before.length)
            $.each(opts.before, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
        var after = function() {
            if ($.browser.msie)
                this.style.removeAttribute('filter');
            $.each(opts.after, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
        };

        if (opts.nextSlide != opts.currSlide) {
            opts.busy = 1;
            $.fn.cycle.custom(curr, next, opts, after);
        }
        var roll = (opts.nextSlide + 1) == els.length;
        opts.nextSlide = roll ? 0 : opts.nextSlide+1;
        opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
    }
    if (opts.timeout)
        p.cycleTimeout = setTimeout(function() { go(els,opts,0,!opts.rev) }, opts.timeout);
};

// advance slide forward or back
function advance(els, opts, val) {
    var p = els[0].parentNode, timeout = p.cycleTimeout;
    if (timeout) {
        clearTimeout(timeout);
        p.cycleTimeout = 0;
    }
    opts.nextSlide = opts.currSlide + val;
    if (opts.nextSlide < 0) {
        opts.nextSlide = els.length - 1;
    }
    else if (opts.nextSlide >= els.length) {
        opts.nextSlide = 0;
    }
    go(els, opts, 1, val>=0);
    return false;
};

$.fn.cycle.custom = function(curr, next, opts, cb) {
    var $l = $(curr), $n = $(next);
    $n.css({opacity:0});
    var fn = function() {$n.animate({opacity:1}, opts.speedIn, opts.easeIn, cb)};
    $l.animate({opacity:0}, opts.speedOut, opts.easeOut, function() {
        $l.css({display:'none'});
        if (!opts.sync) fn();
    });
    if (opts.sync) fn();
};

$.fn.cycle.transitions = {
    fade: function($cont, $slides, opts) {
        $slides.not(':eq(0)').css('opacity',0);
        opts.before.push(function() { $(this).show() });
    }
};

$.fn.cycle.ver = function() { return ver; };

// @see: http://malsup.com/jquery/cycle/lite/
$.fn.cycle.defaults = {
    timeout:       4000, 
    speed:         1000, 
    next:          null, 
    prev:          null, 
    before:        null, 
    after:         null, 
    height:       'auto',
    sync:          1,    
    fit:           0,    
    pause:         0,    
    delay:         0,    
    slideExpr:     null  
};

})(jQuery);    

$('#slideshow').cycle({
    fx: 'fade',
    speed: 'slow',
    timeout: 0,
    next: '#next_button',
    prev: '#prev_button',
    before: s5before,
    after: s5after, 
    cleartype: 1,
    pause: 1
});

function s5before() { 
{$('#s5text').fadeOut('slow');}
//track slides in Google Analytics
//if (!(this.id == "s1"))
//{pageTracker._trackPageview(this.id);}
}; 

function s5after() { 
if (this.id == 's5')
{$('#s5text').fadeIn('fast');}
}; 

$('#slideshow_front_pic').cycle({
    fx: 'shuffle',
    speed: 1500,
    timeout: 10000,
    cleartype: 1,
    pause: 1
});

(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);
}

//function to give all containers the class "pngfix" so they can be fixed for IE6
addLoadEvent(png_fix_class);

function png_fix_class()
{
    /**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[@src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[@src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);

    $(document).ready(function(){ 
        $(document).pngFix(); 
    });
}
