
var checkedI = new Array()
var checkedS = new Array()
var countI = 5
var buyme = false
var buyspec = ''
var buyQuant = '1'
var localSKU = ''


function clearCheckedI(){ for (var i=0; i<countI; i++){checkedI[i]=''} }
function pushCheckedI(n,v){ checkedI[n] = v }
function popCheckedI(n){ checkedI[n] = '' }
function storeCheckedI(){ for (var i=0; i<countI; i++){checkedS[i]=checkedI[i]}; }
function restoreCheckedI(){ for (var i=0; i<countI; i++){checkedI[i]=checkedS[i]} }

function strobeCheckedI(){
	if (!buyme){return false}
	for (var i=0; i<countI; i++){
		if (checkedI[i] != ''){
			// window.open("http://lifet.ivdesk.com/Storefront/showproduct.aspx?productid=13&skinid=3", "_blank")
			OpenPurchase();
			checkedI[i] = ''
			window.top.getElementById('prox').document.getElementById('ampr').click()
			return false
		}
	}
	if (buyspec != ''){
		OpenPurchase();
		// window.open("http://lifet.ivdesk.com/Storefront/showproduct.aspx?productid=13&skinid=3", "_blank")
		buyspec = ''
		window.top.getElementById('prox').document.getElementById('ampr').click()
		return false
	}
	if (buyme){
		OpenPurchase();
		// window.open("http://lifet.ivdesk.com/Storefront/showproduct.aspx?productid=13&skinid=3", "_blank")
		try { document.getElementById('buyb').src='purc/graphics/buy.gif' } catch(e) {}
		buyme = false
	}
}

function fetchSKU(v){
	if (localSKU==''){
//		fetchNCLBTCookie()
		localSKU = cookieS
	}
	return localSKU.split(',')[v]
}


clearCheckedI()


function popupSettings(w,h,borderless){
	if (screen.width < 1100){
		rv = 'fullscreen'
	} else {
		wl = (screen.width-w)/2
		wh = (screen.height-h)/2
		if (borderless){
			rv = "fullscreen=1,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=1,width=" + w.toString()
		} else {
			rv = "fullscreen=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=0,width=" + w.toString()
		}
		rv = rv + ',height=' + h.toString()
		rv = rv + ',left=' + wl.toString()
		rv = rv + ',top=' + wh.toString()
	}
	return rv
}


function OpenPurchase()
{
	// window.open("../llpay1/default.aspx", "_blank")

	hf = "../llpay/default.aspx"
	w = 725
	h = 550
	borderless = false

	try {
		llWindow = window.open(hf,"lifetimeLibrary",popupSettings(w,h,borderless),true)

		if (borderless){
			wl = (screen.width-w)/2
			wh = (screen.height-h)/2
			llWindow.resizeTo( Math.ceil( w )  , Math.ceil( h ) )
			llWindow.moveTo  ( Math.ceil( wl ) , Math.ceil( wh ) )
		}
	} catch(e) {
		alert("The Purchase window could not be opened./n/nSomething is preventing this.")
	}

}


