﻿var dlloc = "0";
var hsClose;
var dlPrID = "0";
var dlPrT = "0";
function DoDownload(result, context)   {
    //alert(result);   
	result2 = result; 
	//HideMouseLoading();
	//HideThumbExtender2();
	//hideTT2();
	if(result.indexOf(",SS,") != -1)
	{
	    hs.close();
	    result = result.toString().replace(",SS,1,1,1,1,",",T,").replace(",SS,0,1,1,1,",",T,").replace(",SS,1,0,1,1,",",T,").replace(",SS,1,1,0,1,",",T,").replace(",SS,1,1,1,0,",",T,").replace(",SS,0,0,1,1,",",T,").replace(",SS,1,0,0,1,",",T,").replace(",SS,0,1,0,0,",",T,").replace(",SS,0,0,1,0,",",T,").replace(",SS,1,0,0,0,",",T,").replace(",SS,0,1,0,0,",",T,").replace(",SS,0,0,0,1,",",T,");
	}
	if(result.indexOf("doChng") != -1){
		actStatus = 3; 
		dls = document.getElementById("ctl00_MainContent_xpp_lbl_dlr");	
		if(dls != null)
			dls.innerHTML = "Unlimited";
		result = result.replace(",doChng",""); 
	}   
	if(result == "N/A")
		return;
	if(result.indexOf("pError:") == 0){
		alert(result); 
		return; 
	}   
    var tarr = result.split(",");
   if(tarr[0] == "ERR"){
       //alert(result);
        hs.close();
		if(tarr[1] == "Error:AlertDL"){
			document.getElementById("hid_retryCommand").value = tarr[2];
			document.getElementById("hid_PT").value = tarr[5];
			tdiv = document.getElementById("div_AlertDL");
			tdiv.style.left = tarr[3] - 150;
			tdiv.style.top = tarr[4] - 110;
			tdiv.style.visibility = "visible";
		}else if(tarr[1] == "Error:pc"){
			//Jeff - Do Content above account range Error
		    hr = document.getElementById("rdrr");
		    return hs.htmlExpand(hr, { src: '/Signup.aspx?opt=upgrade', objectType: 'iframe', align: 'center', width: 800, height: 700 } );
		} else if (tarr[1] == "Error:Activate") {
			//Jeff - Do Content above account range Error
		    hr = document.getElementById("rdrr");
		    return hs.htmlExpand(hr, { src: '/AccountActivation.aspx', objectType: 'iframe', align: 'center', width: 500, height: 400 } );
		}else if(tarr[1] == "Error:pe"){
			//Jeff - Do Max Poinst Reached Error
		    hr = document.getElementById("rdrr");
		    return hs.htmlExpand(hr, { src: '/dlMax.aspx', objectType: 'iframe', align: 'center' } );
		}else if(tarr[1] == "Error:wl"){
		    //Jeff 1/27/2010 - Added to WL Error
		    //alert("Item added to wish list.");
		    //Jeff 2/9/2010 - Changed to HS Popup
		    return hs.htmlExpand(curElement, { contentId: 'div_AddWL', width: 100 });
		}else if(tarr[1] == "Error:rwl"){
		    //Jeff 2/11/2010 - Added ReDownload Error
		    dlPrID = tarr[3];
		    dlPrT = tarr[6];
		    return hs.htmlExpand(curElement, { contentId: 'div_dlmRDL', width: 100 });
		} else if (tarr[1] == "Error:rwlsA") {
		    //Jeff 2/17/2010 - Added Set ReDownload Error with ALL products downloaded
		    dlPrID = result.replace("ERR,Error:rwlsA,", "");
		    return hs.htmlExpand(curElement, { contentId: 'div_dlmRDLSA', width: 100 });
		}else if(tarr[1] == "Error:rwls"){
		    //Jeff 2/17/2010 - Added Set ReDownload Error
		    dlPrID = result.replace("ERR,Error:rwls,", "");
		    return hs.htmlExpand(curElement, { contentId: 'div_dlmRDLS', width: 100 });
		}else if(tarr[1] == "Error:Dle" || tarr[1] == "Error:ndlp" || tarr[1] == "Error:dlp"){
		    hr = document.getElementById("rdrr");
		    //hr = curElement;
		    return hs.htmlExpand(hr, { src: '/Signup.aspx?opt=upgrade', objectType: 'iframe', align: 'center', width: 800, height: 700 });
		}else if(tarr[1] == "Error:CCD"){
			document.getElementById("spn_Reason").innerHTML = tarr[2];
			tdiv = document.getElementById("div_CCDEC");
			tdiv.style.left = tarr[3] - 130;
			tdiv.style.top = tarr[4] - 160;
			tdiv.style.visibility = "visible";
		}else if(tarr[1] == "Error:ndlm"){
			tdiv = document.getElementById("div_NDLM");
			tdiv.style.left = tarr[3] - 160;
			tdiv.style.top = tarr[4] - 100;
			tdiv.style.visibility = "visible";	
		}else
			alert(result);
   }
   else if(tarr[0] == "pdl"){
       if (tarr[4] != "D") {
           var tdoc = document.getElementById('dlded' + tarr[4] + '_' + tarr[1])
           if (tdoc)
               tdoc.style.display = 'inline';
       }
       //Jeff 3/3/10 Removed first Time Download Popup
//			if(tarr[5] == "1"){
//				tdiv = document.getElementById('div_FirstTimeDL');
//				tdiv.style.left = tarr[2] - 170;
//				tdiv.style.top = tarr[3] - 260;
//				tdiv.style.visibility = "visible";
//			}
			//Jeff 1/26/2010 - Dowload with downlaod manager.
			if (dlt == 2){
	            //Next line commented out by Jeff 1/26/2010. If they are setup to download with the download manager products will add to the Que and will download the next time they launch the download manager.				    //
			    //if(!window.external.verifyApp){document.location = 'logout.aspx';}
			    //Jeff added 1/26/2010. Check for app ability before telling the app to download.
			    var tWd = document.getElementById("spn_idlm");
			    var tWd2 = document.getElementById("spn_idlm2");
			    if (window.external.verifyApp) {
			        window.external.newDownloadsAdded();
			    }
			    else {
			        tWd.style.display = "inline";
			        tWd2.style.display = "inline";
			    }
			    return hs.htmlExpand(curElement, { contentId: 'div_DLComp', width: 100 });
			}
			dlloc = '/proddl2.dlf?dlk=' + tarr[6];
			//alert(result);
			//tdiv = document.getElementById('div_DLReady');
			//tdiv.style.left = tarr[2] -100;
			//tdiv.style.top = tarr[3] -50;
			//tdiv.style.visibility = "visible";
			try{document.getElementById("div_dla22").style.display = "none";document.getElementById("div_dla23").style.display = "inline";}catch(err){}
			//alert(curElement.id);
			if(hs.htmlExpand(curElement, { contentId: 'div_DLReady', width: 100 } ))
			    hs.htmlExpand(curElement.parent, { contentId: 'div_DLReady', width: 100 } );
			//div_DLReady
		  //pagepop = window.open('/proddl2.dlf?dlk=' + tarr[6], 'pagepop', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=200');
		  //alert(pagepup);
			if(tarr[7] == "0" && actStatus != 3){
				//alert(result);
				downloads = downloads - parseInt(tarr[8]);
				dls = document.getElementById("ctl00_MainContent_xpp_lbl_dlr");
				if(dls != null)	
					dls.innerHTML = "Points Remaining " + downloads;
			}else if(tarr[7] == "0")
			{
				dls = document.getElementById("ctl00_MainContent_xpp_lbl_dlr");
				if(dls != null)
					dls.innerHTML = "Unlimited";
			}
		return;
	  }
	  else if(tarr[0] == "pdl2"){
	  if (tarr[4] != "D") {
	      var tdoc = document.getElementById('dlded' + tarr[4] + '_' + tarr[1])
		    if(tdoc)
			    tdoc.style.display = 'inline'; 
	    }
			//Jeff 1/26/2010 - Dowload with downlaod manager.
	    if (dlt == 2) {
			    //Next line commented out by Jeff 1/26/2010. If they are setup to download with the download manager products will add to the Que and will download the next time they launch the download manager.				    //
			    //if(!window.external.verifyApp){document.location = 'logout.aspx';}
			    //Jeff added 1/26/2010. Check for app ability before telling the app to download.
	        var tWd = document.getElementById("spn_idlm");
	        var tWd2 = document.getElementById("spn_idlm2");
			    if (window.external.verifyApp) {
			        window.external.newDownloadsAdded();
			    }
			    else {
			        tWd.style.display = "inline";
			        tWd2.style.display = "inline";
			    }
			    hsClose = setTimeout("hs.close()", 2500);
			    return hs.htmlExpand(curElement, { contentId: 'div_DLCompp', width: 100 });
			}
			//Jeff 3/3/10 Removed first time download popup
//				if(tarr[5] == "1"){
//					tdiv = document.getElementById('div_FirstTimeDL');
//					tdiv.style.left = tarr[2] - 170;
//					tdiv.style.top = tarr[3] - 260;
//					tdiv.style.visibility = "visible";
//				}
				if(tarr[7] == "0" && actStatus != 3){
					downloads = downloads - parseInt(tarr[8]);
					dls = document.getElementById("ctl00_MainContent_xpp_lbl_dlr");	
					if(dls != null)
						dls.innerHTML = "Points Remaining " + downloads;
				}
				else if (tarr[7] == "0"){
					dls = document.getElementById("ctl00_MainContent_xpp_lbl_dlr");	
					if(dls != null)
						dls.innerHTML = "Unlimited";
				}
	  }
	  else if (tarr[0] == "RDR"){
			document.location = tarr[1];
	  }
	  else if (tarr[0] == "RDRR"){
			hr = document.getElementById("rdrr");
			return hs.htmlExpand(hr, { src: tarr[1], objectType: 'iframe', align: 'center', width: 850, height: 700 } );
	  }
	  else
	  {
		alert(result); 
	  }
    doClickOnce();
}
var curElement;
function dodl(tarr){
	
}
function dodl2(tarr){

}
function downloadProduct(){

}