window.onload = function()
{
	setButtons();
	setupForm1();
}

function imageOver(vObj)
{
	myImg = vObj;
	myImg.src = './images/'+myImg.id+'_f2.jpg';
}

function imageOut(vObj)
{
	myImg = vObj;
	myImg.src = './images/'+myImg.id+'.jpg';
}


// Check for changes to Step 1 Form
function checkForm1()
{
	my8x10 = document.getElementById('8x10');
	my8x10quan = document.getElementById('8x10quan');
	my8x10price = document.getElementById('8x10price');
	my8x10extra = document.getElementById('8x10extra');
	my8x10type = document.getElementById('8x10type');

	my4x6 = document.getElementById('4x6');
	my4x6quan = document.getElementById('4x6quan');
	my4x6price = document.getElementById('4x6price');
	my4x6extra = document.getElementById('4x6extra');
	my4x6type = document.getElementById('4x6type');

	myNoframe = document.getElementById('noframe');

	myFrameB = document.getElementById('frameB');
	myFrameBquan = document.getElementById('frameBquan');

	myFrameW = document.getElementById('frameW');
	myFrameWquan = document.getElementById('frameWquan');

	myFrameM = document.getElementById('frameM');
	myFrameMquan = document.getElementById('frameMquan');

	myPreview = document.getElementById('preview');
	myPreview1 = document.getElementById('preview1');
	myPreview2 = document.getElementById('preview2');
	myPreview3 = document.getElementById('preview3');
	myPreview4 = document.getElementById('preview4');
	myFraming = document.getElementById('framing');
	myTotal = document.getElementById('total');

	myTotalText = '<table cellspacing="0" cellpadding="0">';
	myTotalPrice = 0;

	useFrame = false;

	difQuan = 0;
	totalQuan = 0;

	if(my8x10.checked == true)
	{
		if((my8x10quan.value*1) > 0)
		{
			difQuan = (my8x10quan.value*1);
			useFrame = true;
			myPreview.style['display'] = 'block';
			myFraming.style['display'] = 'block';
			extra = ((my8x10quan.value*1)-1);
			mySubPrice = (my8x10price.value*1) + (extra * (my8x10extra.value*1));
			myTotalPrice = myTotalPrice + mySubPrice;
			myS = '';
			if(extra > 0)
			{
				myS = 's';
			}
			myTotalText+= '\n<tr><td width="1%">'+(my8x10quan.value*1)+'</td><td>8" x 10" Four Seasons Print'+myS+'</td><td>$'+mySubPrice+'</td></tr>';
		}
		else
		{
			myPreview.style['display'] = 'none';
			myPreview1.style['display'] = 'none';
			myPreview2.style['display'] = 'none';
			myPreview3.style['display'] = 'none';
			myFraming.style['display'] = 'none';
		}
	}
	else
	{
		myPreview.style['display'] = 'none';
		myPreview1.style['display'] = 'none';
		myPreview2.style['display'] = 'none';
		myPreview3.style['display'] = 'none';
		myFraming.style['display'] = 'none';
		my8x10quan.value = '0';
	}

	if(my4x6.checked == true)
	{
		if((my4x6quan.value*1) > 0)
		{
			myPreview4.style['display'] = 'block';
			extra = ((my4x6quan.value*1)-1);
			mySubPrice = (my4x6price.value*1) + (extra * (my4x6extra.value * 1));
			myTotalPrice = myTotalPrice + mySubPrice;
			myS = '';
			if(extra > 0)
			{
				myS = 's';
			}
			myTotalText+= '\n<tr><td width="1%">'+(my4x6quan.value*1)+'</td><td>Set'+myS+' of 4" x 6" Four Seasons Prints</td><td>$'+mySubPrice+'</td></tr>';
		}
		else
		{
			my4x6quan.value = '1';
			myPreview4.style['display'] = 'block';
		}
	}
	else
	{
		my4x6quan.value = '0';
		myPreview4.style['display'] = 'none';
	}

	if(myFrameM.checked == true)
	{
		if(((myFrameMquan.value*1) > 0) && useFrame)
		{
			difQuan = difQuan-(myFrameMquan.value*1);
			totalQuan = totalQuan + (myFrameMquan.value*1);
			myPreview1.style['display'] = 'block';
			mySubPrice = ((myFrameMquan.value*1) * 15);
			myTotalPrice = myTotalPrice + mySubPrice;
			myS = '';
			if((myFrameMquan.value*1) > 1)
			{
				myS = 's';
			}
			myTotalText+= '\n<tr><td width="1%">'+(myFrameMquan.value*1)+'</td><td>White Archival Matte'+myS+'</td><td align="left" width="4%">$'+mySubPrice+'</td></tr>';
		}
		else
		{
			myFrameMquan.value = '1';
			myPreview1.style['display'] = 'block';
		}
	}
	else
	{
		myPreview1.style['display'] = 'none';
		myFrameMquan.value = '0';
	}

	if(myFrameB.checked == true)
	{
		if(((myFrameBquan.value*1) > 0) && useFrame)
		{
			difQuan = difQuan-(myFrameBquan.value*1);
			totalQuan = totalQuan + (myFrameBquan.value*1);
			myPreview2.style['display'] = 'block';
			mySubPrice = ((myFrameBquan.value*1) * 59);
			myTotalPrice = myTotalPrice + mySubPrice;
			myS = '';
			if((myFrameBquan.value*1) > 1)
			{
				myS = 's';
			}
			myTotalText+= '\n<tr><td width="1%">'+(myFrameBquan.value*1)+'</td><td>12" x 14" Black Frame'+myS+'</td><td align="left" width="4%">$'+mySubPrice+'</td></tr>';
		}
		else
		{
			myFrameBquan.value = '1';
			myPreview2.style['display'] = 'block';
		}
	}
	else
	{
		myPreview2.style['display'] = 'none';
		myFrameBquan.value = '0';
	}

	if(myFrameW.checked == true)
	{
		if(((myFrameWquan.value*1) > 0) && useFrame)
		{
			difQuan = difQuan-(myFrameWquan.value*1);
			totalQuan = totalQuan + (myFrameWquan.value*1);
			myPreview3.style['display'] = 'block';
			mySubPrice = ((myFrameWquan.value*1) * 59);
			myTotalPrice = myTotalPrice + mySubPrice;
			myS = '';
			if((myFrameWquan.value*1) > 1)
			{
				myS = 's';
			}
			myTotalText+= '\n<tr><td width="1%">'+(myFrameWquan.value*1)+'</td><td>12" x 14" White Frame'+myS+'</td><td align="left" width="4%">$'+mySubPrice+'</td></tr>';
		}
		else
		{
			myFrameWquan.value = '1';
			myPreview3.style['display'] = 'block';
		}
	}
	else
	{
		myPreview3.style['display'] = 'none';
		myFrameWquan.value = '0';
	}

	if(difQuan > 0)
	{
		myPreview.style['display'] = 'block';
	}
	else
	{
		myPreview.style['display'] = 'none';
	}

	if(totalQuan > (my8x10quan.value*1))
	{
		my8x10quan.value = totalQuan;
	}

	if(myTotalPrice > 0)
	{
		myTax = (Math.round(myTotalPrice*8.75)/100);

		myTotalText+= '\n<tr><td width="1%">&nbsp;</td><td align="right">Subtotal:</td><td align="left" width="4%">$'+myTotalPrice+'</td></tr>';
		myTotalText+= '\n<tr><td width="1%">&nbsp;</td><td align="right">NYS Tax:</td><td align="left" width="4%">$'+myTax+'</td></tr>';
		myTotalText+= '\n<tr><td colspan="3"><hr/></td></tr>';
		myTotalText+= '\n<tr><td width="1%">&nbsp;</td><td align="right" class="red"><b>Total:</b></td><td align="left" width="4%" class="red"><b>$'+(myTotalPrice + myTax)+'</b></td></tr>';
	}
	myTotalText+='</table>';
	myTotal.innerHTML = myTotalText;

	setTimeout('checkForm1()', 1000);
}

// Setup Step 1 Form
function setupForm1()
{
	if(document.getElementById('orderform1'))
	{
		my8x10 = document.getElementById('8x10');
		my8x10quan = document.getElementById('8x10quan');

		my4x6 = document.getElementById('4x6');
		my4x6quan = document.getElementById('4x6quan');

		myFrameB = document.getElementById('frameB');
		myFrameBquan = document.getElementById('frameBquan');

		myFrameW = document.getElementById('frameW');
		myFrameWquan = document.getElementById('frameWquan');

		myFrameM = document.getElementById('frameM');
		myFrameMquan = document.getElementById('frameMquan');

		document.getElementById('preview4').style['display'] = 'none';

		my8x10.onchange = function()
		{
			if((this.checked == true) && (my8x10quan.value == '0'))
			{
				my8x10quan.value = '1';
			}
		}

		my4x6.onchange = function()
		{
			if((this.checked == true) && (my4x6quan.value == '0'))
			{
				my4x6quan.value = '1';
			}
		}

		myFrameB.onchange = function()
		{
			if((this.checked == true) && (myFrameBquan.value == '0'))
			{
				myFrameBquan.value = '1';
			}
		}

		myFrameW.onchange = function()
		{
			if((this.checked == true) && (myFrameWquan.value == '0'))
			{
				myFrameWquan.value = '1';
			}
		}

		myFrameM.onchange = function()
		{
			if((this.checked == true) && (myFrameMquan.value == '0'))
			{
				myFrameMquan.value = '1';
			}
		}
		checkForm1();
	}
	dropShadow();
}

function setButtons()
{
	if(document.getElementById('continue'))
	{
		document.getElementById('continue').onmouseover = function()
		{
			document.getElementById('continue').src = './images/continue_over.gif';
		}
		document.getElementById('continue').onmouseout = function()
		{
			document.getElementById('continue').src = './images/continue.gif';
		}
	}

	if(document.getElementById('confirm'))
	{
		document.getElementById('confirm').onmouseover = function()
		{
			document.getElementById('confirm').src = './images/confirm_over.gif';
		}
		document.getElementById('confirm').onmouseout = function()
		{
			document.getElementById('confirm').src = './images/confirm.gif';
		}
	}

	if(document.getElementById('goback'))
	{
		document.getElementById('goback').onmouseover = function()
		{
			document.getElementById('goback').src = './images/goback_over.gif';
		}
		document.getElementById('goback').onmouseout = function()
		{
			document.getElementById('goback').src = './images/goback.gif';
		}
	}

	if(document.getElementById('cancel'))
	{
		document.getElementById('cancel').onmouseover = function()
		{
			document.getElementById('cancel').src = './images/cancel_over.gif';
		}
		document.getElementById('cancel').onmouseout = function()
		{
			document.getElementById('cancel').src = './images/cancel.gif';
		}
	}

	if(document.getElementById('order'))
	{
		document.getElementById('order').onmouseover = function()
		{
			document.getElementById('order').src = './images/order_over.gif';
		}
		document.getElementById('order').onmouseout = function()
		{
			document.getElementById('order').src = './images/order.gif';
		}
	}

	if(document.getElementById('enlarge'))
	{
		document.getElementById('enlarge').onmouseover = function()
		{
			document.getElementById('enlarge').src = './images/enlarge_over.gif';
		}
		document.getElementById('enlarge').onmouseout = function()
		{
			document.getElementById('enlarge').src = './images/enlarge.gif';
		}
	}
}

function dropShadow()
{
	allElems = document.getElementsByTagName('h1');
	for(i=(allElems.length-1); i>=0; i--)
	{

		myElem = allElems[i];
		if(myElem.className.match('shadow'))
		{
			myElem.style['position'] = 'relative';
			myElem.style['zIndex'] = '10000000';
			newElem = myElem.cloneNode(true);
			myElem.appendChild(newElem);
			newElem.style['position'] = 'absolute';
			newElem.style['zIndex'] = '0';
			newElem.style['top'] = '-'+(newElem.offsetHeight-5)+'px';
			newElem.style['left'] = '2px';
			newElem.style['opacity'] = '.3';
			if(newElem.filters)
			{
				newElem.style['filter'] = 'alpha(opacity=30)';
			}
		}
	}
}
