var intCounter;
var strWindowOne;
var strWindowTwo;
var intCurrWindow;
var strOperStatus;
var strJsIEWindow;
var intTotalWindows;
arrWeekendSlides = new Array(3);

intCounter = 0;
intTotalWindows = 3;
arrWeekendSlides[0] = 1;
arrWeekendSlides[1] = 2;
arrWeekendSlides[2] = 3;
strWindowOne = "";
strWindowTwo = "";
intCurrWindow = 1;
strOperStatus = "Completed";

// ***************************************************************************************************************************************
// Function :: Used to display Scroller Window / tray according to the Browser
function DispSliderWindow(strWeekendSubType)
{	
	ResetPositionsOfWindows();	
}
// ***************************************************************************************************************************************
// Function :: Check selected Tab and reset Windows accordingly
function TabSelection(strTabName)
{
	if (strOperStatus == "Completed")
	{
		if ((strTabName == "previous") || (strTabName == "next"))
		{
			if ((intCurrWindow == arrWeekendSlides[1]) && (strTabName == "previous"))
			{
				strTabName = "UKWeekends";
			}
			else if (((intCurrWindow + 1) == arrWeekendSlides[1]) && (strTabName == "next"))
			{
				strTabName = "AbroadWeekends";
			}
			else if ((intCurrWindow == arrWeekendSlides[2]) && (strTabName == "previous"))
			{
				strTabName = "AbroadWeekends";
			}
			else if (((intCurrWindow + 1) == arrWeekendSlides[2]) && (strTabName == "next"))
			{
				strTabName = "InspiredWeekends";
			}
		}
		else if (strTabName == "UKWeekends")
		{
			intCurrWindow = arrWeekendSlides[0];
		}
		else if (strTabName == "AbroadWeekends")
		{
			intCurrWindow = arrWeekendSlides[1];
		}
		else if (strTabName == "InspiredWeekends")
		{
			intCurrWindow = arrWeekendSlides[2];
		}
		
		DispTab(strTabName);
		ResetPositionsOfWindows();
	}
}
// ***************************************************************************************************************************************
// Function :: Check selected Tab and reset Windows accordingly
function DispTab(strSelTabName)
{
	if (strSelTabName == "UKWeekends")
	{
		document.getElementById('TabUKWeekends').className = "traytab on" + strSelWeekend;
		document.getElementById('TabAbroadWeekends').className = "traytab off" + strSelWeekend;
		document.getElementById('TabInspiredWeekends').className = "traytab off" + strSelWeekend;
		
		document.getElementById('LnkUKWeekends').className = "inter liber on";
		document.getElementById('LnkAbroadWeekends').className = "inter liber off"  + strSelWeekend;
		document.getElementById('LnkInspiredWeekends').className = "inter liber off"  + strSelWeekend;
	}
	else if (strSelTabName == "AbroadWeekends")
	{
		document.getElementById('TabUKWeekends').className = "traytab off" + strSelWeekend;
		document.getElementById('TabAbroadWeekends').className = "traytab on" + strSelWeekend;
		document.getElementById('TabInspiredWeekends').className = "traytab off" + strSelWeekend;
		
		document.getElementById('LnkUKWeekends').className = "inter liber off"  + strSelWeekend;
		document.getElementById('LnkAbroadWeekends').className = "inter liber on";
		document.getElementById('LnkInspiredWeekends').className = "inter liber off"  + strSelWeekend;
	}
	else if (strSelTabName == "InspiredWeekends")
	{
		document.getElementById('TabUKWeekends').className = "traytab off" + strSelWeekend;
		document.getElementById('TabAbroadWeekends').className = "traytab off" + strSelWeekend;
		document.getElementById('TabInspiredWeekends').className = "traytab on" + strSelWeekend;
		
		document.getElementById('LnkUKWeekends').className = "inter liber off" + strSelWeekend;
		document.getElementById('LnkAbroadWeekends').className = "inter liber off" + strSelWeekend;
		document.getElementById('LnkInspiredWeekends').className = "inter liber on";
	}
}
// ***************************************************************************************************************************************
// Function :: Used to reset positions of all Windows according to the current Tab selection
function ResetPositionsOfWindows()
{
	for (intCounter = 1; intCounter <= intTotalWindows; ++intCounter)
	{
		document.getElementById("SlideWindow" + intCurrWindow).style.left = 0 + "px";
		if (intCounter < intCurrWindow)
		{
			document.getElementById("SlideWindow" + intCounter).style.left = -648 + "px";
		}
		else if (intCounter > intCurrWindow)
		{
			document.getElementById("SlideWindow" + intCounter).style.left = 648 + "px";
		}
	}
}
// ***************************************************************************************************************************************
// Function :: Validate operation, mark windows to be slided and get started with sliding
function StartSliding(strOperation)
{
	if (strOperStatus == "Completed")
	{
		// Mark if this move is going to change Tab
		TabSelection(strOperation);
		
		if (strOperation == "previous")
		{
			if (intCurrWindow == 1)
			{
				//alert("You are already viewing the first window.");
			}
			else
			{
				strWindowOne = "SlideWindow" + intCurrWindow;
				intCurrWindow = intCurrWindow - 1;
				strWindowTwo = "SlideWindow" + intCurrWindow;
				
				strOperStatus = "Incomplete";
				LRSlideWindows();				
			}
		}
		else if (strOperation == "next")
		{
			if (intCurrWindow == intTotalWindows)
			{
				//alert("You are already viewing the last window.");
			}
			else
			{
				strWindowOne = "SlideWindow" + intCurrWindow;
				intCurrWindow = intCurrWindow + 1;
				strWindowTwo = "SlideWindow" + intCurrWindow;
				
				strOperStatus = "Incomplete";
				RLSlideWindows();				
			}
		}
	}
}
// ***************************************************************************************************************************************
// Function :: Used to slides winodws one after another from left to right
function LRSlideWindows()
{
	if (parseFloat(document.getElementById(strWindowOne).style.left) < 648)
	{
		$("#" + strWindowOne).animate({left : parseFloat(document.getElementById(strWindowOne).style.left) + 648 + "px"}, 800);
		$("#" + strWindowTwo).animate({left : parseFloat(document.getElementById(strWindowTwo).style.left) + 648 + "px"}, 800, function(){strOperStatus = "Completed";});		
	}
}
// ***************************************************************************************************************************************
// Function :: Used to slides winodws one after another from right to left
function RLSlideWindows()
{
	if (parseFloat(document.getElementById(strWindowOne).style.left) > -648)
	{
		$("#" + strWindowOne).animate({left : parseFloat(document.getElementById(strWindowOne).style.left) - 648 + "px"}, 800);
		$("#" + strWindowTwo).animate({left : parseFloat(document.getElementById(strWindowTwo).style.left) - 648 + "px"}, 800, function(){strOperStatus = "Completed";});
	}
}
// ***************************************************************************************************************************************
