//Determine the type of Redirect link and send the user to the correct Redirect page

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function wbr(str, num) { 
     return str.replace(RegExp("(\\w{" + num + "})(\\w)", "g"),
function(all,text,char){
    return text + "<wbr>" + char;
  });
}

function extRedir(hrefLink, hrefName) {

var docDomain = hrefLink;
/*
if(docDomain.indexOf("australianprescriber") != -1)
{
location.href="http://www.nps.org.au/You_are_leaving_this_site_to_Australian_Prescriber?link="+encodeURIComponent(hrefLink)+"&name="+hrefName;
} else {
location.href="http://www.nps.org.au/You_are_leaving_this_site?link="+encodeURIComponent(hrefLink)+"&name="+hrefName;
}
*/
	//MA - August 2010 - just removed the else from the if block - we're only doing this redir for AP site now
	if(docDomain.indexOf("australianprescriber") != -1)
	{
		location.href="http://www.nps.org.au/You_are_leaving_this_site_to_Australian_Prescriber?link="+encodeURIComponent(hrefLink)+"&name="+hrefName;
	}
}

//Open the Redirect Link in the current window

function openInThisWondow(redirURL) {
var loc = redirURL;
var locName= decodeURIComponent(gup('name'));
loc=decodeURIComponent(gup('link'));
location.href = loc;

}

//Open the Redirect Link in a new window

function openInNewWondow(redirURL) {
var loc = redirURL;
var locName= decodeURIComponent(gup('name'));
loc=decodeURIComponent(gup('link'));

window.open(loc,"new_window");
}

//Print the URL of the Redirect Link

function printRedirURL() {

var loc = decodeURIComponent(gup('link'));
var locName= decodeURIComponent(gup('name'));

document.write(wbr(locName,6)+"<br/><br/>"+wbr(loc,6));
}

function printAPRedirURL() {

var locName= decodeURIComponent(gup('name'));

document.write(wbr(locName,6));
}

