//Country Select page script for PearsonLongman.com
//v 0.1
//Created by Theo Nicolaou 08/09/09

//The URL for the USA ELT site is displayed as www.pearsonlongman.com in the 2010 US catalogue, however the USA site URL is currently www.longmanusahome.com. This script was written to resolve this issue. When the user visits PearsonLongman.com for the first time, they choose their location and a cookie is saved so that they are redirected to the correct site on their next visit.
//The script below uses the cookieLibrary.js file to allow the creation of custom functions and names.

// check to see if cookie exists
// if yes, redirect to USA website or Global website
if (GetCookie("countryLocation") == "usa")
{
 //alert("cookie for USA has been found");
 document.location.href="http://www.longmanusahome.com";
}
else if (GetCookie("countryLocation") == "other")
{
 //alert("cookie for outside USA has been found");
 document.location.href="http://www.pearsonlongman.com/index.html";
}
 
// function to write selected website to cookie
function setCountryLocation(l)
{
 // set expiry date for 1 year from now
 var d = new Date();
 d.setDate(d.getDate() + 365); 
 
 // write cookie
 SetCookie("countryLocation", l, d);
 
 // take user to appropriate website
 if (l == "usa")
 {
  //alert("cookie for USA has been set");
  document.location.href="http://www.longmanusahome.com";
 }
 else if (l == "other")
 {
  //alert("cookie for outside USA has been set");
  document.location.href="http://www.pearsonlongman.com/index.html";
 }
 
}