$(document).ready(function(){
						   
						   
						    addHTML();
							resizing();
							$(window).resize(resizing)
						   
							$('.vidpop .vidsh').bind('click',function(){$('.vidpop').hide();})
						   
						   });


function resizing()
{
  W = $(window).width();
  H = $(window).height();
  wx = parseInt($('.vidpop .vidpopup').css('width'));
  hx = parseInt($('.vidpop .vidpopup').css('height'));
  
  $('.vidpop .vidsh').css('width',W);
  $('.vidpop .vidsh').css('height',H);
  $('.vidpop .vidsh').css('opacity',0.2);
  $('.vidpop .vidpopup').css('top',(H-hx)/2);
  $('.vidpop .vidpopup').css('left',(W-wx)/2);
}


function addHTML()
{
  var htmlc='<div class="vidpop">';
  htmlc= htmlc+'<div class="vidsh"></div>';
  htmlc= htmlc+'<div class="vidpopup">';
  htmlc= htmlc+'</div></div>';
  
  $('body').append(htmlc);
	
}


function openVideo(flvpath)
{
	var o = new Object();
  	o.width = 640;
  	o.height = 360;
  	o.byteInterval=25;
  	o.playerpath="vid_popup/webguru_video_fx.swf";
  	o.url = flvpath;
  	addVideoPlayer(o);
	resizing();
	$('.vidpop').fadeIn();
}


function addVideoPlayer(o)
{
	var query_string="vidpath="+o.url+"&&byteInterval="+o.byteInterval+"";
	
	var html_content='<object';
	html_content = html_content+'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
	html_content = html_content+'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"';
	html_content = html_content+'width="'+o.width+'"';
	html_content = html_content+'height="'+o.height+'"';
	html_content = html_content+'id="webguru_video_fx"';
	html_content = html_content+' align="middle"';
	html_content = html_content+'>';
	html_content = html_content+'<param name="allowScriptAccess" value="sameDomain" />';
	html_content = html_content+'<param name="allowFullScreen" value="true" />';
	html_content = html_content+'<param name="FlashVars" value="'+query_string+'" />';
	html_content = html_content+'<param name="movie" value="'+o.playerpath+'" />';
	html_content = html_content+'<param name="quality" value="high" />';
	html_content = html_content+'<param name="bgcolor" value="#000000" />';
	html_content = html_content+'<embed';
	html_content = html_content+' src="'+o.playerpath+'"';
	html_content = html_content+' quality="high"';
	html_content = html_content+' bgcolor="#000000"';
	html_content = html_content+' width="'+o.width+'"';
	html_content = html_content+' height="'+o.height+'"';
	html_content = html_content+' name="webguru_video_fx';    
	html_content = html_content+' align="middle"';    
	html_content = html_content+' allowScriptAccess="sameDomain"';    
	html_content = html_content+' allowFullScreen="true"'; 
	html_content = html_content+' type="application/x-shockwave-flash"';  
	html_content = html_content+' FlashVars="'+query_string+'"';  
	html_content = html_content+' pluginspage="http://www.macromedia.com/go/getflashplayer"';  
	html_content = html_content+' />';  
	html_content = html_content+' </object>';
	
	$('.vidpop .vidpopup').html(html_content);
	$('.vidpop .vidpopup').css('width',o.width);
	$('.vidpop .vidpopup').css('height',o.height);
}
