Event.observe(window, 'load', function()
{
	newAnimation = new Animation();
	newAnimation.slideshow(1,4000,'dia');
	
});

function getElementsByClass(searchClass,node,tag) {
        var classElements = new Array();
        if ( node == null )
                node = document;
        if ( tag == null )
                tag = '*';
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
        for (i = 0, j = 0; i < elsLen; i++) {
                if ( pattern.test(els[i].className) ) {
                        classElements[j] = els[i];
                        j++;
                }
        }
        return classElements;
}


var Animation = Class.create(
{
	slideshow: function(start,interval,target)
	{
		var frame 		= start;   
		var nextframe 	= start+1;
		
		if ($('dia' + frame))
		{
			
			//var last		= $('dia' + frame).parentNode.getElementsByClassName('dia').length;
			var last = getElementsByClass('dia', $('dia' + frame).parentNode).length;
			
//			Effect.Appear(target+'1',{duration:.5,from:0.0,to:1.0});   
			
			setInterval(function()
			{   
				Effect.Fade(target+frame,
						{	duration:.5,
							from:1.0,
							to:0.0,
							afterFinish:function()
							{
								$(target+frame).hide();
								
							    frame = nextframe;
							    nextframe = (frame == last) ? start : nextframe+1;
							},
							beforeStart:function()
							{
							    Effect.Appear(target + nextframe,{duration:.5,from:0.0,to:1.0});
							}
						});
			}, interval);   
		}
		return; 
	}
});

function show360 (id)
{
	var so = new SWFObject("/flash/360/"+ id +".swf", "mymovie", "636", "320", "8", "transparent");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.write('full_frame');
	
}

function loadMovie ()
{
	var so = new SWFObject("/flash//opening.swf", "mymovie", "514", "320", "8", "transparent");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.write('flashmovie');
	
}


function webcam()
{
	// Set the BaseURL to the URL of your camera
		
		var BaseURL = "http://82.95.161.214/";
		
		// DisplayWidth & DisplayHeight specifies the displayed width & height of the image. You may change these numbers, the effect will be a stretched or a shrunk image
		
		var DisplayWidth = "320";
		var DisplayHeight = "240";
		
		// This is the path to the image generating file inside the camera itself
		
		var File = "axis-cgi/mjpg/video.cgi?resolution=320x240&compression=30&color=1&clock=1&date=1&text=0";
		
		// No changes required below this point
		
		var output = "";
		
		if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k"))
		{
			// If Internet Explorer under Windows then use ActiveX 
			output  = '<OBJECT ID="Player" width='
			output += DisplayWidth;
			output += ' height=';
			output += DisplayHeight;
			output += ' CLASSID="CLSID:745395C8-D0E1-4227-8586-624CA9A10A8D" ';
			output += 'CODEBASE="';
			output += BaseURL;
			output += 'activex/AMC.cab#version=2,0,22,0">';
			output += '<param name="MediaURL" VALUE="';
			output += BaseURL;
			output += File + '">';
			output += '<param name="MediaType" value="mjpeg-unicast">';
			output += '<param name="ShowStatusBar" value="0">';
			output += '<param name="ShowToolbar" value="0">';
			output += '<param name="AutoStart" value="1">';
			output += '<param name="StretchToFit" value="1">';
			output += '<BR><B>Axis Media Control</B><BR>';
			output += 'The AXIS Media Control, which enables you ';
			output += 'to view live image streams in Microsoft Internet';
			output += ' Explorer, could not be registered on your computer.';
			output += '<BR></OBJECT>';
		}
		else
		{
			// If not IE for Windows use the browser itself to display
			theDate = new Date();
			output  = '<IMG SRC="';
			output += BaseURL;
			output += File;
			output += '&dummy=' + theDate.getTime().toString(10);
			output += '" HEIGHT="';
			output += DisplayHeight;
			output += '" WIDTH="';
			output += DisplayWidth;
			output += '" ALT="Camera Image">';
		}
		document.write(output);
		document.Player.ToolbarConfiguration = "play,+snapshot,+fullscreen"
	
}