
// this function is caught by the JavascriptView object of the player.
function sendEvent(typ,prm) { thisMovie("mediaplayer").sendEvent(typ,prm); };

// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
};

	$(document).ready(function(){ 
		

		$("#ClosePopUpVideo").click(function(e){
				e.preventDefault();
				closePopup();
		});

		$("#OpenPopUpVideo").click(function(e){
				e.preventDefault();
				loadPopup();
				centerPopup();
		});

		$("#physiciansearch_similar_names_link").click(function(e){
			var physnamDiv =$("#physiciansearch_similar_names");
			if (physnamDiv.length>0)
			{
				if ($("#physiciansearch_similar_names").is(":visible"))
				{
					$("#physiciansearch_similar_names_link").html("Click here for similar last names.");
					physnamDiv.hide();
				}
				else
				{
					$("#physiciansearch_similar_names_link").html("Click here to hide similar last names.");
					physnamDiv.show();
				}				
			}
			return false;  
		});
	});




	
		function centerPopup(){  
			//request data for centering  
			var windowWidth = document.body.clientWidth;  
			var windowHeight = document.body.clientHeight;  
			var popupHeight = $("#PopUpVideo").height();  
			var popupWidth = $("#PopUpVideo").width();  
			//centering  
			var visibleHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);

			//only need force for IE6  
			var 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;
			}
		/*
				$("#PopUpVideo").css({  
			"position": "absolute",  
			"top": windowHeight/2-popupHeight/2,  
			"left": windowWidth/2-popupWidth/2  
			});
		*/
				$("#PopUpVideo").css({  
			"position": "absolute",  
			"top": (scrollY+100),  
			"left": windowWidth/2-popupWidth/2  
			});

			$("#backgroundPopup").css({  "height": (windowHeight +scrollY) 	});  

			$("#backgroundPopup").css({  
			"width": windowWidth  
			});  

		};



		function resizeBackground()
		{
			centerPopup();
		}

		var resizeTimer = null;
		$(window).bind('resize', function() {
			if (resizeTimer) clearTimeout(resizeTimer);
			resizeTimer = setTimeout(resizeBackground, 200);
		});

		var popupStatus=0;
		function loadPopup(){
			//loads popup only if it is disabled  
			if(popupStatus==0){  
				$("#backgroundPopup").css({  
				"opacity": "0.7"  
				});  
				$("#backgroundPopup").fadeIn(1000);  
				$("#PopUpVideo").fadeIn(1);  

				popupStatus = 1;  
			}  
		}  

		function closePopup(){
			//loads popup only if it is disabled  
			if(popupStatus==1){  
				$("#backgroundPopup").css({  
				"opacity": "0.7"  
				});  
				$("#backgroundPopup").fadeOut("fast");  
				$("#PopUpVideo").fadeOut("fast");  
				popupStatus = 0;  
				sendEvent('stop');
			}  
		}  


		function PhysicianDirectoryShownPhysicianMovie(pDocKey, pDocTitle)
		{
			$("#PopUpCaptionName").html(pDocTitle);			
			var s1 = new SWFObject("/PhysiciansDirectory/Movies/Player/MediaPlayer.swf","mediaplayer","320","240","8");
			s1.addParam("allowfullscreen","true");
			s1.addVariable("width","320");
			s1.addVariable("height","240");
			s1.addVariable("javascriptid","mediaplayer");
			s1.addVariable("enablejs","true");
			s1.addVariable("file","/PhysiciansDirectory/Movies/Media/" + pDocKey + ".flv");
			s1.addVariable("image","/PhysiciansDirectory/Movies/Media/" + pDocKey +".jpg");
			s1.write("PopUpVideoSWF");
			loadPopup();
			centerPopup();
		}

