$(document).ready(function() {
   $('input#keywords').val('search UPC');
   // clear and restore search input
   $('input.clickClear').focus(function() {
      startText = $(this).val();
      $(this).val('');
   });
   $('input.clickClear').blur(function() {
      blurText = $(this).val();
      if (blurText == '') {
         $(this).val(startText);
      };
   });
   $('#templatelist p a').toggle(
      function() {
         $('ul#templatenav').slideDown('medium');
         $(this).addClass('up');
      },
      function() {
         $('ul#templatenav').slideUp('medium');
         $(this).removeClass('up');
      } 
   );
   $('ul').each(function() {
      $(this).find('li:first').addClass('first');
      $(this).find('li:last').addClass('last');
   });
      // Make external links validate
      $('a.external').attr('target', '_blank');
      // Video Embedding
   	var vid = 1;
   	$('.video').each(function(){
   		var vurl = $(this).attr('href');
   		if(vurl) vurl = vurl.toString();

   		$(this).before('<div id="video'+vid+'">'+vurl+'</div>');		
   		$(this).remove();

   		var flashvars = { 
   			file: vurl,
   			autostart:'false',
   			frontcolor: 'ffffff',
   			lightcolor: 'cc9900',
   			skin: 'http://www.longtailvideo.com/jw/upload/overlay.swf',
   			controlbar: 'over'
   		};

   		var params = { wmode:'transparent', allowFullScreen:true };
   		var attributes = {  };

   		if($(this).find('img').attr('src')){
   			flashvars.image = $(this).find('img').attr('src');
   		}
   		swfobject.embedSWF("/_js/player.swf", "video"+vid, "400", "300", "9.0.0", "/_js/expressInstall.swf", flashvars, params, attributes);		
   		$(this).remove();								
   		vid++;			
   	});
});

// Remove annoying Addthis flash movie

	var addthis_config = {
   data_use_flash: false
}
