var ocrotator = {
	slideSrc : new Array(),
	slideTitle :new Array(),
	slideAlt : new Array(),
	slideWidth : new Array(),
	slideHeight :new Array(),
	slideLink : new Array(),
	slideTarget : new Array(),
	currImage : 0,
	timerId : 0,
	fadestart : 17,
	fadeval : 17,
	maxheight : 300,
	maxwidth : 400,
	maxslides : 4,
	playing : false,
	startRotator : function()
		{
		ocrotator.playing=true;
		if(ocrotator.slideSrc.length>1)
			ocrotator.timerId=window.setTimeout(ocrotator.nextSlide,2000);
		},
	crossFade : function()
		{
		var fadein=0;
		var fadeout=0;
		var fadepointer=0;
		ocrotator.timerId=0;
		if(ocrotator.fadeval>0)
			{
			ocrotator.fadeval--;
			fadeout=ocrotator.fadeval-(ocrotator.fadestart-10);
			if(fadeout<0)
				fadeout=0;
			fadein=10-ocrotator.fadeval;
			if(fadein<0)
				fadein=0;
			fadepointer=(fadein>fadeout)?fadein:fadeout;
			if(fadepointer<0)
				fadepointer=0;
			var strID="";
			var str="";
			
			var i=0;
			for(i=0;i<ocrotator.slideSrc.length;i++)
				{
				if(i!=ocrotator.currImage)
					{
					strID="slideImageDiv"+i;
					str="alpha(opacity="+fadeout+"0)";
					document.getElementById(strID).style.filter=str;
					str = (fadeout/10).toPrecision(1);
					document.getElementById(strID).style.opacity=str;
					if(fadeout==0)
						document.getElementById(strID).style.display="none";
					}
				}
			
			strID="slideImageDiv"+ocrotator.currImage;
			document.getElementById(strID).style.display="block";
			str="alpha(opacity="+fadein+"0)";
			document.getElementById(strID).style.filter=str;
			str = (fadein/10).toPrecision(1);
			document.getElementById(strID).style.opacity=str;

			strID="slideImagePointer";
			str="alpha(opacity="+fadepointer+"0)";
			document.getElementById(strID).style.filter=str;
			str = (fadepointer/10).toPrecision(1);
			document.getElementById(strID).style.opacity=str;
			if(fadeout==1)
				{
				var tHeight=30;
				if(ocrotator.maxslides)
					tHeight=parseInt((ocrotator.maxheight/ocrotator.maxslides)-5);
				var top=(ocrotator.currImage*tHeight)+(ocrotator.currImage*5)+"px";
				document.getElementById(strID).style.top=top;

				for(i=0;i<ocrotator.slideSrc.length;i++)
					{
					if(i==ocrotator.currImage)
						{
						strID="rotatorHeadDiv"+i;
						document.getElementById(strID).className="oc_rotator_link_selected";
						strID="rotatorHeadLink"+i;
						document.getElementById(strID).href=ocrotator.slideLink[i];
						}
					else
						{
						strID="rotatorHeadDiv"+i;
						document.getElementById(strID).className="oc_rotator_link";
						strID="rotatorHeadLink"+i;
						document.getElementById(strID).href="javascript:ocrotator.showSlide("+i+")";
						}
					
					}
				}				
			}
		if(ocrotator.fadeval>0)
			{
			ocrotator.timerId=window.setTimeout(ocrotator.crossFade,50);
			return;
			}
		ocrotator.fadeval=ocrotator.fadestart;
		if(ocrotator.playing)
			ocrotator.timerId=window.setTimeout(ocrotator.nextSlide,2000);
		},
	showSlide : function(index)
		{
		if(ocrotator.timerId)
			{
			window.clearTimeout(ocrotator.timerId);
			ocrotator.timerId=0;
			}
		ocrotator.playing=false;
		if(index>=ocrotator.slideSrc.length)
			return;
		ocrotator.currImage=index;
		var strID="slideImage"+ocrotator.currImage;
		if(document.getElementById(strID).src=="http://common.onset.freedom.com/images/copyrighted.gif")
			document.getElementById(strID).src=ocrotator.slideSrc[ocrotator.currImage];
		if(ocrotator.fadeval!=ocrotator.fadestart)
			ocrotator.fadeval=ocrotator.fadestart;
		else
			ocrotator.crossFade();
		},
	nextSlide : function()
		{
		if(ocrotator.fadeval!=ocrotator.fadestart)
			return;
		ocrotator.timerId=0;
		ocrotator.currImage++;
		if(ocrotator.currImage>=ocrotator.slideSrc.length)
			{
			ocrotator.currImage=0;
			ocrotator.playing=false;
			}
		var strID="slideImage"+ocrotator.currImage;
		if(document.getElementById(strID).src=="http://common.onset.freedom.com/images/copyrighted.gif")
			document.getElementById(strID).src=ocrotator.slideSrc[ocrotator.currImage];
		ocrotator.crossFade();
		},
	showContent : function(multiTitle)
		{
		var tHeight=30;
		if(ocrotator.maxslides)
			tHeight=parseInt(ocrotator.maxheight/ocrotator.maxslides);
		var tWidth=parseInt((tHeight/3)*4);
		document.write('<div style="padding:0; margin:0px; border:0px; border-right:1px solid #444444;">');
		document.write('<div style="padding:0; margin:0px; border:0px; border-right:1px solid #333333;">');
		document.write('<div style="padding:0; margin:0px; border:0px; border-bottom:1px solid #222222; border-right:1px solid #222222;">');
		document.write('<div style="padding:0; margin:0px; border:0px; border-bottom:1px solid #111111; border-right:1px solid #111111;">');
		document.write('<div style="width:628px; border:1px solid black;">');
//		document.write('<div style="height:'+ocrotator.maxheight+'px; width:'+(ocrotator.maxwidth+130)+'px; float:left;">');
		document.write('<div style="position:relative; height:'+ocrotator.maxheight+'px; width:'+(ocrotator.maxwidth)+'px; float:left;">');
		ocrotator.showSlides(tHeight);

		var html='<div id="slideImagePointer" style="position:absolute; top:0px; right:0px; background:none; margin:0px; padding:0px; z-index:5000;">';
		html+='<img src="/images/rotator_arrow_left.gif" height="'+tHeight+'px" />';
		html+='</div>';
		document.write(html);

		document.write('</div>');
		document.write('<div style="height:'+ocrotator.maxheight+'px; width:'+tWidth+'px; float:left;">');
		ocrotator.showThumbnails(tHeight);
		document.write('</div>');
		var infoWidth=628-ocrotator.maxwidth-tWidth;
		document.write('<div style="height:'+ocrotator.maxheight+'px; width:'+infoWidth+'px; padding:0px; float:left;">');
		ocrotator.showHeadlines(tHeight,multiTitle);
		document.write('</div>');
		document.write('<div style="clear:both; width=90%;"><!-- --></div>');
		document.write('</div>');
		document.write('</div>');
		document.write('</div>');
		document.write('</div>');
		document.write('</div>');
		},
	showHeadlines : function(tHeight,multiTitle)
		{
		var html="";
		var tWidth=parseInt((tHeight/3)*4);
		var th=tHeight-10;
		var thclip=tHeight-15;
		for(i=0;i<ocrotator.slideSrc.length&&i<ocrotator.maxslides;i++)
			{
			html='';
			if(i==ocrotator.currImage)
				{
				html += '<div id="rotatorHeadDiv'+i+'" class="oc_rotator_link_selected" style="height:'+th+'px; clip:rect(0 auto '+thclip+' auto);">';
				html += '<a id="rotatorHeadLink'+i+'" href="'+ocrotator.slideLink[i]+'">';
				}
			else
				{
				html += '<div id="rotatorHeadDiv'+i+'" class="oc_rotator_link" style="height:'+th+'px; clip:rect(0 auto '+thclip+' auto);">';
				html += '<a id="rotatorHeadLink'+i+'" href="javascript:ocrotator.showSlide('+i+')">';
				}
			if(multiTitle)
				{
				var title=ocrotator.slideTitle[i];
				var pos=title.indexOf(":");
				if(pos<0)
					html += ocrotator.slideTitle[i];
				else
					{
					html += '<span style="color:white; font-size:14px;">';
					html += title.substr(0,pos);
					html += '</span><br />';
					html += title.substr(pos+1);
					}
				}
			else
				html += ocrotator.slideTitle[i];
			html += '</a></div>';
			document.write(html);
			}
		},
	showThumbnails : function(tHeight)
		{
		var html="";
		var tWidth=parseInt((tHeight/3)*4);
		var w=0;
		var h=0;
		for(i=0;i<ocrotator.slideSrc.length&&i<ocrotator.maxslides;i++)
			{
			html='';
			w=tWidth;
			h=parseInt(tWidth*(ocrotator.slideHeight[i]/ocrotator.slideWidth[i]));
			if(h<tHeight)
				{
				w=parseInt(tHeight*(w/h));
				h=tHeight;
				}
			html += '<div style="border:0; padding:0; margin:0px; background:#222222; width:'+tWidth+'px; height:'+tHeight+'px; clip:rect(0 '+tWidth+'px '+tHeight+'px 0); overflow:hidden; text-align:center;">';
			html += '<a href="javascript:ocrotator.showSlide('+i+')" style="padding:0; background:none;" class="oc_rotator_link" >';
			src=ocrotator.slideSrc[i];
			html += '<img src="'+src+'" border="0" width="'+w+'" height="'+h+'" style="padding:0; background:none;" />';
			html += '</a></div>';
			document.write(html);
			}
		},
	showSlides : function(tHeight)
		{
		var i=0;
		var w=0;
		var h=0;
		var src="";
		var html="";
		for(i=0;i<ocrotator.slideSrc.length&&i<ocrotator.maxslides;i++)
			{
			src=ocrotator.slideSrc[i];
			alt=ocrotator.slideAlt[i];
			w=ocrotator.maxwidth;
			h=parseInt(ocrotator.maxwidth*(ocrotator.slideHeight[i]/ocrotator.slideWidth[i]));
			if(h<ocrotator.maxheight)
				{
				w=parseInt(ocrotator.maxheight*(w/h));
				h=ocrotator.maxheight;
				}
			html='<div id="slideImageDiv'+i+'" style="position:absolute; margin:0px; padding:0px; filter:alpha(opacity=0); opacity: 0.0; top:0px; ';
			html+='left:0px; height:'+ocrotator.maxheight+'px; width:'+ocrotator.maxwidth+'px; clip:rect(0 '+ocrotator.maxwidth+' '+ocrotator.maxheight+' 0); overflow:hidden;';
			if(i==ocrotator.currImage)
				html+=' filter:alpha(opacity=100); opacity: 1.0;';
			else
				html+=' filter:alpha(opacity=0); opacity: 0.0; display:none;';
			html+='">';
			html += '<a class="oc_rotator_link" href="'+ocrotator.slideLink[i]+'" style="padding:0px; margin:0px;">';
			if(i==ocrotator.currImage)
				html+='<img id="slideImage'+i+'" src="'+src+'" border="0" alt="'+alt+'" width="'+w+'" height="'+h+'" style="margin:0px; padding:0px;" />';
			else
				html+='<img id="slideImage'+i+'" src="http://common.onset.freedom.com/images/copyrighted.gif" border="0" alt="'+alt+'" width="'+w+'" height="'+h+'" style="margin:0px; padding:0px;" />';
			html += '</a>';
			html+='</div>';
			document.write(html);
			}
		}
	};
