


function getAllTablesCount(id)
{
	var count = null;
	count = document.getElementById(id).childNodes.length;
	return count;
}

function foldAllTables(preTag,count)
{
	for(i=0; i<=count; i++)
	{
		try
		{
			$getobject(preTag + i).getElementsByTagName('table')[0].style.display ='none';
		}
		catch(e)
		{}
	
	}
}


function foldPointedTables(preTag,count,_id)
{
	for(i=0; i<=count; i++)
	{
		try
		{
			if(_id != ('tab'+i))
				$getobject(preTag + i).getElementsByTagName('table')[0].style.display ='none';
		}
		catch(e)
		{}
	
	}
}


function setShowByRequest(url)
{
	var isFindEqual = false;
	var isHarfEqual = false;
	var  harfPara;
	var requestUrl = splitURL(url);
	var requestRawUrl = url.toLowerCase();
	
	var tableCount = getAllTablesCount('divUserleft');

	
	foldAllTables('tab',tableCount)

	for(i=0; i<=tableCount; i++)
	{
		try
		{
			var tabid = 'tab' + i;
			var trArray = document.getElementById(tabid).getElementsByTagName('table')[0].getElementsByTagName('tr');
		
			if(!isFindEqual)
			{
				
			 	for(j=1; j<=trArray.length-1; j++)
				{
				    try
				    {
					    var url = trArray[j].getElementsByTagName('a')[0].href.toLowerCase();
					    var tagUrl = splitURL(url);
					    if(requestUrl ==tagUrl)
					    {
						    
						    
						    
							
							isHarfEqual = true;
							harfPara =j-1;
							
							if(requestRawUrl==url)
							{
								isFindEqual = true;
								
								$getobject(tabid).getElementsByTagName('table')[0].style.display="block";
							    inializeChildTags(tabid);
							    var t = j-1;
							    
							    var cObj =$getobject(tabid +'_a' + t);
							    if(cObj)
							    {
									cObj.style.color='#FF0000';
									break;
							    }
							    break;
							}
							else if(j==trArray.length-1)
							{
								isFindEqual = true;

								$getobject(tabid).getElementsByTagName('table')[0].style.display="block";
								inializeChildTags(tabid);
								var t = j-1;
								
								var cObj =$getobject(tabid +'_a' + t);
								if(cObj)
								{
									cObj.style.color='#FF0000';
									break;
								}
								break;
								
							}
							else
							{
								continue;
							}
					    }
						
					}
					catch(e)
					{}
				}
				
				if(isHarfEqual)
				{
					isFindEqual = true;

					$getobject(tabid).getElementsByTagName('table')[0].style.display="block";
					inializeChildTags(tabid);
					var cObj =$getobject(tabid +'_a' +harfPara);
					if(cObj)
					{
						cObj.style.color='#FF0000';
						break;
					}
					break;
					
				}
			}
			else
			{
				break;
			}
		}
		catch(e)
		{}
	}
	
	
	
	
	for (i = 0; i <=tableCount; i++) 
	{
		try
		{
			var tabid = 'tab' + i;
			var aArray = document.getElementById(tabid).getElementsByTagName('table')[0].getElementsByTagName('a');

			for (j = 0; j <= aArray.length; j++) 
			{
				try
				{
					var t, aId;

					var url = aArray[j].href;
					
					t = j;
					aId = tabid +'_a' + t;

					
					registerTagAEvent(url,aId);		
				}
				catch(e){}
			}
		}
		catch(e)
		{}
		
		
	}
	
}

function registerTagAEvent(url,aId)
{
	var newopen = function(url)
				{
					return function()
					{
						judgeUserleftIFrame(url);
					}
				};

	if ($getobject(aId).href) 
	{
		var isIE = (document.all && window.ActiveXObject) ? true : false;
		

		try
		{
			if($getobject(aId).target=='')
			{
				if (isIE) 
				{
					$getobject(aId).attachEvent("onclick", newopen(url));
				}
				else 
				{
					$getobject(aId).attachEventListener("click", newopen(url), false);
				}

				$getobject(aId).href = '#';
			}
		}
		catch(e){}
	
		
	}
}


function judgeUserleftIFrame(url)
{
	if(window.parent.location)
	{
		if(window.parent.parent.location)
		{
			window.parent.parent.location.href = url;
		}
		else
		{
			window.parent.location.href = url;
		}
	}
	else
	{
		location.href = url;
	}
}

function inializeChildTags(tableId)
{
	var m_Tags = $getobject(tableId).getElementsByTagName('table')[0].getElementsByTagName('tr');
	var count = m_Tags.length - 1;
            
    for(i=0;i<count;i++)
    {
        try
        { 
            $getobject(tableId+"_a"+i).style.color="#0773CB";
        }
        catch(e){}
    }
}

function splitURL(url)
{
	var finalUrl = null;
	try
	{
		finalUrl = 	url.split('?')[0].toLowerCase();
	}
	catch(e)
	{
		finalUrl = 'www';
	}
	
	return finalUrl;
}

function expendTableTag(_this)
{
	
	
	
	var c = getAllTablesCount('divUserleft');
	
	var id = _this.parentNode.parentNode.parentNode.id;
	
	foldPointedTables('tab',c,id)

	var currentStyle = $getobject(id).getElementsByTagName('table')[0].style.display;
	if(currentStyle=="block")
	{
		$getobject(id).getElementsByTagName('table')[0].style.display = "none";
	}
	else
	{
		$getobject(id).getElementsByTagName('table')[0].style.display = "block";
	}
	inializeChildTags(id);
}

function $getobject(id)
{
	return document.getElementById(id);
}


