var customArgs = new Object();
customArgs.title = "";		// used for the HTML <TITLE> of the browser windows

customArgs.minMajor = 6;
customArgs.minMinor = 0;
customArgs.minBuild = 65;

customArgs.width = '100%';
customArgs.height = '100%';

customArgs.contactInfo = '<P>If you are still having trouble with the application, <A href="mailto:support@enspire.com">email support@enspire.com</A> and we will get back to you as soon as possible.';

var agt=navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
var appVer   = navigator.appVersion.toLowerCase();
var is_ie    = ((appVer.indexOf('msie')!=-1) && (!is_opera));
var is_mac   = (agt.indexOf("mac")!=-1);

var is_gecko = (agt.indexOf('gecko')!=-1);
function openAppWindow(url) {
	if(url.indexOf("?") != -1) {
		url = url + "&launched=true";
	}
	else {
		url = url + "?launched=true";
	}
	var features = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,left=0,top=0';
	if (true) {
		var width = (customArgs.width=="100%") ? screen.availWidth : customArgs.width;
		var height = (customArgs.height=="100%") ? (screen.availHeight-21) : customArgs.height;
                if (url.indexOf("podcasts") >= 0) {
                  width = "900";
                  height="600";
                }
                else if (url.match(/^(ab0625|ab0626|ab0627|ab0628|ab0629|ab0630|ab0631)/ig)  != null) {
                  width = "900";
                  height = "600";
                }
                else if (url.indexOf("pda")  >= 0) {
                  width = "500";
                  height = "400";
                }
                else if (url.indexOf("courselaunch") >= 0) {
                  width = "795";
                  height = "570";
                }
                else if (url.indexOf(".mp3") >= 0) {
                  width = "250";
                  height = "250";
                }
		features += ',resizable=yes,width='+width+',height='+height;

	}
	else if(!(is_gecko || is_opera)) {
		// do not allow resizing on netscape < 5 b/c resizing causes the page to reload (including the flash movie)
		var swidth = (customArgs.width=="100%") ? ('outerWidth='+screen.availWidth) : ('width='+customArgs.width);
		var sheight = (customArgs.height=="100%") ? ('outerHeight='+screen.availHeight) : ('height='+customArgs.height);
		features += ',resizable=no,'+swidth+','+sheight;
	}
	else {
		var swidth = (customArgs.width=="100%") ? ('outerWidth='+(is_mac ? (screen.availWidth-30) : screen.availWidth)) : ('width='+customArgs.width);
		var sheight = (customArgs.height=="100%") ? ('outerHeight='+(is_mac ? (screen.availHeight-6) : screen.availHeight)) : ('height='+customArgs.height);
		features += ',resizable=yes,'+swidth+','+sheight;
	}
	var w = window.open(url, "_blank", features);
	// we can't specify negative offsets in the window.open() call from loader.html, so do it here
	// this allows us to have the window resize borders be offscreen on IE
	// if using a blocker, w may be null (netscape) or closed (IE) which will kill all javascript after this (like the html message warning against popups) if we try to manipulate w
	if(w!=null) {	
		if(!w.closed) {
			w.moveTo(-5, -5);  // in Netscape, this will act like moveTo(0, 0)
		}
	}
	return w;
}

function openAudioWindow (sFile) {
  var loc = window.location.protocol
  var offline = false;

  if (loc.toLowerCase().substring(0, 4) != "http")
    offline = true;

  var w = window.open("", "Audio", "height=250,width=250,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,left=0,top=0")
  var d = w.document;
  d.writeln("<html")
  d.writeln("<header>")
  d.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../styles/mebn.css\"> ")
  d.writeln("</header>")
  d.writeln("<body>")
  d.writeln("<center><table width=\"100%\"> ")
  d.writeln("<tr><td align=\"center\">")

  d.writeln("<OBJECT id=wimpybutton138 ") 
  d.writeln("codeBase=\"http://download.macromedia.com/pub/shockwave/cabs/&#13;&#10;flash/swflash.cab#version=6,0,47,0\"  ")
  d.writeln("height=35 width=35 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  ")
  d.writeln("name=wimpybutton138><PARAM NAME=\"_cx\" VALUE=\"926\"><PARAM NAME=\"_cy\" VALUE=\"926\"> ")
  d.writeln("<PARAM NAME=\"FlashVars\" VALUE=\"autoplay=yes\"> ")

  if (offline) {
    d.writeln("<PARAM NAME=\"Movie\" VALUE=\"wimpy_button.swf?theFile=" + sFile + "\"> ")
    d.writeln("<PARAM NAME=\"Src\" VALUE=\"wimpy_button.swf?theFile=" + sFile + "\"> ")
  }
  else {
    d.writeln("<PARAM NAME=\"Movie\" VALUE=\"http://cme-today.com/mp3/wimpy_button.swf?theFile=" + sFile + "&wimpyReg=Nk5peTN5NyU0MGElN0ZwJTI2JTJCJTdDUVUlNUNSOFdiJTVDTSU3Q3olM0YwVCU1QjhYJTdG\"> ")
    d.writeln("<PARAM NAME=\"Src\" VALUE=\"http://cme-today.com/mp3/wimpy_button.swf?theFile=" + sFile + "&wimpyReg=Nk5peTN5NyU0MGElN0ZwJTI2JTJCJTdDUVUlNUNSOFdiJTVDTSU3Q3olM0YwVCU1QjhYJTdG\"> ")
  }
  d.writeln("<PARAM NAME=\"WMode\" VALUE=\"Window\"> ")
  d.writeln("<PARAM NAME=\"Play\" VALUE=\"-1\"> ")
  d.writeln("<PARAM NAME=\"Loop\" VALUE=\"0\"> ")
  d.writeln("<PARAM NAME=\"Quality\" VALUE=\"High\"> ")
  d.writeln("<PARAM NAME=\"SAlign\" VALUE=\"\"> ")
  d.writeln("<PARAM NAME=\"Menu\" VALUE=\"0\"> ")
  d.writeln("<PARAM NAME=\"Base\" VALUE=\"\"> ")
  d.writeln("<PARAM NAME=\"AllowScriptAccess\" VALUE=\"\"> ")
  d.writeln("<PARAM NAME=\"Scale\" VALUE=\"ShowAll\"> ")
  d.writeln("<PARAM NAME=\"DeviceFont\" VALUE=\"0\"> ")
  d.writeln("<PARAM NAME=\"EmbedMovie\" VALUE=\"0\"> ")
  d.writeln("<PARAM NAME=\"BGColor\" VALUE=\"EFEFDE\"> ")
  d.writeln("<PARAM NAME=\"SWRemote\" VALUE=\"\"> ")
  d.writeln("<PARAM NAME=\"MovieData\" VALUE=\"\"> ")
  d.writeln("<PARAM NAME=\"SeamlessTabbing\" VALUE=\"1\"> ")
  d.writeln("<PARAM NAME=\"Profile\" VALUE=\"0\"> ")
  d.writeln("<PARAM NAME=\"ProfileAddress\" VALUE=\"\"> ")
  d.writeln("<PARAM NAME=\"ProfilePort\" VALUE=\"0\"> ")
  d.writeln("<embed flashvars=\"autoplay=no\"  ")
  if (offline) {
    d.writeln("src=\"wimpy_button.swf?theFile=" + sFile + "\" width=\"35\" height=\"35\"") 
  }
  else {
    d.writeln("src=\"http://cme-today.com/mp3/wimpy_button.swf?theFile=" + sFile + "&wimpyReg=Nk5peTN5NyU0MGElN0ZwJTI2JTJCJTdDUVUlNUNSOFdiJTVDTSU3Q3olM0YwVCU1QjhYJTdG\" width=\"35\" height=\"35\"") 
  }
  d.writeln("bgcolor=\"#efefde\" loop=\"false\" menu=\"false\" quality=\"high\" name=\"wimpybutton138\"  ")
  d.writeln("id=\"wimpybutton138\" align=\"middle\" allowScriptAccess=\"sameDomain\"  ")
  d.writeln("type=\"application/x-shockwave-flash\"  ")
  d.writeln("pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> ")
  d.writeln("</OBJECT> ")

  d.writeln("</td></tr> ")
  d.writeln("<tr><td height=\"40\"></td></tr> ")
  d.writeln("<tr><td class=\"Body\" align=\"center\">To download this audio to your computer, right click on the link below ")
  d.writeln("and select Save Target As</td></tr> ")
  d.writeln("<tr><td align=\"center\" class=\"Body\"><a href=\"" + sFile + "\" class=\"SmallLink\">Right click to Download Audio</a></td></tr> ")
  d.writeln("<tr><td height=\"40\"></td></tr> ")
  d.writeln("<tr><td align=\"center\"><a href=\"#\" onclick=\"window.close()\"><img src=\"../../images/buttons/closewindowbutton.gif\" border=\"0\"></a></td></tr> ")
  d.writeln("</table> ");
  d.writeln("</body>")
  d.writeln("</html>");
  d.close();
}


function openRegularWindow(url) {

	if(url.indexOf("?") != -1) {
		url = url + "&launched=true";
	}
	else {
		url = url + "?launched=true";
	}
	var features = 'width=795,height=570,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,left=0,top=0';
	if (is_ie) {
		var width = (customArgs.width=="100%") ? screen.availWidth : customArgs.width;
		var height = (customArgs.height=="100%") ? (screen.availHeight-21) : customArgs.height;
                if (url.indexOf("podcasts") >= 0) {
                  width = "900";
                  height="600";
                }
                else if (url.indexOf("pda")  >= 0) {
                  width = "500";
                  height = "400";
                }
                else if (url.indexOf("courselaunch") >= 0) {
                  width = "795";
                  height = "570";
                }
                else if (url.indexOf(".mp3") >= 0) {
                  width = "250";
                  height = "250";
                }
		features += ',resizable=yes,width='+width+',height='+height;

	}
	else if(!(is_gecko || is_opera)) {
		// do not allow resizing on netscape < 5 b/c resizing causes the page to reload (including the flash movie)
		var swidth = (customArgs.width=="100%") ? ('outerWidth='+screen.availWidth) : ('width='+customArgs.width);
		var sheight = (customArgs.height=="100%") ? ('outerHeight='+screen.availHeight) : ('height='+customArgs.height);
		features += ',resizable=no,'+swidth+','+sheight;
	}
	else {
		var swidth = (customArgs.width=="100%") ? ('outerWidth='+(is_mac ? (screen.availWidth-30) : screen.availWidth)) : ('width='+customArgs.width);
		var sheight = (customArgs.height=="100%") ? ('outerHeight='+(is_mac ? (screen.availHeight-6) : screen.availHeight)) : ('height='+customArgs.height);
		features += ',resizable=yes,'+swidth+','+sheight;
	}
	var w = window.open(url, "_blank", features);
	// we can't specify negative offsets in the window.open() call from loader.html, so do it here
	// this allows us to have the window resize borders be offscreen on IE
	// if using a blocker, w may be null (netscape) or closed (IE) which will kill all javascript after this (like the html message warning against popups) if we try to manipulate w
	if(w!=null) {	
		if(!w.closed) {
			w.moveTo(-5, -5);  // in Netscape, this will act like moveTo(0, 0)
		}
	}
	return w;
}

