(function ($) {
    
    $.fn.image2Flv = function(flvLink) {
    	return this.each(function (index, element) {
    		var parent = $(element).parent();
    		$(parent).children('.video-preloader').show();

    		// If the swfContainer doesn't exist already create it.
    		var swfContainer = $(parent).children('.swf-container')[0];
    		if ( swfContainer ) {
    			//$(element).hide();
    			
    			$(parent).children('.play-icon').flvHide();
    			//$(parent).children('.video-preloader').hide();
    			
    			$(swfContainer).show();
    			if (typeof swfContainer.startVideo == 'function') {
    				swfContainer.startVideo();
    				$(element).hide();
    			}
    			
    			return;
    		}
    		
    		var swfContainer = $('<div />', {
				'class': 'swf-container',
				'id': 'sc-' + (new Date().getTime()) + '-' + Math.floor(Math.random() * 1000),// <-- not 100% unique ID but close enough
				text: 'This feature is only supported by flash enabled devices.'
			}).appendTo(parent);
    		
    		$(element).addClass($(swfContainer).attr('id'));
    		
    		// Embed the swf.
    		//console.log();
    		swfobject.embedSWF(
    			Drupal.settings.basePath +"sites/default/files/swf/SimpleFlv.swf",
    			$(swfContainer).attr("id"),
    			$(element).width(),
    			$(element).height(),
    			"10.0.0",
    			false,
    			{
    				flv_link : flvLink,
    				swf_id: $(swfContainer).attr('id')
    			},
    			{},
    			{},
    			function (swfObject) {
    				/*
    				$(element).hide();
    				$(parent).children('.play-icon').hide();
    				*/
    				
    				$('#'+ $(swfContainer).attr('id')).addClass('swf-container');
    			}
    		);
    		
    	});
    };
    
    $.fn.flv2Image = function () {
    	return this.each(function (index, element) {
    		var image = $(element).parent().children('img.'+ $(element).attr('id'));
    		var parent = $(element).parent();

    		if (typeof element.stopVideo == 'function')
    			element.stopVideo();
    		
    		$(element).hide();
    		image.show();

    		$(parent).children('.play-icon').flvShow();
    		$(parent).children('.video-preloader').hide();
    	});
    };
    
    $.fn.flvLoaded = function () {
    	return this.each(function (index, element) {
    		var image = $(element).parent().children('img.'+ $(element).attr('id'));
    		var parent = $(element).parent();
    		
    		$(image).hide();
			$(parent).children('.play-icon').flvHide();
			$(parent).children('.video-preloader').hide();
    	});
    };
    
    $.fn.flvHide = function () {
    	return this.each(function (index, element) {
    		$(element).addClass('hide-this-block');
    	});
    };
    $.fn.flvShow = function () {
    	return this.each(function (index, element) {
    		$(element).removeClass('hide-this-block');
    	});
    };
    
})(jQuery);

function flv2Image(swfId) {
	jQuery('#'+ swfId).flv2Image();
}

function flvLoaded(swfId) {
	jQuery('#'+ swfId).flvLoaded();
};
// $Id: base.js,v 1.11.4.5 2010/11/20 23:49:29 dereine Exp $
/**
 * @file base.js
 *
 * Some basic behaviors and utility functions for Views.
 */
(function ($) {

Drupal.Views = {};

/**
 * jQuery UI tabs, Views integration component
 */
Drupal.behaviors.viewsTabs = {
  attach: function (context) {
    if ($.viewsUi && $.viewsUi.tabs) {
      $('#views-tabset').once('views-processed').viewsTabs({
        selectedClass: 'active'
      });
    }

    $('a.views-remove-link').once('views-processed').click(function() {
      var id = $(this).attr('id').replace('views-remove-link-', '');
      $('#views-row-' + id).hide();
      $('#views-removed-' + id).attr('checked', true);
      return false;
   });
  /**
    * Here is to handle display deletion 
    * (checking in the hidden checkbox and hiding out the row) 
    */
  $('a.display-remove-link')
    .addClass('display-processed')
    .click(function() {
      var id = $(this).attr('id').replace('display-remove-link-', '');
      $('#display-row-' + id).hide();
      $('#display-removed-' + id).attr('checked', true);
      return false;
  });
  }
};

/**
 * For IE, attach some javascript so that our hovers do what they're supposed
 * to do.
 */
Drupal.behaviors.viewsHoverlinks = function() {
  if ($.browser.msie) {
    // If IE, attach a hover event so we can see our admin links.
    $("div.view:not(.views-hover-processed)").addClass('views-hover-processed').hover(
      function() {
        $('div.views-hide', this).addClass("views-hide-hover"); return true;
      },
      function(){
        $('div.views-hide', this).removeClass("views-hide-hover"); return true;
      }
    );
    $("div.views-admin-links:not(.views-hover-processed)")
      .addClass('views-hover-processed')
      .hover(
        function() {
          $(this).addClass("views-admin-links-hover"); return true;
        },
        function(){
          $(this).removeClass("views-admin-links-hover"); return true;
        }
      );
  }
}

/**
 * Helper function to parse a querystring.
 */
Drupal.Views.parseQueryString = function (query) {
  var args = {};
  var pos = query.indexOf('?');
  if (pos != -1) {
    query = query.substring(pos + 1);
  }
  var pairs = query.split('&');
  for(var i in pairs) {
    if (typeof(pairs[i]) == 'string') {
      var pair = pairs[i].split('=');
      // Ignore the 'q' path argument, if present.
      if (pair[0] != 'q' && pair[1]) {
        args[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
      }
    }
  }
  return args;
};

/**
 * Helper function to return a view's arguments based on a path.
 */
Drupal.Views.parseViewArgs = function (href, viewPath) {
  var returnObj = {};
  var path = Drupal.Views.getPath(href);
  // Ensure we have a correct path.
  if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
    var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
    returnObj.view_args = args;
    returnObj.view_path = path;
  }
  return returnObj;
};

/**
 * Strip off the protocol plus domain from an href.
 */
Drupal.Views.pathPortion = function (href) {
  // Remove e.g. http://example.com if present.
  var protocol = window.location.protocol;
  if (href.substring(0, protocol.length) == protocol) {
    // 2 is the length of the '//' that normally follows the protocol
    href = href.substring(href.indexOf('/', protocol.length + 2));
  }
  return href;
};

/**
 * Return the Drupal path portion of an href.
 */
Drupal.Views.getPath = function (href) {
  href = Drupal.Views.pathPortion(href);
  href = href.substring(Drupal.settings.basePath.length, href.length);
  // 3 is the length of the '?q=' added to the url without clean urls.
  if (href.substring(0, 3) == '?q=') {
    href = href.substring(3, href.length);
  }
  var chars = ['#', '?', '&'];
  for (i in chars) {
    if (href.indexOf(chars[i]) > -1) {
      href = href.substr(0, href.indexOf(chars[i]));
    }
  }
  return href;
};

})(jQuery);
;
// $Id: field_group.js,v 1.5.2.12 2011/01/07 09:52:30 stalski Exp $

(function($) {

/**
 * Drupal FieldGroup object.
 */
Drupal.FieldGroup = Drupal.FieldGroup || {};
Drupal.FieldGroup.Effects = Drupal.FieldGroup.Effects || {};

/**
 * Implements Drupal.FieldGroup.processHook().
 */
Drupal.FieldGroup.Effects.processAccordion = {
  execute: function (context, settings) {
    $('div.field-group-accordion-wrapper', context).accordion({
      autoHeight: false,
      active: '.field-group-accordion-active'
    });
  }
}

/**
 * Implements Drupal.FieldGroup.processHook().
 */
Drupal.FieldGroup.Effects.processHtabs = {
  execute: function (context, settings) {
  }
}

/**
 * Implements Drupal.FieldGroup.processHook().
 * 
 * TODO clean this up meaning check if this is really 
 *      necessary.
 */
Drupal.FieldGroup.Effects.processDiv = {
  execute: function (context, settings) {

    $('div.collapsible', context).each(function() {
      var $wrapper = $(this);

      // Turn the legend into a clickable link, but retain span.field-group-format-toggler
      // for CSS positioning.
      var $toggler = $('span.field-group-format-toggler:first', $wrapper);
      var $link = $('<a class="field-group-format-title" href="#"></a>');
      $link.prepend($toggler.contents()).appendTo($toggler);
      
      // .wrapInner() does not retain bound events.
      $link.click(function () {
        var wrapper = $wrapper.get(0);
        // Don't animate multiple times.
        if (!wrapper.animating) {
          wrapper.animating = true;
          var speed = $wrapper.hasClass('speed-fast') ? 300 : 1000;
          if ($wrapper.hasClass('effect-none') && $wrapper.hasClass('speed-none')) {
            $('> .field-group-format-wrapper', wrapper).toggle();
          }
          else if ($wrapper.hasClass('effect-blind')) {
            $('> .field-group-format-wrapper', wrapper).toggle('blind', {}, speed);
          }
          else {
            $('> .field-group-format-wrapper', wrapper).toggle(speed);
          }
          wrapper.animating = false;
        }
        return false;
      });
      
    });
  }
};

/**
 * Behaviors.
 */
Drupal.behaviors.fieldGroup = {
  attach: function (context, settings) {
    if (settings.field_group == undefined) {
      return;
    }
    $('body', context).once('fieldgroup-effects', function () {
      // Execute all of them.
      $.each(Drupal.FieldGroup.Effects, function (func) {
        // We check for a wrapper function in Drupal.field_group as 
        // alternative for dynamic string function calls.
        if (settings.field_group[func.toLowerCase().replace("process", "")] != undefined && $.isFunction(this.execute)) {
          this.execute(context, settings);
        }
      });
    });
  }
};

})(jQuery);;

