
//Generic Window Opener
function OpenWindow(prod)
{
    solo_win = window.open(prod,'displayWindow','width=600,height=500,scrollbars=yes,resizable=yes');
    if (solo_win && solo_win.open)
        solo_win.moveTo(100,150);
}

//eNewsletter popup
function OpenWindow2(prod2)
{
    solo_win2 = window.open(prod2,'displayWindow','width=420,height=250,scrollbars=no,resizable=no');
}

//Privacy & Security Policies popup
function OpenWindowLargeModal(prod3)
{
    solo_win3 = window.open(prod3,'displayWindow','width=700,height=500,scrollbars=1,status=1,resizable=1,modal=1');
}

function maxLength(obj, maxChars, str)
{
    var specialChars = 0;
    for (i=0; i < obj.value.length; i++)
    {
        if (obj.value.charAt(i)=='\n' || obj.value.charAt(i)=='\r')
        {
            specialChars = specialChars + 1;
            //alert('Special Character Found -' + obj.value.charAt(i) + '-');
        }
    }
    if ((obj.value.length + specialChars) >= (maxChars + 1))
    {
        obj.value = obj.value.slice(0, (maxChars - specialChars));
        alert(str + ' has a maximum of ' + maxChars + ' characters.');
        //alert('Size = ' + obj.value.length + '\nSpecialcharacters = ' + specialChars + '\nMaximum characters allowed is ' + maxChars + '.');
    }
}

function displayPP()
{
    if (window.showModalDialog)
    {
        window.showModalDialog('/enduser/partner/staples/printableOrder.jsp','PrintableOrderWindow','dialogWidth:800px;dialogHeight:500px;menubar:1');
    } else {
        sn = window.open('/enduser/partner/staples/printableOrder.jsp','PrintableOrderWindow','menubar=0,location=0,status=0,resizable=1,width=800,height=500,modal=yes');
        sn.moveTo(800,500);
    }
}

function toggleLayer(whichLayer, hideShow)
{
	//alert(hideShow);
	var elem, vis;
	if (document.getElementById)
		elem = document.getElementById(whichLayer);
	else if (document.all)
		elem = document.all[whichLayer];
	else if (document.layers)
		elem = document.layers[whichLayer];
	vis = elem.style;
	if (hideShow == 'HIDE')
		vis.display = 'none';
	else
		vis.display = 'block';
}

function ccExpDisplay(whichLayer)
{
	if (document.payment.creditCardType.value == 'STORECARD')
		toggleLayer(whichLayer, 'HIDE');
	else
		toggleLayer(whichLayer, 'SHOW');
}
