﻿var currentScreen = null;
var currentTimer = null;

$(function ()
{
	//Home Page Partner Logo Scroller
	//$("div.logo_banner").smoothDivScroll();
	$("div.logo_banner:not(.partner_page)").smoothDivScroll({ autoScroll: "always", autoScrollDirection: "endlessloopright", autoScrollStep: 1, autoScrollInterval: 25 });

	//Partners Testimonials
	$(".testimonial_companies li a").click(function(e)
	{
		$("#pnlTestimonials").children("p.testimonial").addClass("hidden");

		$(".testimonial_companies li").removeClass("active");
			
		$(this).parent("li").addClass("active");

		$("#testimonial_" + $(this).attr("test")).removeClass("hidden");
	});

	if ($("#map").length >= 1)
	{
		if (GBrowserIsCompatible())
		{
			var map = new GMap2(document.getElementById("map"));
			map.setCenter(new GLatLng(42.487914, -71.197382), 15);
			map.setUIToDefault();
			var point = new GLatLng(42.487914, -71.197382);
			var marker = new GMarker(point);
			map.addOverlay(marker);
		}
	}

	$("#ulFeatures li").mouseover(function()
	{
		$(this).addClass("ui-state-hover");
	})
	.mouseout(function()
	{
		$(this).removeClass("ui-state-hover");
	})
	.click(function()
	{
		var liItem = $(this);
		$("div.feature_options").html("");
		$("div.feature_options").append(liItem.children("div").clone());

		$("div.feature_options div span").mouseover(function()
		{
			$(this).addClass("ui-state-hover");
		})
		.mouseout(function()
		{
			$(this).removeClass("ui-state-hover");
		})
		.click(function()
		{
			var lFeature = $(this);
			$("div.feature_options div span").removeClass("ui-state-active");
			lFeature.addClass("ui-state-active");

			var pnlFeatureScreen = $("#pnlFeatureScreen");
			if (currentScreen != null) pnlFeatureScreen.removeClass(currentScreen);

			currentScreen = "feature_screen_" + lFeature.attr("screen");
			pnlFeatureScreen.addClass(currentScreen);

			$("#pnlFeatureDescriptions div").hide();
			$("#pnlFeature_" + lFeature.attr("screen")).show();
		});
		
		$("#ulFeatures li").removeClass("ui-state-active");
		liItem.addClass("ui-state-active");

		$("div.feature_options div span:first").click();
	});

	$("#ulFeatures li:first").click();

	if ($("#aInteraction").length >= 1)
	{
		$("#aInteraction").lightBox({
			overlayBgColor: '#FFF',
			overlayOpacity: 0.8
		});

		$("#aArchitectureRound").lightBox({
			overlayBgColor: '#FFF',
			overlayOpacity: 0.8
		});
	}

	if ($("#pnlDynamicBlock").length >= 1)
	{
		currentTimer = window.setTimeout("SwitchHomePageFeature();", 7000);
	}
});

function SwitchHomePageFeature()
{
	window.clearTimeout(currentTimer);

	var pnlDynamicBlock = $("#pnlDynamicBlock");
	var pnlProgramDesigner = $("#pnlProgramDesigner");
	var pnlFilter = $("#pnlFilter");
	var pnlRelational = $("#pnlRelational");

	if (pnlDynamicBlock.is(":visible"))
	{
		pnlDynamicBlock.removeClass("feature_active");
		pnlProgramDesigner.addClass("feature_active");
	}
	else if (pnlProgramDesigner.is(":visible"))
	{
		pnlProgramDesigner.removeClass("feature_active");
		pnlFilter.addClass("feature_active");
	}
	else if (pnlFilter.is(":visible"))
	{
		pnlFilter.removeClass("feature_active");
		pnlRelational.addClass("feature_active");
	}
	else if (pnlRelational.is(":visible"))
	{
		pnlRelational.removeClass("feature_active");
		pnlDynamicBlock.addClass("feature_active");
	}

	currentTimer = window.setTimeout("SwitchHomePageFeature();", 7000);
}
