function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
	if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
	// Place ErrorMessage in the center
	if (szDivID == 'vcoDiv'){
		placeOffer(szDivID);
	}
	else {
		placeErrorMessage(szDivID);
	}
} // END: toggleBox

 function placeOffer(plDivID) {
	if (document.getElementById && !document.all) {
		document.getElementById(plDivID).style.top = window.pageYOffset + 30 + "px";
	}
	if (document.all) {
	  document.all[plDivID].style.top = truebody().scrollTop + 30 + "px";
	}
	window.setTimeout("placeOffer('"+ plDivID + "')", 10);
}
 
 function placeErrorMessage(plDivID) {
	if (document.getElementById && !document.all) {
		document.getElementById(plDivID).style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight/2)) + "px";
	}
	if (document.all) {
		document.all[plDivID].style.top = truebody().scrollTop + (truebody().clientHeight - (truebody().clientHeight/2)) + "px";
	}
	window.setTimeout("placeErrorMessage('"+ plDivID + "')", 10);
}

 // END: Place Error message function
 
function showInfoMsg() {
 	$('#infoText').html('To place an AutoBid simply enter your <strong>maximum</strong> bid in the <i>Bid Box</i> and click on the <i>Bid Now</i> button. The system will automatically bid on your behalf up to the value of your maximum bid amount.');
	$('#infoHeader').html('AutoBid');
	toggleBox('infoDiv', 1);
}
 
function showAutobidNews() {
 	$('#infoText').html('Placing an AutoBid at Bidz.com has never been easier. Simply enter your <strong>maximum</strong> bid in the <i>Bid Box</i>. The system will automatically bid on your behalf up to the value of your maximum bid amount.');
	$('#infoHeader').html('New and Improved AutoBid Feature');
	toggleBox('infoDiv', 1);
}
 
function showLayawayMsg() {
 	//$('infoText').innerHTML = 'We are sorry that BillMeLater&#174; could not extend credit to you.<br/><br/>Bidz would like to offer you our <a href="http://www.bidz.com/bzJApp/ViewContent.action?sid=100&tid=100&pageName=layaway" target="_blank">Lay-Away program</a>.<br/><br/>Please call<br/><strong style="font-size: 1.3em; margin: 0.3em; display: block;">1-877-ALL-VIPZ (8479)</strong>now to take advantage of this offer.<br/><strong style="font-size: 1em; margin: 0.3em; display: block; color: #0c3;">Everyone is approved!</strong>';
	$('#infoText').html('Bidz would like to offer you our <a href="http://www.bidz.com/bzJApp/ViewContent.action?sid=100&tid=100&pageName=layaway" target="_blank">Lay-Away program</a>.<br/><br/>Please call<br/><strong style="font-size: 1.3em; margin: 0.3em; display: block;">1-877-ALL-VIPZ (8479)</strong>now to take advantage of this offer.<br/><strong style="font-size: 1em; margin: 0.3em; display: block; color: #0c3;">Everyone is approved!</strong>');
	$('#infoHeader').html('Bidz Layaway Program');
	toggleBox('infoDiv', 1);
}

function showLayawayInvitation() {
 	$('#infoText').html('Bidz would like to offer you our <a href="http://www.bidz.com/bzJApp/ViewContent.action?sid=100&tid=100&pageName=layaway" target="_blank">Lay-Away program</a>.<br/><br/>Please call<br/><strong style="font-size: 1.3em; margin: 0.3em; display: block;">1-877-ALL-VIPZ (8479)</strong>now to take advantage of this offer.<br/><strong style="font-size: 1em; margin: 0.3em; display: block; color: #0c3;">Everyone is approved!</strong>');
	$('#infoHeader').html('Bidz Layaway Program');
	toggleBox('infoDiv', 1);
}

function showLayawayTerms() {
	$('#infoText').html('To continue with your layaway order, please read and accept our <a href="http://www.bidz.com/bzJApp/ViewContent.action?sid=100&tid=100&pageName=layaway" target="_blank">Terms and Conditions</a>. Please note that there is a 20% Layaway cancellation fee of the merchandise total applied on all cancelled layaway orders.');
	$('#infoHeader').html('Attention Lay-Away Customers');
	$('#infoControls').html('<a style="line-height: 60px; color: #777; padding: 0 2em;" href="javascript:' + "cancelLayaway();" + '">Cancel</a> <a style="line-height: 60px; padding: 0 2em;" href="javascript:' + "acceptLayaway();" + '">I Agree</a>');
	toggleBox('infoDiv', 1);
}

var layawayTermsAccepted = false;

function acceptLayaway(){
	layawayTermsAccepted = true;
	toggleBox('infoDiv',0);	
}

function cancelLayaway(){
	document.shoppingCartForm.paymentRadio[1].checked = true;
	toggleBox('infoDiv',0);	
}
