(function(c){
		  c.fn.rssmarquee=function(f){
			  var g=c.extend({},c.fn.rssmarquee.defaults,f);
			  return this.each(function(){
				$this=c(this);
				
				var i=c.metadata?c.extend({},g,$this.metadata()):g;
				
				if(i.rssFeed&&!i.rssUrl&&!i.rssData){
					if(i.rssFeed.indexOf("?")){
						var h=i.rssFeed.split("?");
						i.rssUrl=h[0];
						i.rssData=h[1]
					}else{
						i.rssUrl=i.rssFeed
					}
				}
				
				$this.html("<div class='content_tl topLeftOn'><div class='content_tr topRightOn'></div></div><div class='rssmarquee-feedPane'></div>");
				c.ajax({
					   type:"GET",
					   url:i.rssUrl,
					   data:i.rssData,
					   dataType:"xml",
					   success:function(j){
						   // introduced some new code that uses the window location as the first part of the RSS story URL
						   var relativeLocPreTrimmed=String(window.location);
						   var whereToStart=10;
						   var whereToTrimRelativeLoc=relativeLocPreTrimmed.indexOf("/", whereToStart);
						   var relativeLoc=relativeLocPreTrimmed.substring(0, whereToTrimRelativeLoc);
						   //alert(relativeLoc);
						   c(j).find("item:lt("+i.maxFeedStories+")").each(function(){
							   var whatToTrim=c(this).find("link").text();
							   var whereToTrim=whatToTrim.indexOf("/vwbuzz");
							   var newLoc=relativeLoc+whatToTrim.substring(whereToTrim);
								//markup="<div class='feed-item'>"+c.fn.rssmarquee.format(c(this).find("link").text(),c(this).find("title").text())+"</div>";
								markup="<div class='feed-item'>"+c.fn.rssmarquee.format(newLoc,c(this).find("title").text())+"</div>";
								$this.find(".rssmarquee-feedPane").append(markup);
							});
						   
							if(c("item",j).size()<=1){
								c(".feed-item-prev, .feed-item-next",$this).hide();
							}
							
							$this.find(".feed-item:first").addClass("current");
							$this.find(".feed-item").not(".current").hide();
							$this.append("<div id='rssmarquee-buzzLink'><a href='/vwbuzz/browse/en/us/'>"+i.buzzTitle.toUpperCase()+"</a></div><div class='rssmarquee-controls'><a href='#prev' class='feed-item-prev'>Prev</a><a href='#next' class='feed-item-next'>Next</a><a href='http://www.vw.com/vwbuzz/browse/en/us/?format=rss' class='rss-feed'>RSS</a></div>");
							$this.append("<div class='content_bl bottomLeftOn rss_content_bl' style='top:6px;'><div class='content_br bottomRightOn'></div></div>");
							
							$this.find(".feed-item-prev").click(function(l){
								l.preventDefault();e($this);
							});
							
							$this.find(".feed-item-next").click(function(l){
								l.preventDefault();
								d($this);
							});
							
							if(i.autoPlay){
								b($this,i.timeout);
							}
							
							var k=c(document);
							k.trigger("ajax:complete",["rssmarquee"]);
						},
						error:function(){
							$this.html("<div class='content_tl topLeftOn'><div class='content_tr topRightOn'></div></div><p class='rssmarquee-error'>We're sorry, there was an error loading the feed</p><div class='content_bl botomLeftOn rss_content_bl'><div class='content_br bottomRightOn'></div></div>");
							var j=c(document);
							j.trigger("ajax:complete",["rssmarquee"])}})})};
//minify
function b(g, f) {
    c(g).hover(function() {
        a(g, "pause", f)
    }, function() {
        a(g, "play", f)
    });
    a(g, "play", f)
}
function a(h, g, f) {
    if (h.cycleTimeout) {
        clearTimeout(h.cycleTimeout)
    }
    switch (g) {
    case "play":
        h.cycleTimeout = setTimeout(function() {
            d(c(h));
            a(h, "play", f)
        }, f);
        break;
    case "pause":
        break
    }
}
function e(f) {
    $current = f.find(".current");
    if ($current.prev().size() == 0) {
        $prev = f.find(".rssmarquee-feedPane .feed-item:last")
    } else {
        $prev = $current.prev()
    }
    $current.removeClass("current");
    $prev.addClass("current");
    c.fn.rssmarquee.transitionPrev($current, $prev)
}
function d(f) {
    if (c(".feed-item").size() > 1) {
        $current = f.find(".current");
        if ($current.next().size() == 0) {
            $next = f.find(".rssmarquee-feedPane .feed-item:first")
        } else {
            $next = $current.next()
        }
        $current.removeClass("current");
        $next.addClass("current");
        c.fn.rssmarquee.transitionNext($current, $next)
    }
}
c.fn.rssmarquee.transitionPrev = function(g, f) {
    setTimeout(function() {
        g.animate({
            right: "-825px"
        }, function() {
            g.hide();
            f.css("right", "825px").show().animate({
                right: "0px"
            })
        })
    }, 0)
};
c.fn.rssmarquee.transitionNext = function(g, f) {
    setTimeout(function() {
        g.animate({
            right: "825px"
        }, function() {
            g.hide();
            f.css("right", "-825px").show().animate({
                right: "0px"
            })
        })
    }, 0)
};
c.fn.rssmarquee.format = function(f, g) {
    return "<p><a href='" + f + "'>" + g + "</a></p>"
};
c.fn.rssmarquee.defaults = {
    rssFeed: "",
    rssUrl: "",
    rssData: "",
    maxFeedStories: 10,
    autoPlay: true,
    timeout: 6000,
    buzzTitle: ""
}
})(jQuery);
(function(a) {
    a.promoRotator = function(g, f, e) {
        var b, h;
        a(".promoRotator").css({
            position: "relative"
        });
        a(".promoRotator ul, .promoRotator li").css({
            margin: "0px",
            padding: "0px",
            listStyle: "none"
        });
        a(".promoRotator").each(function() {
            var j = a("img", this).width();
            var k = a("img", this).height();
            var i = a("li", this).size();
            a(this).css({
                width: j + "px",
                height: (k / 2 + 17) + "px"
            });
            a("ul", this).css({
                height: (k / 2) + "px"
            });
            a("li", this).css({
                left: "0px"
            });
            if (i > 1) {
                a("li", this).css({
                    display: "none"
                });
                var n = 0;
                var m = "";
                a("li", this).each(function() {
                    m += '<a href="#" rel="' + n + '">' + n + "</a>";
                    n++
                });
                a(this).append('<div class="promoRotatorNav">' + m + "</div>");
                a(".promoRotatorNav", this).css({
                    position: "absolute",
                    width: (j - (j - (i * 15)) / 2) + "px",
                    paddingLeft: ((j - (i * 15)) / 2) + "px",
                    top: (k / 2 + 5) + "px"
                });
                a("ul li:eq(" + e + ")", this).fadeIn(g).addClass("rotator-current");
                a(".promoRotatorNav a[rel=" + e + "]", this).addClass("promoRotatorNav-current");
                var l;
                if ((e + 1) > (i - 1)) {
                    l = 0
                } else {
                    l = e + 1
                }
                a("ul", this).attr("rel", e);
                a("ul li:eq(" + l + ")", this).addClass("rotator-next");
                a(".promoRotatorNav a[rel=" + l + "]", this).addClass("promoRotatorNav-next")
            }
        });

        function d() {
            a(".promoRotatorNav a.promoRotatorNav-current").removeClass("promoRotatorNav-current");
            a(".promoRotatorNav a.promoRotatorNav-next").removeClass("promoRotatorNav-next");
            a(".rotator-current").fadeOut(g, function() {
                a(".rotator-next").fadeIn(g).removeClass("rotator-next").addClass("rotator-current")
            }).removeClass("rotator-current");
            c()
        }
        function c() {
            a("body .promoRotator").each(function() {
                var i = a(this);
                if (a("li", i).size() > 1) {
                    var j = parseInt(a("ul", i).attr("rel"));
                    if ((j + 1) > (a("li", i).size() - 1)) {
                        b = 0
                    } else {
                        b = j + 1
                    }
                    a("li:eq(" + b + ")", i).addClass("rotator-next");
                    a(".promoRotatorNav a[rel=" + b + "]", i).addClass("promoRotatorNav-current");
                    a(".promoRotatorNav a[rel=" + b + "]", i).addClass("promoRotatorNav-next");
                    a("ul", i).attr("rel", b)
                }
            })
        }
        a(".promoRotatorNav a").click(function() {
            $r = a(this).parent().parent();
            var j = parseInt(a("ul", $r).attr("rel"));
            var i = parseInt(a(this).attr("rel"));
            a(".promoRotatorNav a.promoRotatorNav-current", $r).removeClass("promoRotatorNav-current");
            a(".promoRotatorNav a.promoRotatorNav-next", $r).removeClass("promoRotatorNav-next");
            a("li.rotator-next", $r).removeClass("rotator-next");
            a(".promoRotatorNav a[rel=" + i + "]", $r).addClass("promoRotatorNav-current");
            a("li.rotator-current", $r).fadeOut(g, function() {
                a("li:eq(" + i + ")", $r).fadeIn(g).addClass("rotator-current")
            }).removeClass("rotator-current");
            if ((i + 1) > (a("li", $r).size() - 1)) {
                $next = 0
            } else {
                $next = i + 1
            }
            a("li:eq(" + $next + ")", $r).addClass("rotator-next");
            a(".promoRotatorNav a[rel=" + $next + "]", $r).addClass("promoRotatorNav-next");
            a("ul", $r).attr("rel", i);
            return false
        });
        a(".promoRotator").hover(function() {
            clearInterval(rotatePromos)
        }, function() {
            rotatePromos = setInterval(d, f)
        });
        a(".promoRotator li").hover(function() {
            var i = a("img", this).height() / 2;
            if (a.browser.msie && a.browser.version < 8) {
                i = i + 2
            }
            a(this).css("top", "-" + i + "px")
        }, function() {
            a(this).css("top", "0px")
        });
        rotatePromos = setInterval(d, f)
    }
})(jQuery);
(function(a) {
    a.fn.vwFooter = function(b) {
        return this.each(function() {
            var c = a(this);
            a.get("/global/footer/data/footer.xml", function(f) {
                a(c).html("");
                a(c).append("<ul></ul>");
                a(f).find("link").each(function() {
                  var id = 'footer-' + $(this).find('title').attr('itemID');
                  var h = '<li id="'+ id + '"><a href="'+$(this).find('url').text()+'">'+$(this).find('title').text()+'</a></li>';
                  $('ul',c).append(h);
                  // add target attribute if necessary
                  var target = $(this).find('url').attr('target');
                  if(target == '_blank') {
                    a(c).find('#' + id + " a").attr('target','_blank');
                  }
                });
                var d = a(f).find("copyright");
                var e = '<li id="footer-' + d.find("copyText").attr("itemID") + '">' + d.find("copyText").text() + "</li>";
                a("ul", c).append(e);
                var g = a(document);
                g.trigger("ajax:complete", ["footer"])
            })
        })
    }
})(jQuery);
