/*
 * Embed QuickTime - jQuery plugin for embedding videos
 *
 * Copyright (c) 2007-2008 Andreas Haugstrup Pedersen
 * 
 * Mail: andreas [at] solitude [dot] dk
 * Web: http://www.solitude.dk/archives/embedquicktime/
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 */
(function(A){A.embedquicktime=function(E){E=A.extend({jquery:null,plugin:null,target:null},E);var F=new Array("video/quicktime","video/mp4","video/x-m4v");var G=new Array("mov","mp4","m4v","3gp");var C=new Array("avi","wmv","mpeg","mpg","asf","asx");var H=new Array("video/mpeg","video/x-ms-asf","video/x-msvideo","video/x-ms-wmv");var I=new Array("audio/x-wav","audio/x-aiff","audio/x-mpegurl","audio/mpeg");var D=new Array("wav","aiff","aif","mp3","m3u","m4a","m4b");function B(K,J){for(i in J){if(K==J[i]){return true}}return false}A(".hvlog").not(".hvlog-processed").each(function(){if(E.target!=null&&A(this).attr("id")!=E.target){return }var K=null;A(this).find("a[rel=enclosure]").each(function(){var M=A(this);var N=M.attr("href");var P=N.substr(N.lastIndexOf(".")+1);var O=M.attr("type");K=null;if(B(P,G)||B(O,F)){K="qt"}else{if(B(P,C)||B(O,H)){K="wmv"}else{if(B(P,D)||B(O,I)){K="audio"}}}if(K!=null){A(M).click(function(){A(M).embedquicktime(M,{eqttype:K});return false})}});if(K!=null&&A(this).hasClass("share")){embedHTML="Error: JavaScript URLs not found.";if(E.jquery!=null&&E.plugin!=null){var L="eqt-"+(new Date()).getTime();embedHTML='<script type="text/javascript" src="'+E.jquery+'"><\/script> <script type="text/javascript" src="'+E.plugin+'"><\/script> <script type="text/javascript">jQuery.noConflict();jQuery(document).ready(function() { jQuery.embedquicktime({jquery: "'+E.jquery+'", plugin: "'+E.plugin+'", target: "'+L+'"});});<\/script><div class="'+A(this).attr("class")+'" id="'+L+'">'+A(this).html()+"</div>"}var J=A(this);J.append('<div class="hvlog_share"><div class="hvlog_share_link">share media</div></div>').find("div.hvlog_share_link").each(function(){A(this).css({background:"#fc9",color:"black",font:"12px sans-serif",cursor:"pointer",width:"12ex","text-align":"center",padding:"1px"}).hover(function(){A(this).css({color:"green"})},function(){A(this).css({color:"black"})}).click(function(){var N=A(this).parents(".hvlog_share");if(N.find(".hvlog_share_share:visible").length>0){N.find(".hvlog_share_share").slideUp("slow");N.find(".hvlog_share_link").empty().append("share media")}else{var M=N.parents(".hvlog").find("img").eq(0);if(M.length==0){M=N.parents(".hvlog").find("object").eq(0)}N.width(M.width());N.find(".hvlog_share_link").empty().append("close");if(N.find("div.hvlog_share_share").length==0){A('<div class="hvlog_share_share" style="display:none"><span style="text-align:right;padding:4px">Copy &amp; paste</span><textarea readonly="readonly">'+embedHTML+"</textarea></div>").css({width:N.width()-20,height:"100px",background:"#fc9",color:"black",font:"12px sans-serif",padding:"8px 10px"}).find("textarea").css({"font-size":"10px",display:"block",overflow:"hidden",margin:"0 auto 15px auto",width:N.width()-30,height:"85px"}).end().hide().click(function(){A(this).find("textarea").select();A(this).find("textarea").focus();return false}).appendTo(N).slideDown("slow")}else{N.find("div.hvlog_share_share").slideDown("slow")}}return false})})}A(this).addClass("hvlog-processed")});return this};A.fn.embedquicktime=function(B,C){var D=A.extend({},A.fn.embedquicktime.defaults,C);return this.each(function(){var J=A(this).parents(".hvlog");var H=J.metadata?A.extend({},D,J.metadata()):D;H=B.metadata?A.extend({},H,B.metadata()):H;var E=A(this).attr("href");if(H.src){E=H.src}var F=J.find("img").eq(0);if(F.length>0){var G=F.width();var M=F.height();if(H.width){G=H.width}if(H.height){M=H.height}if(H.eqttype=="audio"){M=0}if((!H.controller||H.controller!="true")||(!H.showcontrols||H.showcontrols!="true")){M=parseInt(M)+16}var I="";var K="";for(i in H){if(i!="height"&&i!="width"&&i!="src"&&i!="autoplay"&&i!="autoStart"&&i!="pluginspage"&&i!="eqttype"){I=I+'<param name="'+i+'" value="'+H[i]+'">';K=K+" "+i+'="'+H[i]+'"'}}var L=J.find(".hvlog_share").eq(0).clone(true);J.empty();if(H.eqttype=="qt"||H.eqttype=="audio"){J.append('<object width="'+G+'" height="'+M+'" autoplay="'+H.autoplay+'" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="'+E+'"><param name="autoplay" value="'+H.autoplay+'">'+I+'<embed src="'+E+'" width="'+G+'" height="'+M+'" autoplay="'+H.autoplay+'" pluginspage="http://www.apple.com/quicktime/download/"'+K+"></embed></object>").append(L)}else{if(H.eqttype=="wmv"){J.append('<object CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="'+G+'" height="'+M+'"><param name="fileName" value="'+E+'" ><param name="autoStart" value="'+H.autoStart+'">'+I+'<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="'+G+'" height="'+M+'" src="'+E+'" autostart="'+H.autoStart+'"'+K+"></embed></object>").append(L)}}return true}return false})};A.fn.embedquicktime.defaults={autoplay:"true",autoStart:"true",eqttype:"qt"}})(jQuery);

/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.metadata.js 3620 2007-10-10 20:55:38Z pmclanahan $
 *
 */
(function($){$.extend({metadata:{defaults:{type:"class",name:"metadata",cre:/({.*})/,single:"metadata"},setType:function(type,name){this.defaults.type=type;this.defaults.name=name},get:function(elem,opts){var settings=$.extend({},this.defaults,opts);if(!settings.single.length){settings.single="metadata"}var data=$.data(elem,settings.single);if(data){return data}data="{}";if(settings.type=="class"){var m=settings.cre.exec(elem.className);if(m){data=m[1]}}else{if(settings.type=="elem"){if(!elem.getElementsByTagName){return }var e=elem.getElementsByTagName(settings.name);if(e.length){data=$.trim(e[0].innerHTML)}}else{if(elem.getAttribute!=undefined){var attr=elem.getAttribute(settings.name);if(attr){data=attr}}}}if(data.indexOf("{")<0){data="{"+data+"}"}data=eval("("+data+")");$.data(elem,settings.single,data);return data}}});$.fn.metadata=function(opts){return $.metadata.get(this[0],opts)}})(jQuery);