// INITIAL DISPLAY FUNCTIONS -------------------------------



// GENERAL MENU MANAGEMENT FUNCTIONS -------------------------------


function markMenuLeftChoice (selectedOption) {
	for (i=0;i<document.getElementsByTagName("span").length; i++) {
		if (document.getElementsByTagName("span").item(i).className == "menu_left_item_on"){
			document.getElementsByTagName("span").item(i).className = "menu_left_item_off";
			document.getElementsByTagName("span").item(i).MPStatus = "notSelected";
		}
	}
	document.getElementById(selectedOption).className = "menu_left_item_on";
	document.getElementById(selectedOption).MPStatus = "selected";
}


function showSelectedContent (selectedOption) {
	for (i=0;i<document.getElementsByTagName("div").length; i++) {
		if (document.getElementsByTagName("div").item(i).className == "body_content_on"){
			document.getElementsByTagName("div").item(i).className = "body_content_off";
		}
	}
	document.getElementById(selectedOption).className = "body_content_on";

}




function displayGeneralELink (EName, EAddress, EType) {
	email = EName;
	address = EAddress;
	addressType =  EType;
	displayText = email + '@' + address + '.' + addressType;
	document.write('<a href=\"mailto:' + email + '@' + address + '.' + addressType + '\" Title=\"\">');
	document.write(displayText + '</a>');
	} 



// PHOTO SHOW ----------------------------------------------------

var timer; 

var curImage=-1;
var curCaption=-1;


function runPhotoShow () {
stopPhotoShowHere () ;
timer=setTimeout("swapPicture()", 6000);
}

function stopPhotoShow () {
clearTimeout(timer);
curImage=-1;
curCaption=-1;
// alert("curImage: " + curImage);
}

function stopPhotoShowHere () {
clearTimeout(timer);
// alert("curImage: " + curImage);
}


function swapPicture() {

var dimages=new Array();
var numImages=10;
dimages[0]=new Image();
dimages[0].src="images/photo_show_01.jpg";
dimages[1]=new Image();
dimages[1].src="images/photo_show_02.jpg";
dimages[2]=new Image();
dimages[2].src="images/photo_show_03.jpg";
dimages[3]=new Image();
dimages[3].src="images/photo_show_04.jpg";
dimages[4]=new Image();
dimages[4].src="images/photo_show_05.jpg";
dimages[5]=new Image();
dimages[5].src="images/photo_show_06.jpg";
dimages[6]=new Image();
dimages[6].src="images/photo_show_07.jpg";
dimages[7]=new Image();
dimages[7].src="images/photo_show_08.jpg";
dimages[8]=new Image();
dimages[8].src="images/photo_show_09.jpg";
dimages[9]=new Image();
dimages[9].src="images/photo_show_10.jpg";

curPhotoCaptionGroupSize = 10;
var captions=new Array();
var numCaptions=curPhotoCaptionGroupSize;
captions[0]="1";
captions[1]="2";
captions[2]="3";
captions[3]="4";
captions[4]="5";
captions[5]="6";
captions[6]="7";
captions[7]="8";
captions[8]="9";
captions[9]="10";


  var nextImage=curImage+1;
  var nextCaption=curCaption+1;

//alert("Image Index " + nextImage);
//alert("Caption Index " + nextCaption);

  if (document.images)
  {
    if (nextImage>=numImages)
      nextImage=0;
    if (dimages[nextImage] && dimages[nextImage].complete)
    {
      var target=0;
      if (document.images.PRODPHOTO)
        target=document.images.PRODPHOTO;
      if (document.all && document.getElementById("PRODPHOTO"))
        target=document.getElementById("PRODPHOTO");
  
      // make sure target is valid.  It might not be valid
      //   if the page has not finished loading
      if (target)
      {
        target.src=dimages[nextImage].src;
 //	alert(nextImage);



	if (nextCaption>=numCaptions) {

		nextCaption=0;

		}

				
//alert("Next Image " + nextImage);
//alert("Next Caption " + nextCaption);


		nextPhotoCaptionId = "PHOTOCAP" +  captions[nextCaption];

				
//alert("Current PhotoID " + curPhotoCaptionId);
//alert("Next PhotoID " + nextPhotoCaptionId);

	for (i=0;i<document.getElementsByTagName("div").length; i++) {
		if (document.getElementsByTagName("div").item(i).className == "photo_show_text_on"){
			document.getElementsByTagName("div").item(i).className = "photo_show_text_off";
		}
	}

	document.getElementById(nextPhotoCaptionId).className="photo_show_text_on";

        curImage=nextImage;
	curCaption=nextCaption;
      }

     timer=setTimeout("swapPicture()", 6000);

    }
    else
    {
      timer=setTimeout("swapPicture()", 6000);
    }
  }
}


function nextPhoto () {

stopPhotoShowHere () ;

	curPhotoFile = document.getElementById("PRODPHOTO").src;
	curPhotoFileRoot = curPhotoFile.substr(0, curPhotoFile.length-6);
	curPhotoFileGroupSize = 10;
	curPhotoFileEnd = curPhotoFile.substr(curPhotoFile.length-6);
	curPhotoNumber = curPhotoFileEnd.substr(0, 2);

	if (Number(curPhotoNumber)>=curPhotoFileGroupSize) {
		nextPhotoNumber = "01"
		nextPhotoCaptionId = "PHOTOCAP1";
		}

	else	{
		nextPhotoNumber = Number(curPhotoNumber) + 1;
		curCaptionNo = Number(curPhotoNumber);
		nextCaptionNo = curCaptionNo +1;
		nextPhotoCaptionId = "PHOTOCAP" + nextPhotoNumber;
	
		}

	nextPhotoNumber = nextPhotoNumber + "";

	if (nextPhotoNumber.length==1) {
		nextPhotoNumber = "0" + nextPhotoNumber + "";
		}

	nextPhotoFileName = curPhotoFileRoot + nextPhotoNumber + ".jpg";

	document.getElementById("PRODPHOTO").src=nextPhotoFileName;

	for (i=0;i<document.getElementsByTagName("div").length; i++) {
		if (document.getElementsByTagName("div").item(i).className == "photo_show_text_on"){
			document.getElementsByTagName("div").item(i).className = "photo_show_text_off";
		}
	}

	document.getElementById(nextPhotoCaptionId).className="photo_show_text_on";

}


function previousPhoto () {
stopPhotoShowHere () ;


	curPhotoFile = document.getElementById("PRODPHOTO").src;
	curPhotoFileRoot = curPhotoFile.substr(0, curPhotoFile.length-6);
	curPhotoFileGroupSize = 10;
	curPhotoFileEnd = curPhotoFile.substr(curPhotoFile.length-6);
	curPhotoNumber = curPhotoFileEnd.substr(0, 2);

	if (curPhotoNumber==1) {
		nextPhotoNumber = "10"
		nextPhotoCaptionId = "PHOTOCAP10";
		}

	else	{
		nextPhotoNumber = Number(curPhotoNumber) - 1;
		curCaptionNo = Number(curPhotoNumber);
		nextCaptionNo = curCaptionNo - 1;
		nextPhotoCaptionId = "PHOTOCAP" + nextPhotoNumber;
	
		}

	nextPhotoNumber = nextPhotoNumber + "";

	if (nextPhotoNumber.length==1) {
		nextPhotoNumber = "0" + nextPhotoNumber + "";
		}

	nextPhotoFileName = curPhotoFileRoot + nextPhotoNumber + ".jpg";

	document.getElementById("PRODPHOTO").src=nextPhotoFileName;

	for (i=0;i<document.getElementsByTagName("div").length; i++) {
		if (document.getElementsByTagName("div").item(i).className == "photo_show_text_on"){
			document.getElementsByTagName("div").item(i).className = "photo_show_text_off";
		}
	}

	document.getElementById(nextPhotoCaptionId).className="photo_show_text_on";

}



