var bz_video_embed_current_elem_obj='';

function bz_play_embedded_video(e,source_tag,vpu,fullvpu,w,h,autoplay){
if(!e){return;}
if(!vpu){return;}
if(!source_tag){return;}


var selem=document.getElementById(e);
var telem=document.getElementById('video_embed_play_area');
if(!telem){return;}
var celem=document.getElementById('video_embed_play_container');

//alert('Show: '+vpu);

if(!w || (w==0)){w=425;}
if(!h || (h==0)){h=344;}
if(!autoplay){autoplay='y';}



// -- GET CODE FOR THE SOURCE -- STARTS //
// -- GET CODE FOR THE SOURCE -- STARTS //
var embed_code;

	if(source_tag == 'youtube'){
	embed_code=get_youtube_embed_code(vpu,fullvpu,w,h,autoplay);
	}

	if(source_tag == 'metacafe'){
	embed_code=get_metacafe_embed_code(vpu,fullvpu,w,h,autoplay);
	}

	if(source_tag == 'xvideos'){
	embed_code=get_xvideos_embed_code(vpu,fullvpu,w,h,autoplay);
	}

	if(source_tag == 'redtube'){
	embed_code=get_redtube_embed_code(vpu,fullvpu,w,h,autoplay);
	}

if(!embed_code){return;}

// -- GET CODE FOR THE SOURCE -- ENDS //
// -- GET CODE FOR THE SOURCE -- ENDS //



if(celem){
celem.style.display='block';
}

//alert(embed_code);
telem.innerHTML=embed_code;
telem.style.display='block';

//window.status='Showing Video...';

if(bz_video_embed_current_elem_obj){
bz_video_embed_current_elem_obj.style.borderColor='#ddd';
bz_video_embed_current_elem_obj.style.backgroundColor='#ddd';
}
if(selem){
selem.style.borderColor='#000';
selem.style.backgroundColor='#ddd';
bz_video_embed_current_elem_obj=selem;
}

//alert('We are here');
return;
}

// ---------------------------
function bz_close_embed_video(){
var telem=document.getElementById('video_embed_play_area');
if(!telem){return;}

var celem=document.getElementById('video_embed_play_container');
if(!celem){return;}

if(bz_video_embed_current_elem_obj){
bz_video_embed_current_elem_obj.style.borderColor='#ddd';
bz_video_embed_current_elem_obj.style.backgroundColor='#ddd';
bz_video_embed_current_elem_obj=null;
}

celem.style.display='none';
telem.style.display='none';
telem.innerHTML='';
}

// ------------------------
function get_youtube_embed_code(vpu,fullvpu,w,h,autoplay){
//vpu='http://www.youtube.com/v/'+vpu+'&hl=en&fs=1';
fullvpu +='&showsearch=0';
if(autoplay == 'y'){fullvpu +='&autoplay=1';}
//alert(vpu);
var embed_code='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+w+'" height="'+h+'">';
embed_code +='<param name="movie" value="'+fullvpu+'"></param>';
embed_code +='<param name="allowFullScreen" value="true"></param>';
embed_code +='<embed src="'+fullvpu+'" type="application/x-shockwave-flash" ';
embed_code +=' allowfullscreen="true" width="'+w+'" height="'+h+'"></embed>';
embed_code +='</object>';
return embed_code;
}

// ------------------------
function get_metacafe_embed_code(vpu,fullvpu,w,h,autoplay){
//vpu='http://www.youtube.com/v/'+vpu+'&hl=en&fs=1';

if(autoplay == 'y'){fullvpu +='&autoplay=1';}
//if(autoplay == 'y'){vpu +='&autoplay=1';}
//alert(vpu);
//alert(fullvpu);
//alert(w);
//alert(h);

//<embed src="http://www.metacafe.com/fplayer/1928325/crazy_al_at_it_again.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> </embed><br><font size = 1><a href="http://www.metacafe.com/watch/1928325/crazy_al_at_it_again/">Crazy Al at It Again</a> - <a href="http://www.metacafe.com/">The top video clips of the week are here</a></font>

var embed_code='<embed src="'+fullvpu+'" width="'+w+'" height="'+h+'" ';
embed_code +='wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> </embed>';

//alert(embed_code);

return embed_code;
}

// ------------------------
function get_xvideos_embed_code(vpu,fullvpu,w,h,autoplay){
//vpu='http://www.youtube.com/v/'+vpu+'&hl=en&fs=1';

//if(autoplay == 'y'){fullvpu +='&autoplay=1';}
//if(autoplay == 'y'){vpu +='&autoplay=1';}
//alert(vpu);
//alert(fullvpu);
//alert(w);
//alert(h);

//<object width="510" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://www.xvideos.com/sitevideos/flv_player_site_v4.swf" /><param name="allowFullScreen" value="true" /><param name="flashvars" value="id_video=9992" /><embed src="http://www.xvideos.com/sitevideos/flv_player_site_v4.swf" allowscriptaccess="always" width="510" height="400" menu="false" quality="high" bgcolor="#000000" allowfullscreen="true" flashvars="id_video=9992" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>

var embed_code='<object width="'+w+'" height="'+h+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" >';
embed_code +='<param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://www.xvideos.com/sitevideos/flv_player_site_v4.swf" /><param name="allowFullScreen" value="true" /><param name="flashvars" value="'+vpu+'" /><embed src="http://www.xvideos.com/sitevideos/flv_player_site_v4.swf" allowscriptaccess="always" width="'+w+'" height="'+h+'" menu="false" quality="high" bgcolor="#000000" allowfullscreen="true" flashvars="'+vpu+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

return embed_code;
}

function get_redtube_embed_code(vpu,fullvpu,w,h,autoplay){
//vpu='http://www.youtube.com/v/'+vpu+'&hl=en&fs=1';

//if(autoplay == 'y'){fullvpu +='&autoplay=1';}
//if(autoplay == 'y'){vpu +='&autoplay=1';}
//alert(vpu);
//alert(fullvpu);
//alert(w);
//alert(h);

//<object height="344" width="434"><param name="movie" value="http://embed.redtube.com/player/"><param name="FlashVars" value="id=16044&style=redtube"><embed src="http://embed.redtube.com/player/?id=16044&style=redtube" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="344" width="434"></object>

var embed_code='<object height="'+h+'" width="'+w+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="movie" value="http://embed.redtube.com/player/">';
embed_code +='<param name="FlashVars" value="'+vpu+'"><embed src="http://embed.redtube.com/player/?'+vpu+'" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="'+h+'" width="'+w+'"></object>';

return embed_code;
}