﻿$(document).ready(function() {
    //$('.poweredBySitefinityLogo').remove();

    $('#nav-side li').mouseover(function() {
        var subNav = $(this).find('ul.dynamic:first');

        if (!subNav.is(':visible') && !subNav.is(':animated'))
            subNav.show('slide', { direction: 'left' }, 150);
    });

    $('#nav-side li').mouseleave(function() {
        var subNav = $(this).find('ul.dynamic:first');

        setTimeout(function() {
            if (subNav.is(':visible'))
                subNav.hide('slide', { direction: 'left' }, 150);
        }, 150);
    });

    $('a.icon-bookmark').click(function() { addToFavorite(); });
    $('a.icon-print').click(function() { window.print(); });

    //$('a.pretty-photo').prettyPhoto({ theme: 'light_rounded' });
    $('a.pretty-photo').prettyPhoto({ theme: 'light_rounded', deeplinking: false, social_tools: '' });

    $('input.hint-text').focus(function() {
        if ($(this).val() == $(this).attr('title'))
            $(this).val('');
    });

    $('input.hint-text').blur(function() {
        if ($(this).val() == '')
            $(this).val($(this).attr('title'));
    });

    $('a.scroll-to').click(function() {
        var targetSelector = '#' + $(this).attr('target');
        var targetElem = $(targetSelector);
        var targetOffset = targetElem.offset().top;

        $('html,body').animate({ scrollTop: targetOffset }, 'fast');
    });

    $('a.scroll-to-top').click(function() {
        $('html,body').animate({ scrollTop: 0 }, 'fast');
    });

    //$('table.sf_libraryGrid').prepend('<colgroup></colgroup><colgroup></colgroup><colgroup width="0"></colgroup><colgroup width="0"></colgroup><colgroup></colgroup><colgroup></colgroup><colgroup></colgroup>');
    $('table.sf_libraryGrid tr').each(function() {
        $(this).find('th,td').each(function(index) {
            if (index == 2 || index == 3)
                $(this).hide();
        });
    });
});

// Bookmark this page
// copyright 12th February 2005, 21st June 2006
// Stephen Chapman, http://javascript.about.com
// Updated for Opera 9
// You have permission to copy and use this javascript provided that
// the copyright notice is included with the script

function addToFavorite() {
    var chr = 'CTRL-D';
    var agt=navigator.userAgent.toLowerCase();

    if(agt.substr(agt.indexOf('opera')+6,1) < 9) chr = 'CTRL-T';

    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(document.title, self.location, '');
    } else if (window.external) {
        window.external.AddFavorite(self.location,document.title);
    } else {
        alert('Press '+chr+' to bookmark this page.');
    }
}

function validateNotHint(sender, args) {
    var validator = document.getElementById(sender.id);
    var control = document.getElementById(validator.controltovalidate);

    if (args.Value == $(control).attr('title'))
        args.IsValid = false;
    else
        args.IsValid = true;
}

