function pop_video() {
	if(document.getElementById("pop_overlay") === null){
		$("body").append("<div id='pop_overlay'></div>");
		$("#pop_overlay").click(vid_remove);
		$("#vid_closeWindowButton").click(vid_remove);
	}
	
	if(pop_detectMacXFF()){
		$("#pop_overlay").addClass("pop_overlayMacFFBGHack");//use png overlay so hide flash
	}else{
		$("#pop_overlay").addClass("pop_overlayBG");//use background and opacity
	}
	
	vid_position(857,496);
	
	$("#vid_window").fadeIn("slow");
	
	//if(document.mhl_movie)
	//	document.mhl_movie.Play();
}

function vid_remove() {
	if(document.mhl_movie) {
		document.mhl_movie.Stop();
		document.mhl_movie.Rewind();
	}
	$("#vid_closeWindowButton").unbind("click");
	$("#vid_window").fadeOut("def",function(){
	$('#vid_window,#pop_overlay').trigger("unload").unbind();
	$('#pop_overlay').remove();});
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function vid_position(Width, Height) {
	var de = document.documentElement;
	
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrollTop = window.pageYOffset;
	  } else if( document.body && document.body.scrollTop ) {
		//DOM compliant
		scrollTop = document.body.scrollTop;
	  } else if( document.documentElement && document.documentElement.scrollTop ) {
		//IE6 standards compliant mode
		scrollTop = document.documentElement.scrollTop;
	  } else {
	  	scrollTop = 20;
	  }
	  
	  scrollTop = 0;
	
	if (de && de.clientWidth < Width && de.clientHeight < Height) {
		$("#vid_window").css({left: '20px', width: Width + 'px', marginRight:'20px'});
		$("#vid_window").css({top: (scrollTop + 20) + 'px'});
	}
	else if (de&&de.clientWidth < Width) {
		$("#vid_window").css({left: '20px', width: Width + 'px', marginRight:'20px'});
		$("#vid_window").css({top: parseInt(scrollTop + ((de.clientHeight - Height) / 2),10) + 'px'});
	}
	else if (de&&de.clientHeight < Height) {
		$("#vid_window").css({marginLeft: '-' + parseInt((Width / 2),10) + 'px', width: Width + 'px'});
		$("#vid_window").css({top: (scrollTop + 20) + 'px'});
	}
	else {
		$("#vid_window").css({marginLeft: '-' + parseInt((Width / 2),10) + 'px', width: Width + 'px'});
		$("#vid_window").css({top: parseInt(scrollTop + ((de.clientHeight - Height) / 2),10) + 'px'});
	}
}

function pop_parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function pop_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}

function pop_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}