﻿<!--


{
	//remember...curpic represents the 2nd pic, not the first
	var imgid="rimg";	//the image 1 and image 2's ids on the page
	var curpic=1;
	var maximg=3;
	//image path
	var thepath="images/";
	var r_speed=5;	
	var r_pause=6000;	

	var picCollection= new Array(maximg);
	picCollection[0]="construct1.jpg";
	picCollection[1]="construct2.jpg";
	picCollection[2]="construct3.jpg";
	
	/*var destination= new Array(maximg);
	destination[0]="http://www.screechrum.com/";
	destination[1]="http://www.newfoundlandpower.com/";
	destination[2]="http://www.molsoncoors.com/";*/
	
	function setCookie(c_name,value,expiredays)
	{
		var exdate=new Date();
		
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}
	
	function getCookie(c_name)
	{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    {
	    c_start=c_start + c_name.length+1;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    }
	  }
	return "";
	}

	function gotosponsor()
	{
		var temp="";
		
		if((curpic-1)<0)
		{
			temp=destination[maximg-1];
		}else{
			temp=destination[curpic-1];
		}
		window.open(temp,"sponsors");
		//document.location.href=temp;
		
	}
		
	function initrotate(p_imgpath)
	{	
		/*randomize*/
		var laststart;
		var randnum;
		var i=0;	//breakpoint
		
		//image path
		thepath=p_imgpath+thepath;
		
		laststart=getCookie('laststart');
		//laststart=1;
		
		do{
			i=i+1;
			//just in case, so it won't try too many times
			if(i>(maximg+3))
			{
				break;
			}
			randnum = Math.random();
			randnum=randnum*(maximg);
			randnum = Math.floor(randnum);			
		}while(randnum==laststart);
		
		//expire in 1 day
		setCookie('laststart',randnum,1);		

		/*end randomize*/
		
		curpic=randnum;
	
		//dissolve instead
		
		newpic=document.getElementById(imgid+1);
		newpic.src=thepath+picCollection[curpic];
				//document.getElementById('test').innerHTML=curpic;
				
		//use this to dissolve the first img in without initial pause;
		rfade("rimg1",0,r_speed);	
		
		if((curpic>=0) && (curpic<(maximg-1))){
			curpic=curpic+1;		
		}else{
			curpic=0;
		}
		newpic=document.getElementById(imgid+2);
		newpic.src=thepath+picCollection[curpic];			
						
		rotate(2);
	}
	

	function rotate(p_show)
	{
		var r_show;
		var r_hide;
		var r_obj;
		var newpic;		
		
		//show / hide pics
		if(p_show==1)
		{
			r_hide="2";
			r_show="1";
		}else{
			r_hide="1";
			r_show="2";
		}
		
		setTimeout('rfade("'+imgid+r_hide+'",100,'+((-1)*r_speed)+');',r_pause);
		setTimeout('rfade("'+imgid+r_show+'",0,'+r_speed+');',r_pause);		
			
		//start cycle again
		setTimeout('rotate("'+r_hide+'");',r_pause);

	}
	
	function rfade(p_obj,p_alpha,p_speed)
	{
		//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
	
		var robj;
		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;
		}
		
		robj=document.getElementById(p_obj);
		
		//safari / mozilla
		robj.style.opacity=(r_alpha/100);
		//IE
		robj.style.filter = 'alpha(opacity=' + r_alpha + ')';
			
		if(((r_alpha<=(100-r_speed)) && (r_speed>0)) || ((r_alpha>=(0-r_speed)) && (r_speed<0)))
		{
			setTimeout('rfade("'+robj.id+'",('+r_alpha+'),'+r_speed+');',100);	
		}else{
			if(r_speed>0)
			{
				robj.style.zIndex=10;
			}else if(r_speed<0){
				robj.style.zIndex=1;
				changepic(p_obj);
			}
		}
	}
	
	function changepic(p_id)
	{
		//var thepath;
		//thepath=document.forms.thevalue.thepath.value;
		
		//var flashObjStr = "<embed id='clip"+p_id+"' src="+thepath+"assets/img_flash/"+picCollection[curpic-1]+" quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='550' height='75' wmode='opaque'></embed>";
		
		newpic=document.getElementById(p_id);

		// rotate pics
		if((curpic>=0) && (curpic<(maximg-1))){
			curpic=curpic+1;		
		}else{
			curpic=0;
		}
				
		//alert(curpic);
		newpic.style.zIndex=1;
		//safari / mozilla
		newpic.style.opacity=(0);
		//IE
		newpic.style.filter = 'alpha(opacity=0)';
			
		newpic.src=thepath+picCollection[curpic];
	}

}
	
// -->