// JavaScript Document
var timeStart = new Boolean(false);
var timeOutID;
var timeConstant = 2000;


function switchDiv(id,classID)
{
	document.getElementById(id).className = classID;
	document.getElementById(id).style.cursor = "pointer";
}

function showNav(id) //,classID
{
	if (timeStart == true)
	{
		clearInterval(timeOutID);
		timeStart = false;
	}
	document.getElementById(id).style.display = "block";
//	document.getElementById(id).className = classID;
	document.getElementById(id).style.cursor = "pointer";
	
	timeOutID = setInterval('clearMenu()',timeConstant);
	timeStart = true;
}

function hideNav(id) //,classID
{
	stopTimer();
	document.getElementById(id).style.display = "none";
//	document.getElementById(id).className = classID;
}

function showNavsub(id) //,classID
{
	document.getElementById(id).style.display = "block";
	document.getElementById(id).style.cursor = "pointer";
}

function hideNavsub(id) //,classID
{
	document.getElementById(id).style.display = "none";
}

function clearMenu()
{
	clearInterval(timeOutID);
	timeStart = false;
}

function stopTimer()
{
	clearInterval(timeOutID);
	timeStart = false;
}

function startTimer()
{
	if (timeStart == true)
	{
		clearInterval(timeOutID);
		timeStart = false;
	}	
	timeOutID = setInterval('clearMenu()',timeConstant);
	timeStart = true;
}

//function to print page
function printPage()
{
	window.print();
}

//function to email page
function mailPage()
{
  mail_str = "mailto:?subject= " + document.title;
  mail_str += "&body= I recommend you read this -- " + document.title;
  mail_str += ". You should check this out at, " + location.href; 
  location.href = mail_str;
}

//functio to add to favourites
function addFav()
{
	window.external.AddFavorite(location.href, document.title);
}
function fontChange(fnt)
{
	document.getElementById('maincontent').style.fontSize = fnt;
}
function imgOpen(url)
{
	window.open(url,'','scrollbars=yes,resizable=yes,toolbars=no,menu=no,outerWidth=800,outerHeight=600');
}

function imgOpen2(url)
{
	window.open(url,'','scrollbars=yes,resizable=yes,toolbars=no,menu=no,outerWidth=800,outerHeight=300');
}


function openNote(url)
{
	window.open(url,'','scrollbars=yes,resizable=yes,toolbars=no,menu=no');
}
function openWin(url)
{
	window.open(url,'','scrollbars=yes,resizable=yes,toolbars=no,menu=no');
}

function notify()
{
	alert("You are now leaving the Crew Gold Corporation website.\nCrew can not be held responsible for the content, accuracy or timeliness of any other websites.");
}

function applyeffect(){
						if (document.all){
						photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*25)
						photoslider.filters.revealTrans.stop()
						photoslider.filters.revealTrans.apply()
						}
						}
						
						
						
						function playeffect(){
						if (document.all)
						photoslider.filters.revealTrans.play()
						}
						
						function keeptrack(){
						window.status="Image "+(which+1)+" of "+photos.length
						document.getElementById('pagenum').innerHTML = "page: "+(which+1);
						}
						
						
						function backward(){
						if (which>0){
						which--
						applyeffect()
						document.images.photoslider.src=photos[which]
						playeffect()
						keeptrack()
						}
						}
						
						function forward(){
						if (which<photos.length-1){
						which++
						applyeffect()
						document.images.photoslider.src=photos[which]
						playeffect()
						keeptrack()
						}
						}
						
						function lastslide(){
						if (which<photos.length-1){
						which = photos.length-1
						applyeffect()
						document.images.photoslider.src=photos[which]
						playeffect()
						window.status= "Image " +photos.length+" of "+photos.length
						document.getElementById('pagenum').innerHTML = "page: " +photos.length;
						}
						}
						
						function firstslide(){
						which = 0
						applyeffect()
						document.images.photoslider.src=photos[which]
						playeffect()
						window.status="Image 1 of "+photos.length
						document.getElementById('pagenum').innerHTML = "page: 1";
						}
						
function openTransform(URL)
{
	window.open(URL,'','scrollbars,resizable,outerWidth=800,outerHeight=600');
}

/* random banner image script */
var myImages = new Array();

myImages[0] = 'images/banner1.jpg';
myImages[1] = 'images/banner2.jpg';
myImages[2] = 'images/banner3.jpg';
myImages[3] = 'images/banner4.jpg';
myImages[4] = 'images/banner5.jpg';
myImages[5] = 'images/banner6.jpg';
myImages[6] = 'images/banner7.jpg';
myImages[7] = 'images/banner8.jpg';
myImages[8] = 'images/banner9.jpg';
myImages[9] = 'images/banner10.jpg';
myImages[10] = 'images/banner11.jpg';
myImages[11] = 'images/banner12.jpg';
myImages[12] = 'images/banner13.jpg';

function showImage(){
	var td = document.getElementById('banner');
	var index = Math.floor(Math.random() * myImages.length);
	
	td.style.backgroundImage = "url(" + myImages[index] + ")";
}
