function setCookie(cookieName,cookieValue,nDays) 
{
  var today = new Date();
  var expire = new Date();
  if (nDays===null || nDays===0) { nDays=1; }
  expire.setTime(today.getTime() + 3600000*24*nDays);
  document.cookie = cookieName+"="+decodeURI(cookieValue) + ";expires="+expire.toGMTString()+";path=/;";
}


function StoreLang()
{
  var obj = document.getElementById("language").value;
  document.cookie = 'language' + "="+ ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
  setCookie('language',obj,90);
  var sURL = decodeURI(window.location.pathname);
  window.location.href = sURL;
}

function selectDevice(obj)
{
  setCookie('platform',obj,90);
  var sURL = decodeURI(window.location.pathname);
 
  sURL = sURL.replace("downloads.html","");
  sURL = sURL.replace("download.html","");
  sURL = sURL.replace("downloads","");
  sURL = sURL.replace("download","");

  var plRe =/\/.*-software(.*)/ig;
  var urlArray = plRe.exec(sURL);
  var plArray = ["pocketpc", "smartphone", "symbian", "iphone", "android", "blackberry", "webos", "maemo", "bada", "windowsphone"];

  if (urlArray != null && urlArray[1] != null) {
      var endUrl = urlArray[1];
      var currentPlatformStr = plArray[new Number(obj)-1] + "-software";
      sURL ="/" + currentPlatformStr + endUrl;
  }
  window.location.href = sURL;
  return false;
}

