﻿$(document).ready(function () {
    $('div.galBox a').fancybox();
    //video page

    //video first item
    var firstvideo = $('div.vidBox:first a').attr('rel');
    firstvideo = firstvideo.replace("<p>", "");
    firstvideo = firstvideo.replace("</p>", "");
    $('div.vidLargeHref').html('<object width="410" height="329"><param name="movie" value="' + firstvideo + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + firstvideo + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="410" height="329"></embed></object>');

    $('div.vidBox:first').addClass('vidActive');

    var thisFirstVidName = $('div.vidBox:first a').next('p').children('span.vidName').text();
    var thisFirstVidLength = $('div.vidBox:first a').next('p').children('span.vidLength').text();

    $('div.vidLarge p span.vidNameShow').text(thisFirstVidName);
    $('div.vidLarge p span.vidLengthShow').text(thisFirstVidLength);


    //video onclick function
    $('div.vidBox a').click(function () {
        var vidlink = $(this).attr('rel');
        vidlink = vidlink.replace("<p>", "");
        vidlink = vidlink.replace("</p>", "");
        $('div.vidBox').removeClass('vidActive');
        $(this).parent('div.vidBox').addClass('vidActive');

        $('div.vidLargeHref').html('<object width="410" height="329"><param name="movie" value="' + vidlink + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + vidlink + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="410" height="329"></embed></object>');
        $('body , html').animate({ scrollTop: 0 }, 'slow');

        var thisVidName = $(this).next('p').children('span.vidName').text();
        var thisVidLength = $(this).next('p').children('span.vidLength').text();

        $('div.vidLarge p span.vidNameShow').text(thisVidName);
        $('div.vidLarge p span.vidLengthShow').text(thisVidLength);
    });
}); 
    
