if(typeof CreateHTMLRequestor != 'function')
document.write("");
function popupWin(URL, name, windowWidth, windowHeight, params)
{
if (params == '')
params = ",scrollbars=yes,resizable=yes";
else if (params[0] != ',')
params = ','+params;
newWindow = window.open(URL,name,"width="+windowWidth+",height="+windowHeight+params);
if(newWindow)
newWindow.focus();
}
function openWin(URL, name, windowWidth, windowHeight)
{
popupWin(URL, name, windowWidth, windowHeight, '');
}
function openLinkAndCloseWindow( URL, name, windowWidth, windowHeight, params)
{
popupWin(URL,name,windowWidth,windowHeight, params);
window.close();
}
function ResizeWindow(setWidth, setHeight)
{
if (parseInt(navigator.appVersion)>3)
{
if (navigator.appName=="Netscape")
{
winW = window.innerWidth;
winH = window.innerHeight;
}
if (navigator.appName.indexOf("Microsoft")!=-1)
{
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
}
if ( winW < setWidth)
window.resizeTo(setWidth,setHeight);
}
function OpenAndAddProduct(url, prId, zip, tNav)
{
var openResult;
openResult = window.open('/popups/loading.htm','p2l2s',"width=620,height=640");
// Create the XMLHttpRequest object.
c = CreateHTMLRequestor();
// if the XMLHttpRequest object is in any state other than 0 (unitialized), then stop the current request.
if (c && c.readyState!=0)
{
c.abort();
}
// Set the function that handles changes in state.
c.onreadystatechange = function()
{
if (c.readyState == 4)
{
if (c.status == 200)
{
redirectLink = c.responseText.replace( /&/g, "_ampersand");
openResult = window.open(url+'&redirectUrl=' + redirectLink,'p2l2s',"width=620,height=640");
if ( !openResult )
{
WindowRedirect('/cart/cart.htm');
CloseWindows();
}
c.abort();
}
}
}
if ( zip )
var setZipStr = '&setZip=' + zip;
// Send the request.
c.open("GET", "/cart/cart.htm?tNav=" + tNav + "&prId=" + prId+ setZipStr +'&buynow=1&ajaxGetRedirect=1&indexAdd=0&noCache=' + Math.random(), true);
c.send(null);
return false;
}
function RemoveProduct(prId, refreshParent, parentRedirect)
{
// Create the XMLHttpRequest object.
c = CreateHTMLRequestor();
// if the XMLHttpRequest object is in any state other than 0 (unitialized), then stop the current request.
if (c && c.readyState!=0)
{
c.abort();
}
// Set the function that handles changes in state.
c.onreadystatechange = function()
{
if (c.readyState == 4)
{
if (c.status == 200)
{
if(c.responseText == 'refresh')
window.location = parentRedirect;
}
}
};
if (refreshParent)
ajaxGetRedirect=2;
else
ajaxGetRedirect=1;
// Send the request.
c.open("GET", '/cart/cart.htm?ajaxRemovePrId=' + prId + '&removeLast=1&ajaxGetRedirect='+ajaxGetRedirect+'&noCache=' + Math.random(), true);
c.send(null);
}
function CloseWindows()
{
if ( window.opener && window.opener.frames.name == 'phoneresults' )
{
var currentparent = window.opener.parent;
}
else if (window.opener.opener)
{
var grandparent = window.opener.opener;
if ( window.opener.opener.opener)
var greatgrandparent = window.opener.opener.opener;
}
var currentparent = window.opener;
if ( greatgrandparent )
{
window.opener.opener.close();
window.opener.close();
window.close();
}
if(grandparent)
{
window.opener.close();
window.close();
}
else if(currentparent)
{
window.close();
}
}
function WindowRedirect(redirect)
{
if (window.opener)
{
if ( window.opener.frames.name =='phoneresults' )
var grandparent = window.opener.parent;
if ( window.opener.opener )
{
var grandparent = window.opener.opener;
if ( window.opener.opener.frames.name =='phoneresults' )
{
var greatgrandparent = window.opener.opener.parent;
}
if ( window.opener.opener.opener )
{
if (window.opener.opener.opener.frames.name =='phoneresults')
{
var greatgreatgrandparent = window.opener.opener.opener.parent;
}
else
{
var greatgreatgrandparent = window.opener.opener.opener;
}
}
}
}
var currentparent = window.opener;
if ( greatgreatgrandparent )
{
greatgreatgrandparent.location = redirect;
}
else if (greatgrandparent)
{
greatgrandparent.location = redirect;
}
else if(grandparent)
{
grandparent.location = redirect;
}
else if(currentparent)
{
currentparent.location = redirect;
}
else
{
window.location = redirect;
}
}
var termsPopupPopped = new Array();
function TermsPopupOpen(formName, inputCheckboxName, url, displayAsOverlay)
{
if ( typeof(termsPopupPopped[inputCheckboxName]) != "undefined" && termsPopupPopped[inputCheckboxName])
return;
f = document.forms[formName];
if (f.elements[inputCheckboxName].checked)
{
if (displayAsOverlay)
CreateIFrame(event, this, url);
else
popupWin(url,'popup','600','550','');
}
termsPopupPopped[inputCheckboxName] = true;
}
function SubmitOnUnload(formName)
{
if ( !formName)
formName = document.checkoutform;
if(isIE4 && IsCloseButton() == true)
{
formName.secretSubmit.value=1;
formName.submit();
}
}
function getElementPosition( aElement, type )
{
var offset = 0;
while( aElement != null )
{
if (type == 'X')
offset += aElement.offsetLeft;
else
offset += aElement.offsetTop;
aElement = aElement.offsetParent;
}
return offset;
}