/*

	Filename             screen-script.js
	Detail               Screen functionality
	Author:              thunder::tech inc.
	License:             CLIENT is defined as the owner of online property from which this file resides or this code is referenced in.
						 ADDITIONAL PARTY is defined as anyone other than thunder::tech or CLIENT.
						 No right is granted to ADDITIONAL PARTY to sell, distribute, modify or otherwise transfer the following source code without explicit written permission by CLIENT or thunder::tech.

*/

/*  ================================
     Sitewide JavaScript
    ================================ */

var ua = {}, KalinichFence = {};

ua.window = $(window);
ua.document = $(document);

KalinichFence.pageReady = function()
{
	$('.menu-dropdown').add('.menu-dropdown a').append('<span class="menu-cap menu-cap-top"></span><span class="menu-cap menu-cap-bottom"></span><span class="menu-cap menu-cap-left"></span><span class="menu-cap menu-cap-right"></span>');
	KalinichFence.headerImageContainer = $('#header-images');
	KalinichFence.headerImages = KalinichFence.headerImageContainer.children();
	KalinichFence.headerImages.filter('#banner-'+KalinichFence.headerImageContainer.attr('thunder:default')).addClass('default-header-image');
	KalinichFence.distributorSlider = $('#distributors-slider');
	$('#distributors-left-arrow').stop(true, false).css({display: 'none'});
	thunder.client.modify.treeMenu([KalinichFence.menu]);
}

KalinichFence.distributorSlide = function(n)
{
	x = parseInt(KalinichFence.distributorSlider.css('left'));
	w = parseInt(KalinichFence.distributorSlider.css('width'));
	x += (n * 150)
	if((x <= (800 - w))  && (n < 0))
	{
		x = 800 - w;
		$('#distributors-right-arrow').stop(true, false).css({display: 'none'});
	}
	else
	{
		$('#distributors-right-arrow').stop(true, false).css({display: 'block'});
	}
	if((x >= 0) && (n > 0))
	{
		x = 0; $('#distributors-left-arrow').stop(true, false).css({display: 'none'});
	}
	else
	{
		$('#distributors-left-arrow').stop(true, false).css({display: 'block'});
	}
	KalinichFence.distributorSlider.stop(true, false).animate({left: x}, {duration: 500});
}

KalinichFence.menu = {
	over: function(n)
	{
		n = $(n);
		m = KalinichFence.headerImages.filter('#banner-'+n.attr('thunder:image'));
		if(!m.hasClass('default-header-image')) m.stop(true, false).css({display: 'block', opacity: 0}).animate({opacity: 1}, {duration: 500});
	},
	out: function(n)
	{
		n = $(n);
		m = KalinichFence.headerImages.filter('#banner-'+n.attr('thunder:image'));
		if(!m.hasClass('default-header-image')) m.stop(true, false).fadeOut(500);
	}
}

$(KalinichFence.pageReady);
