var buttons = null;
var fadeTo;
var fading = false;
var language = "en-us";
function buttonHover(sender)
{
	var buttonName = sender.id.replace("btn_", "");
	if (!buttons)
	{
		buttons = $(".imgButton");
	}
	for (var i = 0; i < buttons.length; i++)
	{	
		buttons[i].src = buttons[i].src.replace("-on", "-off");
	}
	sender.src = sender.src.replace("-off", "-on");

	fadeTo = "/site/resources/images/" + language + "/banner-{0}.jpg".replace("{0}", buttonName);
	if (!fading)
	{
		fading = true;
		$("#imgBanner").fadeOut('slow', function() {
			fading = false;
			var imgBanner = $("#imgBanner");
			imgBanner[0].src = fadeTo;
			imgBanner.fadeIn('slow');
		});
	}
}

function gotoNews(newsKey)
{
	document.location = $(".lnkMoreNews")[0].href + '#newsKey' + newsKey;
}


//Portfolio

var SWATCH_WIDTH = 560;
var SWATCH_PER_PAGE = 1;

var currentMargin = 0;
var currentIndex = 0;
function moveLeft()
{
	if (currentIndex <=  0)
	{
		currentIndex = swatches.length - SWATCH_PER_PAGE;
		movePhoto(-(SWATCH_WIDTH * (currentIndex)));
	}
	else
	{
		movePhoto(SWATCH_WIDTH);
		currentIndex--;
	}
}
function moveRight()
{
	if (currentIndex >= (swatches.length - SWATCH_PER_PAGE))
	{
		currentIndex = 0;
		movePhoto(SWATCH_WIDTH * (swatches.length - SWATCH_PER_PAGE));
	}
	else
	{
		movePhoto(-SWATCH_WIDTH);
		currentIndex++;
	}
}
function movePhoto(offset)
{
	currentMargin += offset;
	var val = currentMargin + "px";
	var duration = 1000;
	if ((offset != SWATCH_WIDTH) && (offset != -SWATCH_WIDTH))
	{
		duration = 2500;
	}
	$("#divPortfolioSlide").animate({marginLeft: val}, duration, "swing");
}


function showBackground(elts, settings, callback)
{
	//document.getElementById("divVideo").style.display = "none";
	callback();
}
function hideBackground(elts, settings, callback)
{
	//document.getElementById("divVideo").style.display = "block";
	callback();
}

$(document).ready(function () {
    $.nyroModalSettings({showBackground: showBackground, hideBackground: hideBackground});
});
