
function ShowTab(sTabLayers,sTabs,sImageNameBases,iIndex)
{
	var aTabLayers = sTabLayers.split(",");
	var aTabs = sTabs.split(",");
	var aImageNameBases = sImageNameBases.split(",");
	var i = 0;

	for(i=0;i<aTabLayers.length;i++)
	{
		//turn off all tab sections
		document.getElementById(aTabLayers[i]).style.display = "none";

		//turn off all tabs themselves
		document.getElementById(aTabs[i]).src = "/i/dl/doors/" + aImageNameBases[i] + "_off.gif";
	}

	//display the correct tab section and tab image (according to the arguments passed in to this function)
	var sSectionDivId = aTabLayers[iIndex];
	var sTabImageId = aTabs[iIndex];
	document.getElementById(sSectionDivId).style.display = "block";
	document.getElementById(sTabImageId).src = "/i/dl/doors/" + aImageNameBases[iIndex] + "_on.gif";
}



function MouseOverTab(sTabs, sImageNameBases, iIndex)
{
	var aTabs = sTabs.split(",");
	var aImageNameBases = sImageNameBases.split(",")
	var sTabId = aTabs[iIndex];
	var sTabName = aImageNameBases[iIndex];

	var sImage = document.getElementById(sTabId).src;
	sImage = sImage.substring(sImage.length-6,sImage.length-4)
	if (sImage != "on")
	{
		document.getElementById(sTabId).src = "/i/dl/doors/" + sTabName + "_over.gif";
	}
}

function MouseOutTab(sTabs, sImageNameBases, iIndex)
{

	var aTabs = sTabs.split(",");
	var aImageNameBases = sImageNameBases.split(",")
	var sTabId = aTabs[iIndex];
	var sTabName = aImageNameBases[iIndex];

	var sImage = document.getElementById(sTabId).src;
	sImage = sImage.substring(sImage.length-6,sImage.length-4)
	if (sImage != "on")
	{
		document.getElementById(sTabId).src = "/i/dl/doors/" + sTabName + "_off.gif";
	}
}



//imgExpandCollapse[1..n]  for expand/coll images
//tablayer-result-1          for divs

function ExpandCollapse(sDivIndex)
{
	if (document.getElementById("tablayer-result-" + sDivIndex).style.display == "block")
	{
		document.getElementById("tablayer-result-" + sDivIndex).style.display = "none";
		document.getElementById("tablayer-result-lw-" + sDivIndex).style.display = "none";
		document.getElementById("imgExpandCollapse" + sDivIndex).src = "/i/dl/listings/icon_expand.gif";
	}
	else
	{
		document.getElementById("tablayer-result-" + sDivIndex).style.display = "block";
		document.getElementById("tablayer-result-lw-" + sDivIndex).style.display = "block";
		document.getElementById("imgExpandCollapse" + sDivIndex).src = "/i/dl/listings/icon_collapse.gif";
	}
}


function ExpandAll(max)
{
	var imgExpandAll = document.getElementById("imgExpandAll");
	var sDivState = "";
    var nLinkTop = document.getElementById("nextLinkTop");
    var nLinkBottom = document.getElementById("nextLinkBottom");
    var pLinkTop = document.getElementById("prevLinkTop");
    var pLinkBottom = document.getElementById("prevLinkBottom");

	if (imgExpandAll.src.indexOf("collapseall") > 0)
	{
		// do collapse all
		document.getElementById("imgExpandAll").src ="/i/dl/listings/icon_expandall_EBEBE9.gif";
		sDivState = "none"
		sExpandOrCollapse = "expand";

        // turn off expandAll tag
        if ( nLinkTop && nLinkBottom ) {
            if ( nLinkTop.href.indexOf("expandAll=1") > 0 ) { 
				nLinkTop.href = nLinkTop.href.replace("expandAll=1", "expandAll=0"); 
				nLinkBottom.href = nLinkBottom.href.replace("expandAll=1", "expandAll=0"); 
			} else { 
				nLinkTop.href += "&expandAll=0";
				nLinkBottom.href += "&expandAll=0";
			}
        }
        if ( pLinkTop && pLinkBottom ) {
            if ( pLinkTop.href.indexOf("expandAll=1") > 0 ) { 
				pLinkTop.href = pLinkTop.href.replace("expandAll=1", "expandAll=0");
				pLinkBottom.href = pLinkBottom.href.replace("expandAll=1", "expandAll=0"); 
			} else { 
				pLinkTop.href += "&expandAll=0";
				pLinkBottom.href += "&expandAll=0";
			}
        }
		if ( self.location.href.indexOf("expandAll=1") > 0 ) {
			self.location.href = self.location.href.replace("expandAll=1", "expandAll=0");
		} 
	} else {
		// do expand all
		document.getElementById("imgExpandAll").src ="/i/dl/listings/icon_collapseall.gif";
		sDivState = "block"
		sExpandOrCollapse = "collapse";

		// turn on expandAll tag
        if ( nLinkTop && nLinkBottom ) {
            if ( nLinkTop.href.indexOf("expandAll=0") > 0 ) { 
				nLinkTop.href = nLinkTop.href.replace("expandAll=0", "expandAll=1");
				nLinkBottom.href = nLinkBottom.href.replace("expandAll=0", "expandAll=1"); 
			} else { 
				nLinkTop.href += "&expandAll=1"; 
				nLinkBottom.href += "&expandAll=1";
			}
        }
        if ( pLinkTop && pLinkBottom ) {
            if ( pLinkTop.href.indexOf("expandAll=0") > 0 ) { 
				pLinkTop.href = pLinkTop.href.replace("expandAll=0", "expandAll=1");
				pLinkBottom.href = pLinkBottom.href.replace("expandAll=0", "expandAll=1"); 
			} else { 
				pLinkTop.href += "&expandAll=1";
				pLinkBottom.href += "&expandAll=1"; 
			}
        }
		if ( self.location.href.indexOf("expandAll=0") > 0 ) {
			self.location.href = self.location.href.replace("expandAll=0", "expandAll=1");
		} 
	}
	
	// update search result items
	for ( i=1; i<=max; i++ )
	{
		document.getElementById("tablayer-result-" + i).style.display = sDivState;
		document.getElementById("tablayer-result-lw-" + i).style.display = sDivState;
		document.getElementById("imgExpandCollapse" + i).src = "/i/dl/listings/icon_" + sExpandOrCollapse + ".gif";
	}
}

function ExpandAllFlag(max) {
    if ( self.location.href.indexOf("expandAll=1") > 0 ) {
        ExpandAll(max);
    }
}

function Expand()
{

}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=838,height=628');");
}


function openPopup(url, name) {
        popupWin = window.open(url, name, 'scrollbars,resizable,width=480,height=320');
        window.self.name = 'cnetParent';
}

function downloadNow(file,redUrl,extUrl) {
    var isIe = (window.navigator.userAgent.toUpperCase().indexOf('MSIE') != -1);
    var isOpera = (window.navigator.userAgent.toUpperCase().indexOf('OPERA') != -1);

    if (isIe && extUrl == 0 && !isOpera) {
        window.open(file,'dlnow','toolbar=0,location=no,directories=0,status=0, scrollbars=no,resizable=0,width=1,height=1,top=0,left=0');
        window.focus();
        location.href = redUrl + '?idl=n';
    } else {
        location.href = redUrl;
    }
}


