﻿if (typeof console == "undefined")
{
	console = {log: function(){}};
}

//------------------------Start Navigation------------------------\\
var mainlinkTimeout;
var trimTimeout;
var vehicleImages = new Array();

jQuery(document).ready
(
	function($)
	{
		$("#main-navigation > ul > li > a.main-link").mouseenter
		(
			function()
			{
				var self = $(this);
				
				mainlinkTimeout = setTimeout
				(
					function()
					{
						var yearIndex = 0;
							
						$(self).parent().find(".models strong span").each
						(
							function(i)
							{
								if ($(this).hasClass("selected"))
								{
									yearIndex = i;
								}
							}
						);
						
						$("#main-navigation .nav-dropdown").stop(true, true);
						$("#main-navigation > ul > li > a.main-link").removeClass("selected");
						$(self).addClass("selected");
						
						if ($("#main-navigation .nav-dropdown.active").length > 0)
						{
							$("#navigation-overlay").stop(true, true).fadeTo(0, 0.6);							
							$("#main-navigation .nav-dropdown").removeClass("active").hide(0);
							$(self).parent().children(".nav-dropdown").addClass("active").show(0);
							
							if (!$(self).parent().hasClass("secondary") && (!$(self).parent().find(".model-landing")[0] || $(self).parent().find(".model-landing").css("display") == "none"))
							{
								$("#trim-info").stop(true, true).show(0);
								
								if ($(self).parent().find(".year:eq(" + yearIndex + ") li.selected a")[0])
								{
									updateTrimInfo($(self).parent().find(".year:eq(" + yearIndex + ") li.selected a"));
								}
								else
								{
									updateTrimInfo($(self).parent().find(".year:eq(" + yearIndex + ") li a:eq(0)"));
								}
							}
							else
							{
								$("#trim-info").stop(true, true).hide(0);
							}
						}
						else
						{
							$("#navigation-overlay").stop(true, true).fadeTo(500, 0.6);
							$(self).parent().children(".nav-dropdown").stop(true, true).addClass("active").fadeIn(500);
							
							if (!$(self).parent().hasClass("secondary") && (!$(self).parent().find(".model-landing")[0] || $(self).parent().find(".model-landing").css("display") == "none"))
							{
								$("#trim-info").stop(true, true).delay(200).fadeIn(200);
								
								if ($(self).parent().find(".year:eq(" + yearIndex + ") li.selected a")[0])
								{
									updateTrimInfo($(self).parent().find(".year:eq(" + yearIndex + ") li.selected a"));
								}
								else
								{
									updateTrimInfo($(self).parent().find(".year:eq(" + yearIndex + ") li a:eq(0)"));
								}
							}
						}
						
						$(self).parent().find("img[lazysrc]").each
						(
							function()
							{
								chrysler.lazy.showPreloader(this);
								chrysler.lazy.loadContent(this);
							}
						);
						
						if (typeof homepageCarousel != "undefined")
						{
							homepageCarousel.pause();
						}
					},
					250
				);
				
				$(this).bind
				(
					"mouseleave",
					function()
					{
						clearTimeout(mainlinkTimeout);
					}
				);
			}
		);
		
		$("#main-navigation").mouseleave
		(
			function()
			{
				$("#navigation-overlay, #trim-info").stop(true, true).delay(350).fadeOut(400);
				$("#main-navigation .nav-dropdown").stop(true, true).delay(350).fadeOut
				(
					400,
					function()
					{
						$("#main-navigation > ul > li > a.main-link").removeClass("selected");
						$("#main-navigation .nav-dropdown").removeClass("active");
						
						if (typeof homepageCarousel != "undefined")
						{
							homepageCarousel.resume();
						}
					}
				);
			}
		);
		
		$("#main-navigation .nav-dropdown").mouseenter
		(
			function()
			{
				$(this).parent().children("a.main-link").addClass("selected");
				$(this).addClass("active");
			}
		);
		
		$("#main-navigation").mouseenter
		(
			function()
			{
				if ($("#main-navigation .nav-dropdown").hasClass("active") && $("#main-navigation .nav-dropdown:animated").length == 0)
				{
					$("#main-navigation .nav-dropdown, #navigation-overlay, #trim-info").stop(true, false);
					
					if (typeof homepageCarousel != "undefined")
					{
						homepageCarousel.pause();
					}
				}
			}
		);
		
		$("#main-navigation .models strong span").click
		(
			function()
			{
				if (!$(this).hasClass("selected"))
				{
					$(this).parents(".models").children(".years").animate({left: (-180 * $(this).index())}, 300);					
					$(this).siblings(".selected").removeClass("selected");
					$(this).addClass("selected");
					linkTrack("global_top_nav_flyout", String.format("{0}_{1}_models", $(this).html(), $(this).parents("li").attr("id").replace("mi-", "")));
					
					if (!$(this).parents(".nav-dropdown").find(".model-landing")[0] || $(this).parents(".nav-dropdown").find(".model-landing").css("display") == "none")
					{
						var selectedLi = $(this).parents(".models").find(".year:eq(" + $(this).index() + ") li.selected a");
						
						if (selectedLi[0])
						{
							updateTrimInfo(selectedLi);
						}
						else
						{
							updateTrimInfo($(this).parents(".models").find(".year:eq(" + $(this).index() + ") li a:eq(0)"));
						}
					}
				}
			}
		);
		
		$("#main-navigation .models ul li ul li a").click
		(
			function(event)
			{
				event.preventDefault();
				
				var href = $(this).attr("href");
				href = href.substring(0, href.indexOf('#'));
				
				if (String.isNullOrWhiteSpace(href))
				{
					bridge.buildMyOwn($(this).attr("href").substring(1));
				}
				else
				{
					window.location.href = href;
				}
			}
		);
		
		$("#main-navigation .models ul li ul li a").mouseenter
		(
			function()
			{
				if (!$(this).parent().hasClass("selected"))
				{
					var self = $(this);
					
					trimTimeout = setTimeout
					(
						function()
						{
							updateTrimInfo(self);
						},
						350
					);
					
					$(this).bind
					(
						"mouseleave",
						function()
						{
							clearTimeout(trimTimeout);
						}
					);
				}
			}
		);
		
		$("#mi-tools form:eq(0)").submit
		(
			function(event)
			{
				event.preventDefault();
				
				window.location.href = "/hostc/fad/findDealers.do?zipCode=" + $("#find-dealer_zipcode").val();
			}
		);
		
		$("#mi-tools form:eq(1)").submit
		(
			function(event)
			{
				event.preventDefault();
				
				if (chrysler.currentVehicleId)
				{
					window.location.href = String.format("/bridge?zipcode={0}&app=daa&family={1}&model={2}&year={3}", $("#offers_zipcode").val(), chrysler.vehicles[chrysler.currentVehicleId].model, chrysler.vehicles[chrysler.currentVehicleId].name, chrysler.vehicles[chrysler.currentVehicleId].year);
				}
				else
				{
					window.location.href = String.format("/bridge?zipcode={0}&app=daa", $("#offers_zipcode").val());
				}
			}
		);
		
		if (/iPad/i.test(window.navigator.userAgent))
		{
			$("#main-navigation > ul > li > a.main-link").click
			(
				function(event)
				{
					event.preventDefault();
				}
			);
		}
		
		function updateTrimInfo(self)
		{
			$(self).parent().siblings(".selected").removeClass("selected");
			$(self).parent().addClass("selected");
			
			var vid = $(self).attr("href").substring($(self).attr("href").lastIndexOf("#") + 1);
			var year = vid.substring(3, 7);
			
			chrysler.lazy.requires
			(
				String.format("/javascript/chrysler.vehicles{0}.js", (year == 2011) ? ("." + year) : ""),
				function()
				{
					var vehicle = chrysler.vehicles[vid];
					
					$("#mi-" + vehicle.model).find(".model-landing").hide().css('display', 'none');
					$("#trim-info").show();
					
					switch (vehicle.model)
					{
						case "300":
							$("#trim-info h2").html(String.format("The {0}New {1} Chrysler <strong>300{2}</strong>", (vehicle.year == 2011) ? "All-" : "", vehicle.year, (vehicle.name == "300") ? "" : (vehicle.name.substring(0, 1) == "C") ? vehicle.name : " " + vehicle.name));
							break;
							
						case "200":
							$("#trim-info h2").html(String.format("The New {0} Chrysler <strong>200 {1}</strong>", vehicle.year, vehicle.name));
							break;
							
						case "Town & Country":
							$("#trim-info h2").html(String.format("The New {0} <strong>Town &amp; Country {1}</strong>", vehicle.year, vehicle.name));
							break;
					}
					
					$("#trim-info .msrp-info .price").html(String.format("<span class=\"dollar-sign\">$</span><span class=\"amount\">{0}</span>", chrysler.util.formatCurrency(vehicle.msrp)));
					$("#trim-info .mpg-info .hwy").html(vehicle.mpg.highway);
					$("#trim-info .mpg-info .city").html(vehicle.mpg.city);
					$("#trim-info .mpg-info .tooltip").attr("title", vehicle.mpg.disclaimer);
					
					if (vehicle.year == 2011)
					{
						$("#trim-info .msrp-info .button").html("Build My Own<span></span>");
						$("#trim-info .msrp-info .button").attr("href", "javascript:bridge.buildMyOwn(\"" + vehicle.id + "\")");
						$("#trim-info .msrp-info .button").attr("name", String.format("&lid={0}_{1}{2}_build_my_own&lpos=global_top_nav_flyout", vehicle.year, vehicle.model.replace(" & ", "_").replace(" ", "_").toLowerCase(), vehicle.name == 300 ? "" : "_" + vehicle.name.replace(" ", "_").toLowerCase()));
						$("#trim-info .mpg-info .button").hide();
					}
					else
					{
						$("#trim-info .msrp-info .button").html("Explore<span></span>");
						$("#trim-info .msrp-info .button").attr("href", $(self).attr("href").replace("#" + vehicle.id, ""));
						$("#trim-info .msrp-info .button").attr("name", String.format("&lid={0}_{1}{2}_explore&lpos=global_top_nav_flyout", vehicle.year, vehicle.model.replace(" & ", "_").replace(" ", "_").toLowerCase(), vehicle.name == 300 ? "" : "_" + vehicle.name.replace(" ", "_").toLowerCase()));
						$("#trim-info .mpg-info .button").show();
						$("#trim-info .mpg-info .button").attr("href", "javascript:bridge.buildMyOwn(\"" + vehicle.id + "\")");
						$("#trim-info .mpg-info .button").attr("name", String.format("&lid={0}_{1}{2}_build_my_own&lpos=global_top_nav_flyout", vehicle.year, vehicle.model.replace(" & ", "_").replace(" ", "_").toLowerCase(), vehicle.name == 300 ? "" : "_" + vehicle.name.replace(" ", "_").toLowerCase()));
					}
					
					//REMOVE AFTER 300C LUX GOES ON SALE
					if (vehicle.id == "CUC201201LXCR48A")
					{
						$("#trim-info .msrp-info .price").html("<span class=\"dollar-sign\">$</span><span class=\"amount\">41,970</span>");
						$("#trim-info .mpg-info .button").hide();
					}
					
					var offerDetail = "";
					
					if (vehicle.incentives)
					{
						if (vehicle.incentives.lease)
						{
							$("#trim-info .lease-info").removeClass("apr");
							offerDetail = "<span class=\"verb\">Lease for:</span>";
							offerDetail += String.format("<span class=\"price\"><span class=\"dollar-sign\">$</span><span class=\"amount\">{0}</span><span class=\"slash\">/</span><span class=\"more-info\"><span class=\"month\">Month</span><span class=\"term-copy\">For <span class=\"term\">{1}</span> Months<sup title=\"{2}\" class=\"tooltip\">+</sup></span></span><span class=\"clear-both\"></span></span>", chrysler.util.formatCurrency(vehicle.incentives.lease.payment), vehicle.incentives.lease.term, vehicle.incentives.lease.disclaimer);
							offerDetail += String.format("<div class=\"legal\">${0} due at signing. {1} security deposit required.</div>", chrysler.util.formatCurrency(vehicle.incentives.lease.downPayment), (vehicle.incentives.lease.securityDeposit == 0) ? "No" : chrysler.util.formatCurrency(vehicle.incentives.lease.securityDeposit, false, true));
						}
						else if (vehicle.incentives.finance)
						{
							$("#trim-info .lease-info").addClass("apr");
							offerDetail = "<span class=\"verb\">Finance for:</span>";
							offerDetail += String.format("<span class=\"price\"><span class=\"amount\">{0}</span><span class=\"slash\">%</span><span class=\"more-info\"><span class=\"month\">APR</span><span class=\"term-copy\">For <span class=\"term\">{1}</span> Months<sup title=\"{2}\" class=\"tooltip\">+</sup></span></span><span class=\"clear-both\"></span></span>", vehicle.incentives.finance.apr, vehicle.incentives.finance.term, vehicle.incentives.finance.disclaimer);
						}
					}
					
					$("#trim-info .lease-info").html(offerDetail);
					
					if (vehicle.name.indexOf("Convertible") > -1)
					{
						$("#trim-info .ipad-download").hide();
					}
					else
					{
						$("#trim-info .ipad-download").show();
					}
					
					if (vehicleImages.contains(vid))
					{
						if (vehicleImages[vehicleImages.indexOf(vid) + 1].src != $("#trim-info #trim_image")[0].src)
						{
							$("#trim-info #trim_image").replaceWith($(vehicleImages[vehicleImages.indexOf(vid) + 1]));
						}
					}
					else
					{
						$("#trim-info #trim_image").replaceWith("<img id=\"trim_image\" class=\"loading\" alt=\"Loading...\" src=\"/images/blank.gif\" />");
						
						chrysler.lazy.loadImage
						(
							String.format("/images/vehicles/{0}/{1}/{2}-a.png", vehicle.year, vehicle.model.replace(" & ", "_").toLowerCase(), vehicle.id.substring(9)),
							function(img)
							{
								//img.alt = title;
								img.id = "trim_image";
								$("#trim-info #trim_image").replaceWith($(img));
								vehicleImages.push(vid);
								vehicleImages.push(img);
							}
						);
					}
				}
			);
		}
		//------------------------End Navigation------------------------\\
		
		/*--------Fade out--------*/
		$(".fade-in").fadeTo(0, 0.65);
		
		$(".fade-in").live
		(
			"mouseenter",
			function()
			{
				$(this).fadeTo(100, 1);
			}
		);
		
		$(".fade-in").live
		(
			"mouseleave",
			function()
			{
				$(this).fadeTo(200, 0.65);
			}
		);
		/*
		$(".fade").each
		(
			function()
			{
				$("<div/>", {"class": "fade-overlay"}).appendTo($(this)).fadeTo(0, 0.35);
			}
		);
		
		$(".fade").mouseenter
		(
			function()
			{
				$(".fade:visible .fade-overlay").stop(true, false).fadeOut(200);
			}
		);
		
		$(".fade").mouseleave
		(
			function()
			{
				$(".fade").children(".fade-overlay").stop(true, false).fadeTo(250, 0.35);
			}
		);
		*/
		$(".fade-out, #mi-tools .thumbnail").each
		(
			function()
			{
				$("<div/>", {"class": "fade-overlay"}).appendTo($(this)).fadeTo(0, 0).hide();
			}
		);
		
		$(".fade-out").mouseenter
		(
			function()
			{
				$(".fade-out:visible").not(this).children(".fade-overlay").stop(true, false).fadeTo(250, 0.75);
			}
		);
		
		$(".fade-out").mouseleave
		(
			function()
			{
				$(".fade-out:visible .fade-overlay").stop(true, false).fadeOut(200);
			}
		);
		
		/*$("#mi-tools .thumbnail").mouseenter
		(
			function()
			{
				$(this).children(".fade-overlay").stop(true, false).fadeTo(250, 0.75);
				$(this).children("form").stop(true, false).fadeTo(250, 1);
			}
		);
		
		$("#mi-tools .thumbnail").mouseleave
		(
			function()
			{
				$(this).children(".fade-overlay").stop(true, false).fadeOut(250);
				$(this).children("form").stop(true, false).fadeOut(250);
			}
		);*/
		
		$(".fade-other").hover
		(
			function()
			{
				$(".fade-other").stop().animate({opacity: 0.30});
				$(this).stop().animate({opacity: 1});
			},
			function()
			{
				$(".fade-other").stop().animate({opacity: 1});
				$(this).stop().animate({opacity: 1});
			}
		);
		
		$(".textbox, .search-box").each
		(
			function()
			{
				if ($(this).children("input").val() != "")
				{
					$(this).children("label").hide();
				}
			}
		);
		
		$(".textbox input, .search-box input").focus
		(
			function()
			{
				$(this).siblings("label").hide();
			}
		);
		
		$(".textbox input, .search-box input").focusout
		(
			function()
			{
				if ($(this).val() == "")
				{
					$(this).siblings("label").show();
				}
			}
		);
		
		$("#legal-footer .legal").click
		(
			function()
			{
				if ($(this).hasClass("active"))
				{
					$("#footnotes").slideUp(500);
					$(this).removeClass("active");
				}
				else
				{
					$("#footnotes").slideDown(500).scrollTo(500);
					$(this).addClass("active");
				}
			}
		);
		
		jQuery('#long-footer .chrysler-logo').click(function() {
		    linkTrack("chrysler_homepage", "footer_ifd_logo");
			window.location.replace("/en/"); 
		});
		
		$("a[href^='#']").click
		(
			function(event)
			{
				if ($(this).attr("href") != "#")
				{
					event.preventDefault();
					$("a[name='" + $(this).attr("href").substring(1) + "']").scrollTo(500);
				}
			}
		);
		
		//------------------------Start uConnect------------------------\\
		$(".uconnect li p").show(0).fadeOut(0);
		$(".uconnect li.selected p").fadeIn(0);
		
		$(".uconnect li .cta").click
		(
			function()
			{
				$(this).parent().siblings().removeClass("selected");
				$(this).parent().addClass("selected");
				$(this).parent().siblings().children("p").fadeOut(500);
				$(this).siblings("p").fadeIn(500);
				
				var image = $(".uconnect .image img").eq($(this).parent().index())[0];
				
				if ($(image).attr("lazysrc"))
				{
					$(image).attr("callback", "uconnectcb");
					chrysler.lazy.loadContent(image);
				}
				else
				{
					uconnectcb(image);
				}
				
				linkTrack("feature_content", $(this).html().replace(" ", "_").toLowerCase());
			}
		);
		//------------------------End uConnect------------------------\\
		
		//------------------------Start Tooltip------------------------\\
		function showDisclaimer(el){
			$(".disclaimer").remove();
			$("body").append("<div class=\"disclaimer\"><div></div><span class=\"tip\"></span></div>");
			$(".disclaimer div").html($(el).attr("title"));
			
			var disc = $("<div class=\"disclaimer\"></div>").html($(el).attr("title"));
			$("body").append(disc);
			var width = disc.outerWidth(true);
			disc.remove();
			
			$(".disclaimer").removeClass("top").css("right", "auto").css("left", ($(el).offset()).left - 104).css("top", ($(el).offset()).top - $(".disclaimer").outerHeight(true) - 8);
			$(".disclaimer").show().css("visibility", "hidden");
			
			if (Math.round($(".disclaimer").outerWidth(true) + ($(".disclaimer").position()).left) == $(window).width() || width + ($(".disclaimer").offset()).left > $(window).width())
			{
				if (width < parseInt($(".disclaimer").css("max-width").replace("px", "")))
				{
					$(".disclaimer").css("left", "auto").css("right", 10).css("top", ($(el).offset()).top - $(".disclaimer").outerHeight(true) - 8);
				}
				else
				{
					$(".disclaimer").css("left", (($(el).offset()).left - 114) - (width - $(".disclaimer").outerWidth(true))).css("top", ($(el).offset()).top - $(".disclaimer").outerHeight(true) - 8);
				}
				
				$(".disclaimer .tip").css("left", ($(el).offset()).left - ($(".disclaimer").offset()).left - 3);
			}
			
			if (($(".disclaimer").offset()).top < 0)
			{
				$(".disclaimer").css("top", ($(el).offset()).top + $(el).outerHeight(true) + 10).addClass("top");
			}
			
			$(".disclaimer").hide().css("visibility", "visible");				
			$(".disclaimer").fadeIn(500);
			$(el).attr("title", "");	
		}
		
		function hideDisclaimer(el){
			$(el).attr("title", $(".disclaimer div:first").html());
			$(".disclaimer").fadeOut(500, function(){$(this).remove()});	
		}
		
		$("sup.tooltip, span.tooltip")
			.live("mouseenter",function(){ showDisclaimer(this); })
			.live("mouseleave",function(){ hideDisclaimer(this); });
		
		//iPad fix
		if (/iPad/i.test(window.navigator.userAgent)){
			console.log('ipad disc');
			var currentDisclaimer;
			
			$("body").delegate("sup.tooltip, span.tooltip","click",function(){ 
				console.log('click event');
				currentDisclaimer = this;
				showDisclaimer(currentDisclaimer);
				console.log(currentDisclaimer);
			});
			
			$("body").delegate("div.disclaimer","click",function(){ 
				console.log('disc click');
				hideDisclaimer(currentDisclaimer);
			});
		}
		//------------------------End Tooltip------------------------\\
		
		$(window).load
		(
			function()
			{
				//------------------------Start Tracking------------------------\\
				/*chrysler.lazy.requires
				(
					["/crossbrand/shared/javascripts/vendor/nr_c.js", "/javascript/chrysler.analytics.js"],
					function()
					{
						chrysler.analytics.init("chrysler");
						chrysler.analytics.trackPageView();
					}
				);*/
				brand = "chrysler";
				
				chrysler.lazy.requires
				(
					["/crossbrand/shared/javascripts/vendor/nr_c.js", "/crossbrand/shared/javascripts/cadreon.core.js"],
					function()
					{
						chrysler.lazy.requires
						(
							["/crossbrand/shared/javascripts/wss_funcs.js", "/shared/javascripts/cadreon.config.js", "/crossbrand/shared/javascripts/cadreon.tags.js"],
							function()
							{
								setPageViewVariables();
								cadreon.tags.init();
							}
						);
					}
				);
				//------------------------End Tracking------------------------\\
				
				//------------------------Start AdChoices------------------------\\
				var adChoicesImg = document.createElement("img");
				adChoicesImg.src = document.location.protocol + "//l.betrad.com/pub/p.gif?pid=84&ocid=832&ii=1&r=" + Math.random();
				adChoicesImg.height = "1";
				adChoicesImg.width = "1";
				document.body.appendChild(adChoicesImg);
				
				$(".adchoices a").click
				(
					function(event)
					{
						event.preventDefault();
						var f = this;
						
						chrysler.lazy.requires
						(
							[document.location.protocol + "//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js", (document.location.protocol == "https:" ? "https://info.evidon.com/c/betrad/pub/" : "http://cdn.betrad.com/pub/") + "pub1.js"],
							function()
							{
								BAPW.i
								(
									f,
									{
										pid: 84,
										ocid: 832
									},
									false
								);
							}
						);
						
						$(this).unbind("click");
					}
				);
				//------------------------End AdChoices------------------------\\
			}
		);
		
		if (typeof fixFootnotes == "function")
		{
			fixFootnotes();
		}
	}
);

jQuery.fn.extend
(
	{
		scrollTo: function(speed, easing)
		{
			return this.each
			(
				function()
				{
					jQuery("html, body").animate({scrollTop: (jQuery(this).offset()).top}, speed, easing);
				}
			);
		}
	}
);

function uconnectcb(image)
{
	$(".uconnect .image img").fadeOut(500, function(){$(this).removeClass("selected");});
	$(image).stop(true, true).fadeIn(500, function(){$(this).addClass("selected");});
	$(".uconnect .image img").eq(0).stop(true, true).fadeIn(0);
}

function copyAlign(element)
{
	$(element).css("padding-top", ($(element).parent().height() - $(element).height()) / 2);
}

function share(moduleId)
{
	chrysler.lazy.requires
	(
		"http://connect.facebook.net/en_US/all.js",
		function()
		{
			var title = $("#" + moduleId).find("h4").eq(0).text();
			var description = $("#" + moduleId).find("p").eq(0).text();
			var image = $("#" + moduleId).find(".image img")[0];
			
			if (!image)
			{
				image = $("#" + moduleId).find(".image-1 img")[0];
			}
			
			var url = window.location.href.replace("index.html", "");
			
			if (url.indexOf("#") > -1)
			{
				url = url.substring(0, url.indexOf("#"))
			}
			
			if (moduleId == "gallery")
			{
				title = document.title;
				description = $(".gallery .caption p").html();
				image = $("#gallery-image img")[0];
			}
			else
			{
				url = url + "#" + moduleId;
			}
			
			if (!FB._apiKey)
			{
				FB.init
				(
					{
						appId: "142041459208055",
						status: true,
						cookie: true,
						xfbml: true
					}
				);
			}
			
			FB.ui
			(
				{
					method: "feed",
					message: "",
					name: title,
					caption: "",
					description: description,
					link: url,
					picture: image.src
				}
			);
		}
	);
}

//-----------------------------------------

featureHotspots = function(id)
{
	this.id = id;
	this.animationSpeed = 1000;
	this.hotspots = new Object();
	this.imageHeight;
	this.imageWidth;
	
	this.init = function(moduleId)
	{
		var hotspotsUl = $("<ul class=\"feature-hotspots\" />");
		var hotspotLi;
		var closeButton;
		var image;
		
		for (var hotspot in this.hotspots)
		{
			hotspotLi = $("<li id=\"" + hotspot + "\" />").css({left: this.hotspots[hotspot].coordinates.x, top: this.hotspots[hotspot].coordinates.y});
			closeButton = $("<span />");
			hotspotLi.append($("<div />").append(closeButton));
			hotspotsUl.append(hotspotLi);
			
			var self = this;
			
			hotspotLi.click
			(
				function()
				{
					var thisLi = $(this);	
					
					if (!thisLi.hasClass("selected"))
					{
						thisLi.removeAttr("style").addClass("selected");
						var id = thisLi.attr("id");
						
						if (!thisLi.find("img")[0])
						{
							$(".feature-hotspots-loader").show();
							
							chrysler.lazy.loadImage
							(
								self.hotspots[id].image,
								function(img)
								{
									thisLi.children("div").append($(img));
									$(".feature-hotspots-loader").hide();
									window.setTimeout(function(){self.animate(thisLi, id)}, 50);
								}
							);
						}
						else
						{
							self.animate(thisLi, id);
						}
					}
				}
			);
			
			closeButton.click
			(
				function(event)
				{
					event.stopPropagation();
					var hotspotLi = $(this).parents("li");
					var id = hotspotLi.attr("id");
					$(this).fadeOut(self.animationSpeed / 2);
					
					hotspotLi.find("img").animate({width: 0, height: 0}, self.animationSpeed, function(){$(this).css({width: self.imageWidth, height: self.imageHeight})});
					hotspotLi.find("div").animate
					(
						{left: self.hotspots[id].coordinates.x + 25, top: self.hotspots[id].coordinates.y + 24},
						self.animationSpeed,
						function()
						{
							$(this).hide();
							hotspotLi.removeClass("selected").css({left: self.hotspots[id].coordinates.x, top: self.hotspots[id].coordinates.y});
						}
					);
				}
			);
		}
		
		$("#" + moduleId).children(".image").append(hotspotsUl).append("<div class=\"feature-hotspots-loader\"></div>");
	};
	
	this.animate = function(hotspotLi, id)
	{
		this.imageHeight = hotspotLi.find("img")[0].height;
		this.imageWidth = hotspotLi.find("img")[0].width;
		var self = this;
						
		hotspotLi.find("img").css({width: 0, height: 0}).animate({width: this.imageWidth, height: this.imageHeight}, self.animationSpeed);
		hotspotLi.find("div").css({left: this.hotspots[id].coordinates.x + 25, top: this.hotspots[id].coordinates.y + 24}).show().animate
		(
			{top: (hotspotLi.height() / 2) - (this.imageHeight / 2), left: (hotspotLi.width() / 2) - (this.imageWidth / 2)},
			this.animationSpeed,
			function()
			{
				hotspotLi.find("span").fadeIn(self.animationSpeed / 2);
			}
		);
	};
};

//-----------------------------

var bridge = new function()
{
	this.buildMyOwn = function(vehicleId)
	{
		if (vehicleId)
		{
			if (vehicleId.length == 9)
			{
				window.location.href = "/hostc/models/" + vehicleId + "/bmo/selectModel.do";
			}
			else
			{
				chrysler.lazy.requires
				(
					String.format("/javascript/chrysler.vehicles{0}.js", (vehicleId.substring(3, 7) == 2011) ? ("." + vehicleId.substring(3, 7)) : ""),
					function()
					{
						window.location.href = String.format("/hostc/bmo/{0}/{1}/colors.do", vehicleId, chrysler.vehicles[vehicleId].package);
					}
				);
			}
		}
		else
		{
			window.location.href = "/en/lineup?app=priceequip";
		}
	};
	
	this.getAQuote = function(vehicleId)
	{
		if (vehicleId)
		{
			chrysler.lazy.requires
			(
				String.format("/javascript/chrysler.vehicles{0}.js", (vehicleId.substring(3, 7) == 2011) ? ("." + vehicleId.substring(3, 7)) : ""),
				function()
				{
					window.location.href = "/en/gaq?vehicle=" + chrysler.vehicles[vehicleId].model.replace(" & ", "_").toLowerCase() + "&year=" + chrysler.vehicles[vehicleId].year + "&model=" + chrysler.vehicles[vehicleId].name;
				}
			);
		}
		else
		{
			window.location.href = "/en/gaq";
		}
	};
	
	this.viewOffers = function(vehicleId)
	{
		this._bridge(vehicleId, "daa", "/en/incentives");
	};
	
	this.getBrochure = function(vehicleId)
	{
		this._bridge(vehicleId, "brochure", "/en/lineup?app=brochure");
	};
	
	this.paymentCalculator = function(vehicleId)
	{
		this._bridge(vehicleId, "pe", "/en/lineup?app=pe");
	};
	
	this.locateVehicle = function(vehicleId)
	{
		this._bridge(vehicleId, "newinventory", "/en/lineup?app=newinventory");
	};
	
	this.searchPreOwned = function()
	{
		chrysler.lazy.requires
		(
			"/javascript/chrysler.cookies.js",
			function()
			{
				var zipcode = "";
				
				if (chrysler.cookies["zipcode"])
				{
					zipcode = "?zipcode=" + chrysler.cookies["zipcode"].value;
				}
				
				window.location.href = "/hostc/cpov/vehicleSearch.do" + zipcode;
			}
		);
	};
	
	this.testDrive = function(vehicleId)
	{
		this._bridge(vehicleId, "testdrive", "/en/satd");
	};
	
	this.findDealer = function(vehicleId)
	{
		//this._bridge(vehicleId, "cdl", "/en/lineup?app=brochure");
		
		if (vehicleId)
		{
			this._bridge(vehicleId, "cdl");
		}
		else
		{
			chrysler.lazy.requires
			(
				"/javascript/chrysler.cookies.js",
				function()
				{
					var zipcode = "";
					
					if (chrysler.cookies["zipcode"])
					{
						zipcode = "zipcode=" + chrysler.cookies["zipcode"].value + "&";
					}
					
					window.location.href = String.format("/bridge?{0}app=cdl", zipcode);
				}
			);
		}
	};
	
	this._bridge = function(vehicleId, app, page)
	{
		if (vehicleId)
		{
			chrysler.lazy.requires
			(
				[String.format("/javascript/chrysler.vehicles{0}.js", (vehicleId.substring(3, 7) == 2011) ? ("." + vehicleId.substring(3, 7)) : ""), "/javascript/chrysler.cookies.js"],
				function()
				{
					var zipcode = "";
					
					if (chrysler.cookies["zipcode"])
					{
						zipcode = "zipcode=" + chrysler.cookies["zipcode"].value + "&";
					}
					if (app=="pe") {
						overlay.build('pe', {ccode: chrysler.vehicles[vehicleId].id});
					} else {
						window.location.href = String.format("/bridge?{0}app={1}&family={2}&model={3}&year={4}", zipcode, app, chrysler.vehicles[vehicleId].model.replace(" & ", "_").toLowerCase(), chrysler.vehicles[vehicleId].name, chrysler.vehicles[vehicleId].year);
					}
				}
			);
		}
		else if (app=="pe" || app=="newinventory"){
			overlay.build(app, {});
		}
		else
		{
			window.location.href = page;
		}
	};
}

function switchLanguage()
{
	chrysler.lazy.requires
	(
		"http://es.chrysler.com/mpel/mpel.js",
		function()
		{
			var subDomain = (window.location.host.indexOf("es.") != -1) ? "www" : "es";
			var queryString = String.isNullOrWhiteSpace(window.location.search) ? "?1023749632" : "?1023749632&" + window.location.search.replace("?1023749632&", "").replace("?", "");
			
			window.location.href = String.format("{0}//{1}.chrysler.com{2}{3}", window.location.protocol, subDomain, window.location.pathname, queryString);
		}
	);
}

//-----------------------------

var modal = new function()
{
	this.overlay;
	this.modal;
	this.closeButton;
	this.isOpen = false;
	this.onClose;
	this.options =
	{
		closeButton: true
	};
	
	this.init = function(options)
	{
		if (options)
		{
			this.options = options;
		}
		
		if (!this.overlay)
		{
			this.overlay = $("<div/>",
				{
					id: "overlay"
				}
			).prependTo("body");
			
			if (this.options.closeButton)
			{
				this.closeButton = $("<img/>",
					{
						"class": "close",
						alt: "",
						src: "/images/modal-close.png"
					}
				);
			}
			
			this.modal = $("<div/>",
				{
					id: "modal"
				}
			).prependTo("body").append(this.closeButton);
		}
		
		this.overlay.bind("click", function(){modal.close();});
		if (this.closeButton)
		{
			this.closeButton.bind("click", function(){modal.close();});
		}
		$(window).resize(function(){modal.centerWindow();});
		$(document).bind
		(
			"keyup",
			function(event)
			{
				if (event.which == 27)
				{
					modal.close();
				}
			}
		);
	};
	
	this.open = function(content, options)
	{
		if (!this.overlay)
		{
			this.init(options);
		}
		
		if (content)
		{
			this.modal.append(content);
		}
		
		this.centerWindow();
		this.modal.fadeIn(500);
		this.overlay.fadeTo(500, 0.7);
		this.modal.resize(function(){modal.centerWindow();});
	};
	
	this.close = function(destroy)
	{
		this.modal.fadeOut(500, function(){$(this).children().not(modal.closeButton).remove();});
		this.overlay.fadeOut(500);
		
		if (typeof this.onClose == "function")
		{
			this.onClose();
		}
		
		if (destroy)
		{
			this.destroy();
		}
	};
	
	this.centerWindow = function()
	{
		this.modal.css("top", ($(window).height() / 2) - (this.modal.outerHeight(true) / 2));
		this.modal.css("left", ($(window).width() / 2) - (this.modal.outerWidth(true) / 2));
	};
	
	this.destroy = function()
	{
		this.overlay.remove();
		this.modal.remove();
		$(document).unbind("keypress");
	};
};

var videoType = 
{
	YouTube: "YOUTUBE",
	RTMP: "RTMP",
	MP4: "MP4/FLV"
};

videoPlayer = function(id)
{
	this.height = 480; 
	this.id = id;
	this.object;
	this.tracking = new Object();
	this.video = new Object();
	this.video.autoPlay = false;
	this.width = 853;
	this.onReady;
	this.onPlay;
	this.onPause;
	this.onComplete;
	this.onBuffer;
	
	this.init = function(callback)
	{
		var player = this;
		
		chrysler.lazy.requires
		(
			"http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
			function()
			{
		    	var params = new Object();
		    	params.base = "/flash/assets/swfs/";
		    	params.wmode = "transparent";
		    	params.allowscriptaccess = "always";
		    	params.allowfullscreen = "true";
		    	params.menu = "false";
		    	
		    	var flashVars = new Object();
		    	flashVars._type = player.video.type;
				flashVars._autoPlay = player.video.autoPlay;
		    	flashVars.menu = "false";
		    	
		    	if (!String.isNullOrWhiteSpace(player.video.poster))
		    	{
		    		flashVars.posterImageUrl = player.video.poster;
		    	}
		    	
		    	switch (player.video.type)
		    	{
		    		case videoType.YouTube:
		    			flashVars._youtubeId = player.video.id;
		    			break;
		    			
		    		case videoType.RMTP:
		    			flashVars._source = player.video.source;
						flashVars._connectionPath = player.video.connection;
						flashVars._backupSource = player.video.AltSource;
		    			break;
		    			
		    		case videoType.MP4:
		    			flashVars._videoUrl = player.video.source;
		    			break;
		    	}
		    	
		    	flashVars.trackingBrandName = player.tracking.brand;
				flashVars.trackingFilePath = player.tracking.mediaPath;
				flashVars.trackingPageUri = (String.isNullOrWhiteSpace(player.tracking.page)) ? window.location.pathname : player.tracking.page;
				flashVars.trackingTitle = player.tracking.mediaTitle;
				flashVars.trackingVehicleId = player.tracking.vehicle;
				flashVars.trackingVideoId = player.tracking.mediaId;
		    	
		    	swfobject.embedSWF
		    	(
		    		"/flash/assets/swfs/shell.swf", player.id, player.width, player.height, "10", "/flash/assets/swfs/expressinstall.swf", flashVars, params, null,
			    	function()
			    	{
			    		player.object = document.getElementById(player.id);
			    		
			    		if (typeof callback == "function")
			    		{
			    			callback();
			    		}
			    	}
		    	);
			}
		);
	};
	
	this.play = function()
	{
		if (this.object)
		{
			this.object.playVideo();
		}
	};
	
	this.pause = function()
	{
		if (this.object)
		{
			this.object.pauseVideo();
		}
	};
	
	this.stop = function()
	{
		if (this.object)
		{
			this.object.stopEverything();
		}
	};
};

//jQuery onresize
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);

//Mootools Json object
var Json={toString:function(a){switch(typeof a){case"string":return'"'+a.replace(/(["\\])/g,"\\$1")+'"';case"array":return"["+a.map(Json.toString).join(",")+"]";case"object":var b=[];for(var c in a)b.push(Json.toString(c)+":"+Json.toString(a[c]));return"{"+b.join(",")+"}";case"number":if(isFinite(a))break;case false:return"null"}return String(a)},evaluate:function(str,secure){return typeof str!="string"||secure&&!str.test(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/)?null:eval("("+str+")")}};

//PE & incentive tooltip function
function htmlDecode(a){var b=document.createElement("div");b.innerHTML=a;return b.childNodes[0].nodeValue;}
function wrap(argApp, argMisc, argFamily, argModel) {
	argApp = argApp.toLowerCase();
	
	var model_year = argFamily.substr(0,4);
	if (isNaN(model_year)) { model_year = ""; }
	else { argFamily = argFamily.substr(4); 	}
	
	//PE updates
	if(argApp == 'pe') overlay.build('pe',{context:{year:model_year, vehicle:argFamily}});

	//SNI updates
	else if(argApp == 'newinventory' && (argFamily =='' || !Cookie.get('zipcode'))){  overlay.build('getting-started'); }
	
	//rest of the apps
	else{
		var launchUrl = "/bridge/index.html?";
	
		if (argMisc != '' )	launchUrl += argMisc + "&";
		if (argMisc.indexOf( "zipcode" ) == -1 && !isNaN(Cookie.get('zipcode'))) { launchUrl += "zipcode=" + Cookie.get('zipcode') + "&"; }
	
		launchUrl += "app=" + argApp + "&family=" + argFamily + "&year=" + model_year;
		window.location = launchUrl;
	}
}

var overlay = {
	//scrollTo plugin
	scrollTo : function(el,speed){  var $el = jQuery(el); speed = speed||500; if($el.length>0) jQuery("html, body").animate({scrollTop:$el.offset().top-10},speed); },
	
	//holder for options pushed into build function
	options:{},
	
	//build overlay content
	build : function(app,options){
		//load blockUI plugin if not already loaded in DOM
		if(typeof(jQuery.blockUI)!="function"){
			jQuery.getScript('/crossbrand/shared/javascripts/vendor/jquery/blockUI.js',function(){ 
				//get Vehicles data file if not already loaded in DOM
				if(typeof(Vehicles)!="object"){
					jQuery.getScript('/en/includes/vehicle_data/data.js',function(){ loaded(app,options); })
				} 
				else loaded(app,options);
			});
		}
		else if(typeof(Vehicles)!="object"){
			jQuery.getScript('/en/includes/vehicle_data/data.js',function(){ loaded(app,options); })
		}
		else loaded(app,options);
		
		 
		//blockUI is now loaded
		function loaded(app,options){			 
			 switch(app){
				//getting started (AutoData - SNI)
				case 'getting-started':
				case 'newinventory':
					var defaults = { 
						app:'getting-started',
						divisionCode:Vehicles.getDivision(),
						anametrixPath: typeof(anametrixPath)=="undefined"?'':anametrixPath,
						domain:Vehicles.getBrand(), 
						year:Vehicles.getAvailableYears().length>1?Vehicles.getAvailableYears()[1]:Vehicles.getAvailableYears()[0], 
						radius:25, 
						zipCode:(Cookie.get('zipcode')!=false?Cookie.get('zipcode'):''), 
						overlayWidth:1000 
					};
					overlay.options = jQuery.extend(defaults, options);
					
					//set as var to calc margin-left dynamically
					var defaultCss = {'position':'absolute','width':overlay.options.overlayWidth+'px','margin-left':'-'+overlay.options.overlayWidth/2+'px','left':'50%','top':'5%','text-align':'left','background':'transparent','border':'none'},
						params = '?';
					
					for(p in overlay.options){ params += '&'+p+'='+overlay.options[p]; }
					
					jQuery.blockUI({ 
						//overlay css
						css: defaultCss,
						
						//overlay fadeIn speed
						fadeIn: 1000, 
						
						message:'&nbsp;',
						
						//IE Fix
						centerY : false,
						centerX : false,
						
						//overlay init callback
							onBlock: function() { 
								//overlay.ajaxRequest('/hostc/sni/getstarted.do'+params); 
								overlay.ajaxRequest('/crossbrand/en/sni/sni_form.html');
							}
					});//end blockUI				
				break;
				
				//payment estimator
				case 'pe':
					var defaults = { app:'pe',changeZip:true, changeVehicle:true, displayVehicleName:false, displayVin:false, applyBtn:false, overlayWidth:760 };
					overlay.options = jQuery.extend(defaults, options);
					
					//set as var to calc margin-left dynamically
					var defaultCss = {'position':'absolute','width':overlay.options.overlayWidth+'px','margin-left':'-'+overlay.options.overlayWidth/2+'px','left':'50%','top':'5%','text-align':'left'};
									
					jQuery.blockUI({ 
						//overlay css
						css: defaultCss,						
						//overlay fadeIn speed
						fadeIn: 1000, 						
						//IE Fix
						centerY : false,
						centerX : false,
						//overlay init callback
						onBlock: function() { overlay.ajaxRequest('/crossbrand/en/payment_estimator/form.html');
							}
					});//end blockUI				
				break;
				
				//get a quote
				case 'gaq':
					//un-comment when ready to deploy
					var defaults = {  app: 'gaq', calling_app: '', ccode: '', llp: '', vin: '', dealer_id: '', dealer_name: '', dealer_address: '', dealer_city: '', dealer_state: '', dealer_zip: '', dealer_phone: '', dealer_url: '', overlayWidth: 600 };
					
					overlay.options = jQuery.extend(defaults, options);
			
					//set as var to calc margin-left dynamically
					var defaultCss = {'position':'fixed','width':overlay.options.overlayWidth+'px','margin-left':'-'+overlay.options.overlayWidth/2+'px','left':'50%','top':'5%','text-align':'left'};
					
					jQuery.blockUI({ 
						//overlay css
						css: defaultCss,
						
						//overlay fadeIn speed
						fadeIn: 1000, 
						
						//IE Fix
						centerY : false,
						centerX : false,
						
						//overlay init callback
						onBlock: function() { overlay.ajaxRequest('/crossbrand/en/gaq/form.html',false); 								
								}
					});//end blockUI				
				break;
				
				//default
				default:
					var defaults = { app:'custom', overlayWidth:800 }; 
					overlay.options = jQuery.extend(defaults, options);
					
					var defaultCss = {'position':'absolute','width':overlay.options.overlayWidth+'px','margin-left':'-'+overlay.options.overlayWidth/2+'px','left':'50%','top':'5%','text-align':'left'};

					jQuery.blockUI({ 
						//overlay css
						css: defaultCss,
						//overlay fadeIn speed
						fadeIn: 1000, 
						
						//IE Fix
						centerY : false,
						centerX : false,
						
						//overlay init callback
						onBlock: function() { overlay.ajaxRequest(app); }
					});//end blockUI
				break;
			}//end switch
		}//end loaded function
	},//end build
	ajaxRequest : function(url,scroll){ jQuery.get(url, function(data) { jQuery('.blockMsg').html(data); }); if(scroll!==false) this.scrollTo('.blockMsg'); }
};

//wrapper functions for AutoData SNI
function SNI_closeGetStartedOverlay(){ jQuery.unblockUI(); }
function SNI_loadGetStartedOverlay(divisionCode, year, domain, radius, zipCode){ 
	        jQuery.get("/hostc/sni/getstarted.do?divisionCode="+divisionCode+"&year="+year+"&domain="+domain+"&radius="+radius+"&zipCode="+zipCode, function(data) {
					jQuery('.blockMsg').html(data);});
}
//end AutoData SNI wrapper functions

var Cookie = {
    options: {
        domain: false,
        path: false,
        duration: false,
        secure: false
    },
    set: function (key, value, options) {
        options = jQuery.extend(this.options, options);
        value = encodeURIComponent(value);
        if (options.domain) value += '; domain=' + options.domain;
        if (options.path) value += '; path=' + options.path;
        if (options.duration) {
            var date = new Date();
            date.setTime(date.getTime() + options.duration * 24 * 60 * 60 * 1000);
            value += '; expires=' + date.toGMTString()
        }
        if (options.secure) value += '; secure';
        document.cookie = key + '=' + value;
        return true;
    },
   get: function(name){
			var value = document.cookie.match('(?:^|;)\\s*' + name.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1') + '=([^;]*)');
			return value ? decodeURIComponent(value[1]) : false;
	}
};
function check_zip() {
	try {
		if (!Cookie.get('zipcode')) {
			var ct_akamai = Cookie.get('CT_Akamai');
			var zip = ct_akamai.match(/zip=(\d{5})/i);
			Cookie.set('zipcode', zip[1], {path: '/'});
		}
	} catch(e) {
		return;
	}
}
check_zip();

function getParameter(aP){var qS = new String(location.search.substring(1,location.search.length));var p = qS.split("&");var val = "";if(aP){for(i=0;i<p.length;i++){if(p[i].split( "=" )[0] == aP){val = p[i].split( "=" )[1];}}return val;}}

function flexWin(aU,aS,aW,aH,aN,aO,aX,aY,aC){
	var wN = aN ? aN : "myWin" + nocacheRandom();
	var oV = aO == "all" ? 1 : 0;
	var oS = "history="+oV+",toolbar="+oV+",location="+oV+",directories="+oV+",status="+oV+",menubar="+oV+",resizable="+oV;
	var wO = aO != "all" ? aO : oS;
	var wW = aW ? aW : 800;wO += ",width=" + wW;
	var wH = aH ? aH : 600;wO += ",height=" + wH;
	var sB = ",scrollbars="+aS;wO+=sB;
	var wX = aX ? aX :(screen.availWidth-wW)/2;wO+=",left="+wX+",screenX="+wX;
	var wY = aY ? aY :((screen.availHeight-wH)/2)-40;wO+=",top="+wY+",screenY="+wY;
	//temporary code for 9/15 to handle CF integration from MoMS Pmt Est buttons
 //to be removed for M09 when those pages are generated.
	if (aU.indexOf("tname=cf_payment") > -1){ wrap('cf_pmt_est','zipcode='+populate_zip,cur_year+cur_vehicle,''); } 
 	else {
		window.open(aU,wN,wO);
		aC ? window.close():"";
 	}
}

