
// Initialization

var featuredPartnerOut = false;
var featuredSolutionOut = false;
var featuredServiceOut = false;
var featuredNewsOut = false;
var featuredProjectOut = false;
var featuredEventOut = false;
var pressReleasesOut = false;

var OPEN_CLOSE_DURATION = 0.4;


function closeAllFeaturedItemsExcept(index) {
	if ((index != 0) && (featuredPartnerOut)) {
		featuredPartnerOut = false;
		new Effect.Move('featured_partner', {x:147, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
	if ((index != 1) && (featuredSolutionOut)) {
		featuredSolutionOut = false;
		new Effect.Move('featured_solution', {x:340, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
	if ((index != 2) && (featuredServiceOut)) {
		featuredServiceOut = false;
		new Effect.Move('featured_service', {x:533, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
	if ((index != 2) && (featuredNewsOut)) {
		featuredNewsOut = false;
		new Effect.Move('featured_news', {x:533, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
	if ((index != 3) && (featuredProjectOut)) {
		featuredProjectOut = false;
		new Effect.Move('featured_project', {x:726, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
//	if ((index != 3) && (featuredEventOut)) {
//		featuredEventOut = false;
//		new Effect.Move('featured_event', {x:726, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
//	}
	if ((index != 4) && (pressReleasesOut)) {
		pressReleasesOut = false;
		new Effect.Move('press_releases', {x:919, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
		new Effect.Move('featured_webinar', {x:919, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
}

function closeAllFeaturedItems() {
	if (featuredPartnerOut) {
		featuredPartnerOut = false;
		new Effect.Move('featured_partner', {x:147, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
	if (featuredSolutionOut) {
		featuredSolutionOut = false;
		new Effect.Move('featured_solution', {x:340, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
	if (featuredServiceOut) {
		featuredServiceOut = false;
		new Effect.Move('featured_service', {x:533, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
	if (featuredNewsOut) {
		featuredNewsOut = false;
		new Effect.Move('featured_news', {x:533, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
	if (featuredProjectOut) {
		featuredProjectOut = false;
		new Effect.Move('featured_project', {x:726, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
//    if (featuredEventOut) {
//		featuredEventOut = false;
//		new Effect.Move('featured_event', {x:726, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
//	}
	if (pressReleasesOut) {
		pressReleasesOut = false;
		new Effect.Move('press_releases', {x:919, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
		new Effect.Move('featured_webinar', {x:919, y:686, mode:'absolute', duration: OPEN_CLOSE_DURATION});
	}
}

Event.observe(
	window,
	'load',
	function() {

		$('featured_partner').style.top=686;
		$('featured_solution').style.top=686;
		$('featured_service').style.top=686;
		$('featured_news').style.top=686;
		$('featured_project').style.top=686;
		//$('featured_event').style.top=686;
		$('featured_webinar').style.top=686;
		$('press_releases').style.top=686;

		Event.observe(
			'featured_partner',
			'mouseover',
			function() {
				featuredPartnerOut = true;
				new Effect.Move('featured_partner', {x:147, y:596, mode:'absolute', duration: 0.2});
				closeAllFeaturedItemsExcept(0);
			}
		);

		Event.observe(
			'featured_solution',
			'mouseover',
			function() {
				featuredSolutionOut = true;
				new Effect.Move('featured_solution', {x:340, y:596, mode:'absolute', duration: 0.2});
				closeAllFeaturedItemsExcept(1);
			}
		);

		Event.observe(
			'featured_service',
			'mouseover',
			function() {
				featuredServiceOut = true;
				new Effect.Move('featured_service', {x:533, y:596, mode:'absolute', duration: 0.2});
				closeAllFeaturedItemsExcept(2);
			}
		);

		Event.observe(
				'featured_news',
				'mouseover',
				function() {
					featuredNewsOut = true;
					new Effect.Move('featured_news', {x:533, y:596, mode:'absolute', duration: 0.2});
					closeAllFeaturedItemsExcept(2);
				}
			);

		Event.observe(
			'featured_project',
			'mouseover',
			function() {
				featuredProjectOut = true;
				new Effect.Move('featured_project', {x:726, y:596, mode:'absolute', duration: 0.2});
				closeAllFeaturedItemsExcept(3);
			}
		);
		
		/*
		Event.observe(
			'featured_event',
			'mouseover',
			function() {
				featuredEventOut = true;
				new Effect.Move('featured_event', {x:726, y:596, mode:'absolute', duration: 0.2});
				closeAllFeaturedItemsExcept(3);
			}
		);
		*/

		Event.observe(
			'press_releases',
			'mouseover',
			function() {
				pressReleasesOut = true;
				new Effect.Move('press_releases', {x:919, y:596, mode:'absolute', duration: 0.2});
				closeAllFeaturedItemsExcept(4);
			}
		);

		Event.observe(
				'featured_webinar',
				'mouseover',
				function() {
					pressReleasesOut = true;
					new Effect.Move('featured_webinar', {x:919, y:596, mode:'absolute', duration: 0.2});
					closeAllFeaturedItemsExcept(4);
				}
			);

		Event.observe('main_left_side', 'mouseover', function() { closeAllFeaturedItems(); });
		Event.observe('main_left_side_body', 'mouseover', function() { closeAllFeaturedItems(); });
		Event.observe('main_content', 'mouseover', function() { closeAllFeaturedItems(); });
		Event.observe('main_right_side_body', 'mouseover', function() { closeAllFeaturedItems(); });
		Event.observe('main_right_side', 'mouseover', function() { closeAllFeaturedItems(); });
		Event.observe('footer_left', 'mouseover', function() { closeAllFeaturedItems(); });
		Event.observe('footer_copyright', 'mouseover', function() { closeAllFeaturedItems(); });
		Event.observe('footer_black_strip', 'mouseover', function() { closeAllFeaturedItems(); });

	}
);

