// Check for namespace, create one if it doesn't exist

if (!ucsdlib)
	var ucsdlib = {};

//<!--
//
//  ucsdlib.autoRedirect
//
//  Purpose: To redirect Vignette articles to external web sites
//
//  Description: This function redirects a web page to, wait for it, another web
//  page. Automatically. It also checks to see if it is on preview-n or www-n.
//  No need to break that user experience while trying to be sneaky in Vignette.
//  On live web sites it will fetch and display the new page without breaking
//  the back button of the user's broswer. That's always a nice touch. Huzzah!
//
//  Usage: To use, add the following code to the source of your article's body.
//  Be sure to change the URL to the page you want to redirect to. Easy peezy.
//
//  <div>
//  <script src="http://orpheus.ucsd.edu/vignette_css/js/ucsdlib_autoRedirect.js" type="text/javascript"></script>
//  <script type="text/javascript">
//    ucsdlib.autoRedirect("http://www.example.com/dir/page.html");
//  </script>
//  </div>
//
//  Author: DT
//
//-->

ucsdlib.autoRedirect = function(URL){

		var s = top.location.href;
		var wn = "//www-n.";
		var pn = "//preview-n.";

		if (URL != ""){
			if (s.indexOf(pn) != -1 || s.indexOf(wn) != -1)
				document.write("[Redirect on live to: " + URL + "]");
			else
				top.location.replace(URL);
		}
};
