(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='crop')";
                }
            });

            //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);

var JQ = jQuery.noConflict();
var imgsrc = "";

function mainMenuHover(){
	JQ('.divHeader a').each(
		function(){
			JQ(this).hover(
				function () {
					imgsrc = JQ(this).find('img').attr('src');
					JQ(this).find('img').attr('src', JQ(this).find('img').attr('src').replace('-off.png','-on.png') );
				},
				function (){
					//alert(imgsrc.indexOf('-on.png'));
					if (imgsrc.indexOf('-on.png') == -1) { 
						JQ(this).find('img').attr('src', JQ(this).find('img').attr('src').replace('-on.png','-off.png') );
					}else{
						JQ(this).find('img').attr('src', JQ(this).find('img').attr('src').replace('-on.png','-on.png') );
					}
				}
			);
		}
	);
}

function drop_down(obj) {
	obj.parentNode.onmouseover = function() {
		JQ(this).children('ul[class=dropdown]').show();
	}	
	obj.parentNode.onmouseout = function() {
		JQ(this).children('ul[class=dropdown]').hide();
	}
}

function setLeftHeight() {
	JQ('.divLeft').css('height', JQ(document).height());
}

function blockAccordion(){
	JQ('#hc1 ul li').each(
		function(){
			JQ(this).hover(
				function () {
					JQ('#hc1 ul li').stop().animate({width: '172px', opacity: '0.5'});
					JQ('#hc1 ul li .blockLeft').stop().animate({width: '172px'});;
					JQ(this).stop().animate({width: '511px',  opacity: '1'});
					JQ('#hc1 ul li .blockLeft:eq(' + JQ(this).index() + ')').stop().animate({width: '285px'});
					JQ('#hc1 ul li .blockRight:eq(' + JQ(this).index() + ')').removeClass('none');					
				},
				function (){
					JQ('#hc1 ul li').stop().animate({width: '285px', opacity: '1'});
					JQ('#hc1 ul li .blockLeft').stop().animate({width: '285px'});
					JQ('#hc1 ul li .blockRight').addClass('none');
				}
			);
		}
	);
}

/* RUN THE JQ ANIMATE CODE */
JQ(document).ready(function() {
	mainMenuHover();
	JQ('#text00').find("img").hover(function() {
		JQ(this).animate({
			marginTop: 'px', 
			marginLeft: '-20px', 
			width: '451px', 
			height: '81px'
		}, 200);
	},
		function() {
			JQ(this).animate({
				marginTop: '0px', 
				marginLeft: '0px', 
				width: '415px', 
				height: '75px'
			}, 200);
		}
	);
	JQ('#text11').find("img").hover(function() {
		JQ(this).animate({
			marginTop: '0px', 
			marginLeft: '-20px', 
			width: '451px', 
			height: '40px'
		}, 200);
	},
		function() {
			JQ(this).animate({
				marginTop: '0px', 
				marginLeft: '0px', 
				width: '415px', 
				height: '36px'
			}, 200);
		}
	);

	JQ('#text22').find("img").hover(function() {
		JQ(this).animate({
			marginTop: '-3px', 
			marginLeft: '-20px', 
			width: '495px', 
			height: '77px'
		}, 200);
	},
		function() {
			JQ(this).animate({
				marginTop: '0px', 
				marginLeft: '0px', 
				width: '450px', 
				height: '70px'
			}, 200);
		}
	);
	JQ('#text33').find("img").hover(function() {
		JQ(this).animate({
			marginTop: '-2px', 
			marginLeft: '-15px', 
			width: '352px', 
			height: '55px'
		}, 200);
	},
		function() {
			JQ(this).animate({
				marginTop: '0px', 
				marginLeft: '0px', 
				width: '320px', 
				height: '50px'
			}, 200);
		}
	);
	JQ('#text44').find("img").hover(function() {
		JQ(this).animate({
			marginTop: '-2px', 
			marginLeft: '-10px', 
			width: '236px', 
			height: '50px'
		}, 200);
	},
		function() {
			JQ(this).animate({
				marginTop: '0px', 
				marginLeft: '0px', 
				width: '215px', 
				height: '45px'
			}, 200);
		}
	);
	JQ('#text55').find("img").hover(function() {
		JQ(this).animate({
			marginTop: '-2px', 
			marginLeft: '-20px', 
			width: '440px', 
			height: '55px'
		}, 200);
	},
		function() {
			JQ(this).animate({
				marginTop: '0px', 
				marginLeft: '0px', 
				width: '400px', 
				height: '50px'
			}, 200);
		}
	);
	JQ('#text66').find("img").hover(function() {
		JQ(this).animate({
			marginTop: '-2px', 
			marginLeft: '-15px', 
			width: '319px', 
			height: '50px'
		}, 200);
	},
		function() {
			JQ(this).animate({
				marginTop: '0px', 
				marginLeft: '0px', 
				width: '290px', 
				height: '45px'
			}, 200);
		}
	);
	JQ('#text77').find("img").hover(function() {
		JQ(this).animate({
			marginTop: '-2px', 
			marginLeft: '-12px', 
			width: '259px', 
			height: '44px'
		}, 200);
	},
		function() {
			JQ(this).animate({
				marginTop: '0px', 
				marginLeft: '0px', 
				width: '235px', 
				height: '40px'
			}, 200);
		}
	);
});

