/////////////////////////////////////////////////////////////////////
//  TPScripts1
/////////////////

// Client side script

function load()
{
	var agt = navigator.userAgent.toLowerCase(); 
    var is_ie  = ( agt.indexOf('msie')!= -1 );
    
    if ( !is_ie )
    {
  		for( var i = 0; i < document.images.length; i++)
		{
			var image = document.images[i];
			
			if ( image.id.search(/img/i) == 0 )
			{
				image.addEventListener("click", MozClick, false);
			}
		}
	}
}
 
function MozClick(e)
{
 	var suffix = e.target.id.slice(e.target.id.length - 2);
	if(suffix == "Sm" || suffix == "Vw") // We will replace the thumbnail with the large View
	{
		var Src = e.target.parentNode.parentNode;
		
		if ( suffix == "Vw" )
			Src = e.target.parentNode; // The View version is not also inside a DIV

        if (Src.tagName.toLowerCase() == "td")
			MozReplaceAll(Src, e);
	}
	
	e.stopPropagation(); 
	
	// this ought to keep t-daddy from getting the click. 

}
 

function onClick(Src)
{
//	debugger;
	var agt = navigator.userAgent.toLowerCase(); 
    var is_moz  = ( agt.indexOf('mozilla')!= -1 );
    var is_msie  = ( agt.indexOf('msie')!= -1 );

	if(Src.tagName.toLowerCase() == "area") // Then we have clicked a map section for display
	{
		showMenuItem(Src, is_msie);
	}

	else if (Src.tagName.toLowerCase() == "img")
	{
		restoreDesc(Src);
	}

	else if (Src.tagName.toLowerCase() == "td")
	{
	//	alert("onClick():Src.tagName= " + Src.tagName);
	    if (event.srcElement.tagName.toLowerCase() == "img")
		{
			var suffix = event.srcElement.name.slice(event.srcElement.name.length-2);
			if(suffix == "Sm" || suffix == "Vw") // We will replace the thumbnail with the large View
				replaceAll(Src, event.srcElement.name)
		}
	}
}


function doRoll(over, imgName)
{
	if(over)
	{
		document.images[imgName].src = "../../Images/" + imgName + "Red.gif";
		switch (imgName)
		{
			case "Ukulele":
				window.status = "Ukulele and Hawaiian Music Page";
				break;
			case "Cleveland":
				window.status = "Cleveland Page";
				break;
			case "NewOrleans":
				window.status = "New Orleans info and Restaurant Review Page";
				break;
			case "MyWork":
				window.status = "Pictures and Descriptions of My User Interface Work";
				break;
		}
	}
	else
	{
		document.images[imgName].src = "../../Images/" + imgName + "Blue.gif";
		window.status = "";
	}
	return true;
}

function MozReplaceAll(TD, e)
{
	var srcName = e.target.id;
	var goingToView = false;
	var temp = "";
	var srcRoot = "";
	var suffix = srcName.slice(srcName.length - 2);
	if(suffix  == "Sm") // We are hiding the thumbnail and displaying the View
	{
		temp = srcName.slice(0, srcName.length - 2); // Remove the "Sm"
		srcRoot = temp.slice(3);
		goingToView = true;
	}
	else if(suffix  == "Vw") // We are hiding the View and displaying the thumbnail
	{
		temp = srcName.slice(0, srcName.length - 2); // Remove the "View"
		srcRoot = temp.slice(3);
		goingToView = false;
	}
	else 
		return; // To handle click on another type of image object (like HotDog)
		
	for( var i = 0; i < TD.childNodes.length; i++)
	{
		// Hiding of the View element would be done, above
			
		var TDchild = TD.childNodes[i];
		if(TDchild.nodeName == "DIV") // This will be the thumbnail/description
		{
			if(goingToView) 
				TDchild.style.display = "none";
			else
				TDchild.style.display = "";
		}
		else if (TDchild.nodeName.toLowerCase() == "img") // Then these are the large View images
		{
			// Make sure that only the View corresponding to the thumbnail gets displayed
					
			temp = TDchild.name.slice(0, TDchild.name.length - 2);
			if(temp.slice(3) == srcRoot)
			{
				if(goingToView)
				{
					TDchild.style.display = "";
					var newSrc = "";
					if(TD.id == "JLC") // Jumbo Lahaina Cam
						newSrc = "http://www.ccmaui.net/~bobp/lahaina.jpg"; //"<img src="http://www.ccmaui.net/~bobp/lahaina.jpg?t=998335412" width="600" height="450" border="0" />"; //"http://maui.net/~bob/lahaina/lahaina.jpg?t=989332263";
					else
						newSrc = e.target.src.replace(/_Sm./i, "_Lg.");
					TDchild.src = newSrc; //"./Images/PM_FetchFromSearchLgProg.jpg"
				}
				else
					TDchild.style.display = "none";
			}
		}
	}
}

function replaceAll(TD, srcName)
{
	var goingToView = false;
	var temp = "";
	var srcRoot = "";
	var suffix = srcName.slice(srcName.length - 2);
	if(suffix  == "Sm") // We are hiding the thumbnail and displaying the View
	{
		temp = srcName.slice(0, srcName.length - 2); // Remove the "Sm"
		srcRoot = temp.slice(3);
		goingToView = true;
	}
	else if(suffix  == "Vw") // We are hiding the View and displaying the thumbnail
	{
		temp = srcName.slice(0, srcName.length - 2); // Remove the "View"
		srcRoot = temp.slice(3);
		goingToView = false;
	}
	else 
		return; // To handle click on another type of image object (like HotDog)
		
	for( var i = 0; i < TD.children.length; i++)
	{
		// Hiding of the View element would be done, above
			
		var TDchild = TD.children[i];
		if(TDchild.tagName == "DIV") // This will be the thumbnail/description
		{
			if(goingToView) 
				TDchild.style.display = "none";
			else
				TDchild.style.display = "";
		}
		else if (TDchild.tagName.toLowerCase() == "img") // Then these are the large View images
		{
			// Make sure that only the View corresponding to the thumbnail gets displayed
					
			temp = TDchild.name.slice(0, TDchild.name.length - 2);
			if(temp.slice(3) == srcRoot)
			{
				if(goingToView)
				{
					TDchild.style.display = "";
					var newSrc = "";
					if(TD.id == "JLC") // Jumbo Lahaina Cam
						newSrc = "http://www.ccmaui.net/~bobp/lahaina.jpg"; //"<img src="http://www.ccmaui.net/~bobp/lahaina.jpg?t=998335412" width="600" height="450" border="0" />"; //"http://maui.net/~bob/lahaina/lahaina.jpg?t=989332263";
					else
						newSrc = event.srcElement.src.replace(/_Sm./i, "_Lg.");
					TDchild.src = newSrc; //"./Images/PM_FetchFromSearchLgProg.jpg"
				}
				else
					TDchild.style.display = "none";
			}
		}
	}
}

function expandSection(TD)
{
//	debugger;
	
	// get the view td object
	var strView = TD.id + "View";
	var tdView = $(strView);

	var root = TD.id.slice(2);
	var divDesc = getDivDesc(root);

	// Toggle state of the text description and the menu closeup images
	if( tdView.style.display == "none")
	{
		tdView.style.display = "";
		divDesc.style.display = "";

		showDescDiv(root, true);
		showImgDiv(root, false); 
	}
	else
	{
		tdView.style.display = "none";
		divDesc.style.display = "none";
		showImgDiv(root, false);
	}
}

function getDivDesc(root)
{
	return $("div" + root + "Desc");
//	return eval("div" + root + "Desc");
}

function getCurDesc(root)
{
	return $("cur" + root + "Desc");
//	return eval("cur" + root + "Desc");
}

function setCurDesc(obj, root) {
    var desc = $("cur" + root + "Desc");
    return desc;
//    return curDesc;
//    
//	return $("cur" + root + "Desc = " + obj);
	return eval("cur" + root + "Desc = " + obj);
}

