
var m_compared	= false;
var m_htmlText	= "";
function Hide(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				divs[i].style.display = "none";
			}
		}		
	}
}


function Show(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				divs[i].style.display = "block";
			}
		}		
	}
}

function ShowHide(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				if ( divs[i].style.display == "none" )
				{
					divs[i].style.display = "block";
				}
				else
				{
					divs[i].style.display = "none" 	
				}
			}
		}		
	}
}

function Ocultar(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				divs[i].style.display = "none";
			}
		}		
	}
}


function Mostrar(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				divs[i].style.display = "block";
			}
		}		
	}
}

function ShowHide(id) {
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				if ( divs[i].style.display == "none" )
				{
					divs[i].style.display = "block";
				}
				else
				{
					divs[i].style.display = "none" 	
				}
			}
		}		
	}
}
function Resize(id , cnt, isFirst) {
	
	
	var	newWidth	= "178";
	if ( cnt == 3 )
	{
		newWidth	= "239";
	}
	if ( cnt == 2 )
	{
		newWidth	= "361";
	}
	if ( cnt == 1 )
	{
		newWidth	= "728";
	}
	if( document.getElementsByName )
	{
		var divs = document.getElementsByName( id );
		if( divs && divs.length > 0 )
		{	
			for( i=0;i<divs.length;i++ )
			{
				var	chld		= divs[i].childNodes[0];
				if ( chld && chld.name == "spacercol"  )
				{
					continue;
				}
				divs[i].width	= newWidth;
				if ( i==0)
				{
					continue
				}
				if ( isFirst )
				{
					divs[i].style.borderLeft= "";
				}
				else
				{
					divs[i].style.borderLeft = "1px solid #cccccc";
				}
				
				divs[i].width	= newWidth;
			}
				
		}
		
		//impacttitles
		divs = document.getElementsByName( "it_" + id );
		if( divs && divs.length > 0 )
		{
			for( i=0;i<divs.length;i++ )
			{
				divs[i].width = newWidth;
			}
		}		
	}
}



function RemoveItem(id) 
{
	
	if( document.dynamiccompare )
	{
	
		
		 
		if( document.dynamiccompare.show.length )
		{
			for( i=0;i<document.dynamiccompare.show.length;i++ )
			{
				if( document.dynamiccompare.show[i].value == id )
				{
					document.dynamiccompare.show[i].checked = false;
				}	
				else
				{
					if ( !m_compared )
					{
						document.dynamiccompare.show[i].checked = true;
					}
				}
			}
			
			Reorder( false );
			
		}
		else
		{
			if( document.dynamiccompare.show.value == id )
			{
				document.dynamiccompare.show.value = "";
			}
			
			
			document.dynamiccompare.submit();	
		}
		
			
	}
}

function Validate ( )
{
	
	if ( m_htmlText.length== 0 )
	{
		
		if( document.getElementsByName )
		{
			
			var cTable	 = document.getElementsByName( "compareTable" );
			
			if ( cTable && cTable.length == 1 )
			{
				m_htmlText	= cTable[0].innerHTML;	
			}
		}
	
	}
	Reorder ( true );
}

function Reset ()
{
	if( document.dynamiccompare )
	{
		for( resetIdx=0;resetIdx<document.dynamiccompare.show.length;resetIdx++ )
		{
			document.dynamiccompare.show[resetIdx].checked = false;
		}
		Reorder ( false );
	}
}
function Reorder( validateEmpty ) 
{
	if( document.dynamiccompare )
	{
		var cnt		= 0;
		for( prodIndx=0;prodIndx<document.dynamiccompare.show.length;prodIndx++ )
		{
			if( document.dynamiccompare.show[prodIndx].checked  )
			{
			
				cnt++;
			}
			
		}
		
		
	
		if ( cnt == 0 )
		{
			if ( validateEmpty )
			{
				if ( alertVal )
				{
					alert ( alertVal );
				}
				else
				{
					alert ( "Please Select System");
				}
				return;
			}
			else
			{
				
				if( readIEVer() < 5.0 || isOpera )
				{
					
					if( m_htmlText.length > 0 && document.getElementsByName )
					{
						var cTable	 = document.getElementsByName( "compareTable" );
						
						if ( cTable && cTable.length == 1 )
						{
							cTable[0].innerHTML= m_htmlText;	
							return;
						}
					}
					location.reload();
					return;
				}
				
			}
			
		}
		var		isFirst		= true;
		
		if ( cnt > 0 )
		{
			Show  ( "trashcan" );
			Hide ( "selectors" );
		
			for( prodIndx=0;prodIndx<document.dynamiccompare.show.length;prodIndx++ )
			{
				if( document.dynamiccompare.show[prodIndx].checked == false )
				{
					Hide (  document.dynamiccompare.show[prodIndx].value );
				}
				else
				{
					Resize ( document.dynamiccompare.show[prodIndx].value  , cnt , isFirst);
					isFirst		= false;
				
				}
			}
		}
		else
		{
			
			cnt				= document.dynamiccompare.show.length;
			
			Show  ( "selectors" );
			Hide ( "trashcan" );
			
			for( prodIndx=0;prodIndx<document.dynamiccompare.show.length;prodIndx++ )
			{
				Show (  document.dynamiccompare.show[prodIndx].value );
				Resize ( document.dynamiccompare.show[prodIndx].value  , cnt , prodIndx == 0 );
			}
		}
		
		m_compared	= true;
				
	}
}