﻿function turnon(div, offsetX, offsetY)
{
	var thediv = document.getElementById(div);

	// modified by celst 03.15.06
	// Simple follow the mouse script
	// copyright Stephen Chapman, 30th September 2005
	// you may copy this script provided that you retain the copyright notice
	
	var offX = offsetX;         // X offset from mouse position
	var offY = offsetY;         // Y offset from mouse position
	
	// no changes required below this line
	function mouseX(evt)
	{
		if (!evt) evt = window.event;
		
		if (evt.pageX) return evt.pageX; 
		
		else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); 
	
		else return 0;
	} 
	
	function mouseY(evt) 
	{
		if (!evt) evt = window.event;
		
		if (evt.pageY) return evt.pageY;
	
		else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	
		else return 0;
	}
	
	
	function follow(evt)
	{
		if (document.getElementById)
		{
			var obj = document.getElementById(div).style;
			obj.left = (parseInt(mouseX(evt))+offX) + 'px';  obj.top = (parseInt(mouseY(evt))+offY) + 'px';
	
		}
	} 
	
	document.onmousemove = follow;

	// change display css to block
	// put this at the end or PCI makes it appear early
		thediv.style.display="block";
}

function devNull() {
	return false;
}


function turnoff(div)
{
	var thediv = document.getElementById(div);
  
  document.onmousemove = devNull;
	// change display css to none
	thediv.style.display="none";

}

function popup(theurl,windowname,features)
{
window.open(theurl,windowname,features);
void 0;
}

//generate a random number
function genrandom(){
random_num = (Math.round((Math.random()*2)+1));
}

function preloader()
{

	genrandom();

	// counter
	var i = 0;
	
	// create object
	imageObj = new Image();
	
	// set image list
	images = new Array();
	images[0]='images/home/photo' + random_num + '/recreation.gif';
	images[1]='images/home/photo' + random_num + '/day_touring.gif';
	images[2]='images/home/photo' + random_num + '/touring.gif';
	images[3]='images/home/photo' + random_num + '/tandem.gif';
	images[4]='images/home/photo' + random_num + '/whitewater.gif';
	
	// start preloading
	for(i=0; i<=4; i++) 
	{
		imageObj.src=images[i];
	}

}

function extrasportPopup() {
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/extrasportDemo.html","Demo","resizable=0,toolbar=0,scrollbars=0,width=500,height=400");
	else
		this.wind.focus();
}

function selectPopup() {
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/materials/linear_select.html","Linear_Select","resizable=0,toolbar=0,scrollbars=0,width=500,height=325");
	else
		this.wind.focus();
}

function polylitePopup() {
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/materials/polylite.html","Polylite","resizable=0,toolbar=0,scrollbars=0,width=500,height=351");
	else
		this.wind.focus();
}

function ultralitePopup() {
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/materials/ultralite.html","Ultralite","resizable=0,toolbar=0,scrollbars=0,width=500,height=310");
	else
		this.wind.focus();
}

function advcompPopup() {
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/materials/advcomp.html","Advanced_Composite","resizable=0,toolbar=0,scrollbars=0,width=500,height=358");
	else
		this.wind.focus();
}

function recycledPopup() {
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/materials/recycled.html","Recycled","resizable=0,toolbar=0,scrollbars=0,width=500,height=362");
	else
		this.wind.focus();
}

function setProductPage(whichState) {
	if (currentState == whichState) return;
	
	var currentLink = document.getElementById(currentState + 'Link');
	var newLink = document.getElementById(whichState + 'Link');
	
	var galleryDiv = document.getElementById('productGallery').style;

	var contentDiv = document.getElementById('boatContent').style;
	var overviewDiv = document.getElementById('overview').style;
	var featspecDiv = document.getElementById('features_specs').style;
    

	switch(whichState) {
		case 'overview' :
			galleryDiv.display = 'none';
			overviewDiv.display = 'block';
			featspecDiv.display = 'none';
			contentDiv.display = 'block';


			break;
		case 'features' :
			galleryDiv.display = 'none';
			overviewDiv.display = 'none';
			featspecDiv.display = 'block';
			contentDiv.display = 'block';
                        
					
		    break;
		case 'gallery' :
			contentDiv.display = 'block';
			overviewDiv.display = 'none';
			galleryDiv.display = 'block';
			featspecDiv.display = 'none';	
	        break;
	}
	
	currentLink.className = 'off';
	newLink.className = 'on';
	currentState = whichState;
}

function setPro(whichState) {
	var articlesLink = document.getElementById('articlesLink');
	var articlesDiv = document.getElementById('articles').style;

	var meetProsLink = document.getElementById('meetProsLink');
	var meetProsDiv = document.getElementById('meetPros').style;

	switch(whichState) {
		case 'articles' :
			articlesLink.className = 'on';
			articlesDiv.display = 'block';
			meetProsLink.className = 'off';
			meetProsDiv.display = 'none';

			break;
		case 'meetPros' :
			articlesLink.className = 'off';
			articlesDiv.display = 'none';
			meetProsLink.className = 'on';
			meetProsDiv.display = 'block';

			break;
	}
}