$(window).load(function () {
    ResizeContainer();
});

$(document).ready(function() {
    var nav = window.location.pathname;
    $('ul[id^="ni"] li[^="link"] a[href$="' + nav + '"] ').addClass('activeLink');
});

function SetActiveLink(id)
{
    $('#' + id + ' a').addClass('activeLink');
}

function ResizeContainer()
{  
    var difference = 0;
    
    $('div[id^="mod"]').each(function()
    {
        var currentDifference = parseInt($(this).height() - $(this).css('min-height').replace('px', ''));
        
        if(currentDifference > difference)
        {
            difference = currentDifference;
        }
    });
    
    $('#container').height($('#container').height() + difference);
}

function ResizeModule(name, type)
{
    if(type == 'Form')
    {
        if (typeof(Page_Validators) != 'undefined') 
        {
            if(!Page_IsValid)
            {
                if(!$('.' + name).parent().attr('style'))
                {
                    var offset = 10; 
                    var numberOfValidators = $('span[id*="RequiredFieldValidator"]').length;
                
                    $('.' + name).parent().height($('.' + name).parent().height() + (offset * numberOfValidators));
                    ResizeContainer();
                }
            }
        }
   }
   else
   {
       var spaceBetweenContainer = 10;
       var newHeight = parseInt($(name).height()) + parseInt($(name).css('top').replace('px', '')) + spaceBetweenContainer;
       $('#container').height(newHeight);
   }
}

function ClearInputText(selector)
{
    $(selector).val('');
}

function SetCursorToEndOfText(textControlID)
{
    var text = document.getElementById(textControlID);
    
    if (text != null && text.value.length > 0)
    {
        if (text.createTextRange)
        {
            var fieldRange = text.createTextRange();
            fieldRange.moveStart('character', text.value.length);
            fieldRange.collapse();
            fieldRange.select();
        }
    }
}

String.prototype.endsWith = function(a){ return this.substr(this.length - a.length) === a; }
String.prototype.startsWith = function(a){ return this.substr(0, a.length) === a; }
String.prototype.trim = function(){ return this.replace(/^\s*/, '').replace(/\s*$/, ''); }
String.prototype.trimEnd = function(){ return this.replace(/\s+$/, ""); }
String.prototype.trimStart = function(){ return this.replace(/^\s+/, ""); }

function ShowFullImage(imageSelector)
{
    $(imageSelector).fadeIn(500);
}

function HideFullImage(imageSelector)
{
    $(imageSelector).hide();
}
$(document).ready(function() {
	$('#slideshowHolderEquipment').jqFancyTransitions({
		width: 979,
		height: 186,
		strips: 22, // number of strips
		delay: 3000, // delay between images in ms
		stripDelay: 50, // delay beetwen strips in ms
		titleOpacity: 0.0, // opacity of title
		titleSpeed: 500, // speed of title appereance in ms
		position: 'alternate', // top, bottom, alternate, curtain
		direction: 'fountainAlternate', // left, right, alternate, random, fountain, fountainAlternate
		navigation: true, // prev and next navigation buttons
		links: false // show images as links
	 });
});
$(document).ready(function() {
	$('#slideshowHolder').jqFancyTransitions({
		width: 941,
		height: 362,
		strips: 22, // number of strips
		delay: 3000, // delay between images in ms
		stripDelay: 50, // delay beetwen strips in ms
		titleOpacity: 0.0, // opacity of title
		titleSpeed: 500, // speed of title appereance in ms
		position: 'alternate', // top, bottom, alternate, curtain
		direction: 'fountainAlternate', // left, right, alternate, random, fountain, fountainAlternate
		navigation: true, // prev and next navigation buttons
		links: false // show images as links
	 });
});
