﻿
function setVideo(pfile, controlId,pautostart,pwidth, hdfile)
    { // autostart for autoplay set to true else flase

        var hashd = false;

        if (hdfile != null) {
            hashd = true;
        }

        if($('#'+controlId).css('display') == 'none')
        {
            $('#'+controlId).attr('style','display:block;');
        }
        
        if (pwidth == 0) { pwidth = 300; }

        $('#' + controlId).html('<div id="player_' + controlId + '"></div>');

        if (hashd) {

            jwplayer('player_' + controlId).setup({
                flashplayer: "/player.swf",
                file: pfile,
                'hd.file': hdfile,
                height: 300,
                width: pwidth,
                image: "/Images/headerDocraftsLogo.jpg",
                controlbar: 'bottom',
                screencolor: '#000',
                backcolor: '#e9e6f0',
                autostart: pautostart,
                plugins: 'hd-1'
            });
        }
        else {

            jwplayer('player_' + controlId).setup({
                flashplayer: "/player.swf",
                file: pfile,
                height: 300,
                width: pwidth,
                image: "/Images/headerDocraftsLogo.jpg",
                controlbar: 'bottom',
                screencolor: '#000',
                backcolor: '#e9e6f0',
                autostart: pautostart
            });
        }
        
        var _gaq = _gaq || [];
        _gaq.push(['_trackEvent', 'Videos', 'Project', pfile]);
    }
    
function toggleVideo(controlId)
{//Doing it like this because toggle in jquery bounces
   if($('#' + controlId).css('display') == 'none')
   {
        $('#' + controlId).fadeIn('slow'); //.attr('style','display:block')
   }
}


