//	
//	Banner Slider
//	
var SimpleSlide = new Class({
	initialize: function(container,options) {
		this.container = container;
		this.options = options;
		var automated;
        var direction;
        var hideshow_flag;

        this.hideshow_flag=true;

		if(this.options) this.direction = this.options.direction;
		else this.direction = "forward";

		//	Is it on autorun or manual?
		if (this.direction!="pause")
		{
		if(this.options.auto == "loop" || this.options.auto == "once") {

	 	   this.automated = this.slider.periodical(this.options.time,this,$(this.container));
		} else {
			this.slider($(this.container))
		}
        }
	},

    next: function(type) {
             if(this.options.auto == "loop" || this.options.auto == "once") {
               this.pause();
             };
              this.options.type=type;
              this.direction="forward";
              this.slider($(this.container));
    	},
    prev: function(type) {
               if(this.options.auto == "loop" || this.options.auto == "once") {
               this.pause();
             };
              this.options.type=type;
              this.direction="back";
              this.slider($(this.container));
    	},
    pause: function() {
              this.direction="pause";
              this.slider($(this.container));
    	},
	run: function() {
		   this.direction="forward";
	 	   this.automated = this.slider.periodical(this.options.time,this,$(this.container));
                             },
	slider: function(container) {
		if ((this.options.auto == "once" || this.options.auto == "loop") && this.direction == "pause")
		{
		   $clear(this.automated);
		}else{
		var child;
		// Get all child nodes to scroll between.
		var children = container.getChildren().getChildren()[0];
		// Run through all child nodes to see if there is a tagged one.
		children.each(function(e) {
			// If there is, make it current child.
			if(e.id == "currentChild") {
				child = e;
			}
           // alert(e.id);
		});
		//alert(this.direction);

		if(!child && (this.direction == "forward" || this.direction == "pause")) {
			// If there isn't, make the first one current child.
			child = children[0].getNext();
			child.id = "currentChild";
		} else {
			// Are we going to the next or previous node?
			if(this.direction == "forward") {
				var lastElement = container.getChildren()[0].getLast();
				// Stops the loop at the last element.
				if(lastElement == child.getNext() && this.options.auto == "once") $clear(this.automated);
				// Is the current child the last node? Then set the first node as child, otherwise set the next node as child.
				if(lastElement == child) child = children[0];
				else child = child.getNext();
			}
			else if(this.direction == "back") child = child.getPrevious();
		}
		// Is the child defined?
		if(child && this.direction != "pause") {
			// Which type of slider is defined?
			if(this.options.type == "scroll") this.scroll(container,children,child);
			else if(this.options.type == "fade") this.fade(container,children,child);
			else if(this.options.type == "scrollfade") this.scrollfade(container,children,child);
		}
		}
	},

    init_vertical: function() {

       $(this.container).setStyle('position','relative');
       var children = $(this.container).getChildren().getChildren()[0];
       var i;
       var s_h;
       var s_w;
       var b_w;

       b_w=$(this.container).getStyle('border-width').toInt();

       s_h=$(this.container).getSize().size.y-2*b_w;
       s_w=$(this.container).getSize().size.x-2*b_w;

       //s_h=100;
       //s_w=600;

       i=0;
       children.each(function(e) {
          if (i!=0)
          {
            e.id = "currentChild";
            $('currentChild').setStyle('position','relative');
            $('currentChild').setStyle('left',0-s_w*i);
            $('currentChild').setStyle('top',0+s_h*i);
            e.id = "";
          }
		  i++;
		});

        children.each(function(e) {
				e.id = "";
			});
    	},
    init_horizontal: function() {
 $(this.container).setStyle('position','relative');
       var children = $(this.container).getChildren().getChildren()[0];
       var i;
       var s_h;
       var s_w;
       var b_w;

       b_w=$(this.container).getStyle('border-width').toInt();

       s_h=$(this.container).getSize().size.y-2*b_w;
       s_w=$(this.container).getSize().size.x-2*b_w;

       //s_h=100;
       //s_w=600;

       i=0;
       children.each(function(e) {
          if (i!=0)
          {
            e.id = "currentChild";
            $('currentChild').setStyle('position','relative');
            $('currentChild').setStyle('left',0);
            $('currentChild').setStyle('top',0);
            e.id = "";
          }
		  i++;
		});
    	},
	scroll: function(container,children,child) {
		// Make it a scroll slide.
  	    var scroll = new Fx.Scroll(container,{duration: this.options.duration, onComplete: function() {
			// Remove tags from all child nodes.
			children.each(function(e) {
				e.id = "";
			});
			// Tag this child as current
			child.id = "currentChild";
		}}).toElement(child);
	},
	fade: function(container,children,child) {
		// Make it a fade slide
		var fade = new Fx.Style(container,'opacity',{duration: this.options.duration, onComplete: function() {
			new Fx.Scroll(container,{duration: 1,onComplete: function() {
				// Remove tags from all child nodes.
				children.each(function(e) {
					e.id = "";
				});
				// Tag this child as current
				child.id = "currentChild";
				new Fx.Style(container,'opacity').start(0.01,1);
			}}).toElement(child);
		}})
		fade.start(1,0.01);
	},
	scrollfade: function(container,children,child) {
		// In case you input the miliseconds as a string instead of integer.
		var durationInt = this.options.duration.toInt();
		// Make it a scrollfade slide
		var fade = new Fx.Style(container,'opacity',{duration: (durationInt/2)})
		fade.start(1,0.01).chain(function() {
			fade.start(0.01,1);
		});
		new Fx.Scroll(container,{duration: durationInt, onComplete: function() {
			// Remove tags from all child nodes.
			children.each(function(e) {
				e.id = "";
			});
			// Tag this child as current
			child.id = "currentChild";
		}}).toElement(child);
	},
	hide_and_show_fade:function()
	{
	   var fade = new Fx.Style($(this.container),'opacity',{duration: this.options.duration});
       if (this.hideshow_flag)
       {
         fade.start(1,0.01);
       }else
       {
         fade.start(0.01,1);
       }
       this.hideshow_flag=!this.hideshow_flag;
	}
});
window.addEvent('domready', function() {

var Tips1 = new Tips($$('.youjoomla3'));

});


/*
* Slider News
*/
var csbustcachevar=0;
var enabletransition=1;
var csloadstatustext="Loading...";
var csexternalfiles=[];
var enablepersist=true;
var slidernodes=new Object();
var csloadedobjects="";

function GN_ContentSlider(sliderid, autorun, nextText, linkMore){
	var slider=document.getElementById(sliderid);
	if (typeof nextText!="undefined" && nextText!="")slider.nextText=nextText;
	if (typeof linkMore!="undefined" && linkMore!="")slider.linkMore=linkMore;
		
	slidernodes[sliderid]=[];
	GN_ContentSlider.loadobjects(csexternalfiles);
	var alldivs=slider.getElementsByTagName("div");
	for (var i=0; i<alldivs.length; i++){
		if (alldivs[i].className=="gn_opacitylayer")
			slider.opacitylayer=alldivs[i];
		else if (alldivs[i].className=="gn_news"){
			slidernodes[sliderid].push(alldivs[i]);
			if (typeof alldivs[i].getAttribute("rel")=="string") 
				GN_ContentSlider.ajaxpage(alldivs[i].getAttribute("rel"), alldivs[i]);
		}
	}
	GN_ContentSlider.buildpagination(sliderid);
	var loadfirstcontent=true;
	if (enablepersist && getCookie(sliderid)!=""){
		var cookieval=getCookie(sliderid).split(":");
		if (document.getElementById(cookieval[0])!=null && typeof slidernodes[sliderid][cookieval[1]]!="undefined"){
			GN_ContentSlider.turnpage(cookieval[0], parseInt(cookieval[1]));
			loadfirstcontent=false;
		}
	}
	if (loadfirstcontent==true)
		GN_ContentSlider.turnpage(sliderid, 0); 
	if (typeof autorun=="number" && autorun>0)
		window[sliderid+"timer"]=setTimeout(function(){GN_ContentSlider.autoturnpage(sliderid, autorun)}, autorun);
}

GN_ContentSlider.buildpagination=function(sliderid){
	var slider=document.getElementById(sliderid);
	var paginatediv=document.getElementById("paginate-"+sliderid);
	var pcontent="";
	for (var i=0; i<slidernodes[sliderid].length; i++)
		pcontent+='<a href="#" onClick=\"GN_ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(i+1)+'</a> ';
	pcontent+='<a href="#" onClick=\"GN_ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">'+(slider.nextText || "")+'</a>';
	if (slider.linkMore)
		pcontent+=slider.linkMore;
	paginatediv.innerHTML=pcontent;
	paginatediv.onclick=function(){
	if (typeof window[sliderid+"timer"]!="undefined")
		clearTimeout(window[sliderid+"timer"]);
	}
}

GN_ContentSlider.turnpage=function(sliderid, thepage){
	var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a"); 
	for (var i=0; i<slidernodes[sliderid].length; i++){
		paginatelinks[i].className="";
		slidernodes[sliderid][i].style.display="none";
	}
	paginatelinks[thepage].className="selected";
	if (enabletransition){
		if (window[sliderid+"fadetimer"])
			clearTimeout(window[sliderid+"fadetimer"]);
		this.setopacity(sliderid, 0.1);
	}
	slidernodes[sliderid][thepage].style.display="block";
	if (enabletransition)
		this.fadeup(sliderid, thepage);
	paginatelinks[slidernodes[sliderid].length].setAttribute("rel", thenextpage=(thepage<slidernodes[sliderid].length-1)? thepage+1 : 0);
	if (enablepersist)
		setCookie(sliderid, sliderid+":"+thepage);
}

GN_ContentSlider.autoturnpage=function(sliderid, autorunperiod){
	var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a");
	var nextpagenumber=parseInt(paginatelinks[slidernodes[sliderid].length].getAttribute("rel")); 
	GN_ContentSlider.turnpage(sliderid, nextpagenumber);
	window[sliderid+"timer"]=setTimeout(function(){GN_ContentSlider.autoturnpage(sliderid, autorunperiod)}, autorunperiod);
}

GN_ContentSlider.setopacity=function(sliderid, value){ 
	var targetobject=document.getElementById(sliderid).opacitylayer || null;
	if (targetobject && targetobject.filters && targetobject.filters[0]){ 
		if (typeof targetobject.filters[0].opacity=="number")
			targetobject.filters[0].opacity=value*100;
		else
			targetobject.style.filter="alpha(opacity="+value*100+")";
		}
	else if (targetobject && typeof targetobject.style.MozOpacity!="undefined")
		targetobject.style.MozOpacity=value;
	else if (targetobject && typeof targetobject.style.opacity!="undefined")
		targetobject.style.opacity=value;
	targetobject.currentopacity=value;
}

GN_ContentSlider.fadeup=function(sliderid){
	var targetobject=document.getElementById(sliderid).opacitylayer || null;
	if (targetobject && targetobject.currentopacity<1){
		this.setopacity(sliderid, targetobject.currentopacity+0.1);
		window[sliderid+"fadetimer"]=setTimeout(function(){GN_ContentSlider.fadeup(sliderid)}, 100);
	}
}

function getCookie(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); 
	if (document.cookie.match(re))
		return document.cookie.match(re)[0].split("=")[1];
	return "";
}

function setCookie(name, value){
	document.cookie = name+"="+value;
}

GN_ContentSlider.ajaxpage=function(url, thediv){
	var page_request = false;
	var bustcacheparameter="";
	if (window.XMLHttpRequest)
		page_request = new XMLHttpRequest();
	else if (window.ActiveXObject){
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
		try{
		page_request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e){}
		}
	}
	else
		return false;
	thediv.innerHTML=csloadstatustext;
	page_request.onreadystatechange=function(){
		GN_ContentSlider.loadpage(page_request, thediv);
	}
	if (csbustcachevar)
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();
	page_request.open('GET', url+bustcacheparameter, true);
	page_request.send(null);
}

GN_ContentSlider.loadpage=function(page_request, thediv){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		thediv.innerHTML=page_request.responseText;
}

GN_ContentSlider.loadobjects=function(externalfiles){
	for (var i=0; i<externalfiles.length; i++){
		var file=externalfiles[i];
		var fileref="";
		if (csloadedobjects.indexOf(file)==-1){
			if (file.indexOf(".js")!=-1){
				fileref=document.createElement('script');
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ 
				fileref=document.createElement("link");
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref);
			csloadedobjects+=file+" ";
		}
	}
}




//
//  Buendnispartner Slider
//
//This file is part of briaskISS.
//
//    briaskISS is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    briaskISS is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with briaskISS.  If not, see <http://www.gnu.org/licenses/>.

function briaskISS(idModule, random, picInterval, transDelay, picArray)
{
	this.picRandom = random;
	this.picInterval = picInterval;
	this.transDelay = transDelay;
	this.picArray = picArray;

	this.curPic = 0;
	this.nextPic = 0;
	this.numPics = 0;
	this.curOpacity = 99
	this.nextOpacity = 0;

	this.idModule = idModule;

	this.initISS();
}

briaskISS.prototype.initISS=function()
{
	if (!document.getElementById || !document.createElement) return;

	this.picArray[0]
		= document.getElementById("briask-iss"+this.idModule).getElementsByTagName("img");

	this.numPics = this.picArray[0].length ;

	for(i = 0; i < this.picArray[0].length; i++)
		{
			this.picArray[0][i].opacity = 0;
			this.picArray[0][i].style.MozOpacity = .0;
			this.picArray[0][i].style.filter = "alpha(opacity=0)";
		}

	if (this.picRandom == 3)
	{
		this.issNextPic();
	}

	this.picArray[0][this.nextPic].style.display = "block";
	this.picArray[0][this.nextPic].style.opacity = .99;
	this.picArray[0][this.nextPic].style.MozOpacity = .99;
	this.picArray[0][this.nextPic].style.filter = "alpha(opacity=" + (.99*100) + ")";

	this.curPic = this.nextPic;
	setTimeout("briaskInstance"+this.idModule+".issShow()", this.picInterval);
}

briaskISS.prototype.issShow=function()
{
	this.issNextPic();

	this.curOpacity = 100, this.nextOpacity = 0;

	setTimeout("briaskInstance"+this.idModule+".issTransition()", this.transDelay);
}

briaskISS.prototype.issNextPic=function()
{
	if (this.picRandom == 0)
	{
		if (this.curPic < (this.numPics - 1))
		{
			this.nextPic = this.curPic + 1;
		}
		else
		{
			this.nextPic = 0;
		}
	}
	else
	{
		do
		{
			now = new Date();

			var rndPic = Math.ceil(this.numPics * Math.random(this.idModule)) - 1;

		} 	while (this.curPic == rndPic)

		this.nextPic = rndPic;
	}
}

briaskISS.prototype.issTransition = function ()
{
	this.picArray[0][this.nextPic].style.display = "block";

	this.picArray[0][this.curPic].style.opacity = this.curOpacity/100;
	this.picArray[0][this.curPic].style.MozOpacity = this.curOpacity/100;
	this.picArray[0][this.curPic].style.filter = "alpha(opacity=" + (this.curOpacity) + ")";

	this.picArray[0][this.nextPic].style.opacity = this.nextOpacity/100;
	this.picArray[0][this.nextPic].style.MozOpacity = this.nextOpacity/100;
	this.picArray[0][this.nextPic].style.filter = "alpha(opacity=" + (this.nextOpacity) + ")";

	if (this.curOpacity > 0)
	{
		this.curOpacity -= 4;
		this.nextOpacity += 4;
		setTimeout("briaskInstance"+this.idModule+".issTransition()", this.transDelay);
	}
	else
	{
		this.picArray[0][this.curPic].style.display = "none";

		this.curPic = this.nextPic;
		setTimeout("briaskInstance"+this.idModule+".issShow()", this.picInterval);
	}
}
