/*** caption.js ***/

/**
* @version		$Id: caption.js 5263 2006-10-02 01:25:24Z webImagery $
* @copyright	Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

/**
* JCaption javascript behavior
*
* Used for displaying image captions
*
* @package	Joomla
* @since	1.5
* @version	1.0
*/
var JCaption = new Class({
	initialize: function(selector)
	{
		this.selector = selector;

		var images = $$(selector);
		images.each(function(image){ this.createCaption(image); }, this);
	},

	createCaption: function(element)
	{
		var caption   = document.createTextNode(element.title);
		var container = document.createElement("div");
		var text      = document.createElement("p");
		var width     = element.getAttribute("width");
		var align     = element.getAttribute("align");

		if(!width) {
			width = element.width;
		}

		//Windows fix
		if (!align)
			align = element.getStyle("float");  // Rest of the world fix
		if (!align) // IE DOM Fix
			align = element.style.styleFloat;

		if (align=="") {
			align="none";
		}

		text.appendChild(caption);
		text.className = this.selector.replace('.', '_');

		element.parentNode.insertBefore(container, element);
		container.appendChild(element);
		if ( element.title != "" ) {
			container.appendChild(text);
		}
		container.className   = this.selector.replace('.', '_');
		container.className   = container.className + " " + align;
		container.setAttribute("style","float:"+align);

		container.style.width = width + "px";

	}
});

document.caption = null;
window.addEvent('load', function() {
	var caption = new JCaption('img.caption')
	document.caption = caption
});


/*** mod_bannerslider.js ***/

function ContentSlider(A,I,G,E,D){this.id=A;this.timer=A+"timer";this.delay=(typeof (G)=="number")?G:3000;this.effect=(typeof (I)=="string")?I:"none";this.sliders=[];this.pointer=0;this.pause=0;var C=document.getElementById(A);var B=C.getElementsByTagName("div");for(var F=0;F<B.length;F++){if(B[F].className=="bs_opacitylayer"){C.opacitylayer=B[F]}else{if(B[F].className=="bs_contentdiv"){this.sliders.push(B[F])}}}if(this.sliders.length==0){return }this.targetobject=C.opacitylayer||null;this.width=parseInt(C.style.width);this.height=parseInt(C.style.height);if((typeof (D)!="undefined")&&(D==1)){this.showall();ContentSlider.resizeImg(A,this.width,this.height);this.hideall()}var H=this;C.onmouseover=function(){H.pause=1};C.onmouseout=function(){H.pause=0};if((typeof (E)=="undefined")||(E==1)){this.sliders.sort(function(){return 0.5-Math.random()})}if(this.effect.charAt(0)=="s"){this.accel=1.05;this.pos=1;for(var F=0;F<this.sliders.length;F++){this.sliders[F].style.position="relative"}}switch(I){case"scroll_left":case"scroll_up":this.scrollL();break;case"scroll_right":case"scroll_down":this.scrollR();break;case"fade":default:this.fade()}}ContentSlider.prototype.next=function(){this.pointer=(this.pointer<this.sliders.length-1)?++this.pointer:0};ContentSlider.prototype.hideall=function(){for(var A=0;A<this.sliders.length;A++){this.sliders[A].style.display="none"}};ContentSlider.prototype.showall=function(){for(var A=0;A<this.sliders.length;A++){this.sliders[A].style.display="block"}};ContentSlider.prototype.fade=function(){var A=this;if(this.pause){window[this.timer]=setTimeout(function(){A.fade()},1000)}else{this.sliders[this.pointer].style.display="none";if(this.effect!="none"){if(window[this.id+"fadetimer"]){clearTimeout(window[this.id+"fadetimer"])}this.setopacity(0.1)}this.next();this.sliders[this.pointer].style.display="block";if(this.effect!="none"){this.fadein()}window[this.timer]=setTimeout(function(){A.fade()},this.delay)}};ContentSlider.prototype.fadein=function(){if(this.targetobject&&this.targetobject.currentopacity<1){this.setopacity(this.targetobject.currentopacity+0.1);var A=this;window[this.id+"fadetimer"]=setTimeout(function(){A.fadein()},100)}};ContentSlider.prototype.setopacity=function(A){if(this.targetobject&&this.targetobject.filters&&this.targetobject.filters[0]){if(typeof this.targetobject.filters[0].opacity=="number"){this.targetobject.filters[0].opacity=A*100}else{this.targetobject.style.filter="alpha(opacity="+A*100+")"}}else{if(this.targetobject&&typeof this.targetobject.style.MozOpacity!="undefined"){this.targetobject.style.MozOpacity=A}else{if(this.targetobject&&typeof this.targetobject.style.opacity!="undefined"){this.targetobject.style.opacity=A}}}this.targetobject.currentopacity=A};ContentSlider.prototype.scrollL=function(){var A=this;if(this.pause){window[this.timer]=setTimeout(function(){A.scrollL()},1000)}else{if((this.effect=="scroll_left"&&this.pos>-this.width)||(this.effect=="scroll_up"&&this.pos>-this.height)){if(this.pos==0){this.pos=-1;window[this.timer]=setTimeout(function(){A.scrollL()},this.delay);return }else{if(this.pos<0){this.pos=Math.floor(this.pos*this.accel)-1}else{this.pos=Math.floor(this.pos/this.accel)}}}else{this.sliders[this.pointer].style.display="none";this.pos=-this.pos;this.next()}this.sliders[this.pointer].style.display="block";if(this.effect=="scroll_left"){this.sliders[this.pointer].style.left=this.pos+"px"}else{this.sliders[this.pointer].style.top=this.pos+"px"}window[this.timer]=setTimeout(function(){A.scrollL()},55)}};ContentSlider.prototype.scrollR=function(){var A=this;if(this.pause){window[this.timer]=setTimeout(function(){A.scrollR()},1000)}else{if((this.effect=="scroll_right"&&this.pos<this.width)||(this.effect=="scroll_down"&&this.pos<this.height)){if(this.pos==0){this.pos=1;window[this.timer]=setTimeout(function(){A.scrollR()},this.delay);return }else{if(this.pos<0){this.pos=Math.ceil(this.pos/this.accel)}else{this.pos=Math.ceil(this.pos*this.accel)}}}else{this.sliders[this.pointer].style.display="none";this.pos=-this.pos;this.next()}this.sliders[this.pointer].style.display="block";if(this.effect=="scroll_right"){this.sliders[this.pointer].style.left=this.pos+"px"}else{this.sliders[this.pointer].style.top=this.pos+"px"}window[this.timer]=setTimeout(function(){A.scrollR()},55)}};ContentSlider.resizeImg=function(G,B,D){var A=document.getElementById(G).getElementsByTagName("img");if(A.length>0){var F,E;for(var C=0;C<A.length;C++){E=ContentSlider.getDimension(A[C]);if(E.width>B||E.height>D){F=Math.min((B-E.padH)/E.width,(D-E.padV)/E.height);A[C].style.width=parseInt(E.width*F)+"px";A[C].style.height=parseInt(E.height*F)+"px"}}}};ContentSlider.getDimension=function(E){var B=E.style.display;E.style.display="block";var A=E.width;var C=E.height;var F=E.offsetWidth-A;var D=E.offsetHeight-C;E.style.display=B;return{width:A,height:C,padH:F,padV:D}};