var popupStatus = 0;
var imagePopupStatus = 0;
var chartPopupStatus = 0;
var mediaPopupStatus = 0;
var webcamPopupStatus = 0;
var slideShowPopupStatus = 0;

var myjCarousel1 = null;
var myjCarousel2 = null;
var myjCarousel3 = null;
var myjCarousel4 = null;

var videoUrl = "";

$(document).ready(function() 
{
    $("#popupClose").click(function() 
    {
        disablePopup();
    });  
    
    $('.popupClose').live('click', function() 
    {
      disablePopup();
    });

    $(".popupClosePhoto").click(function() 
    {
        disablePopup();
    });   
    
    $("#backgroundPopup").click(function() 
    {
        disablePopup();
    });


	$(".barker-vidbox").live('click', function(event) 
	{
		event.preventDefault();

		var desc = $(this).next().html();
        var downloadLink = $(this).next().next().html();
        var movieurl = $(this).attr("href");
        videoUrl = movieurl;
        var swfID = downloadLink; //path to video
        var swfDATE = ""; //$(this).attr("title");
        var docScrollTop = $(document).scrollTop(); //Gets Scroll position
        var clickcoordinate = event.pageY; //Gets position where the click happene
        loadbarkerVidPopup(swfID, swfDATE, docScrollTop, clickcoordinate, movieurl);  //LOADING POPUP
	});


	$(".webcam-box").live('click', function(event) 
	{
		event.preventDefault();

        var docScrollTop = $(document).scrollTop(); //Gets Scroll position
        var clickcoordinate = event.pageY; //Gets position where the click happene
        loadWebcamPopup(docScrollTop, clickcoordinate);  //LOADING POPUP
	});


	//Procure Chart Enlarge Click Handler
	$(".procure-chartenlarge").live('click', function() 
	{
		var imgSRC = $(this).attr("src");
		imgSRC = imgSRC.substr(0, imgSRC.length - 4);
		var imgALT = $(this).attr("alt");
		var docScrollTop = $(document).scrollTop(); //Gets Scroll position
		
		var img = new Image();
		
		img.onload = function() 
		{ 
		    var imgWidth = img.width;
		    var imgHeight = img.height;
		    var displayImage = img.src;
		    loadChartPopup(displayImage, imgALT, imgHeight, imgWidth, docScrollTop);  //LOADING POPUP
    	};
		
		img.src = imgSRC+"-large.jpg";
	});
   

    var procureCurrentGalleryElement;
	
	//Procure PhotoTour Click Handler
    $(".procure-imagebox-phototour").click(function() 
    {
        procureCurrentGalleryElement = this;
		var imgTitle = $(this).attr("alt");
        procureSetInfoGalleryPopup(procureCurrentGalleryElement, imgTitle);
    });


    function procureGetGalleryElements(inP) 
    {
        var elList = $(".procure-gallery-item");
        
    }


	//Procure PhotoTour Invoke Popup
    function procureSetInfoGalleryPopup(el, imgTitle) 
    {
        var display = $(el).parent().children(".procure-gallery-disp").html();
        var title = $(el).parent().children(".procure-gallery-title").html();
        var desc = $(el).parent().children(".procure-gallery-desc").html();
        var downloadLink = $(el).parent().children(".procure-gallery-org").html();

		popIsOpen = true;

        var img = new Image();
		var imgSRC = display;
        var imgALT = title;
        imgSRC = "/" + imgSRC.substr(0, imgSRC.length - 4);
        var docScrollTop = $(document).scrollTop(); //Gets Scroll position

		img.onload = function() 
		{
			var imgWidth = img.width; //$(this).width();
			var imgHeight = img.height; //$(this).height();
		
		    loadIMGPopup(imgSRC, imgALT, imgWidth, imgHeight, docScrollTop, downloadLink, desc, imgTitle);  //LOADING POPUP  
		}

        img.src = "/" + display;
    }


    $(".image-link-lightbox-click").live('click', function() 
    {
        var img = $(this).parent().parent().parent().children(':first-child').html();
        //var img = $(this).parent().parent().parent().parent().children(':first-child').children(':first-child').html();
        var desc = $(img).next().html();
        var downloadLink = $(img).next().next().html();
        var display = $(img).next().next().next().attr("src");
        //display = display.substr(0, display.length - 4);
        var img = new Image();
        var imgSRC = display; //$(this).attr("src");
        imgSRC = imgSRC.substr(0, imgSRC.length - 4);
        var imgALT = $(this).attr("alt");
        var docScrollTop = $(document).scrollTop(); //Gets Scroll position

        img.onload = function() 
        {
		    var imgWidth = img.width; //$(this).width();
		    var imgHeight = img.height; //$(this).height();
    	
	        loadMediaPopup(imgSRC, imgALT, imgWidth, imgHeight, docScrollTop, downloadLink, desc);  //LOADING POPUP  
		}

        img.src = display;
    });


	//Procure Media Image Click Handler
    $('.procure-imagebox').live('click', function() 
    {
        // Live handler called.
        var desc = $(this).next().html();
        var downloadLink = $(this).next().next().html();
        var display = $(this).next().next().next().attr("src");
        //display = display.substr(0, display.length - 4);

        var img = new Image();
        var imgSRC = display; //$(this).attr("src");
        imgSRC = imgSRC.substr(0, imgSRC.length - 4);
        var imgALT = $(this).attr("alt");
        var docScrollTop = $(document).scrollTop(); //Gets Scroll position

		img.onload = function() 
		{
			var imgWidth = img.width; //$(this).width();
			var imgHeight = img.height; //$(this).height();
		
		    loadMediaPopup(imgSRC, imgALT, imgWidth, imgHeight, docScrollTop, downloadLink, desc);  //LOADING POPUP  
		}

        img.src = display;
    });


	$(".video-link-lightbox-click").live('click', function(event) 
	{
        //$(this).parent().parent().parent().parent().find('.procure-vidbox').click();

        var img = $(this).parent().parent().parent().children(':first-child').html();
        //alert(img);
        var desc = $(img).next().html();
        var downloadLink = $(img).next().next().html();
        var movieurl = $(img).next().next().next().html();

        $("#popupVideoDescription").html(desc);
        $("#popupVideoDownload").html('<h3  class="press-release-title-lightbox"><a href="'+downloadLink+'">Download</a></h3>');

        var swfID = downloadLink; //path to video
        var swfDATE = ""; //$(this).attr("title");
        var docScrollTop = $(document).scrollTop(); //Gets Scroll position
        var clickcoordinate = event.pageY; //Gets position where the click happene
        loadPopup(swfID, swfDATE, docScrollTop, clickcoordinate, movieurl);  //LOADING POPUP
    });


	//Procure Media Video Click Handler
    $(".procure-vidbox").live('click', function(event) {

        var desc = $(this).next().html();
        var downloadLink = $(this).next().next().html();
        var movieurl = $(this).next().next().next().html();
        
        $("#popupVideoDescription").html(desc);
        $("#popupVideoDownload").html('<h3  class="press-release-title-lightbox"><a href="'+downloadLink+'">Download</a></h3>');

        event.preventDefault();
        var swfID = downloadLink; //path to video
        var swfDATE = ""; //$(this).attr("title");
        var docScrollTop = $(document).scrollTop(); //Gets Scroll position
        var clickcoordinate = event.pageY; //Gets position where the click happene
        loadPopup(swfID, swfDATE, docScrollTop, clickcoordinate, movieurl);  //LOADING POPUP
    });


    $(".barker-slideshowbox").click(function(event)
    {
        event.preventDefault()						
        var slideShowId = "#"+$(this).attr("href")
        var docScrollTop = $(document).scrollTop()
        var clickcoordinate = event.pageY;
        loadSlideShowPopup(slideShowId, docScrollTop)
    });
});


// Procure Patient Story Slideshow Popup
function loadSlideShowPopup(slideShowId, docScrollTop) 
{	
	var winH = $(window).height()
	var winW = $(window).width()		
	var posTop = winH / 2 - $(slideShowId).height() / 2 + docScrollTop
	var posLeft = winW / 2 -  $(slideShowId).width() / 2
	$(slideShowId).css('top', posTop)
	$(slideShowId).css('left', posLeft)	
	
	if(slideShowPopupStatus == 0)	
	{		
		$("#backgroundPopup").css({"opacity": "0.7"})
		$("#backgroundPopup").fadeIn("slow")		
		$(slideShowId).fadeIn("slow")		
		slideShowPopupStatus = 1
		//alert(slideShowPopupStatus)
    }
	
	$(window).resize(function() 
	{				
		var newWinW = $(window).width()		
		var newPosLeft = newWinW / 2 - $(slideShowId).width() / 2
		$(slideShowId).css('left', newPosLeft)
	});

		popIsOpen = true;
}
 

//Procure Barker Video Popup
function loadWebcamPopup(docScrollTop, clickcoordinate) 
{
	var winH = $(window).height();
	var winW = $(window).width();
	popIsOpen = true;

	//Determine positioning based on user scrolling
	$('#popupWebcam').css('top', (winH / 2 - $('#popupWebcam').height() / 2) + docScrollTop);
	$('#popupWebcam').css('left', winW / 2 - $('#popupWebcam').width() / 2);

	$(window).resize(function() 
	{
		var newwinW = $(window).width();
		$('#popupWebcam').css('left', newwinW / 2 - $('#popupWebcam').width() / 2);
	});
	
	if(webcamPopupStatus==0)
	{
		$("#backgroundPopup").css({"opacity": "0.7"});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupWebcam").fadeIn("slow");
		webcamPopupStatus = 1;
	}
}


//Procure Barker Video Popup
function loadbarkerVidPopup(swfID, swfDATE, docScrollTop, clickcoordinate, movieurl) 
{
	var winH = $(window).height();
	var winW = $(window).width();
	var descH = 200;

	popIsOpen = true;
	formIsOpen = true;

	$("#popupVideo").css("width", "542px");
    $('#popupVideo').css('height', "376px");
	//Determine positioning based on user scrolling
	$('#popupVideo').css('top', (winH / 2 - $('#popupVideo').height() / 2) + docScrollTop);
	$('#popupVideo').css('left', winW / 2 - $('#popupVideo').width() / 2);

	$(window).resize(function() 
	{
		var newwinW = $(window).width();
		$('#popupVideo').css('left', newwinW / 2 - $('#popupVideo').width() / 2);
	});
	
	if(popupStatus == 0)
	{
		$("#backgroundPopup").css({"opacity": "0.7"});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupVideo").fadeIn("slow");
		popupStatus = 1;
		var finalID = "movies\\" + swfID + ".swf";
		$("#popup-bottom-interior").prepend('<div id="video-holder-interior"></div>');
		$("#popup-bottom-interior").append('<p class="video-date-interior">' + swfDATE + '</p>');
     
        playVideo(movieurl);
	}
}

/* MPH code */
function isValidEmail(val)
{
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;

    if (!val.match(re)) 
    {
        return false;
    } 
    else 
    {
        return true;
    }
}


function shareVideo() 
{
    var url_shareVideo = "/Portals/_default/Skins/procure/includes/videoShare.htm"; // can change to Controls/file
	//var url_shareVideo = "/csControls/VideoShare.ascx"; 
    $('#video-holder-interior').hide(); 
    $('.shareLink').hide(); 
	$('#popupVideo').append( $('<div></div>').attr("id","shareContainer") ); 
	
	$('#popupVideo').css({height:"420px",width:"730px" }); 
	
	$('#shareContainer').html("loading..."); 
	$('#shareContainer').load(url_shareVideo, function() 
	{
		formatShareButtons(); 
	}); 
}


function formatShareButtons(youtube,vidtitle) 
{
    var PATIENT_STORIES_URL = "http://www.procure.com/PatientStories.aspx?video=";
    
    var title = encodeURIComponent("Checking out this video at Procure.com");
    
    var videoId = "";
	var youtube = "";
	    
    switch (videoUrl.toLowerCase())
    {
        case "/xml/spinal_final.xml": 
            videoId = "spinal_tumor";
            youtube = "e44gupY0mVgg";
            $("#facebook-icon").attr("src", "http://www.procure.com/videos/spinaltumor_video.html");
            break;
            
        case "/xml/brain_tumor_final.xml":
            videoId = "brain_tumor";
            youtube = "e44gupY0mVgg";
            $("#facebook-icon").attr("src", "http://www.procure.com/videos/braintumorvideo.html");
            break;
            
        case "/xml/prostate_final.xml":
            videoId = "prostate_cancer";
            youtube = "e44gupY0mVgg";
            $("#facebook-icon").attr("src", "http://www.procure.com/videos/prostatecancervideo.html");
            break;
            
        case "/xml/prostate_bill_gumerson_final.xml":
            videoId = "prostate_cancer_gumerson";
            youtube = "e44gupY0mVgg";
            $("#facebook-icon").attr("src", "http://www.procure.com/videos/prostatecancervideo_gumerson.html");
            break;            
    }
    
    //
    //alert(videoUrl);
    var url = encodeURIComponent(PATIENT_STORIES_URL + videoId);
    	
 	// share on twitter
    var href_twitter  = "http://twitter.com/share?counturl=http://groups.google.com/group/twitter-api-announce&url=" + url + "&text=" + title; 
    
    $(".twitter-icon").attr("href", href_twitter);	
    $(".twitter-icon").live("click", function(event)
    {
        window.open(href_twitter, "twitter", "toolbar=no,width=550,height=550"); 
        return false;
    });    
    
    // bookmark on delicious 
    var href_delicious = "http://www.delicious.com/save?url=" + url + "&title=" + title; 
    
    $(".delicious-icon").attr("href", href_delicious);	
    $(".delicious-icon").live("click", function(event)
    {
        //event.preventDefault();
        window.open(href_delicious, "delicious", "toolbar=no,width=950,height=550"); 
        return false;
    });
        
    // youtube embed
    $('.youtube-icon').click(function() 
    {
	     $('#youtubeCode').toggle("clip"); 
	});   
	
    $("#btn_SendEmail").hover(
    function()
    {
        $(this).attr({ src : "/Portals/_default/Skins/procure/images/share-form-button-over.gif"});
    },
    function()
    {
        $(this).attr({ src : "/Portals/_default/Skins/procure/images/share-form-button.gif"});             
    });	
	
	// emailer //
	$('#btn_SendEmail').click(function() 
	{
	    var sendTo = $('#ReceiptEmailTextBox').val();
		var frommer = $('#YourEmailTextBox').val(); 
		var errors = ""; 
		
		if(!isValidEmail(sendTo)) 
		{
		  $('#receiptError').show(); 
		  errors = "Invalid send to email"; 
		} 
		else 
		{
		  $('#receiptError').hide(); 		
		}
		
		if(!isValidEmail(frommer)) 
		{
		  $('#senderError').show(); 
		  errors = "Invalid send to email"; 
		} 
		else 
		{
		  $('#senderError').hide(); 
		}
		
		if(errors=='') 
		{
		    //$('#share_via_email').html("<h3>Email Sent</h3>"); 
		    //$('#share_via_email').append("<p>An email containing a link to this video has been sent to "+sendTo+ "on behalf of "+frommer);
		  
            $.post("EmailStoryHandler.axd", 
                   { salutation: "ShareVideo",
                     firstname: $("#ReceiptEmailTextBox").val(),
                     lastname: "",
                     city: "",
                     state: "",
                     phonenumber: "",
                     email: $("#YourEmailTextBox").val(),
                     message: $("#dnn_ProcureVideoShare_PersonalMessageTextBox").val(),
                     attachmentpath: url
                     },
                function(data)
                {
                    disablePopup();
                    
                    /*
                    $("#popupPatientStory").fadeOut("slow");
                    
                    docScrollTop = $(document).scrollTop(); //Gets Scroll position
                    loadPatientStoriesThankYouPopup(docScrollTop);  //LOADING POPUP
                    */
            });		 
            
            
		}
    });	
}
/* end of MPH code */


//Procure Media Video Popup
function loadPopup(swfID, swfDATE, docScrollTop, clickcoordinate, movieurl) 
{
	var winH = $(window).height();
	var winW = $(window).width();
	var descH = 310;

	popIsOpen = true;
	formIsOpen = true;
		
	$("#popupVideo").css({ "width": "640px" });
    $('#popupVideo').css('height', descH + 400);
	//Determine positioning based on user scrolling
	$('#popupVideo').css('top', (winH / 2 - $('#popupVideo').height() / 2) + docScrollTop);
	$('#popupVideo').css('left', winW / 2 - $('#popupVideo').width() / 2);

	$(window).resize(function() 
	{
		var newwinW = $(window).width();
		$('#popupVideo').css('left', newwinW / 2 - $('#popupVideo').width() / 2);
	});
	
	if(popupStatus == 0)
	{
		$("#backgroundPopup").css({"opacity": "0.7"});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupVideo").fadeIn("slow");
		popupStatus = 1;
		var finalID = "movies\\" + swfID + ".swf";
		$("#popup-bottom-interior").prepend('<div id="video-holder-interior"></div>');
		$("#popup-bottom-interior").append('<p class="video-date-interior">' + swfDATE + '</p>');
        
        playMediaVideo(movieurl);
	}
}


//Procure PhotoTour Popup
function loadIMGPopup(imgSRC, imgALT, imgWidth, imgHeight, docScrollTop, downloadLink, desc, imgTitle) 
{
	var imagewinH = $(window).height();
	var imagewinW = $(window).width();

	popIsOpen = true;
	
	$('#popupImage').css('width', imgWidth);
	//Determine positioning based on user scrolling
	$('#popupImage').css('top', (imagewinH / 2 - imgHeight / 2) + docScrollTop);
	$('#popupImage').css('left', imagewinW / 2 - imgWidth / 2);
	$('#phototour-nav-wrapper').css('left', imgWidth/2);

	$(window).resize(function() 
	{
		var newwinW = $(window).width();
		$('#popupImage').css('left', (newwinW / 2));
	});
	
	if(imagePopupStatus == 0)
	{
		$("#backgroundPopup").css({"opacity": "0.7"});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupImage").fadeIn("slow");
		imagePopupStatus = 1;

			
		$('#PhotoTourGallery-wrapper').cycle(
		{ 
		    fx:     'fade', 
		    speed:  'fast', 
		    timeout: 0,
		    cleartype:     !$.support.opacity,  // true if clearType corrections should be applied (for IE) 
            cleartypeNoBg: true, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides) 
		    before: onPrevNext,
		    next:   '#PhotoTour-next', 
		    prev:   '#PhotoTour-prev',
		    startingSlide: imgTitle
		});
     }
}


//Procure PhotoTour Slideshow Callback
function onPrevNext(currSlideElement, nextSlideElement)  
{ 
	var getHTML = $(nextSlideElement).html();
	var getImage = $(getHTML).find("img").attr("src");
	var img = new Image();
	var newimagewinH = $(window).height();
	var newimagewinW = $(window).width();

	popIsOpen = true;

    img.src = getImage;
    var getWidth = img.width;
	var getHeight = img.height;
	
	$('#popupImage').css('width', getWidth);
	$('#popupImage').css('left', newimagewinW / 2 - getWidth / 2);
	$('#phototour-nav-wrapper').css('left', (getWidth/2)-50);
}


//Procure Media Images Popup
function loadMediaPopup(imgSRC, imgALT, imgWidth, imgHeight, docScrollTop, downloadLink, desc) 
{
	var imagewinH = $(window).height();
	var imagewinW = $(window).width();

	popIsOpen = true;
	
	//Determine positioning based on user scrolling
	$('#popupImage').css('width', imgWidth);
	$('#popupImage').css('top', (imagewinH / 2 - imgHeight / 2) + docScrollTop);
	$('#popupImage').css('left', imagewinW / 2 - imgWidth / 2);
	
	$(window).resize(function() 
	{
		var newwinW = $(window).width();
		$('#popupImage').css('left', (newwinW / 2));
	});
	
	if(mediaPopupStatus==0)
	{
		$("#backgroundPopup").css({"opacity": "0.7"});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupImage").fadeIn("slow");
		mediaPopupStatus = 1;
		
		$("#popupMedia-content").append('<img src="'+imgSRC+'.jpg"  />');
		$("#popupMedia-content").append("<p>"+desc+"</p>");
        $("#popupMedia-content").append('<a href="'+downloadLink+'" class="press-release-title-lightbox">Download</a>');
	}
}


//Procure Charts Popup
function loadChartPopup(displayImage, imgALT, imgHeight, imgWidth, docScrollTop) 
{
	var imagewinH = $(window).height();
	var imagewinW = $(window).width();

	popIsOpen = true;
	
	//Determine positioning based on user scrolling
	if(chartPopupStatus == 0)
	{
		$("#backgroundPopup").css({"opacity": "0.7"});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupChart").fadeIn("slow");
		chartPopupStatus = 1;

		$('#popupChart').css('width', imgWidth);
		$('#popupChart').css('top', (imagewinH / 2 - (imgHeight+30)/2 ) + docScrollTop);
		$('#popupChart').css('left', imagewinW / 2 - imgWidth/2);
		$("#popupChart-content").append('<img src="'+displayImage+'"/>');

		$(window).resize(function() 
		{
		    var newwinW = $(window).width();
		    $('#popupChart').css('left', newwinW / 2 - $('#popupChart').width()/2);
		});
	}
}


//Disables Popup 
function disablePopup()
{     
	if(popupStatus == 1) 
	{   
	    // clear form when close
	    $("#dnn_ProcureVideoShare_ReceiptEmailTextBox").val("");
	    $("#dnn_ProcureVideoShare_YourEmailTextBox").val("");
	    $("#dnn_ProcureVideoShare_PersonalMessageTextBox").val("");
	    
		

	    //
	    
        //$('#video-holder-interior').each(function ()
        //{
            //$(this).pauseVideo();
            //if(uvplayerSWF() != null)
            //    uvplayerSWF().pauseVideo();
            //else
            //    swfobject.removeSWF($(this).attr('id'));
        //});
        
        /*
        try
        {
            var videoObj = document.getElementById('VideoHolderInterior');
        
            if(videoObj != null)
                videoObj.pauseVideo();
        }
        catch(err)
        {}
	    */
	    
	    /*
		$("#backgroundPopup").fadeOut("slow");
		$("#popupShare").fadeOut("slow");
		popupStatus = 0;
		uvplayerSWF().startVideo();
		*/
		
		$("#video-holder-interior").empty(); //val("");
		$(".video-date-interior").empty();
		$("#shareContainer").empty("slow");
		$("#popupVideo, #backgroundPopup").fadeOut("slow");
		popupStatus = 0;
		$('#video-holder-interior').hide(); 
		//uvplayerSWF().pauseVideo(); //pauses video when popup loads		
		//uvplayerSWF().startVideo(); //pauses video when popup loads		
	
	    	   	var flashDiv = document.getElementById('video-holder-interior');
	   	var flashDivParent = document.getElementById('video-delete');
	   	
	    flashDivParent.removeChild(flashDiv);
	    flashDivParent.appendChild(flashDiv);	
	}
	
	
	if(mediaPopupStatus == 1) 
	{   
		$("#backgroundPopup").fadeOut("slow");
		$("#popupImage").fadeOut("slow", function() 
		{
			mediaPopupStatus = 0;

			$("#popupMedia-content").empty();
		});
	}   

	if(imagePopupStatus == 1) 
	{   
		$("#backgroundPopup").fadeOut("slow");
		$("#popupImage").fadeOut("slow", function() 
		{
			imagePopupStatus = 0;
		});
	}   

	if(chartPopupStatus == 1) 
	{   
		$("#backgroundPopup").fadeOut("slow");
		$("#popupChart").fadeOut("slow", function() 
		{
		    chartPopupStatus = 0;

		    $("#popupChart-content").empty(); 
		});
	}   

	if(webcamPopupStatus == 1) 
	{   
		$("#backgroundPopup").fadeOut("slow");
		$("#popupWebcam").fadeOut("slow", function() 
		{
			webcamPopupStatus = 0;
		});
	
	}
	
	if(slideShowPopupStatus == 1) 
	{	  
		$("#lightbox-slideshow-jcars").children().filter(":visible").fadeOut("slow", function()
		{
			//if(myjCarousel) { myjCarousel.scroll(1); myjCarousel = null }	
			//alert(myjCarousel1)
			if(myjCarousel1 != null) myjCarousel1.scroll(1);
			if(myjCarousel2 != null) myjCarousel2.scroll(1);
			if(myjCarousel3 != null) myjCarousel3.scroll(1);
			if(myjCarousel4 != null) myjCarousel4.scroll(1);
		});

		$("#backgroundPopup").fadeOut("slow");
		
		slideShowPopupStatus = 0;
	}

    popIsOpen = false;
    formIsOpen = true;
}  


function playVideo(xml) 
{ 
    if(xml.indexOf(".swf") > 0)
    {
		var params = {};
		params.allowfullscreen = "false";
		swfobject.embedSWF(xml, "video-holder-interior", "542", "346", "9.0.0", false, "", params);
			
	}	
	else 
	{
		var flashvars = {};
		flashvars.xmlPath = xml;
		var params = {};
		params.allowfullscreen = "false";
		var attributes = {};
		swfobject.embedSWF("/swf/UVPlayer.swf", "video-holder-interior", "542", "346", "9.0.0", false, flashvars, params, attributes);
	}
}


function playMediaVideo(xml)
{
	var flashvars = {};
	flashvars.xmlPath = xml;
	var params = {};
	params.allowfullscreen = "false";
	var attributes = {};
	swfobject.embedSWF("/swf/UVPlayer.swf", "video-holder-interior", "640", "480", "9.0.0", false, flashvars, params, attributes);
}


//gets correct video player ID
function uvplayerSWF() 
{
    //return document["patient-stories-vidplayer"];
	return document["video-holder-interior"];
} 
