function positionDropDiv()
{
	//alert(findPos('chooseFormat')[0]);
	
	var div = document.getElementById('formatDropDiv');
	
	var pos = findPos('chooseFormat');
	
	div.style.left = ( 214 ) + 'px';
	div.style.top = ( pos[1] - 239 ) + 'px';
}

function findPos(id)
{
	var obj = document.getElementById(id);
	
	if ( obj )
	{
		var curleft = curtop = 0;
		
		if ( obj.offsetParent )
		{
			do
			{
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
			while ( obj = obj.offsetParent );
		
			return [curleft,curtop];
		}
	}
}

function formatTick(id)
{
	var img = document.getElementById('formatTick' + id);
	var input = document.getElementById('formatField' + id);
	
	if ( img.src.match('1.png') != null )
	{
		hideDiv('maxReachedDiv');
		
		flashed = 0;
	
		img.src = img.src.replace('1.png','.png');
		
		input.value = '0';
			
		ticked = ticked - 1;
	}
	else
	{
		if ( ticked < maxTicked )
		{
			hideDiv('maxReachedDiv');
		
			flashed = 0;
		
			img.src = img.src.replace('.png','1.png');
		
			input.value = '1';
		
			ticked = ticked + 1;
		}
		else
		{
			showDiv('maxReachedDiv');
			
			if ( flashed == 0 )
			{
				flashCartItem(2);
				
				flashed = 1;
			}
			
			//alert('You may select a maximum of ' + maxTicked + ' formats.');	
		}
	}
}

function clearDefault(o,val)
{
	if ( o.value == val )
	{
		o.value = '';
		o.style.color = '#333';
	}
}

function loadDefault(o,val)
{
	if ( o.value == '' )
	{
		o.value = val;	
		o.style.color = '#999';
	}
}

function navSelect(i)
{
	if ( document.getElementById('h' + i).className == 'a' )
	{
		var c = true;	
	}
	else
	{
		var o = true;	
	}
	
	document.getElementById('formats').style.display = 'none';
	document.getElementById('formats').style.visibility = 'hidden';
	document.getElementById('hformats').className = '';

	document.getElementById('genres').style.display = 'none';
	document.getElementById('genres').style.visibility = 'hidden';
	document.getElementById('hgenres').className = '';

	document.getElementById('series').style.display = 'none';
	document.getElementById('series').style.visibility = 'hidden';
	document.getElementById('hseries').className = '';

	document.getElementById('types').style.display = 'none';
	document.getElementById('types').style.visibility = 'hidden';
	document.getElementById('htypes').className = '';
	
	if ( o == true )
	{
		document.getElementById(i).style.display = 'block';
		document.getElementById(i).style.visibility = 'visible';
		document.getElementById('h' + i).className = 'a';
	}
	
	//new ajax('expandMenu.php',{postBody:'expand='+i, onComplete: null, update: null}).request();
	new ajax('/expand/'+i+'/',{postBody:null, onComplete:null, update:null}).request();
}

function showCurrency()
{
	document.getElementById('currencyDiv').style.display = 'block';	
	document.getElementById('currencyDiv').style.visibility = 'visible';	
}

function hideCurrency()
{
	document.getElementById('currencyDiv').style.display = 'none';	
	document.getElementById('currencyDiv').style.visibility = 'hidden';	
}

function showDiv(n)
{
	if ( document.getElementById(n) )
	{
		document.getElementById(n).style.display = 'block';	
		document.getElementById(n).style.visibility = 'visible';	
	}
}

function hideDiv(n)
{
	if ( document.getElementById(n) )
	{
		document.getElementById(n).style.display = 'none';	
		document.getElementById(n).style.visibility = 'hidden';	
	}
}

function openFormats()
{
	window.open("/static/which-format.php","format","menubar=no,width=430,height=360,toolbar=no,location=no,status=no,titlebar=no,directories=no,scrollbars=yes");
}

function openCheckoutdetails()
{
	window.open("/static/checkout-info.php","format","menubar=no,width=430,height=360,toolbar=no,location=no,status=no,titlebar=no,directories=no,scrollbars=yes");
}

function openHowCopy()
{
	window.open("/static/how-copy.php","format","menubar=no,width=430,height=360,toolbar=no,location=no,status=no,titlebar=no,directories=no,scrollbars=yes");
}
