var divkey;
var cell;

function pricedisplay(divkey,cell)
	{
	var thiscell = document.getElementById(cell);
	options = thiscell.getElementsByTagName('div');
	for (x=0; x<options.length; x++)
		{
		var thisclass = options[x].className;
		var thisid = "var"+divkey;
		if(thisclass=='variant')
			{
			options[x].style.display='none';
			}
		document.getElementById("var"+divkey).style.display='block';
		}
	}

function changer(thiscellname)
	{
	thisproduct = document.getElementById(thiscellname);
	if(thisproduct.getElementsByTagName('select').length>0)
		{
		var dropdown = thisproduct.getElementsByTagName('select')[0];
		dropdown.onchange = function()
			{
			pricedisplay(this.value,thiscellname);
			}
		}
	}

function pagecontrol()
	{
	if(document.getElementById('category'))
		{
		products = document.getElementById('category').getElementsByTagName('td');
		for(cell = 1; cell <= products.length; cell++)
			{
			thiscellname = 'prod'+cell;
			if(document.getElementById(thiscellname))
				{
				changer(thiscellname);
				}
			}
		}

	if(document.getElementById('central'))
		{
		var divs = document.getElementsByTagName('div');
		for(y = 0; y < divs.length; y++)
			{
			if(divs[y].className=='product')
				{
				divs[y].onmouseover = function()
					{
					this.className = 'product over'
					}
				divs[y].onmouseout = function()
					{
					this.className = 'product'
					}
				}
			}
		}
	
	if(document.getElementById("billingaddress"))
		{
		var displayState='none';
		billingcontrol = document.getElementById("billingaddress");
		if(billingcontrol.checked)
			{
			document.getElementById("billing").style.display='none';
			}
		else
			{
			document.getElementById("billing").style.display='block';
			}
			
		billingcontrol.onclick=function()
			{
			displayState = (displayState == 'block') ? 'none' : 'block';
			var element = document.getElementById("billing");
			element.style.display = displayState;
			}
		
		billingcontrol.ondoubleclick=function()
			{
			displayState = (displayState == 'block') ? 'none' : 'block';
			var element = document.getElementById("billing");
			element.style.display = displayState;
			}
		}
	}
window.onload= pagecontrol;

				