function addToCart(itemId)
{
    document.buyForm.cartAction.value = "addItem";
    document.buyForm.itemQuantity.value = 1;
    document.buyForm.itemID.value = itemId;
    document.buyForm.action = '/shoppingCart.htm';
    document.buyForm.method = 'post';
    document.buyForm.submit();
}
function addToCart2(docId,itemId)
{
    document.getElementById(docId).cartAction.value = "addItem";
    document.getElementById(docId).itemQuantity.value = 1;
    document.getElementById(docId).itemID.value = itemId;
    document.getElementById(docId).action = '/shoppingCart.htm';
    document.getElementById(docId).method = 'post';
    document.getElementById(docId).submit();
}
var discountId = '';
function addToCart3(docId,itemId)
{
    document.getElementById(docId).cartAction.value = "addItem";
    document.getElementById(docId).itemQuantity.value = 1;
    document.getElementById(docId).itemID.value = itemId;
	document.getElementById(docId).scholarship.value = discountId;
    document.getElementById(docId).action = '/shoppingCart.htm';
    document.getElementById(docId).method = 'post';
	document.getElementById(docId).submit();
}
function displayPaymentDiv(id)
{
    if(document.getElementById('ddDetails')!=null)
        document.getElementById('ddDetails').style.display='none';
    if(document.getElementById('ccDetails')!=null)
        document.getElementById('ccDetails').style.display='none';
    if(document.getElementById('obtDetails')!=null)
        document.getElementById('obtDetails').style.display='none';
    if(document.getElementById('ddDiv')!=null)
        document.getElementById('ddDiv').className='dTpo';
    if(document.getElementById('ccDiv')!=null)
        document.getElementById('ccDiv').className='dTpo';
    if(document.getElementById('obtDiv')!=null)
        document.getElementById('obtDiv').className='dTpo';

	document.getElementById(id+'Details').style.display='';
	document.getElementById(id+'Div').className='dTpoE';
}
function onsubmitButtonClick(method)
{
	document.paymentForm.paymentMethod.value=method;
    document.paymentForm.action = "/paymentConfirmation.htm";
    document.paymentForm.submit();
}
function expandDiv(id)
{
	document.getElementById(id).style.display='';
}
function autoFillDetailFormAndSubmit()
{
	document.forms['leadForm'].billingAddress1.value = document.forms['leadForm'].shipmentAddress1.value;
	document.forms['leadForm'].billingCityId.value = document.forms['leadForm'].shipmentCityId.value;
	document.forms['leadForm'].billingStateId.value = document.forms['leadForm'].shipmentStateId.value;
	document.forms['leadForm'].billingZip.value = document.forms['leadForm'].shipmentZip.value;
	document.forms['leadForm'].billingPhone.value = document.forms['leadForm'].shipmentPhone.value;
	document.forms['leadForm'].billingMobile.value = document.forms['leadForm'].shipmentMobile.value;
	document.forms['leadForm'].billingEmail.value = document.forms['leadForm'].shipmentEmail.value;
	return checkPaidFormEducation();
}
function autoFillDetailFormAndSubmitNew()
{
		document.forms['leadForm'].shipmentAddress1.value =  document.forms['leadForm'].billingAddress1.value;  
  document.forms['leadForm'].shipmentCityId.value   =  document.forms['leadForm'].billingCityId.value;  
  document.forms['leadForm'].shipmentStateId.value  =  document.forms['leadForm'].billingStateId.value; 
  document.forms['leadForm'].shipmentZip.value      =  document.forms['leadForm'].billingZip.value;  
  document.forms['leadForm'].shipmentPhone.value    =  document.forms['leadForm'].billingPhone.value; 
  document.forms['leadForm'].shipmentMobile.value   =  document.forms['leadForm'].billingMobile.value;  
  document.forms['leadForm'].shipmentEmail.value    =  document.forms['leadForm'].billingEmail.value;  

	return checkPaidFormEducation();
}
function displayShoppingDiv()
{
	var id = document.getElementById('sessionShoppingFlow').value;
	if(id==null) return;
	document.getElementById(id).style.display='';
	window.location.hash="paymentHeading";
}
function expandColapseDiv(id)
{
	if(document.getElementById(id).style.display=='')
		document.getElementById(id).style.display='none';
	else
		document.getElementById(id).style.display='';
}
function removeItemAndSubmit(id)
{
	var confirm1 = confirm("Are you sure to remove this product?");
	if(!confirm1)
	{
		return false;
	}
	document.getElementById('removals['+id+']').value=1;
    return updateCartByAjax();
}
function removeItem(id)
{
	var confirm1 = confirm("Are you sure to remove this product?");
	if(!confirm1)
	{
		return false;
	}
	document.getElementById('removals['+id+']').value=1;
}

function updateCartByAjax()
{
	var form = document.forms["shoppingCartForm"];
    var status = AjaxRequest.submit(form, {
        'onSuccess':function(req)
        {
			if(req.responseText.indexOf("error")==-1)
            {
             	document.getElementById("cartDetailsTable").innerHTML = req.responseText;
				if(document.getElementById("itemsInSession").value<=0)
				{
					document.getElementById("proceedSpan").innerHTML = '';
				}
            }
        }
    } );
    return false;
}

