function showSubProducts(subProducts,maxProducts,CategoryId)
{	
	for(x = 1; x <= maxProducts; x++)
	{
		if(x != subProducts)
		{
			document.getElementById('sub' + x).style.display = 'none';	
		}
		else
		{
			document.getElementById('sub' + subProducts).style.display = 'block';	
		}
		
	}
	
	if (CategoryId)	
	{
		var mainImageElement = document.getElementById("main_image");
		if (mainImageElement != null)
		{
			document.getElementById('main_image').src = "images/"+CategoryId+".jpg";
		}	
	}
}

function showSubProducts2(subProducts,maxProducts)
{	
	for(x = 1; x <= maxProducts; x++)
	{
		if(x != subProducts)
		{
			document.getElementById('sub' + x).style.display = 'none';	
		}
		else
		{
			document.getElementById('sub' + subProducts).style.display = 'block';	
		}
		
	}	
}

function popWindow(url,width,height)
{
	//default pos
	xposition = 10;
	yposition = 10;
	
	//center it
	if ((parseInt(navigator.appVersion) >= 4 ))
	{
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	
	args = "width=" + (width) + "," 
	+ "height=" + (height) + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"
	+ "scrollbars=1,"
	+ "status=1," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "left=" + xposition + ","
	+ "top=" + yposition;
	window.open(url,'sgPop' + Math.floor(Math.random()*1000000000),args);
}

function changeColor(code)
{
	handle = document.getElementById('orderCode');
	while(handle.hasChildNodes() == true)
	{
		handle.removeChild(handle.childNodes[0]);
	}
	codeText = document.createTextNode(code);
	handle.appendChild(codeText);

	imghandle = document.getElementById('shotImage');

	if(code.indexOf('/') != -1)
	{
		image = code.split('/');
		imghandle.src = 'assets/images/colours/' + image[0] + image[1] + '.jpg';
	}
	else
	{
		if(code.length <= 4)
		{
			imghandle.src = 'assets/images/products/' + code + '.jpg';	
		}
		else
		{
			imghandle.src = 'assets/images/colours/' + code + '.jpg';	
		}
	}
}


function changeView(image,link,max)
{
	handle = document.getElementById('shotImage');
	handle.src = 'assets/images/products/' + image;	
	
	for(x = 1; x <= max; x++)
	{
		linkHandle = document.getElementById('view' + x);
		if(x == link)
		{
			linkHandle.style.color = '#CC0000';
		}
		else
		{
			linkHandle.style.color = '#333333';		
		}
	}	
}

function showSubs(sub,link)
{
	handle = document.getElementById('selectSubs'+sub);
	if(handle.style.display == 'block')
	{
		handle.style.display = 'none';
	}
	else
	{
		handle.style.display = 'block';
	}
}