var strCookieName = 'RWDINFOPAKSIMULATOR'+escape('Burn Client Data to CD-R');
var strAudioConfirm = "The Playback requires Windows Media Player to play sound. \nDo you want to download it from: \n http://www.microsoft.com/Windows/MediaPlayer/?";
function saveCookie(name,value,days) {
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "";
		expires=""+date.toGMTString();
	}else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

if (document.all) {
	if (!navigator.cookieEnabled)
		alert("The cookie in your browse has been disabled. Please turn on it to effect a change in description window.");
}else {
	//if (document.cookie == "")
	//	alert("The cookie in your browse has been disabled. Please turn on it to effect a change in description window.");
}

var descWindow = null;
saveCookie(strCookieName, "", -1);

function openPlayback(url){
	if (!hasWMP) { 
		notHasAudio();
		if (audioStatus != 2) {//Cancel button clicked
			return;
		}		
	}
	
	if(descWindow != null && (typeof descWindow.close=='function' || typeof descWindow.close=='object')){
		descWindow.close();
	}
	saveCookie(strCookieName+'Auto',(url.indexOf('=AutoPlayback')!=-1),false);
	saveCookie(strCookieName+'SelfTest',(url.indexOf('=SelfTest')!=-1),false);
	var htmlWidth=window.screen.width-((url.indexOf('=SelfTest')!=-1)?12:310);
	var htmlHeight=window.screen.height-70;
	window.open(url,'InfoPakSimulator','width='+htmlWidth+',height='+htmlHeight+',top=0,left=0,status=yes,scrollbars=yes,resizable=yes');
}

document.writeln('<OBJECT id="AudioPlayer" width="0" height="0" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" \n'
	+ 'codebase=""\n'
    + 'standby="Loading Microsoft® Windows® Media Player components..." \n'
    + 'type="application/x-oleobject">\n'
    + '<embed type="application/x-mplayer2"  \n' 
	+ '	pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" \n' 
	+ '	name="AudioPlayer"  \n' 
	+ '	width="2"  \n' 
	+ '	height="2"  \n' 
	+ '	showstatusbar="0"  \n' 
	+ '	autostart=-1\n' 
	+ '	autosize="0"> \n' 	
	+ '</embed> \n'
    + '</OBJECT>');

var hasWMP;
if (document.layers) {
	navigator.plugins.refresh();
	var fHasWMP52 = navigator.mimeTypes && navigator.mimeTypes["application/x-mplayer2"] && navigator.mimeTypes["application/x-mplayer2"].enabledPlugin;
	var fHasWMP64 = navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && navigator.mimeTypes["video/x-ms-wm"].enabledPlugin && navigator.mimeTypes["video/x-ms-wmv"] && navigator.mimeTypes["video/x-ms-wmv"].enabledPlugin;
	hasWMP = (fHasWMP64 || fHasWMP52) && (typeof document.embeds["AudioPlayer"] != 'undefined');
} else {
	hasWMP = (typeof document.AudioPlayer != 'undefined' 
			 && typeof document.AudioPlayer.FileName != 'undefined');
}
var audioStatus = 0;
function notHasAudio() {
	if (audioStatus == 0) { //Not processed yet
		if (confirm(strAudioConfirm)) {
			window.open("http://www.microsoft.com/Windows/MediaPlayer/", "WMPDownload");
			audioStatus = 1;
		} else { //Cancel
			audioStatus = 2;
		}
	} else if (audioStatus == 1) { //Downloading		
	}
}
