var current_video = "";

var video_init = function()
{
	$("div.inject_container img.watch_how").click(pop_inject_video);
        $("div.pso_moa_video img.watch_how, div.pso_moa_video a.watch_how").click(pop_video);
        $("div.small_video_container img.watch_how, div.small_video_container a.watch_how").click(pop_video);
}

var close_video = function(flash_cont, flash_cont_parent) {
    evokeModalDialog.hide(); 
    destroy_flash_element(flash_cont, flash_cont_parent);
}

var show_inject_video = function(mec_code, wt_track_playerName)
{
	mecTrack(mec_code);     // MEC tracking
    
	var flashvars = {
		configXml: file_path + "xml/data.xml",
		playerName: wt_track_playerName
	};
	var params = {};
	params.bgcolor = "#ffffff";
	var attributes = {};
	attributes.id = "flash_holder";
	swfobject.embedSWF(file_path + swf_filename, "flash_holder", wid, ht, "9.0.0", "fp_flash/expressInstall.swf", flashvars, params, attributes);
}

var show_video = function(mec_code, wt_track_videoGroupName, wt_track_videoName)
{
	mecTrack(mec_code);     // MEC tracking
        
        var flashvars = {
		serverUrl: "rtmp://cp31394.edgefcs.net/ondemand/amgen/docs-enbrel",
                movieUrl: flv_filename,
                video_group_name: wt_track_videoGroupName,
		name_of_video: wt_track_videoName
	};

	var params = {};
	params.bgcolor = "#ffffff";
	var attributes = {};
	attributes.id = "flash_holder";
	swfobject.embedSWF(file_path + swf_filename, "flash_holder", wid, ht, "9.0.0", "fp_flash/expressInstall.swf", flashvars, params, attributes);
}

var pop_inject_video = function(event)
{
	switch(this.id)
	{
		case "sureclick":
			video_popup_title = "How to Use the Enbrel<sup>&reg;</sup> (etanercept) SureClick<sup>&reg;</sup> Autoinjector";
			job_code = "MC47141-H";
                        var bottom_text = "This overview contains only injection highlights. See your health care professional for formal injection training. Please see the<br/><a href='#isi' target='_blank'>Important Safety Information</a> below and refer to the full <a href='/documents/ENBREL-Prescribing-Information.pdf' target='_blank'>Prescribing Information</a>, or view the <a href='/documents/ENBREL_piu.pdf' target='_blank'>Patient Instructions for Use</a>.";                        
                        file_path = "injection-demos/sureclick/";
			swf_filename = "sureclick_video.swf";
                        wid = "850";
                        ht = "405";
                        footer_class="gray_footer";
                        cur_vid = "sureclick";
                        mec_track_code = "deienb_NEWEnbrelInjectionSureClickVideo_6";
						wt_track_playerName = "sureclick";
			break;
		case "syringe":
			video_popup_title = "How to Use the Enbrel<sup>&reg;</sup> (etanercept) Single-use Prefilled Syringe";
			job_code = "MC47141-G";
                        var bottom_text = "This overview contains only injection highlights. See your health care professional for formal injection training. Please see the<br/><a href='#isi' target='_blank'>Important Safety Information</a> below and refer to the full <a href='/documents/ENBREL-Prescribing-Information.pdf' target='_blank'>Prescribing Information</a>, or view the <a href='/documents/ENBREL_piu.pdf' target='_blank'>Patient Instructions for Use</a>.";
                        file_path = "injection-demos/prefilled-syringe/";
			swf_filename = "prefilled_syringe_video.swf";
			wid = "850";
                        ht = "405";
                        footer_class="gray_footer";
                        cur_vid = "prefilled";
                        mec_track_code = "deienb_NEWEnbrelInjectionSingleUseSyringeVideo_6";
			wt_track_playerName = "syringe";
                        break;
		case "freehand":
			video_popup_title = "Steps for Taking Enbrel<sup>&reg;</sup> (etanercept) Using the 25-mg Multi-Use Vial Free-Hand Method";
			job_code = "MC47141-N";
                        var bottom_text = "Please see your health care professional for formal injection training. Please see the <a href='#isi' target='_blank'>Important Safety Information</a> below and refer to the full<br/><a href='/documents/ENBREL-Prescribing-Information.pdf' target='_blank'>Prescribing Information</a>, or view the <a href='/documents/ENBREL_piu.pdf' target='_blank'>Patient Instructions for Use</a>."
                        file_path = "injection-demos/free-hand/";
			swf_filename = "free_hand_video.swf";
			wid = "850";
                        ht = "405";
                        footer_class = "white_footer";
                        cur_vid = "free_hand_method";
                        mec_track_code = "deienb_NEWEnbrelInjectionVialFreeHandVideo_6";
			wt_track_playerName = "freehand";
                        break;
		case "vialadaptor":
			video_popup_title = "Steps for Taking Enbrel<sup>&reg;</sup> (etanercept) Using the 25-mg Vial Adapter Method";
			job_code = "MC47141-N";
                        var bottom_text = "Please see your health care professional for formal injection training. Please see the <a href='#isi' target='_blank'>Important Safety Information</a> below and refer to the full<br/><a href='/documents/ENBREL-Prescribing-Information.pdf' target='_blank'>Prescribing Information</a>, or view the <a href='/documents/ENBREL_piu.pdf' target='_blank'>Patient Instructions for Use</a>."
                        file_path = "injection-demos/vial-adapter/";
			swf_filename = "vial_adapter_video.swf";
			wid = "850";
                        ht = "405";
                        footer_class = "white_footer";
                        cur_vid = "vial_adapter_method";
                        mec_track_code = "deienb_NEWEnbrelInjectionVialAdapterVideo_6";
			wt_track_playerName = "vialadaptor";
                        break;                   
		default:
			video_popup_title = "";
			job_code = "";
                        var bottom_text = "";
                        file_path = "";
			swf_filename = "";
                        wid = "";
                        ht = "";
                        footer_class="";
                        cur_vid = "";
                        mec_track_code = "empty";
			wt_track_playerName = "";
	}

	evokeModalDialog.setBgColor("#ffffff");
	$("#video_title_text").html(video_popup_title);
        $("#jobcode_text").html(job_code);
        $("#bottom_text").html(bottom_text);
        $("#video_footer").removeClass();
        $("#video_footer").addClass(footer_class);
        evokeModalDialog.show("video_container");
	current_video = cur_vid;
        show_inject_video(mec_track_code, wt_track_playerName);
        event.preventDefault();
}

var pop_video = function(event)
{
	if (this.id == "vp_howworks_psa" || this.id == "vp_howworks_psa_img") {  
            video_popup_title = "How ENBREL Works";
            file_path = "videos/";
            swf_filename = "EVK_Video_Player_43.swf";
            flv_filename = "DrLeonardi_MOA_568x383_v1";
            wid = "568";
            ht = "383";
            cur_vid = "MOAvideo";
            mec_track_code = "deienb_NEWEnbrelHowEnbrelWorksVideo_6";
			wt_track_videoGroupName = "other_video";
			wt_track_videoName = "MOA";
        } else if (this.id == "vp_jack" || this.id == "vp_jack_img") {
            video_popup_title = "Jack S. ENBREL user since 2004";
            file_path = SITEROOT + "/videos/";
            swf_filename = "EVK_Video_Player.swf";
            flv_filename = "Jack_568x320_v1";
            flv_url = "";
            wid = "568";
            ht = "320";
            cur_vid = "JackSAdvocatevideo";
            mec_track_code = "empty";
			wt_track_videoGroupName = "advocate_video";
			wt_track_videoName = "JackS";			
        } else if (this.id == "vp_alex" || this.id == "vp_alex_img") {
            video_popup_title = "Alex R. ENBREL user since 2005";
            file_path = SITEROOT + "/videos/";
            swf_filename = "EVK_Video_Player.swf";
            flv_filename = "Alex_568x320_v1";
            wid = "568";
            ht = "320";
            cur_vid = "AlexRAdvocatevideo";
            mec_track_code = "deienb_NEWEnbrelAlexVideo_6";
			wt_track_videoGroupName = "advocate_video";
			wt_track_videoName = "AlexR";
        } else if (this.id == "vp_debra" || this.id == "vp_debra_img") {
            video_popup_title = "Debra J. ENBREL user since 2004";
            file_path = SITEROOT + "/videos/";
            swf_filename = "EVK_Video_Player.swf";
            flv_filename = "Debra_568x320_v1";
            wid = "568";
            ht = "320";
            cur_vid = "DebraJAdvocatevideo";
            mec_track_code = "deienb_NEWEnbrelDebraVideo_6";
			wt_track_videoGroupName = "advocate_video";
			wt_track_videoName = "DebraJ";
        } else {
            video_popup_title = "";
            file_path = "";
            swf_filename = "";
            flv_filename = "";
            wid = "";
            ht = "";
            cur_vid = "";
            mec_track_code = "empty";
			wt_track_videoGroupName = "";
			wt_track_videoName = "";		
        }

	evokeModalDialog.setBgColor("#ffffff");
	$("#video_title_text").html(video_popup_title);
        evokeModalDialog.show("video_container");
        current_video = cur_vid;
        show_video(mec_track_code, wt_track_videoGroupName, wt_track_videoName);	
        event.preventDefault();
}
