//---------------------------------------------------------------------------------------------------------
//	DHTML JavaScript (ver 2.3)
//---------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------
//	Show/ Hide menus
//-------------------------------------------------------------------------------------------------------
function show(group,item,imgId,imgBase)
{
	if(document.getElementById)
	{
		menuCount	= eval("m_" + group);
		
		mainMenu	= document.getElementById("m" + group + "0");
		subMenu		= document.getElementById("m" + group + item);

		//	Does object exist?
		if( !subMenu )
		{
			//	No, don't process
			return false;
		}
		
		if( imgId != 'NULL' )
		{
			imgObj	= document.getElementById( imgId );
			imgObj.setAttribute( 'base', imgBase );
			imgObj.setAttribute( 'src', imgBase );
		}
		
		mainMenu.style.visibility	= "visible";
		
		if ((mainMenu != subMenu) && (item != 0))
		{
			subMenu.style.visibility	= "visible";
			for (i = 1; i <= menuCount; i++)
			{
				if (i != item)
				{
					document.getElementById("m" + group + i).style.visibility	= "hidden";
				}
			}
		}
	}
}

//-------------------------------------------------------------------------------------------------------
//	Hide menu
//-------------------------------------------------------------------------------------------------------
function hide(group,item,imgId,imgBase)
{
	if(document.getElementById)
	{
		menuCount	= eval("m_" + group);

		//	Does object exist?
		if( !document.getElementById( "m" + group + menuCount ))
		{
			//	No, don't process
			return false;
		}
		
		if( imgId != 'NULL' )
		{
			imgObj	= document.getElementById( imgId );
			imgObj.setAttribute( 'base', imgBase );
			imgObj.setAttribute( 'src', imgBase );
		}
		
		if (item == 0)
		{
			startFrom	= 0;
		}
		else
		{
			startFrom	= 1;
		}
		for (i = startFrom; i <= menuCount; i++)
		{
			document.getElementById("m" + group + i).style.visibility	= "hidden";
		}
	}
}

//-------------------------------------------------------------------------------------------------------
//	Image swap
//-------------------------------------------------------------------------------------------------------
function swapImg(id,img)
{
	if( document.getElementById)
	{
		obj	= document.getElementById(id);
		obj.setAttribute( 'src', img );
	}
}

//-------------------------------------------------------------------------------------------------------
//	Client_text Selector
//-------------------------------------------------------------------------------------------------------
//	track what Client_text is highlighted in the sponsor a Client_text selector
currentClient_text	= 0;

function showClient_text(what)
{
	Client_textId			= "Client_text" + what;
	
	if(document.getElementById)
	{
		if ( !document.getElementById(Client_textId) )
		{
			return;
		}

		document.getElementById(Client_textId).style.visibility	= "visible";
		if (currentClient_text != what)
		{
			previousClient_textId		= "Client_text" + currentClient_text;
			document.getElementById(previousClient_textId).style.visibility	= "hidden";
		}
	}

	currentClient_text	= what;
}

//-------------------------------------------------------------------------------------------------------
//	Client_image Selector
//-------------------------------------------------------------------------------------------------------
//	track what Client_image is highlighted in the sponsor a Client_image selector
currentClient_image	= 0;

function showClient_image(what)
{
	Client_imageId			= "Client_image" + what;
	
	if(document.getElementById)
	{
		if ( !document.getElementById(Client_imageId) )
		{
			return;
		}

		document.getElementById(Client_imageId).style.visibility	= "visible";
		if (currentClient_image != what)
		{
			previousClient_imageId		= "Client_image" + currentClient_image;
			document.getElementById(previousClient_imageId).style.visibility	= "hidden";
		}
	}

	currentClient_image	= what;
}

//-------------------------------------------------------------------------------------------------------
//	Redirect
//-------------------------------------------------------------------------------------------------------
function redirectTo( nav )
{
	//	Selected a url?
	dropdown	= nav.options;
	value		= dropdown[dropdown.selectedIndex].value;

	if ( value )
	{
		window.location.href = value;	
	}
}

function gallerySwap(id)
{
	detailsImage	= document.getElementById('detailsgraphic');
	detailsImage.setAttribute( 'src', gallery[id] );
	
	textElement		= document.getElementById('detailstitle');
	textElement.innerHTML	= gallerytitle[id];
	
	textElement		= document.getElementById('detailstext');
	textElement.innerHTML	= gallerytext[id];
}

//	Google statsbox
function toggleGoogleStats( box_id )
{
	stats_box_table = document.getElementById( box_id );

	if ( !stats_box_table )
	{
		return;
	}

	if ( stats_box_table.style.display == 'block' )
	{
		stats_box_table.style.display = 'none';
	}
	else
	{
		stats_box_table.style.display = 'block';
	}
}

function expand(param)
{
    param.style.display=(param.style.display=="none")?"block":"none";
}

function expandById(id,active_color,inactive_color)
{
	expand(document.getElementById(id));
    make_link_active(id,active_color,inactive_color);
}

function make_link_active(id,active_color,inactive_color)
{

	active_color	= active_color 
					? active_color
					: '#797d03';

	inactive_color	= inactive_color 
					? inactive_color
					: '#646464';
	var anchor = document.getElementById('anchor_' + id);
    var content_block = document.getElementById(id);
   anchor.style.color = content_block.style.display == 'block' ? active_color : inactive_color;
}
function validate_warranty()
{
	form = document.details;

	var first_item;
	
	for (idx in products )
	{
		control = form["fields["+products[idx]+"]"];
		
		if( idx == 0)
		{
			first_item = control;
		}

		if ( control.checked )
		{
			return true;
		}
		
	}

	alert("Which product(s) did you purchase is required.");
	first_item.focus();



	return false;
}

function AddRow(table_id)
{
	var obj = $('#'+table_id+'_add');
	next = obj.attr('next_row');

	var next_row = $('#' + table_id +'_'+ next  );
	if(next_row.attr('id'))
	{
		//next_row.css({'display':'block'});
		next_row.css({'display':'table-row'});
		obj.attr('next_row',((obj.attr('next_row')*1)+1));
	}
	else
	{
		alert('No more Rows');
	}
	//return false;
}

function EnableKitAttr(idx)
{
	
	$('#'+idx+ ' td').css({'background':'#fff'});
	$('#'+idx+ ' table input').attr('disabled','').css({'background':'#fff','color':'#000'});
}

function DisableKitAttr(idx)
{
	$('#'+idx+ ' table td').css({'background':'#eee'});
	$('#'+idx+ ' table input').attr('disabled','disabled').css({'background':'#eee','color':'#666'});
}
	//Document.ready
	// - 
	$(document).ready(function(){
		$('.button-image').hover( 
			function()
			{
				if( $(this).attr('hover_image'))
				{
					$(this).attr('src',$(this).attr('hover_image'));
				}
			},
			function()
			{
				if( $(this).attr('normal_image'))
				{
					$(this).attr('src',$(this).attr('normal_image'));
				}
			}	
		);
	});
