$(document).ready(function()
{
    RotatorStartTimeout();
    $("#Rotator-btn-Prev").click(RotatorPrev_OnClick);
    $("#Rotator-btn-0").click(Rotator0_OnClick);
    $("#Rotator-btn-1").click(Rotator1_OnClick);
    $("#Rotator-btn-2").click(Rotator2_OnClick);
    $("#Rotator-btn-3").click(Rotator3_OnClick);
    $("#Rotator-btn-Next").click(RotatorNext_OnClick);
    
    $("#Product-left").click(ProductLeft_OnClick);
    $("#Product-right").click(ProductRight_OnClick);
    $("#Industry-left").click(IndustryLeft_OnClick);
    $("#Industry-right").click(IndustryRight_OnClick);
});

function RotatorChange()
{
    $('#Rotator-wrapper').fadeOut('fast', function() {
    	$('#RotatorName').html(RotatorNames[ItemIndex]);
    	$('#RotatorImage').html(RotatorImages[ItemIndex]);
    	
    	$('#Rotator-btn-'+PrevItemIndex).removeClass('select');
    	$('#Rotator-btn-'+ItemIndex).addClass('select');

    	$('#Rotator-wrapper').fadeIn('fast');
    });
}

function RotatorBtnClick(Value)
{
	ItemIndexChange(Value);
	RotatorChange();
}

function RotatorPrev_OnClick()
{
	RotatorBtnClick(ItemIndex - 1);
}

function RotatorNext_OnClick()
{
	RotatorBtnClick(ItemIndex + 1);
}

function Rotator0_OnClick()
{
	RotatorBtnClick(0);
}

function Rotator1_OnClick()
{
	RotatorBtnClick(1);
}

function Rotator2_OnClick()
{
	RotatorBtnClick(2);
}

function Rotator3_OnClick()
{
	RotatorBtnClick(3);
}

//--
var ProductName = Array();
var ProductImage = Array();
var ProductText = Array();
var ProductURL = Array();
var ProductLeftIndex = 0;
var ProductTotal = 5;

function ProductLeft_OnClick()
{
	if(ProductLeftIndex-1<0)
		return;
	ProductLeftIndex--;
	RefreshProducts();
}

function ProductRight_OnClick()
{
	if(ProductLeftIndex+1>ProductRightIndex-ProductTotal)
		return;
	ProductLeftIndex++;
	RefreshProducts();
}
function RefreshProducts()
{
	var Row = 0;
	for(var i=ProductLeftIndex; i<ProductLeftIndex+ProductTotal; i++)
	{
		$('#Product-'+Row+'-Name').html(ProductName[i]);
		$('#Product-'+Row+'-Image').css('background-image', ProductImage[i]);
		$('#Product-'+Row+'-Text').html(ProductText[i]);
		$('#Product-'+Row+'-URL').attr('href', ProductURL[i]);
		$('#Product-'+Row+'-Image-URL').attr('href', ProductURL[i]);
		Row++;
	}
}

//--
var IndustryName = Array();
var IndustryImage = Array();
var IndustryText = Array();
var IndustryURL = Array();
var IndustryLeftIndex = 0;
var IndustryTotal = 5;

function IndustryLeft_OnClick()
{
	if(IndustryLeftIndex-1<0)
		return;
	IndustryLeftIndex--;
	RefreshIndustries();
}

function IndustryRight_OnClick()
{
	if(IndustryLeftIndex+1>IndustryRightIndex-IndustryTotal)
		return;
	IndustryLeftIndex++;
	RefreshIndustries();
}

function RefreshIndustries()
{
	var Row = 0;
	for(var i=IndustryLeftIndex; i<IndustryLeftIndex+IndustryTotal; i++)
	{
		$('#Industry-'+Row+'-Name').html(IndustryName[i]);
		$('#Industry-'+Row+'-Image').css('background-image', IndustryImage[i]);
		//$('#Industry-'+Row+'-Text').html(IndustryText[i]);
		//$('#Industry-'+Row+'-URL').css('href', IndustryURL[i]);
		Row++;
	}
}

