// JavaScript Document

var MAX_ADV_POPUP = 7;

function removeAdvLinks(popUpNum)
{
	for (var i = 1; i <= MAX_ADV_POPUP; i++)
	{
		if (i != popUpNum)
		{
			$('#advPopup0' + i).css("display", "none");
			$('#advLink0' + i).css("color", "#ffffff");
		}
	}
}

$(document).ready(function()
{
	// exits popups using background click
	$('#smartPopupBG').click(function() {
		$('#smartPopup').fadeOut('slow');
		$('#smartPopupBG').fadeOut('slow');
		$('#advPopup').fadeOut('slow');
		
		// if in advantage & choice page, removes used link
		removeAdvLinks(0);
	});
	
	// closes advantage & choice popup using exit buttonn
	$('img.btnExit').click(function() {
		$('#smartPopupBG').fadeOut('slow');
		$('#advPopup').fadeOut('slow');
		
		// if in advantage & choice page, removes used link
		removeAdvLinks(0);
	});
	
	// shows advantage menu01 : bumper bars
	$('#advIcon01').click(function() {
		$('#smartPopupBG').fadeIn('slow');
		$('#smartPopupBG').animate({opacity:0.5}, 1000);
		$('#advPopup').fadeIn('slow');
		$('#advPopup01').fadeIn('slow');
		$('#advLink01').css("color", "#f26631");
	});
	
	$('#advLink01').click(function() {
		$('#advPopup01').fadeIn('slow');
		$('#advLink01').css("color", "#f26631");
		//this should be the whole links to remove
		removeAdvLinks(1);
   });

	// shows advantage menu02 : side mirrors
	$('#advIcon02').click(function() {
		$('#smartPopupBG').fadeIn('slow');
		$('#smartPopupBG').animate({opacity:0.5}, 1000);
		$('#advPopup').fadeIn('slow');
		$('#advPopup02').fadeIn('slow');
		$('#advLink02').css("color", "#f26631");
	});
	
	$('#advLink02').click(function() {
		$('#advPopup02').fadeIn('slow');
		$('#advLink02').css("color", "#f26631");
		//this should be the whole links to remove
		removeAdvLinks(2);
   });

	// shows advantage menu03 : alloy wheels
	$('#advIcon03').click(function() {
		$('#smartPopupBG').fadeIn('slow');
		$('#smartPopupBG').animate({opacity:0.5}, 1000);
		$('#advPopup').fadeIn('slow');
		$('#advPopup03').fadeIn('slow');
		$('#advLink03').css("color", "#f26631");
	});
	
	$('#advLink03').click(function() {
		$('#advPopup03').fadeIn('slow');
		$('#advLink03').css("color", "#f26631");
		//this should be the whole links to remove
		removeAdvLinks(3);
   });

	// shows advantage menu04 : alloy wheels
	$('#advIcon04').click(function() {
		$('#smartPopupBG').fadeIn('slow');
		$('#smartPopupBG').animate({opacity:0.5}, 1000);
		$('#advPopup').fadeIn('slow');
		$('#advPopup04').fadeIn('slow');
		$('#advLink04').css("color", "#f26631");
	});
	
	$('#advLink04').click(function() {
		$('#advPopup04').fadeIn('slow');
		$('#advLink04').css("color", "#f26631");
		//this should be the whole links to remove
		removeAdvLinks(4);
   });

	// shows advantage menu05 : alloy wheels
	$('#advIcon05').click(function() {
		$('#smartPopupBG').fadeIn('slow');
		$('#smartPopupBG').animate({opacity:0.5}, 1000);
		$('#advPopup').fadeIn('slow');
		$('#advPopup05').fadeIn('slow');
		$('#advLink05').css("color", "#f26631");
	});
	
	$('#advLink05').click(function() {
		$('#advPopup05').fadeIn('slow');
		$('#advLink05').css("color", "#f26631");
		//this should be the whole links to remove
		removeAdvLinks(5);
   });

	// shows advantage menu06 : alloy wheels
	$('#advIcon06').click(function() {
		$('#smartPopupBG').fadeIn('slow');
		$('#smartPopupBG').animate({opacity:0.5}, 1000);
		$('#advPopup').fadeIn('slow');
		$('#advPopup06').fadeIn('slow');
		$('#advLink06').css("color", "#f26631");
	});
	
	$('#advLink06').click(function() {
		$('#advPopup06').fadeIn('slow');
		$('#advLink06').css("color", "#f26631");
		//this should be the whole links to remove
		removeAdvLinks(6);
   });

	// shows advantage menu07 : alloy wheels
	$('#advIcon07').click(function() {
		$('#smartPopupBG').fadeIn('slow');
		$('#smartPopupBG').animate({opacity:0.5}, 1000);
		$('#advPopup').fadeIn('slow');
		$('#advPopup07').fadeIn('slow');
		$('#advLink07').css("color", "#f26631");
	});
	
	$('#advLink07').click(function() {
		$('#advPopup07').fadeIn('slow');
		$('#advLink07').css("color", "#f26631");
		//this should be the whole links to remove
		removeAdvLinks(7);
   });

});