
   function changevideo(vidurl) {
      $f().play(vidurl, 2);
    }

var t;
var hide = true;

     
function showad(){
	//var gap = $f().getClip().fullDuration/5;
	//$f().getPlugin("myContent").show();
	//setTimeout("hidead()", gap*1000);       
}
    
function hidead(){
    // $f().getPlugin("myContent").hide();   
}

function closeControls(){
	if (hide) clearTimeout(hide);
	$("#player_icons").hide();
	$f().getControls().hide();
}
function startNext(){
	if ($("ul.playlistul li.playing").next().length > 0) {
		setTimeout(function(){$("ul.playlistul li.playing").next().trigger('click');}, 2000);
	} else {
		// end of video list
	}
}


var SHARE_ICONS = '<a target="_blank" href="http://www.facebook.com/share.php?u=#U#" id="facebook"><img src="/static/images/social_icons/facebook_32.png" alt="facebook" /></a>'+
	'<a target="_blank" href="http://twitter.com/home?status=#U#" id="twitter"><img src="/static/images/social_icons/twitter_32.png" alt="twitter" /></a>'+
	'<a target="_blank" href="http://www.myspace.com/index.cfm?fuseaction=postto&t=#T#&c=#C#&u=#U#" id="myspace"><img src="/static/images/social_icons/myspace_32.png" alt="myspace" /></a>'+
	'<a target="_blank" href="http://digg.com/submit?phase=2&amp;url=#U#&amp;title=#T#&amp;bodytext=" id="digg"><img src="/static/images/social_icons/digg_32.png" alt="digg" /></a>'+
	'<a target="_blank" href="http://reddit.com/submit?url=#U#&amp;title=#T#" id="reddit"><img src="/static/images/social_icons/reddit_32.png" alt="reddit" /></a>'+
	'<a target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&bkmk=#U#&title=#T#&annotation=#C#"><img src="/static/images/social_icons/google_32.png" alt="google" /></a>'+
	'<br />'+
	'<a target="_blank" href="http://friendfeed.com?url=#U#&amp;title=#T#" id="friendfeed"><img src="/static/images/social_icons/friendfeed_32.png" alt="friendfeed" /></a>'+
	'<a target="_blank" href="http://www.blogger.com/blog_this.pyra?t=#C#&u=#U#&n=#T#"><img src="/static/images/social_icons/blogger_32.png" alt="blogger" /></a>'+
	'<a target="_blank" href="http://www.stumbleupon.com/submit?url=#U#&amp;title=#T#" id="stumbleupon"><img src="/static/images/social_icons/stumbleupon_32.png" alt="stumbleupon" /></a>'+
	'<a target="_blank" href="httsdfp://www.linkedin.com/shareArticle?mini=true&url=#U#&title=#T#&summary=#C#" id="linkedin"><img src="/static/images/social_icons/linkedin_32.png" alt="linkedin" /></a>'+
	'<a target="_blank" href="http://del.icio.us/save?v=5&amp;noui&amp;jump=close&amp;url=#U#&amp;title=#T#" id="delicious"><img src="/static/images/social_icons/delicious_32.png" alt="delicious" /></a>'+
	'<a class="facebox" title="Send Email" href="/ajax/share/?url=#U#&amp;title=#T#" id="email"><img src="/static/images/social_icons/email_32.png" alt="email" /></a>'



function urlencode(url) {
	str = escape(url);
	str = str.replace('+', '%2B');
	str = str.replace('%20', '+');
	str = str.replace('*', '%2A');
	str = str.replace('/', '%2F');
	str = str.replace('@', '%40');
	return str;
}

function rebuild_share(url, title, description){
	h = SHARE_ICONS;
	h=h.replace(/#U#/g, 'http://'+document.domain+urlencode(url));
	h=h.replace(/#T#/g, urlencode(title));
	h=h.replace(/#C#/g, urlencode(description));
	$('.shareimages').html(h);
	$('#video_url').val('http://'+document.domain+url);
}


$(function() {   
		$("#embedPane textarea").html($f().embed().getEmbedCode());
		
		$("div.close_player").click(function() {
		    $(this).parent().hide();	    		   		
			$f().show();
			$f().resume();
		});
});

$("#player").mousemove(function(e){
	if (hide) clearTimeout(hide);
    $("#player_icons").show();
    $f().getControls().show();
    hide=false;
    hide=setTimeout('closeControls();', 3000);
});
	

$("#imgembed").click(function(){ 
	$f().pause();
	$(".player_overlay").hide();
	$("#embedPane").fadeIn();
	return false;

});

$("#imglink").click(function(){ 
	$f().pause();
	$(".player_overlay").hide();
	$("#linkPane").fadeIn();
	return false;
});                                
$("#imgshare").click(function(){ 
	$f().pause();
	$(".player_overlay").hide();
	$("#sharePane").fadeIn();
	return false;
});                             
 
$("#imgcopy").click(function(){
    $("#embedcode").select();
    var ht = $("#embedcode").text();        
    $.copy("copy this ");                           
	return false;
});

