var currentMain ;
var currentSub ;

function toggle( ele )
{
	topEle = document.getElementById( ele );
	if ( topEle.style.display == "" )
		topEle.style.display = "none";	
	else
		topEle.style.display = "";
}

function toggleform(ele, val)
{
  topEle = document.getElementById( ele );
     if ( topEle != null )
	if (topEle.style.visibility != val)
	{
	     topEle.style.visibility = val;
	}
}
function setdisplay( ele, val )
{

     topEle = document.getElementById( ele );
     if ( topEle != null )
	if (topEle.style.display != val)
	{
	     topEle.style.display = val;
	}
}
function toggleTrueFalse( ele )
{
	topEle = document.getElementById( ele );
	
	if ( topEle.value == "" )
		topEle.value = "true";
	else
		topEle.value = "";
}

function toggleSub( ele )
{	
	var oldele = document.getElementById( currentSub + "c" );
	var newele = document.getElementById( ele + "c" );
	
	if(oldele != null)
	{
		if(oldele.id == newele.id)
		{
			currentSub = null;
		}
		}
	
	if ( currentSub != null)
	{	
		oldele.className = "";
				
		if ( currentSub != ele )
			setdisplay(currentSub, 'none');
			}
	
	if(newele.className == "open")
	{
		newele.className = "";
		}
	else
	{
		newele.className = "open";
		}
	
	toggle(ele);
	currentSub = ele ;
	
	
}

function toggleMain( ele )
{
	if ( currentMain != null)
		if ( currentMain != ele )
			setdisplay(currentMain, 'none');
	toggle(ele);
	currentMain = ele ;
}

function swapImage( ele, src)
{
	ele = document.getElementById( ele );
	mag = document.getElementById('enlargeLink');
	
	if ( ele != null )
		ele.src = src ;
		
	if (mag != null )
		mag.href = src;
}

function clearfield(ele, value)
{
	ele = document.getElementById( ele );
	if ( ele.value == value )
		ele.value = "" ;
}
function toggleClass(ele, value)
{
	if(ele.className != value)
		ele.className = value;
	else
		ele.className = "";
}


function productCompare( root )
{
	Count = 0;
	ListString = ":";
	var c = document.forms["prdForm"].elements["check"];
	if (c && c.length)
	{
		for (var i = 0; i < c.length; i++)
		{
			if (c[i].checked )
			{
				Count =  Count + 1  ;
				ListString = ListString + document.forms["prdForm"].t[i].value ; 
				ListString = ListString + ":" ;
			}
		}
	}
	if ( Count < 1 ) 
		window.alert( "Select at least one item from list") ; 
	else 
	{ 
		if ( Count > 8 ) 
			window.alert( "Select only up to 8 transducers from the list") ; 
		else 
			document.location = "/products/compare.aspx?list=" + ListString + "&p=" + root; 
	} 
} 

function submitForm()
{
    if (document.forms['form2'].elements["searchText"].value  == "" || document.forms['form2'].elements["searchText"].value == "Search")
    { alert("Please specify something to search for..."); return false; }

	return true;
}
function submitFAQForm()
{
    if (document.forms['frmForm'].elements["supFAQSearch"].value  == "" )
    { alert("Please specify something to search for..."); return false; }

	return true;
}

function redirec( arg)
{
	document.location.href = arg ;
}
