// commonpopup.js

// popup window Function

function popup(pf,height,width,scrollbars,top,left,name)
{
	if(height == null)
	{
		height=340;
	}
	if(width == null)
	{
		width=488;
	}
	if(top == null)
	{
		top=100;
	}
	if(left == null)
	{
		left=200;
	}
	if(scrollbars == null)
	{
		scrollbars='NO'; 
	}
	var s = "height="+height+",width="+width+",top="+top+",left="+left+",scrollbars="+scrollbars;
    if(name == null)
		window.open(pf,null,s);
	else
		window.open(pf,name,s);
}

function goBack()
{
	history.back();
}

function popupCalendarBasket(productPrice, productSKU, locationType, quantityIndex, dateIndex)
{
    var month = document.getElementById("cartItem(" + dateIndex + ").deliveryMonth").value;
    var year = document.getElementById("cartItem(" + dateIndex + ").deliveryYear").value;
    var zip = document.getElementById("cartItem(" + dateIndex + ").zip").value;
    var itemCount = document.getElementById("cartItem(" + quantityIndex + ").quantity").value;
    var country = "";
    var pf = "calendar.do?month="+month+"&year="+year+"&locationType="+locationType+"&itemCount="+itemCount+"&productPrice="+productPrice+"&zip="+zip+"&country="+country+"&productSKU="+productSKU+"&dateIndex="+dateIndex;
    window.open(pf, null, "height=412,width=312,top=100,left=280,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function popupShippingCalendar(productPrice, productSKU, zip, quantity, country, groupIndex, itemId)
{
    var month = document.getElementById("giftMessages(" + itemId + ").deliveryMonth").value;
    var year = document.getElementById("giftMessages(" + itemId + ").deliveryYear").value;
    var locationType = document.getElementById("shippingMethods(" + groupIndex + ").locationType").value;
    var pf = "calendar.do?month="+month+"&year="+year+"&locationType="+locationType+"&itemCount="+quantity+"&productPrice="+productPrice+"&zip="+zip+"&country="+country+"&productSKU="+productSKU+"&itemId="+itemId;
    window.open(pf, null, "height=412,width=312,top=100,left=280,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function popupDeliDateCalendar()
{
    var form = document.getElementById("mgcdeliverydate");
    var month = form.elements["deliveryDate(0).deliveryMonth"].value;
    var year = form.elements["deliveryDate(0).deliveryYear"].value;
    var locationType = form.elements["location"].value;
    var itemCount = 1;
    var zip = form.elements["zip"].value;
    var country = "";
    var productSKU = form.elements["sku"].value;
    var productPrice = form.elements["price"].value;
    var pf ="calendar.do?month="+month+"&year="+year+"&locationType="+locationType+"&itemCount="+itemCount+"&productPrice="+productPrice+"&zip="+zip+"&country="+country+"&productSKU="+productSKU+"&deliDate=true";
    window.open(pf, null, "height=412,width=312,top=100,left=280,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function popupCalendar()
{
    var month = document.getElementById("deliveryMonth").value;
    var year = document.getElementById("deliveryYear").value;
    var locationType = document.getElementById("locationCode").value;
    var itemCount = 1;
    var quantity = document.getElementById("quantity");
    if(quantity != null)
    {
    	itemCount = quantity.value;
    }
    var zip = document.getElementById("zipCode").value;
    var country = "";
//    var skuselect = document.getElementById("sku");
//    var productSKU = skuselect.options[skuselect.selectedIndex].value;
//    var productPrice = skuselect.options[skuselect.selectedIndex].getAttribute("skuprice");
	var checkedSku;
	var skuArray = document.getElementsByName("sku");

	for(var i=0;i<skuArray.length;i++)
	{
		if(skuArray[i].checked == true)
		{
			checkedSku = skuArray[i];
			break;
		}
	}
    if(month == 0)
    {
	month='09';
	year='2006';
    }
	var productSKU = checkedSku.value;
	var productPrice = checkedSku.getAttribute("skuprice");
    var pf ="calendar.do?month="+month+"&year="+year+"&locationType="+locationType+"&itemCount="+itemCount+"&productPrice="+productPrice+"&zip="+zip+"&country="+country+"&productSKU="+productSKU;
    window.open(pf, null, "height=412,width=312,top=100,left=280,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function popupGiftNotice()
{
	window.open("giftnotice.do", null, "height=600,width=800,top=0,left=0,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
}

function popupYourChoice()
{
	window.open("yourchoice.jsp", "yourchoice", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=696,height=465,top=10,left=10");
}