<!--//

/***********rotation**************/

//files must be within the images dir and called rotate1.jpg (function initializepic(1))  
//and rotatesub1.jpg (function initializepic(2)) (set used for subpages)
//or you can customize this via the var below

	
	var maxnum=3;
	var curpic;	
	var nextnum;
	var head="images/rotate";
	var tail=".jpg";
	var r_speed=2;	//the lower, the slower
	var r_pause=5000;
	//var i_obj;
	//id of the img to be rotated
	var r_objid1="rotate";
	var r_objid2="rotate2";
	var threshold=0;
	//hold the prefix for sub images
	var subhead="";
	
	//1=main page, 2=sub page (cause the use of subhead)
	function initializepic(p_where)
	{
		var thecode;
		
		curpic=Math.floor(Math.random()*(maxnum))+1;	
		nextnum=(curpic>=maxnum ? 1 : (curpic+1));
		
		if(p_where==2)
		{
			//sub
			subhead="sub";
		}
		
		thecode='<img id="rotate" src="images/rotate';
		thecode=thecode+subhead+curpic;
		thecode=thecode+'.jpg" alt="RDC - Research and Development Corporation Newfoundland and Labrador" name="rotate" border="0"';
		thecode=thecode+'" /><img id="rotate2" src="images/rotate';
		thecode=thecode+subhead+nextnum;
		thecode=thecode+'.jpg" alt="RDC - Research and Development Corporation Newfoundland and Labrador" name="rotate2" border="0"';
		thecode=thecode+'" />';
				
		document.writeln(thecode);
		r_init();
	}
	
	//initializepic not used to enable static pic for non js-enabled users
	function initializepicnonjs(p_where)
	{
		var thecode;
		
		curpic=1;	
		nextnum=2;
		
		if(p_where==2)
		{
			//sub
			subhead="sub";
		}
		
		thecode='<img id="rotate2" src="images/rotate';
		thecode=thecode+subhead+nextnum;
		thecode=thecode+'.jpg" alt="RDC - Research and Development Corporation Newfoundland and Labrador" name="rotate2" border="0"';
		thecode=thecode+'" />';
				
		document.writeln(thecode);
		r_init();
	}
		
	function returnnextnum()
	{
		return nextnum;
	}
	
	function r_init()
	{
		var iobj=document.getElementById(r_objid2);
		var myArray = new Array(maxnum);
		
		for(var i=3;i<=maxnum;i++)
		{
			myArray[i]=new Image();
			myArray[i].src = "images/rotate"+subhead+i+".jpg";
		}		
		
		//curpic=Math.floor(Math.random()*(maxnum+1));
				
		//curpic=p_currpic;
		//nextnum=(curpic>=maxnum ? 1 : (curpic+1));
				
		iobj.src=head+subhead+nextnum+tail;
		
		setTimeout('rotate()',r_pause);
	}
	
	//rotate_show
	function rotate()
	{
		var i_obj=document.getElementById(r_objid1);
		var r_obj=document.getElementById(r_objid2);
			
		//gently show it
		rfade(r_obj.id,0,((1)*r_speed),1);
		
		//gently fade it
		rfade(i_obj.id,100,((-1)*r_speed),1);
		
		//gently fade text
		//rfade("bannertext"+curpic,100,((-1)*r_speed),2);
		
	}
		
	function rfade(p_obj,p_alpha,p_speed,p_change)
	{
		//this will cause the object to fade / appear.  p_alpha is the current opacity, the speed is the interval amount.  negative amount will cause it to fade, pos. will cause it to appear.
		//0 is nothing, 100 is full
		//if p_change=1, then proceed to change to the next image (only if it is increment is <0)
		//if p_change=2, then proceed to change to the next text (only if it is increment is <0)
	
		var robj=document.getElementById(p_obj);
		var r_speed=p_speed;
		var r_alpha=p_alpha+p_speed;
	
		//just in case
		if(r_alpha>=100)
		{
			r_alpha=100;
		}else if(r_alpha<=0){
			r_alpha=0;
		}
	
		//safari / mozilla
		robj.style.opacity=(r_alpha/100);
		//IE
		robj.style.filter = 'alpha(opacity=' + r_alpha + ')';
	
	
	//alert(p_obj+" "+p_alpha);
		if(((r_alpha+r_speed)>=0) && ((r_alpha+r_speed)<=100))
		{	
			setTimeout('rfade("'+p_obj+'",'+r_alpha+','+p_speed+','+p_change+');',50);
		}else{	
			changeimg();	
		}
	}
		
	function changeimg()
	{
		var cobj1=document.getElementById(r_objid1);
		var cobj2=document.getElementById(r_objid2);
		
		threshold=(threshold==0 ? 1 : 0);
		
		if(threshold==1)
		{
			curpic=nextnum;
			nextnum=(nextnum>=maxnum ? 1 : (curpic+1));			
			
			cobj1.src=head+subhead+nextnum+tail;
			//cobj1.className="rotate_show";
			r_objid1=cobj2.id;
			
			//cobj2.className="rotate_hidden";
			r_objid2=cobj1.id;
			
			//start cycle again		
			setTimeout('rotate()',r_pause);
		}
	}
	
	
	/***********end rotation**************/

//-->