// JavaScript Document


    
/*
 *	BROWSER BOOKMARK
 */

function addBookmark(title,url) {
		
    if( document.all ) {
        window.external.AddFavorite( url, title);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(title, url,"");
    }
    else if( window.opera && window.print ) {
        return true;
    }
}


window.addEvent('domready', function() {

	
    if ($('main').getElements('.video')) {
        var videos	=	$('main').getElements('.video');
        videos.each(function(item,index) {
            var src		=	item.getProperty('src');
            var img		=	item.getProperty('img');
            var height	=	item.getProperty('height');
            var width	=	item.getProperty('width');
            item.setHTML('<object wmode="transparent"><param name="wmode" value="transparent"/><param name="FlashVars" value="file='+src+'&amp;backcolor=0x000000&amp;frontcolor=0xCCCCCC&amp;lightcolor=0x557722&amp;image='+img+'"/><embed type="application/x-shockwave-flash" src="http://entwickler.de/zonen/magazine/videos/flvplayer.swf" style="" id="single" name="single" quality="high" allowfullscreen="true" flashvars="file='+src+'&amp;backcolor=0x000000&amp;frontcolor=0xCCCCCC&amp;lightcolor=0x557722&amp;image='+img+'" height="'+height+'" width="'+width+'"></object>');
        });
    }


    if ($('random_exhibitors'))
    {

        //hole die Topspeaker
        var module_sponsors	=	$('random_exhibitors').getProperty('rel');
        var lang_sponsors	=	$('random_exhibitors').getProperty('lang');
        var host	=	window.location.host;
        url_sponsors		=	'http://'+host+'/konferenzen/ext_scripts/v3/php/random_projects_rotate.php?module='+module_sponsors+'&lang='+lang_sponsors;
        var data_sponsors	=	new Ajax(url_sponsors, {
                                            method: 'get',
                                            update: $('random_exhibitors')
                                        });
        data_sponsors.request();
        ( function () {
            data_sponsors.request();
        }).periodical(5000);
    }

		
    if ($('twitter')) {
			
        twitterContainer	=	$('twitter');
        twitterID			=	twitterContainer.getProperty('user');
        twitterName			=	twitterContainer.getProperty('name');
        twitterLimit		=	2;
			
        // http://twitter.com/statuses/user_timeline/*twitterID*.json
        twitterRequestUrl		=	"/konferenzen/ext_scripts/v1/php/twitterJSON.php?twitterID=" + twitterID;
        twitterRequestUrl1                =        "/konferenzen/ext_scripts/v1/php/twitterJSON1.php?twitterID=" + twitterID;
        twitterRequestUrl2                =        "/konferenzen/ext_scripts/v1/php/twitterJSON2.php?twitterID=" + twitterID;

        var twitterJSON1 = new Json.Remote(twitterRequestUrl1, {
            onComplete: function(twitter){
                //alert(twitter);
                if(twitter != 0){
                    sortTwitterData(twitter);

                } else {
                    var twitterList =    new Element('ul').setProperty('id','twitterlists');
                    li = new Element('li').setStyle('visibility','hidden');
                    new Element('div').setProperty('class','content').setHTML("Twitter is currently not available.").injectInside(li);
                    li.injectInside(twitterList);
                    twitterList.injectInside(twitterContainer);

                    twitterContainerHeight = $('twitter').getStyle('height');
                    if (window.ie != true) {
                        twitterContainer.setStyle('height', 70);
                        new Fx.Style(twitterContainer, 'height', {
                            duration: 250,
                            transition: Fx.Transitions.linear
                            }).start(70,twitterContainerHeight);
                    } else {
                        col3Height	=	col3.getStyle('height').toInt();
                        col3.setStyle('height', col3Height+600);
                    }

                    twitterListings        =        $('twitterlists').getElements('li');
                    twitterListings.each(function(item,index) {
                        ( function(){
                            new Fx.Style(item, 'opacity', {
                                duration: 250,
                                transition: Fx.Transitions.linear
                                }).start(0.0,1.0);
                        }).delay(500*(index+1));
                    });

                }

                var twitterJSON2 = new Json.Remote(twitterRequestUrl2, {
                    onComplete: function(twitter){
                        if(twitter != 0){
                            var tw = document.getElementById('twitter');
                            var twl = document.getElementById('twitterlists');
                            twitterContainer.setStyle('height','');
                            tw.removeChild(twl);
                            sortTwitterData(twitter);
                        }
                    }
                    }).send();

            }
            }).send();

			
        /*
	
			var twitterJSON = new Json.Remote(twitterRequestUrl, {onComplete: function(twitter){
				// alert(dump(twitter));
				sortTwitterData(twitter);
			}}).send();
			*/
			
			
        function sortTwitterData(data) {
            //alert(dump(data[0]));
				
            // auslesen der elemente des twitterObjects
            twitterObjectLength	=	data.length;
            twitterObject		=	data;
            twitterResults		= 	new Array();
				
				
            var	twitterList	=	new Element('ul').setProperty('id','twitterlists');
				
            twitterObject.each(function(item,index) {
                if (index < twitterLimit)	{
                    twitterResults[index]				= 	new Array();
                    twitterResults[index]["name"]		=	twitterObject[index]["user"]["name"];
                    twitterResults[index]["location"]	=	twitterObject[index]["user"]["location"];
                    twitterResults[index]["url"]		=	"http://twitter.com/"+twitterObject[index]["user"]["name"];
                    twitterResults[index]["date"]		=	twitterObject[index]["created_at"];
                    twitterResults[index]["text"]		=	twitterObject[index]["text"];
						
						
                    // Datum transformieren
                    // Fri Jun 27 13:31:43 +0000 2008 => Freitag, 27. Juni, 13:31 Uhr
						
                    twitterResults[index]["date"]	=	twitterResults[index]["date"].substr(0, twitterResults[index]["date"].lastIndexOf("+"));


                    // Urls in texten finden und ggfls formatieren
                    if (twitterResults[index]["text"].contains('http')) {
                        twitterResults[index]["text"] = twitterResults[index]["text"].replace(/(http:\/\/\S*)/g, '<a href="$1">$1<\/a> ');
                    } else if (twitterResults[index]["text"].contains('www') ){
                        twitterResults[index]["text"] = twitterResults[index]["text"].replace(/(www.\S*)/g, '<a href="http://$1">$1<\/a> ');
                    }
                    if (twitterResults[index]["text"].contains('@') ){
                        twitterResults[index]["text"] = twitterResults[index]["text"].replace(/(@\S*)/g, '<a href="http://www.twitter.com/$1">$1<\/a> ').replace('@','');
                    }
                    if (twitterResults[index]["text"].contains('#') ){
                        twitterResults[index]["text"] = twitterResults[index]["text"].replace(/(#\S*)/g, '<a href="http://twitter.com/search?q=$1">$1<\/a> ').replace('q=#','q=%23');
                    }
						
                    // erstellen des HTML Quellcoed
                    li	=	new Element('li').setStyle('visibility','hidden');
                    div	=	new Element('div').setProperty('class','content');
                    // new Element('a').setProperty('href',twitterResults[index]["url"]).setText(twitterResults[index]["name"]+": ").injectInside(div);
                    new Element('span').setHTML(twitterResults[index]["text"]).injectInside(div);
                    new Element('div').setText(twitterResults[index]["date"]).setProperty('class','date').injectInside(div);
                    div.injectInside(li);
                    li.injectInside(twitterList);
                }
                if (index == twitterLimit)	{
                    li	=	new Element('li').setStyle('visibility','hidden');
                    new Element('div').setProperty('class','content').setHTML("Latest <b>"+ twitterLimit +"</b> Messages from Twitter.<br> More under <a href='http://twitter.com/"+twitterName+"'>http://twitter.com/"+twitterName+"</a> ").injectInside(li);
						
                    li.injectInside(twitterList);
                }
            });

				
            twitterList.injectInside(twitterContainer);
            // shcnell holen der höhe und sofort verstecken!
            twitterContainerHeight	=	$('twitter').getStyle('height');
			
				
            if (window.ie != true) {
                // alert(twitterContainerHeight);
                twitterContainer.setStyle('height', 70);
					
                new Fx.Style(twitterContainer, 'height', {
                    duration: 250,
                    transition: Fx.Transitions.linear
                    }).start(70,twitterContainerHeight);
            } else {
                col3Height	=	col3.getStyle('height').toInt();
                col3.setStyle('height', col3Height+600);
            }

					
            twitterListings	=	$('twitterlists').getElements('li');
            twitterListings.each(function(item,index) {
                ( function(){
                    new Fx.Style(item, 'opacity', {
                        duration: 250,
                        transition: Fx.Transitions.linear
                        }).start(0.0,1.0);
                }).delay(500*(index+1));
            });
				
				
        // einfaden und ausfahren der twitterbox
        }
			
			
	
			
			
			
			
			
    }
	
	
	
	
	
	
	
    if ($('generateSidebar'))
    {
        if ($('sessions-js'))
        {
            new Element('h2').setText('Sessions').injectInside('col3_content');
        }
			
        // hole alle h3s
        headlines	=	$('col1_content').getElements('h3');
        output	=	new Element('div',{
            'id': 'col3_anchors',
            'class': 'box'
        });
        ul		=	new Element('ul');
        headlines.each(function(item, index)
        {
					
            if (item.getElement('span[class=company]'))
            {
                company	=	item.getElement('span[class=company]').getText();
                item.getElement('span[class=company]').setText('');
                name	=	item.getText('');
                item.getElement('span[class=company]').setText(company);
            }
            else if (item.getElement('span[class=info]'))
            {
                company	=	item.getElement('span[class=info]').getText();
                item.getElement('span[class=info]').setText('');
                name	=	item.getText('');
                item.getElement('span[class=info]').setText(company);
            }
            else
            {
                name	=	item.getText('');
            }
            li	=	new Element('li');
            a	=	new Element('a').setText(name).setStyle('cursor','pointer');
            a.addEvent('click', function()
            {
                scroller.toElement(item);
            });
            a.injectInside(li);
            li.injectInside(ul);
				
        });
				
        ul.injectInside(output);
        output.injectInside('col3_content');
		
		
		
		

		
    }
    else
    {
        if($('col3_anchors')) {
            scrolling('col3_anchors');
        }
        
    }
		
	
	
    // Tool Tips
	
    var Tips1 = new Tips($$('.tooltip'));
    var Tips2 = new Tips($$('.tooltip_arrow'), {
        className: 'arrow'
    });


			
    if ( $('feed-icon') != null)
    {
        $('feed-icon').addEvent('mouseover', function()	{
            this.src='/konferenzen/img/layout/feed-active.png';
        });
        $('feed-icon').addEvent('mouseout', function()	{
            this.src='/konferenzen/img/layout/feed-inactive.png';
        });
        $('blog-icon').addEvent('mouseover', function()	{
            this.src='/konferenzen/img/layout/blog-active.png';
        });
        $('blog-icon').addEvent('mouseout', function()	{
            this.src='/konferenzen/img/layout/blog-inactive.png';
        });
        $('flickr-icon').addEvent('mouseover', function(){
            this.src='/konferenzen/img/layout/blog-active.png';
        });
        $('flickr-icon').addEvent('mouseout', function(){
            this.src='/konferenzen/img/layout/blog-inactive.png';
        });
        $('speaker-icon').addEvent('mouseover', function(){
            this.src='/konferenzen/img/layout/blog-active.png';
        });
        $('speaker-icon').addEvent('mouseout', function(){
            this.src='/konferenzen/img/layout/blog-inactive.png';
        });
    }
	
    if ( $('toplink') != null)
    {
        $('toplink').addEvent('click', function() {
            scroller.toTop();
        });
    }
		
    var scroller = new Fx.Scroll(window);
    var el	=	$('col1_content').getElements('a[name=top]');
    for (var i=0;i<=el.length-1;i++)
    {
        var element	= el[i];
        $(element).addEvent('click', function() {
            scroller.toTop();
        });
    }

	




    if (navigator.appName.indexOf("Explorer") != -1)
    {
        var col1Height	=	$('col1').getStyle('height');
        var col3Height	=	$('col3').getStyle('height');
        col1Height	=	col1Height.replace('px','');
        col1Height	=	parseInt(col1Height);
        col3Height	=	col3Height.replace('px','');
        col3Height	=	parseInt(col3Height);
        if (col1Height >= col3Height)
        {
            $('col3').setStyle('height', col1Height);
        }
			
    }


});


/* Googlemaps Implementierung */

var googleMaps	=	new Array();
var	googleAdressIndex	=	"";
var map			=	new Array();
var geocoder	=	new Array();
	
window.addEvent('load', function() {
    if (googleMaps.length > 0) {
        containerMaps	=	$('col1').getElements('div[id=google]');
        googleMaps.each(function(item, index){
            /* Google API:begin --------------------------------------------------- */
            map[index] 			= null;
            geocoder[index] 	= null;
						
            containerMaps[index].setStyles({
                'height':375,
                'margin':'0px 0px 0px 0px',
                'overflow':'hidden'
            });

							
            if (GBrowserIsCompatible()) {
							  
                map[index] = new GMap2(containerMaps[index]);
								
                //map[index].setOnLoadCallback(function() { alert('fertig geladen'); });
								
                map[index].addControl(new GSmallMapControl());
                // map[index].addControl(new GScaleControl());
                geocoder[index] = new GClientGeocoder();
								
                eventTabOne	=	"<b>"+item['name']+"</b><br/>"+item['strasse']+"<br/>"+item['ort']+"<br/><a href='"+item['webseite']+"'>"+item['webseite']+"</a>";
                eventTabTwo	=	"";
								
                var tabsArray		=	new Array();
                tabsArray[0]	=	new GInfoWindowTab("Adresse", eventTabOne);
                address	=	item['adress'];
							
                if (geocoder[index]) {
                    geocoder[index].getLatLng(
                        address,
                        function(point) {
                            if (!point) {
                                alert(address + " not found");
                            }
									

                            map[index].setCenter(point, 13);
                            map[index].panDirection(0, 1);
									  
                            var marker = new GMarker(point);
                            map[index].addOverlay(marker);
                            marker.openInfoWindowTabs(tabsArray);
                            GEvent.addListener(marker, "click", function() {
                                marker.openInfoWindowTabs(tabsArray);
                            });
									
                        }
                        );
                }
            }
        /* Google API:en ----------------------------------------------------- */
        });
    }
});
	
	
	


window.addEvent('load', function() {
	
	
    if ($('shortlinks'))
    {
        $('col3_content').empty();
        $('shortlinks').injectInside('col3_content');
			
    }


    // Navigation
    if ( $('navigation') != null)
    {
        var links		=	$$('#navigation li.shover');
        var homebtn             =	$('navigation').getElements('li[class=c]');
        var subitems            =	$$('#navigation ul.subitem');
        var lastItem            =	0;
        var navPosition 	= 	$('navigation').getPosition().x;
        var navheight           = 	$('navigation').getStyle('height').toInt();

        window.addEvent('resize', function(){
            navPosition = 	$('navigation').getPosition().x;
        });
        window.addEvent('load', function(){
            navPosition = 	$('navigation').getPosition().x;
        });
        for (var i=0;i<=links.length-1;i++)
        {
            var element	= links[i];
            var elmPosition = null;
            var curIndex = i;


            element.setProperty('rel',i);

            element.addEvent('mouseover', function() {
                elmPosition		=	this.getPosition().x;
                submenuPosition         = 	(elmPosition) - navPosition;
                show(parseInt(this.getProperty('rel')), submenuPosition);
            });

            element.addEvent('click', function() {
                elmPosition		=	this.getPosition().x;
                submenuPosition         = 	(elmPosition) - navPosition;
                show(parseInt(this.getProperty('rel')), submenuPosition);
            });

            subitems.addEvent('mouseleave', function() {
                hide(parseInt(this.getProperty('rel')));
            });
        }

    }

    function show(index, pos) {

        hide(lastItem);
        subitems[index].setStyles({
            'display':'block',
            'position':'absolute',
            'top': (navheight),
            'left': (pos+10)+'px',
            'z-index':'999'
        });
        lastItem = index;
    }

    function hide(index, pos) {
        subitems.setStyles({
            'display':'none'
        });
    }
});

// PopUp Script //

var pop = null;

function popdown() {
//if (pop && !pop.closed) pop.close();
}

function popup(obj,w,h) {
    var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
    if (!url) return true;
    w = (w) ? w += 20 : 150;  // 150px*150px is the default size
    h = (h) ? h += 25 : 150;
    var args = 'width='+w+',height='+h+',resizable,'+'scrollbars=yes';
    popdown();
    pop = window.open(url,'',args);
    return (pop) ? false : true;
}

window.onunload = popdown;
window.onfocus = popdown;


/**
 * adds the title (second h1-tag) at the end of the url in the link-object
 */
function addTitle(linkObj) {
    linkObj.href += document.getElementsByTagName("h2")[0].innerHTML;
}


//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
    var version;
    var axo;
    var e;

    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }

    if (!version)
    {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful.
			
            // default to the first public version
            version = "WIN 6,0,21,0";

            // throws if AllowScripAccess does not exist (introduced in 6.0r47)
            axo.AllowScriptAccess = "always";

            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");

        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }
	
    return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;
	
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // older WebTV supports Flash 2
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if ( isIE && isWin && !isOpera ) {
        flashVer = ControlVersion();
    }
    return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
    versionStr = GetSwfVer();
    if (versionStr == -1 ) {
        return false;
    } else if (versionStr != 0) {
        if(isIE && isWin && !isOpera) {
            // Given "WIN 2,0,0,11"
            tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
            tempString        = tempArray[1];			// "2,0,0,11"
            versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
        } else {
            versionArray      = versionStr.split(".");
        }
        var versionMajor      = versionArray[0];
        var versionMinor      = versionArray[1];
        var versionRevision   = versionArray[2];

        // is the major.revision >= requested major.revision AND the minor version >= requested minor
        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
}

function AC_AddExtension(src, ext)
{
    if (src.indexOf('?') != -1)
        return src.replace(/\?/, ext+'?');
    else
        return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
        str += '<object ';
        for (var i in objAttrs)
        {
            str += i + '="' + objAttrs[i] + '" ';
        }
        str += '>';
        for (var i in params)
        {
            str += '<param name="' + i + '" value="' + params[i] + '" /> ';
        }
        str += '</object>';
    }
    else
    {
        str += '<embed ';
        for (var i in embedAttrs)
        {
            str += i + '="' + embedAttrs[i] + '" ';
        }
        str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
    var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
        , "application/x-shockwave-flash"
        );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
    var ret =
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
        , null
        );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
    var ret = new Object();
    ret.embedAttrs = new Object();
    ret.params = new Object();
    ret.objAttrs = new Object();
    for (var i=0; i < args.length; i=i+2){
        var currArg = args[i].toLowerCase();

        switch (currArg){
            case "classid":
                break;
            case "pluginspage":
                ret.embedAttrs[args[i]] = args[i+1];
                break;
            case "src":
            case "movie":
                args[i+1] = AC_AddExtension(args[i+1], ext);
                ret.embedAttrs["src"] = args[i+1];
                ret.params[srcParamName] = args[i+1];
                break;
            case "onafterupdate":
            case "onbeforeupdate":
            case "onblur":
            case "oncellchange":
            case "onclick":
            case "ondblclick":
            case "ondrag":
            case "ondragend":
            case "ondragenter":
            case "ondragleave":
            case "ondragover":
            case "ondrop":
            case "onfinish":
            case "onfocus":
            case "onhelp":
            case "onmousedown":
            case "onmouseup":
            case "onmouseover":
            case "onmousemove":
            case "onmouseout":
            case "onkeypress":
            case "onkeydown":
            case "onkeyup":
            case "onload":
            case "onlosecapture":
            case "onpropertychange":
            case "onreadystatechange":
            case "onrowsdelete":
            case "onrowenter":
            case "onrowexit":
            case "onrowsinserted":
            case "onstart":
            case "onscroll":
            case "onbeforeeditfocus":
            case "onactivate":
            case "onbeforedeactivate":
            case "ondeactivate":
            case "type":
            case "codebase":
            case "id":
                ret.objAttrs[args[i]] = args[i+1];
                break;
            case "width":
            case "height":
            case "align":
            case "vspace":
            case "hspace":
            case "class":
            case "title":
            case "accesskey":
            case "name":
            case "tabindex":
                ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
                break;
            default:
                ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
        }
    }
    ret.objAttrs["classid"] = classid;
    if (mimeType) ret.embedAttrs["type"] = mimeType;
    return ret;
}

Slideshow = new Class({
	
    //-------------------------------------------------------
    //	Function: initialize
    //
    //	  Called automatically when a new slideshow instance is created.
    //
    //	Arguments:
    //
    //	  slideshow     - Instance or ID of element that wraps the slideshow images, usually a DIV
    //	  props					- Property list as described for the class
    //-------------------------------------------------------

    initialize: function(slideshow, props) {
        this.props = Object.extend({
            captions: false,
            classes: ['prev', 'next', 'active'],
            duration: [2000, 4000],
            height: false,
            hu: '/',
            images: [],
            navigation: false,
            pan: 100,
            resize: true,
            thumbnailre: [/\./, 't.'],
            transition: Fx.Transitions.sineInOut,
            type: 'fade',
            width: false,
            zoom: 50
        }, props || {});

        if (this.props.images.length <= 1) {
            return;
        }

        if (this.props.pan != 'rand') {
            if (isNaN(this.props.pan.toInt()) || this.props.pan.toInt() < 0 || this.props.pan.toInt() > 100) {
                this.props.pan = 0;
            }
        }

        if (this.props.zoom != 'rand') {
            if (isNaN(this.props.zoom.toInt()) || this.props.zoom.toInt() < 0 || this.props.zoom.toInt() > 100) {
                this.props.zoom = 0;
            }
        }

        this.slideshow = $(slideshow);

        this.a = img = $E('img', this.slideshow);

        this.fx = [];

        this.start();
    },

    //-------------------------------------------------------
    //	Function: start
    //
    //	  Sets class variables; creates slideshow, navigation and caption elements; resizes images.
    //-------------------------------------------------------
	
    start: function() {
        this.slideshow.setHTML('');

        this.a.setStyles({
            display: 'block',
            position: 'absolute',
            left: '0px',
            top: '0px',
            zIndex: 1
        });
        this.a.injectInside(this.slideshow);
		
        this.fx.each(function(fx) {
            fx.time = fx.options.duration = 0;
            fx.stop(true);
        });

        obj = this.a.getCoordinates();

        this.height = ((this.props.height) ? this.props.height : obj['height']);
        this.width = ((this.props.width) ? this.props.width : obj['width']);
		
        this.slideshow.setStyles({
            display: 'block',
            position: 'relative',
            width: this.width + 'px'
            });

        // Images appear within a bounding div inside of the slideshow div
        // This div may be used to attach events - such as myShow.div.onmouseover - in order to show / hide navigation or further manipulate the slideshow
        this.div = new Element('div');
        this.div.setStyles({
            display: 'block',
            height: (this.height + 'px'),
            overflow: 'hidden',
            position: 'relative',
            width: (this.width + 'px')
            });
        this.div.injectInside(this.slideshow);

        this.a.injectInside(this.div);

        if ((this.props.height || this.props.width) && this.props.resize) {
            dh = this.height / obj['height'];
            dw = this.width / obj['width'];
	
            n = (dw > dh) ? dw : dh;

            this.a.setStyles({
                height: Math.ceil(obj['height'] * n) + 'px',
                width: Math.ceil(obj['width'] * n) + 'px'
                });
        }
				
        this.b = this.a.clone();
        this.b.setStyle('opacity', 0);
        this.b.injectAfter(this.a);

        if (this.props.navigation) {
            this.navigation();
        }

        if ($type(this.props.captions) == 'array') {
            this.p = new Element('p');
            this.p.setHTML(this.props.captions[0]);
            this.p.injectInside(this.slideshow);
        }

        this.direction = 'left';
        this.curr = [1, 1];
        this.timer = (this.timer) ? [0] : [(new Date).getTime() + this.props.duration[1], 0];

        this.loader = new Image();
        this.loader.src = this.props.hu + this.props.images[this.curr[0]].trim();

        this.preload();
    },

    //-------------------------------------------------------
    //	Function: preload
    //
    //	  Loops until new image has loaded or delay has been met; calculates and executes effects.
    //
    //	Arguments:
    //
    //	  fast     		- True if the navigation is in 'fast' mode
    //-------------------------------------------------------

    preload: function(fast) {
        if (this.loader.complete && ((new Date).getTime() > this.timer[0])) {
            img = (this.curr[1] % 2) ? this.b : this.a;
            img.setStyles({
                height: 'auto',
                opacity: 0,
                width: 'auto',
                zIndex: this.curr[1]
                });
            img.setProperty('src', this.loader.src);
			
            dh = this.height / this.loader.height;
            dw = this.width / this.loader.width;

            n = (dw > dh) ? dw : dh;

            if (this.props.resize) {
                img.setStyles({
                    height: Math.ceil(this.loader.height * n) + 'px',
                    width: Math.ceil(this.loader.width * n) + 'px'
                    });
            }
			
            if (fast) {
                img.setStyles({
                    left: '0px',
                    opacity: 1,
                    top: '0px'
                });
                if ($type(this.props.captions) == 'array') {
                    this.p.setHTML(this.props.captions[this.curr[0]]).setStyle('opacity', 1);
                }
                return this.loaded();
            }

            this.fx = [];

            if ($type(this.props.captions) == 'array') {
                fn = function(i) {
                    if (this.props.captions[i]) {
                        this.p.setHTML(this.props.captions[i]);
                    }
					
                    fx = new Fx.Style(this.p, 'opacity');
                    fx.start(0, 1);
                    this.fx.push(fx);
                }.pass(this.curr[0], this);
	
                fx = new Fx.Style(this.p, 'opacity', {
                    onComplete: fn
                });
                fx.start(1, 0);
                this.fx.push(fx);
            }

            if (this.props.type.test(/push|wipe/)) {
                img.setStyles({
                    left: 'auto',
                    right: 'auto'
                });
                img.setStyle(this.direction, this.width + 'px');
                img.setStyle('opacity', 1);

                if (this.props.type == 'wipe') {
                    fx = new Fx.Style(img, this.direction, {
                        duration: this.props.duration[0],
                        transition: this.props.transition
                        });
                    fx.start(this.width, 0);
                    this.fx.push(fx);
                }
                else {
                    arr = [img, ((this.curr[1] % 2) ? this.a : this.b)];

                    p0 = {};
                    p0[this.direction] = [this.width, 0];
                    p1 = {};
                    p1[this.direction] = [0, (this.width * -1)];

                    // Navigation has changed direction
                    // The image shifts when changing from right <> left so we need to correct the positioning
                    if (arr[1].getStyle(this.direction) == 'auto') {
                        x = this.width - arr[1].getStyle('width').toInt();
					
                        arr[1].setStyle(this.direction, x + 'px');
                        arr[1].setStyle(((this.direction == 'left') ? 'right' : 'left'), 'auto');
						 
                        p1[this.direction] = [x, (this.width * -1)];
                    }
					
                    fx = new Fx.Elements(arr, {
                        duration: this.props.duration[0],
                        transition: this.props.transition
                        });
                    fx.start({
                        '0': p0,
                        '1': p1
                    });
                    this.fx.push(fx);
                }
            }
            else {
                img.setStyles({
                    bottom: 'auto',
                    left: 'auto',
                    right: 'auto',
                    top: 'auto'
                });

                arr = ['left top', 'right top', 'left bottom', 'right bottom'][this.curr[1] % 4].split(' ');
                arr.each(function(p) {
                    img.setStyle(p, 0);
                });

                zoom = ((this.props.type).test(/zoom|combo/)) ? this.zoom() : {};
					
                pan = ((this.props.type).test(/pan|combo/)) ? this.pan() : {};
				
                fx = new Fx.Style(img, 'opacity', {
                    duration: this.props.duration[0]
                    });
                fx.start(0, 1);
                this.fx.push(fx);

                fx = new Fx.Styles(img, {
                    duration: (this.props.duration[0] + this.props.duration[1]),
                    transition: Fx.Transitions.linear
                    });
                fx.start(Object.extend(zoom, pan));
                this.fx.push(fx);
            }

            this.loaded();
        }
        else {
            this.timeout = this.preload.delay(100, this);
        }
    },

    //-------------------------------------------------------
    //	Function: loaded
    //
    //	  Sets next image in slideshow; updates status of navigation elements.
    //-------------------------------------------------------

    loaded: function() {
        if (this.ul) {
            anchors = $ES('a[name]', this.ul);
            anchors.each(function(a, i) {
                if (i == this.curr[0]) {
                    a.addClass(this.props.classes[2]);
                }
                else {
                    a.removeClass(this.props.classes[2]);
                }
            }, this);
        }

        this.direction = 'left';
        this.curr[0] = (this.curr[0] == this.props.images.length - 1) ? 0 : this.curr[0] + 1;
        this.curr[1]++;
        this.timer[0] = (new Date).getTime() + this.props.duration[1] + ((this.props.type.test(/fade|push|wipe/)) ? this.props.duration[0] : 0);
        this.timer[1] = (new Date).getTime() + this.props.duration[0];

        this.loader = new Image();
        this.loader.src = this.props.hu + this.props.images[this.curr[0]].trim();
		
        this.preload();
    },

    //-------------------------------------------------------
    //	Function: zoom
    //
    //	  Calculates degree of zooming based on image and slideshow properties.
    //
    //	Returns:
    //
    //	  A property array with the height and width styles for the effect.
    //-------------------------------------------------------

    zoom: function() {
        z = (this.props.zoom == 'rand') ? Math.random() + 1 : (this.props.zoom.toInt() / 100.0) + 1;

        eh = Math.ceil(this.loader.height * n);
        ew = Math.ceil(this.loader.width * n);

        sh = parseInt(eh * z);
        sw = parseInt(ew * z);

        return {
            height: [sh, eh],
            width: [sw, ew]
            };
    },



    //-------------------------------------------------------
    //	Function: pan
    //
    //	  Calculates degree of panning based on image and slideshow properties.
    //
    //	Returns:
    //
    //	  A property array with the left and right styles for the effect.
    //-------------------------------------------------------

    pan: function() {
        p = (this.props.pan == 'rand') ? Math.random() : Math.abs((this.props.pan.toInt() / 100.0) - 1);

        ex = (this.width - img.width);
        ey = (this.height - img.height);

        sx = parseInt(ex * p);
        sy = parseInt(ey * p);

        obj = {};

        if (dw > dh) {
            obj[arr[1]] = [sy, ey]
        }
        else {
            obj[arr[0]] = [sx, ex];
        }
		
        return obj;
    },

    //-------------------------------------------------------
    //	Function: navigation
    //
    //	  Generates navigation elements / functionality based on slideshow properties
    //-------------------------------------------------------

    navigation: function() {
        this.ul = new Element('ul');

        if (this.props.navigation.test(/arrows/)) {
            li = new Element('li');

            a = new Element('a');
            a.addClass(this.props.classes[0]);
            a.onclick = function() {
                if (this.props.navigation.test(/fast/) || (new Date).getTime() > this.timer[1]) {
                    $clear(this.timeout);
			
                    // Clear the FX array only for fast navigation since this stops combo effects
                    if (this.props.navigation.test(/fast/)) {
                        this.fx.each(function(fx) {
                            fx.time = fx.options.duration = 0;
                            fx.stop(true);
                        });
                    }

                    this.direction = 'right';
                    this.curr[0] = (this.curr[0] < 2) ? this.props.images.length - (2 - this.curr[0]) : this.curr[0] - 2;
                    this.timer = [0];
					
                    this.loader = new Image();
                    this.loader.src = this.props.hu + this.props.images[this.curr[0]].trim();

                    this.preload(this.props.navigation.test(/fast/));
                }
            }.bind(this);
            a.injectInside(li);
			
            li.injectInside(this.ul);
        }
		
        if (this.props.navigation.test(/arrows\+|thumbnails/)) {
            for (i = 0; i < this.props.images.length; i++) {
                li = new Element('li');

                a = new Element('a');
                a.setProperty('name', i);
                if (this.props.navigation.test(/thumbnails/)) {
                    src = this.props.hu + this.props.images[i].trim().replace(this.props.thumbnailre[0], this.props.thumbnailre[1]);
                    a.setStyle('background-image', 'url(' + src + ')');
                }
                if (i == 0) {
                    a.className = this.props.classes[2];
                }
                a.onclick = function(i) {
                    if (this.props.navigation.test(/fast/) || (new Date).getTime() > this.timer[1]) {
                        $clear(this.timeout);
				
                        // Clear the FX array only for fast navigation since this stops combo effects
                        if (this.props.navigation.test(/fast/)) {
                            this.fx.each(function(fx) {
                                fx.time = fx.options.duration = 0;
                                fx.stop(true);
                            });
                        }
						
                        this.direction = (i < this.curr[0] || this.curr[0] == 0) ? 'right' : 'left';
                        this.curr[0] = i;
                        this.timer = [0];
		
                        this.loader = new Image();
                        this.loader.src = this.props.hu + this.props.images[this.curr[0]].trim();
		
                        this.preload(this.props.navigation.test(/fast/));
                    }
                }.pass(i, this);
                a.injectInside(li);
				
                li.injectInside(this.ul);
            }
        }

        if (this.props.navigation.test(/arrows/)) {
            li = new Element('li');
	
            a = new Element('a');
            a.addClass(this.props.classes[1]);
            a.onclick = function() {
                if (this.props.navigation.test(/fast/) || (new Date).getTime() > this.timer[1]) {
                    $clear(this.timeout);

                    // Clear the FX array only for fast navigation since this stops combo effects
                    if (this.props.navigation.test(/fast/)) {
                        this.fx.each(function(fx) {
                            fx.time = fx.options.duration = 0;
                            fx.stop(true);
                        });
                    }

                    this.timer = [0];

                    this.preload(this.props.navigation.test(/fast/));
                }
            }.bind(this);
            a.injectInside(li);
			
            li.injectInside(this.ul);
        }

        this.ul.injectInside(this.slideshow);
    }
});
	

	