﻿
$(document).ready(function () {
    $('#ctl00_btnSubmit').click(function (e) {
        if ($('#ctl00_txtName').val().length == 0) {
            e.preventDefault();
            $('#ctl00_txtName').addClass('invalid');
        } else {
            $('#ctl00_txtName').removeClass('invalid');
        }
        if ($('#ctl00_txtEmail').val().length == 0) {
            e.preventDefault();
            $('#ctl00_txtEmail').addClass('invalid');
        } else {
            $('#ctl00_txtName').removeClass('invalid');
        }
    });
    $('#aViewerClose').click(function (a) {
        a.preventDefault();
        closeViewer();
    });
    $('a[href*="/Videos/"]').click(function (a) {
        a.preventDefault();
        var href = $(this).attr('href');
        showVideo(href);
    });
    $('a[href*="youtube.com"]').click(function (a) {
        if ($(this).attr('rel') != 'ignore') {
            a.preventDefault();
            var href = $(this).attr('href');
            showVideo(href);
        }
    });
    $('a[href*="olls.nacva"]').click(function (a) {
        a.preventDefault();
        var href = $(this).attr('href');
        showVideo(href);
    });
    $('#tagbar a').click(function (a) {
        a.preventDefault();
        $('#content').css('z-index', '11');
        $('#tagviewer').css('display', 'block').animate({ left: '50%' }, 1000);
        $('#mask').css('display', 'block');
        var hash = $(this).attr('href').substring(1);
        $('#tagviewer span').hide();
        $('#tagviewer #sp' + hash).show();
    });
    $('a.tagviewer').click(function (a) {
        a.preventDefault();
        $('#content').css('z-index', '11');
        $('#tagviewer').css('display', 'block').animate({ left: '50%' }, 1000);
        $('#mask').css('display', 'block');
        var hash = $(this).attr('href').substring(1);
        $('#tagviewer span').hide();
        $('#tagviewer #sp' + hash).show();
    });
    $('#aTagViewerClose').click(function (a) {
        a.preventDefault();
        closeTagViewer();
    });
    $('a[id$=CallUs]').click(function (a) {
        a.preventDefault();
        $('#content').css('z-index', '11');
        $('#callus').css('display', 'block').animate({ left: '50%' }, 1000);
        $('#mask').css('display', 'block');
    });
    $('#callus > div > div > a').click(function (a) {
        a.preventDefault();
        $('#content').css('z-index', '');
        $('#callus').css('display', 'none').css('left', '-100%');
        $('#mask').css('display', 'none');
    });
});
function closeViewer() {
    $('#content').css('z-index', '');
    $('#viewer').css('display', 'none').css('left', '-400px');
    $('#mask').css('display', 'none');
    $('#viewer span').html('').removeClass('flash-replaced');
}
function closeTagViewer() {
    $('#content').css('z-index', '');
    $('#tagviewer').css('display', 'none').css('left', '-400px');
    $('#mask').css('display', 'none');
}
function showVideo(href) {
    $('#content').css('z-index', '11');
    $('#viewer').css('display', 'block').animate({ left: '50%' }, 1000);
    $('#mask').css('display', 'block');
    $('#viewer span').flash({ src: href, width: 780, height: 400 }, { version: 8 });
}
