var currentSong='Track_0';			// song id being purchased
var appliedPromoCode='';			// promo code currently applied to order
var newPrice='';					// new content price after promo code application
var tempPrice='';					// temp price for CBN check
var purchaseOverride = 'false';		// override flag for re-purchasing content
var forceCRN = 'false';				// flag for mandatory CRN on file
var accountHolder = 'false';		// flag for price > CBN sub-user case

/* Used for title and artist display in confirm purchase popup - have to strip links out */
function hrefTrim(toBeTrimmed){
	var str = toBeTrimmed;
	str = str.substring(str.indexOf(">")+1,str.lastIndexOf("<"));
	return str;
}

/* Render purchase confirmation box after clicking "BUY" */
function makePurchase(){
	divRender('songPurchaseConf');
	//document.getElementById('songPurchaseConf').innerHTML=origConfCode;
	document.getElementById('finalSongTitle').innerHTML=hrefTrim(document.getElementById('songTitle_'+currentSong).innerHTML);
	document.getElementById('finalArtist').innerHTML='by ' + hrefTrim(document.getElementById('songArtist_'+currentSong).innerHTML);
	document.getElementById('finalCost').innerHTML=document.getElementById('songPrice_'+currentSong).innerHTML;
	YAHOO.CLWRBuyProcess.songPurchaseConf.show();
	document.getElementById('confirmPurchase').focus();

	
	if(getFlashMovie("installer_widget_pp").checkagain) {
		getFlashMovie("installer_widget_pp").checkagain();	
	}
}

/* Download manager method to call when installer displayed */
function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

/* After successful content purchase & recommendation lookup, render purchase completed box */
function finalPurchase(){
	/*
	confirmation=document.getElementById('confText').innerHTML;
	document.getElementById('songPurchHd').innerHTML='<h4>Purchase Confirmation:</h4>';
	document.getElementById('songPurchBody').innerHTML=confirmation;
	document.getElementById('songPurchBody').style.height='250px';
	document.getElementById("closeButton").style.display = "block";
	document.getElementById('songPurchFt').innerHTML='<div class="buttons" style="height:5px;"></div>';	
	*/
	document.getElementById('songPurchaseConfProcessing').innerHTML = '';
	YAHOO.CLWRBuyProcess.songPurchaseConf.hide();
	YAHOO.CLWRBuyProcess.songPurchaseConf.hideMask();
	divRender('confText');
	YAHOO.CLWRBuyProcess.confText.show();	
	document.getElementById('confTextCloseBtnLink').focus();
}

// Popup window function Thumbplay
function thumbplayNewPopup(URL) 
{
	window.open(URL,'_blank','resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes,directories=no, status=yes');
}
