function playVideo(file, autoclose) {
	prepareVideo(autoclose);
	flowplayer("intro", "/Scripts/flowplayer-3.1.5.swf", {
		onLoad: function() {

		},
		clip: {
			url: file
		},
		onStop: function() {
			
			//document.getElementById("counter").style.display="block";
			//document.getElementById("ticker").style.display="block";
			//document.getElementById("intro_trailer").style.display="block";
			
			//document.getElementById("counter").style.visibility="visible";
			//document.getElementById("ticker").style.visibility="visible";
			//document.getElementById("intro_trailer").style.visibility="visible";
			
			//document.getElementById("vback").style.display="none";
			//document.getElementById("embedvideo").style.display="none";
			
			jQuery("#counter").fadeIn(700);
		   	jQuery("#ticker").fadeIn(700);
		   	jQuery("#intro_trailer").fadeIn(700);
		   	
			jQuery("#embedvideo").fadeOut(700);
//			document.getElementById("embedvideo").style.display="none";
			jQuery("#vback").fadeOut(700);
		},
		onFinish: function() {
			if (autoclose == true) {
                closeVideo();
              }

        },
        plugins: {
        	controls: null
                }
	});
	//document.getElementById("embedvideo").style.display="block";
}

function playMovie(file, element){
	flowplayer(element, "/Scripts/flowplayer-3.1.5.swf", {
		clip: {
		url: file
		},
		plugins: {
        	controls: null
        }
	});
}

function closeVideo()  {
	jQuery("#counter").fadeIn(700);
   	jQuery("#ticker").fadeIn(700);
   	jQuery("#intro_trailer").fadeIn(700);
   	
	jQuery("#embedvideo").fadeOut(700);
//	document.getElementById("embedvideo").style.display="none";
	jQuery("#vback").fadeOut(700);		
}

function prepareVideo(autoclose) {
       	if (autoclose == true) {
       		jQuery("#voverlay").html("<div id='vback'></div><div id='embedvideo'><div id='intro'></div></div>");
      	} else {
      		jQuery("#voverlay").html("<div id='vback'></div><div id='embedvideo'><div id='playert'><a href='#' onclick='closeVideo();' id='closelink'></a></div><div id='playerl'></div><div id='intro'></div><div id='playerr'></div><div id='playerb'></div></div>");
    	}
       	jQuery("#counter").fadeOut(800);
       	jQuery("#ticker").fadeOut(800);
       	jQuery("#intro_trailer").fadeOut(800);
		jQuery("#embedvideo").fadeIn(800);
//		document.getElementById("vback").style.display="block";
		jQuery("#vback").css('filter', 'alpha(opacity=100)');
		jQuery("#vback").fadeIn(1000);
}

function stopIE6() {
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popHeight = $("#popup").height();
//	$("#voverlay").prepend("<div id='vback'></div>");
	jQuery("#vback").css({
		"height": windowHeight,
		"width": windowWidth,
		"opacity": "0.7",
		"position": "absolute"
	});
	jQuery("#popup h1").css({
		"font-family": "sans-serif",
		"font-weight": "900",
		"color": "#FF3333"
	});
	jQuery("#popup").css({
		"display": "none",
		"color": "#FF3333",
		"border": "#CC0033 1px solid",
		"text-align": "left",
		"font-family": "sans-serif",
		"position": "absolute",
		"height": "200px",
		"width": "300px",
		"left": (windowWidth/2)-(150),
		"top": (windowHeight/2)-100,
		"background": "#FFCC99",
		"z-index": "500",
		"padding": "15px"
	});
	jQuery("#popup").fadeIn("slow");
	jQuery("#vback").fadeIn("slow");
//	prepareVideo();



	jQuery("#intro").html("<div style='height: 240px; width: 320px;'>NIX IE</div>");
}

function embedPan() {
	prepareVideo();
	jQuery("#intro").html("<object type='application/x-java-applet' archive='ptviewer.jar' code='ptviewer.class' width='320' height='240' name='ptviewer'><param name='file' value='/images/wald_lq3.jpg'><param name=wait value='/images/shamba_splash.jpg'><param name=bar_x value='70'><param name=bar_y value='230'><param name=bar_width value='180'><param name=bar_height value='4'></object>");
	document.getElementById("embedvideo").style.display="block";
	jQuery("#embedvideo").fadeIn(2000);
}


jQuery(document).ready(function() {

        jQuery("#vback").click(function(){
          closeVideo();
        });

	jQuery(".videolink").click(function() {
		prepareVideo();
		document.getElementById("embedvideo").style.display="block";
	});
});
