function toggleMarkets(targetId){   
	if (document.getElementById){         
		target = document.getElementById( targetId );            
		if (target.style.display == "none"){               
			target.style.display = "block";            
		}
		else{               
			target.style.display = "none";            
		}      
	} 
} 

function clearTextBox(ori_val, form, input_name){
	if(form.elements[input_name].value == ori_val)
		form.elements[input_name].value = '';
}

function emailPage(userName, userEmail, emailAddress, title, URL)
{
	var xmlHttp = createXMLHttpObj();
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
		  document.getElementById("emailSendResult").innerHTML = xmlHttp.responseText;
		}
	  }
	  
	  var url = "/ajaxApps.php";
	  url = url+"?action=emailPage&pageURL="+urlencode(Base64.encode(URL))+"&referrerURL="+urlencode(Base64.encode(document.URL))+"&pageTitle="+urlencode(Base64.encode(title))+"&sendTo="+urlencode(Base64.encode(emailAddress));
         url = url+"&userEmailAddress="+urlencode(Base64.encode(userEmail))+"&userName="+urlencode(Base64.encode(userName));

	  xmlHttp.open("GET",url,true);
	  xmlHttp.send(null);
}

function sendEmail(userName, userEmailAddress, message, email, URL, divName, resetDivName)
{
	var xmlHttp = createXMLHttpObj();
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(divName).innerHTML = xmlHttp.responseText;
		}
	}
	
	var url = "/ajaxApps.php";
	url = url+"?action=sendEmail&pageURL="+urlencode(Base64.encode(URL))+"&referrerURL="+urlencode(Base64.encode(document.URL))+"&message="+urlencode(Base64.encode(message))+"&sendTo="+urlencode(Base64.encode(email));
	url = url+"&userEmailAddress="+urlencode(Base64.encode(userEmailAddress))+"&userName="+urlencode(Base64.encode(userName))+"&divName="+urlencode(Base64.encode(divName))+"&resetDivName="+urlencode(Base64.encode(resetDivName));
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function clearEmail(spanID, emailFormID)
{
	var spanID = (spanID == null) ? "emailSendResult" : spanID;
	var emailFormID = (emailFormID == null) ? blankEmail : emailFormID;

	document.getElementById(spanID).innerHTML = emailFormID;
}

function showDiv(elementID, elementIDArray)
{
	
	for (var i = 0; i < elementIDArray.length; i++)
	{

		if (elementIDArray[i] == elementID)
			{
				document.getElementById(elementIDArray[i]).style.display="inline";
				document.getElementById(elementIDArray[i]+"LinkB").className="current";
				document.getElementById(elementIDArray[i]+"LinkA").className="current";

			}
		else
			{
				document.getElementById(elementIDArray[i]).style.display="none";
				document.getElementById(elementIDArray[i]+"LinkB").className="";
				document.getElementById(elementIDArray[i]+"LinkA").className="";

			}
	}
}

function highlightHeaderMenu()
//This function applies the "current" classname to the header menu that applies to the current URL
{
	pathArray = window.location.pathname.split( '/' );		//Gets the pathname of the URL
	var categoryName = pathArray[pathArray.length-2]+"-ddheader";	//Gets the name of the header based on server path
	var headerObj = document.getElementById(categoryName);
	if (headerObj != null)
		{headerObj.className += " current ";}	//Assigns the "current" class
	
}

