var currentID = "";
function videoPlayer(url, dim){
    //-- Check to see if we have flash
    var reqMajorVer=10;
    var reqMinorVer=0;
    var reqRevision=0;
 
    var version = getFlashVersion().split(',').shift(); 
    if(version < reqMajorVer) { 
        var h = 100;
        var w = 300;
        var t = ($(window).height()-h)/2;
        var l = ($(window).width()-w)/2;

        $("body")
           .append('<div id="overlay"></div><div id="flash_container"></div>')
        $("#overlay").animate({"opacity":"0.6"}, 200, "linear");


        $("#flash_container")
            .html("We're sorry, but we require Flash version "+
                reqMajorVer +"."+ reqMinorVer +"."+ reqRevision +
                " to view these videos, and you only appear to have "+ version +".<br><br>\n"+
                "Please <a href=\"http://get.adobe.com/flashplayer/\">Upgrade Adobe Flash Player</a>\n"
            )
            .css({
                  'border': '1px solid red',
                  'background-color': '#000000',
                  'padding': '10px',
                  'top': t+'px',
                  'left': l+'px',
                  'height': h+'px',
                  'width': w+'px'
                 })
            .animate({"opacity":"1"}, 200, "linear");
        if( ($.browser.msie && $.browser.version < 7.0) ) {
            $("#flash_container").css({ 'position': 'absolute' });
        }

        //-- Allow the lightbox to be closed
        $("#overlay").click(function(){
            $("#flash_container, #overlay").remove();
        });
    } else {
        //-- Determine the size of the the video based on the filename
        var a = dim.split('x');
        var w=parseInt(a[0])+4, h=parseInt(a[1])+5;
        //alert("width:"+w+"\nheight:"+h);
   

        //-- Determine where to place the video based on the size of the video
        var t = ($(window).height()-h)/2;
        var l = ($(window).width()-w)/2;
   
        $("body")
           .append('<div id="overlay"></div><div id="flash_container"></div>')
        $("#overlay").animate({"opacity":"0.6"}, 200, "linear");
   
        //-- Load the flash player and make it visiable
        $("#flash_container")
            .flash({
                src: '/player.swf',
                width: w,
                height: h,
                wmode: 'transparent',
                flashvars: { 
                    videoURL: url, 
                    scaleMode:'maintainAspectRatio', 
                    autoPlay: 'true', 
                    autoHide:"false", 
                    inkColor: '0x999999', 
                    highlightColor: '0x333333' 
                }
            })
            .css({
                'top': t+'px',
                'left': l+'px'
            })
            .animate({"opacity":"1"}, 200, "linear");
	          try {
              pageTracker._trackPageview(url);
   	        } catch(e) {
   		        //nothing here
	          }
        
        if( ($.browser.msie && $.browser.version < 7.0) ) {
            $("#flash_container").css({ 'position': 'absolute' });
        }

        //-- Allow the lightbox to be closed
        $("#overlay").click(function(){
            $("#flash_container, #overlay").remove();
        });
    }
}

function getFlashVersion(){ 
    // ie 
    try { 
        try { 
            // avoid fp6 minor version lookup issues 
            // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
            var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
            try { axo.AllowScriptAccess = 'always'; } 
            catch(e) { return '6,0,0'; } 
        } catch(e) {} 
        return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
    // other browsers 
    } catch(e) { 
        try { 


            if (navigator.plugins != null && navigator.plugins.length > 0) {
                if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                    var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                    var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                    var descArray = flashDescription.split(" ");
                    var tempArrayMajor = descArray[2].split(".");
                    var versionMajor = tempArrayMajor[0];
                    var versionMinor = tempArrayMajor[1];
                    if ( descArray[3] != "" ) {
                        tempArrayMinor = descArray[3].split("r");
                    } else {
                        tempArrayMinor = descArray[4].split("r");
                    }
                    var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
                    return flashVer = versionMajor + "," + versionMinor + "," + versionRevision;
                }
            }


        } catch(e) {} 
    } 
    return '0,0,0'; 
} 
