//--[FIX: for IE6 to correctly display 'navigation' elements when rolled over.]----------------|
var fix_navigation = function()
{
	if (document.all && document.getElementById)
	{
		navRoot = document.getElementById("level_1");
		for (i=0; i<navRoot.childNodes.length; i++)
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI" && node.className != "current")
			{
				node.onmouseover=function()
				{
					this.className+="over";
				}
				node.onmouseout=function()
  				{
  					this.className=this.className.replace("over", "");
				}
   		}
   	}
  	}
  	findPNGs();
}

function fixTableRows()
{
	if (document.all && document.getElementById)
	{
   	navRoot = document.getElementById("table_rows");
		for (i=0; i<navRoot.childNodes.length; i++)
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="TR" && node.className != 'listing_detail')
			{
				node.onmouseover=function()
				{
					this.className+=" rowover";
				}
				node.onmouseout=function()
  				{
  					this.className=this.className.replace(" rowover", "");
				}
   		}
   	}
	}
}

//--------------------------------------------------[ LIVE GET THIS ]
function getThis(itemID, sectionID)
{
	var thisPagePath = window.location.pathname;
	regex = /preview.php/
	var preview = regex.test(thisPagePath);
	var page = (preview) ? 'preview' : 'index';
	window.location.href = page + '.php?section=' + sectionID + '&item=' + itemID;
}

//----------------------------------------------[ LIVE SHOW LISTING ]
function showListing(itemID, sectionID)
{
	var thisPagePath = window.location.pathname;
	regex = /preview.php/
	var preview = regex.test(thisPagePath);
	var page = (preview) ? 'preview' : 'index';
	window.location.href = page + '.php?section=' + sectionID + '&listing=' + itemID + '#' + itemID;
}

//------------------------[ LIVE TRANSLATE EXTERNAL LINKS ATTRIBUTE ]
function externalLinks()
{ 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i = 0; i < anchors.length; i ++)
	{ 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		{
			anchor.target = "_blank"; 
		}
	}
}

//-----------------------------------------------------[ EMAIL THIS ]
function mystery( indexValue, subjectText )
{
	var mystery ="109,97,105,108,116,111,58,"; // setup code.
	var train = "?subject=" + subjectText; // setup subject as string.
	var coming = "&body=";
	
	mystery += return2sender(indexValue * 1); // get required code.
	var decode = mystery.split(","); // setup array from encoded.
	mystery = ""; // setup source variable as string.
	for (var e = 0; e < decode.length; e++)
	{
		mystery += String.fromCharCode(decode[e]); // decode as string.
	}
	document.location = mystery + train + coming; // Write call.
}

//--------------------------------------------------[ FIND ALL PNGS ]
function findPNGs()
{
	if (!document.getElementsByTagName) return; 
	var images = document.getElementsByTagName("IMG"); 
	for (var i = 0; i < images.length; i ++)
	{ 
		var image = images[i];
		var imageSrc = image.src;
		var regex = /.png/
		var foundPNG = regex.test(imageSrc);
		if (foundPNG)
		{
			fix_PNG(image);
		}
	}
}

function fix_PNG(imageRef)
{
	var imgID = (imageRef.id) ? "id='" + imageRef.id + "' " : "";
	var imgClass = (imageRef.className) ? "class='" + imageRef.className + "' " : "";
	var imgTitle = (imageRef.title) ? "title='" + imageRef.title + "' " : "title='" + imageRef.alt + "' ";
	var logoMargin = (imageRef.id == 'fyne_logo') ? 'margin: 8px;' : '';
	var imgStyle = "display: block; float: left;" + logoMargin + imageRef.style.cssText;
	var strNewHTML = "<span " + imgID + imgClass + imgTitle;
	strNewHTML += " style=\"" + "width:" + imageRef.width + "px; height:" + imageRef.height + "px;" + imgStyle; // + ";";
	strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	strNewHTML += "(src=\'" + imageRef.src + "\', sizingMethod='image');\"></span>";
	imageRef.outerHTML = strNewHTML;
}

