function linkback() {

// linkback to some referrers
var ref = document.referrer;
var reg = /http:\/\/ideas\./i;
if ( reg.test(ref) ) {
  document.write('<p><a href="' + ref + '">Return to IDEAS</a>');
  return;
  }
var reg = /http:\/\/netec\./i;
if ( reg.test(ref) ) {
  document.write('<p><a href="' + ref + '">Return to NetEc</a>');
  return;
  }
var reg = /http:\/\/socionet\./i;
if ( reg.test(ref) ) {
  document.write('<p><a href="' + ref + '">Return to Socionet</a>');
  return;
  }
var reg = /http:\/\/econpapers\./i;
if ( reg.test(ref) ) {
  document.write('<p><a href="' + ref + '">Return to EconPapers</a>');
  return;
  }

// else give link to author details on EconPapers
var ref = document.URL;
var reg = /http:\/\/repec\.oru\.se/i;
if ( reg.test(ref) ) {
  var href = ref.replace( reg, "http://econpapers.repec.org" );
  document.write( '<p>View author details at <a href="' + href + '">EconPapers</a>' );
  return;
  }
}


//

function Obfuscate( b, a ) {
  
  document.write( '<a href="mailto:' + a + '&#64;' + b + '">' + a + '&#64;' + b + '</a>' );
  
}

// 

function canCookie() {

  var test = getCookie( 'EPTest' );
  if ( test == null ) {
    setCookie( 'EPTest', 'test', null, '/' );
    test = getCookie( 'EPTest' );
  }
  if ( test == null ) {
    return false;
  } else {
    return true;
    //return false;
  }

}
//
function WriteRelocation() {

  var showReloc = false;

  if ( canCookie() ) {
    var kaka = getCookie( 'LogEcredir' );
    count = parseInt( kaka );
    if ( count < 10 ) {
      count++;
      setCookie( 'LogEcredir', count, null, '/' );
      showReloc = true
    }
  } else {
    // kan vi kolla referrer och visa RelocInfo
    var re = /\/logec.repec.org\//i;
    if ( ! re.test( document.referrer ) ) {
      showReloc = true;
    }
  }

  if ( showReloc ) {
    document.write( "<p><font color='red'><b>LogEc has moved to http://logec.repec.org! Please update your bookmarks.</b></font></p>" );
  }  

}



/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 */

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
