//$Id: changeproduct.js,v c23ce53390cd 2010/04/15 18:14:43 rchen 
function GoBackToPage(URL)
{
    //alert('URL is '+ URL);
    if(window.opener)
    {
        window.opener.location = URL;
        var cmd = 'window.close()';
        setTimeout(cmd, 250);
    }
    else
    {
        window.location = URL;
    }
}

function RefreshForm(dev, serv, car, activateYourOwn, formName, stackedView)
{

    if(window.opener.closed)
    {
        alert('The original window that generated this popup is no longer open. This window will now close.');
        window.close();
        return;
    }

    if(!formName)
        formName = "RefreshForm";

    parentForm = window.opener.document.forms[formName];

    if(stackedView)
    {
        parentForm.selectDeviceId.value=dev;
        parentForm.selectPlanId.value=serv;
    }
    else
    {
        if(dev)
            parentForm.selectDeviceId.value=dev;
        if(serv)
            parentForm.selectPlanId.value=serv;
    }
    
    if(car)
    {
        parentForm.carId.value=car;
        if(formName != 'simplecart')
            parentForm.carMenu.value=1;
    }
    
    if(activateYourOwn)
        parentForm.activateYourOwn.value=activateYourOwn;

    if(stackedView)
        parentForm.action = '/product/promo.htm';

    parentForm.action += '#offers';
    parentForm.submit();
    var cmd = 'window.close()';
    setTimeout(cmd, 250);
}

function ChangeProduct(prId, index, changePrId)
{
    parentForm = window.opener.document.forms["ChangeForm"];
    parentForm.prId.value = prId;
    parentForm.indexAdd.value = index;
    if (changePrId)
        parentForm.changePrId.value = changePrId;
    else
        parentForm.changingLine.value = 1;
    parentForm.stayInCart.value = 1;
    parentForm.submit();
    window.close();
}

function UpdateProduct(changePrId, index, type)
{
	var changeform = window.document.forms["ChangeForm"];
	changeform.changeIndex.value = index;
	
	 
	if (type == 'device')
		changeform.changeDevicePrId.value = changePrId;
	else
		changeform.changeServicePrId.value = changePrId;	
	
	changeform.submit();
}
