var t=450; // timers
var c1="#f21f32"; // #1 color
var c2="#0c1c8d"; // #2 color
var c3="#f7941d"; // #3 color
var c4="#a8bf39"; // #4 color
var c0="#fff"; // default

$(document).ready(function() {
    // PNG fix

    // Tooltip
    $(".Tooltip").Tooltip({
        Wrapper: "TipText",
        LineHeight: 14,
        Speed: 150
    });


	$('#rfomerk').jCarouselLite({
	  auto: 4000,
	  speed: 750,
	  visible: 1
	 });

	$('#rfosponsor').jCarouselLite({
	  auto: 6000,
	  speed: 750,
	  visible: 1
	 });
});

$(document).ready(function() {
	
		$("#1")
		.animate({color: c1},t)
		.animate({color: c0},t)
		.animate({color: c0},t,
			function(){$("#2")
				.animate({color: c2},t)
				.animate({color: c0},t)
				.animate({color: c0},t,
					function(){$("#3")
						.animate({color: c3},t)
						.animate({color: c0},t)
						.animate({color: c0},t,
							function(){$("#4")
								.animate({color: c4},t)
								.animate({color: c0},t)
								.animate({color: c0},t
							)}
					)}
			)}
	)
	setTimeout(arguments.callee, (t*12));

});


/* Carrousel */
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:1,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var c=$(this),ul=$("ul",c),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var f=$("li",ul),itemLength=f.size(),curr=o.start;c.css("visibility","visible");f.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"3"});c.css({overflow:"hidden",position:"relative","z-index":"4",left:"0px"});var g=o.vertical?height(f):width(f);var h=g*itemLength;var j=g*v;f.css({width:f.width(),height:f.height()});ul.css(sizeCss,h+"px").css(animCss,-(curr*g));c.css(sizeCss,j+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,a){$(a).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&c.mousewheel)c.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return f.slice(curr).slice(0,v)};function go(a){if(!b){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(a<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*g)+"px");curr=a==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(a>=itemLength-v+1){ul.css(animCss,-((v)*g)+"px");curr=a==itemLength-v+1?v+1:v+o.scroll}else curr=a}else{if(a<0||a>itemLength-v)return;else curr=a}b=true;ul.animate(animCss=="left"?{left:-(curr*g)}:{top:-(curr*g)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this,vis());b=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(a,b){return parseInt($.css(a[0],b))||0};function width(a){return a[0].offsetWidth+css(a,'marginLeft')+css(a,'marginRight')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);

// PNG Fix

/**
* --------------------------------------------------------------------
* jQuery-Plugin "pngFix"
* Version: 1.2, 09.03.2009
* 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:
*    09.03.2009 Version 1.2
*    - Update for jQuery 1.3.x, removed @ from selectors
*    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;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')";
                }
            });
            //progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";

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



// Image Resizer

(function($) {
    $.fn.extend({
        ImageResizer: function(i, Settings) { //ToDo; Applying settings
            return this.each(function() {
                //hide image
                $(this).find("img").hide();

                //set additional properties
                $(this).css("overflow", "hidden");
                $(this).find("img").css("-ms-interpolation-mode", "bicubic");

                //get maximal dimensions
                var MaxHeight = $(this).height();
                var MaxWidth = $(this).width();

                //get image dimensions
                var ImageHeight = $(this).find("img").height();
                var ImageWidth = $(this).find("img").width();

                if (MaxHeight < ImageHeight && MaxWidth < ImageWidth) {
                    //xscale image
                    $(this).find("img").width(MaxWidth);

                    //get new image dimension
                    var NewImageHeight = $(this).find("img").height();

                    if (NewImageHeight < MaxHeight) {
                        //reset image dimension
                        $(this).find("img").width("");

                        //yscale image
                        $(this).find("img").height(MaxHeight);
                    }

                    //get the overflow dimensions
                    var xOverflow = $(this).find("img").width() - MaxWidth;
                    var yOverflow = $(this).find("img").height() - MaxHeight;

                    //center image
                    $(this).find("img").css("margin-left", -xOverflow / 2);
                    $(this).find("img").css("margin-top", -yOverflow / 2);

                    NewImageHeight = $(this).find("img").height();
                    NewImageWidth = $(this).find("img").width();
                }
                else {
                    //get the overflow dimensions
                    var xVoid = (MaxWidth - ImageWidth) / 2;
                    var yVoid = (MaxHeight - ImageHeight) / 2;

                    //center image
                    $(this).find("img").css("margin-left", xVoid);
                    $(this).find("img").css("margin-top", yVoid);
                }

                //check if images are loaded
                if (ImageHeight == 0 || ImageWidth == 0) {
                    i = i + 1;
                    if (i > 700) {
                        return false;
                    }
                    $(this).ImageResizer(i, Settings);
                }

                //show image
                $(this).find("img").fadeIn("slow");
            });
        }
    });
})(jQuery);

// Image Tooltip

(function($) {
    $.fn.extend({
        ImageTooltip: function(Settings) { //ToDo; Applying settings
            return this.each(function() {

                $(this).find(".Picture").hide();

                $(this).hover(function() {
                    $(this).children(".Picture").fadeIn(500);
                    $(this).find(".Picture").ImageResizer();
                });

                $(this).mouseout(function() {
                    $(this).children(".Picture").fadeOut(100);
                });
            });
        }
    });
})(jQuery);





// Tooltip

(function($) {
    $.fn.extend({
        Tooltip: function(Settings) {
            return this.each(function() {

                $(this).css("cursor", "pointer");

                $(this).hover(function() {

                    // Remove the tip if present
                    if ($(this).find(".Balloon")) {
                        $(this).find(".Balloon").remove();
                    }

                    // Build te tip
                    var Tip = "<div class='Balloon'>";
                    Tip += "<div class='Top'></div>";
                    Tip += "<div class='MainArea'>";
                    Tip += "<div class='LeftSide'></div>";
                    Tip += "<div class='" + Settings.Wrapper + "'>";
                    Tip += $(this).attr("alt");
                    //Tip += "<a href='../../_scripts/jQuery/" + $(this).attr("href") + "' title='" + $(this).attr("href") + "'>" + Settings.LinkText + "</a>";
                    Tip += "</div>";
                    Tip += "<div class='RightSide'></div>";
                    Tip += "</div>";
                    Tip += "<div class='Bottom'></div>";
                    Tip += "</div>";

                    // Append to element
                    $(this).append(Tip);

                    // Reset/set some css properties
                    $(this).find("." + Settings.Wrapper).css("line-height", Settings.LineHeight + "px");
                    $(this).css("z-index", "9999");

                    // Push up tip 
                    var Height = $(this).find(".TipText").height();

                    $(this).find(".LeftSide").height(Height);
                    $(this).find(".RightSide").height(Height);

                    var TopMargin = $(this).find(".Balloon").css("top").replace("px", "");
                    $(this).find(".Balloon").css("top", parseInt(TopMargin) - Height);

                    // Show tip												
                    $(this).pngFix();
                    if ($.browser.msie) {
                        $(this).find(".Balloon").show();
                    }
                    else {
                        $(this).find(".Balloon").hide().fadeIn(Settings.Speed);
                    }

                }, function() {
                    // Hide tip
                    if ($.browser.msie) {
                        $(this).find(".Balloon").hide();
                    }
                    else {
                        $(this).find(".Balloon").fadeOut(Settings.Speed);
                    }
                });
            });
        }
    });
})(jQuery);




//IfixPng

/*
* jQuery ifixpng plugin
* (previously known as pngfix)
* Version 2.1  (23/04/2008)
* @requires jQuery v1.1.3 or above
*
* Examples at: http://jquery.khurshid.com
* Copyright (c) 2007 Kush M.
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/

/**
*
* @example
*
* optional if location of pixel.gif if different to default which is images/pixel.gif
* $.ifixpng('media/pixel.gif');
*
* $('img[@src$=.png], #panel').ifixpng();
*
* @apply hack to all png images and #panel which icluded png img in its css
*
* @name ifixpng
* @type jQuery
* @cat Plugins/Image
* @return jQuery
* @author jQuery Community
*/

(function($) {

    /**
    * helper variables and function
    */
    $.ifixpng = function(customPixel) {
        $.ifixpng.pixel = customPixel;
    };

    $.ifixpng.getPixel = function() {
        return $.ifixpng.pixel || 'images/pixel.gif';
    };

    var hack = {
        ltie7: $.browser.msie && $.browser.version < 7,
        filter: function(src) {
            return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='" + src + "')";
        }
    };

    /**
    * Applies ie png hack to selected dom elements
    *
    * $('img[@src$=.png]').ifixpng();
    * @desc apply hack to all images with png extensions
    *
    * $('#panel, img[@src$=.png]').ifixpng();
    * @desc apply hack to element #panel and all images with png extensions
    *
    * @name ifixpng
    */

    $.fn.ifixpng = hack.ltie7 ? function() {
        return this.each(function() {
            var $$ = $(this);
            // in case rewriting urls
            var base = $('base').attr('href');
            if (base) {
                // remove anything after the last '/'
                base = base.replace(/\/[^\/]+$/, '/');
            }
            if ($$.is('img') || $$.is('input')) { // hack image tags present in dom
                if ($$.attr('src')) {
                    if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { // make sure it is png image
                        // use source tag value if set 
                        var source = (base && $$.attr('src').search(/^(\/|http:)/i)) ? base + $$.attr('src') : $$.attr('src');
                        // apply filter
                        $$.css({ filter: hack.filter(source), width: $$.width(), height: $$.height() })
						  .attr({ src: $.ifixpng.getPixel() })
						  .positionFix();
                    }
                }
            } else { // hack png css properties present inside css
                var image = $$.css('backgroundImage');
                if (image.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)) {
                    image = RegExp.$1;
                    image = (base && image.substring(0, 1) != '/') ? base + image : image;
                    $$.css({ backgroundImage: 'none', filter: hack.filter(image) })
					  .children().children().positionFix();
                }
            }
        });
    } : function() { return this; };

    /**
    * Removes any png hack that may have been applied previously
    *
    * $('img[@src$=.png]').iunfixpng();
    * @desc revert hack on all images with png extensions
    *
    * $('#panel, img[@src$=.png]').iunfixpng();
    * @desc revert hack on element #panel and all images with png extensions
    *
    * @name iunfixpng
    */

    $.fn.iunfixpng = hack.ltie7 ? function() {
        return this.each(function() {
            var $$ = $(this);
            var src = $$.css('filter');
            if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) { // get img source from filter
                src = RegExp.$1;
                if ($$.is('img') || $$.is('input')) {
                    $$.attr({ src: src }).css({ filter: '' });
                } else {
                    $$.css({ filter: '', background: 'url(' + src + ')' });
                }
            }
        });
    } : function() { return this; };

    /**
    * positions selected item relatively
    */

    $.fn.positionFix = function() {
        return this.each(function() {
            var $$ = $(this);
            var position = $$.css('position');
            if (position != 'absolute' && position != 'relative') {
                $$.css({ position: 'relative' });
            }
        });
    };

})(jQuery);

