var currentPanel = null;

function showPanel(curTab, panelId, contentId)
{
	var objPanel = document.getElementById(panelId);
	var objContent = document.getElementById(contentId);
	
	if(objContent.className != panelId && objPanel.innerHTML)
	{
		oldPanel = document.getElementById(objContent.className);
		oldPanel.innerHTML = objContent.innerHTML;
		
		objContent.className = panelId;
		objContent.innerHTML = objPanel.innerHTML; 
	}
	
	var getElemsByRel = getRel('tabs');
	for(var i = 0; i < getElemsByRel.length; i++)
	{
		getElemsByRel[i].className = "tabclose";
	}
	
	curTab.className = "tabopen";
}

function getRel(rel){
    aElements = document.getElementsByTagName("a");
    relElems = [];
    for (i = 0; i < aElements.length; i++) {
        if (aElements[i].hasAttribute("rel") && aElements[i].rel == rel) {
            relElems.push(aElements[i]);
        }
    }
	return relElems;
}

function showPhoto(curObj, objName)
{
	var displayObj = document.getElementById(objName);
	
	var newSrc = curObj.getAttribute("src").replace("95px", "400px");
	
	displayObj.setAttribute("src", newSrc);
	if(document.getElementById("aboveList"))
	{
		//curObj.style.borderColor = "#00f";
		curObj.style.opacity=.5;
		setTimeout("unHighlight('" + curObj.id + "')", 500);

	}
	
}

function unHighlight(objName)
{
	var elm = document.getElementById(objName);
	if(elm)
	{
		elm.style.opacity=1;
		//elm.style.borderColor = "#999";
	}
}

function classifiedHelpStatus()
{
	var cookies = new CookieHandler();
	if(cookies)
	{
		var helpStatus = cookies.get("myClassifiedsContactHideHelp");
		if(helpStatus)
		{
			return true;
		}
	}
	
	return false;
}

function classifiedHelpStatusHide()
{
	var cookies = new CookieHandler();
	if(cookies)
	{
		cookies.set("myClassifiedsContactHideHelp", true);
	}
}


function doContactTrack(clickObj, adNum)
{
	if(clickObj && clickObj.hasAttribute("rel"))
	{
		var trackType = "";
		var objText = clickObj.rel;

		if(objText.match(/contactSeller/i))
			trackType = "Communication";

		if(objText.match(/shareAd/i))
			trackType = "Share";

		if(objText.match(/flagSeller/i))
			trackType = "Flag";

		if(trackType)
			doTrack("/classifieds/" + adNum + "-" + trackType);
	}
}
