﻿$(function() {
	$("#inline-video-container .close").click(handleClose_Click);
	$("img[flv]").each(function() {
		$(this).css("cursor", "pointer");
		$(this).click(showVideo);
	});
});
function handleClose_Click()
{
	showModal('modalSubmission');
}
function showVideo(sender)
{
    try
    {
        //sender.href = 'http://smu.prod.atomicplaypen.net/Resources/Images/3056.swf';
        //sender.href = 'http://www.mediacollege.com/video/format/windows-media/streaming/videofilename.wmv';
        var swfPath = "Resources/swf/VideoPlayer.swf";
		var flvPath = $(this).attr("flv");
        var vWidth = '660';
        if($(this).attr("videoWidth") != null)
        {
			vWidth = $(this).attr("videoWidth");
        }
        var vHeight = '500';
        if($(this).attr("videoHeight") != null)
        {
			vHeight = $(this).attr("videoHeight");
        }

        var so = new SWFObject(swfPath, "test title", vWidth, vHeight, "7", "#000000");  
        showModal('modalSubmission');
		so.addVariable("VideoPath", flvPath); 
        so.write("vcontainer"); 
        
        
    }
    catch (e) 
    {
        alert(e);
    }
    
    return false;
}
function showModal(ref){
	var element = $("#"+ref);
    if (element.css("display") == "block")
    {
        element.css("display", "none");
    } 
    else 
    {
		element.css("top", getScrollY());
		element.css("display", "block");
		element.height($(window).height());
		//$("#modalBackground").fadeTo("slow", 0.7);
		$("#inline-video-container").fadeIn();
		$(window).scroll(function () { document.getElementById('modalSubmission').style.top = getScrollY(); });
    }
}
function getScrollY(){
    scrollY = 0;
    if ( document.documentElement && document.documentElement.scrollTop )
    {
        scrollY = document.documentElement.scrollTop;
    }else if ( document.body && document.body.scrollTop )
    {
        scrollY = document.body.scrollTop;
    }else if ( window.pageYOffset )
    {
        scrollY = window.pageYOffset;
    }else if ( window.scrollY )
    {
        scrollY = window.scrollY;
    }
    return scrollY + "px";
}
