function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


//PopUp
function PopUpScroll(filename,windowname,w,h) {
var xw = w;  var xh = h;
  if(screen) { var xxw = (screen.width-xw)/2; var xxh = (screen.height-xh)/2 }
  else { var xxw = 80; var xxh = 80; }
  window.open('http://www.oticon.com' + filename, windowname,'status=no,menubar=no,directories=no,resizable=yes,scrollbars=yes,width=' + w +',height=' + h + ',top=' + xxh + ',left=' + xxw );
}

//PopUp
function PopUp(filename,windowname,w,h) {
var xw = w;  var xh = h;
  if(screen) { var xxw = (screen.width-xw)/2; var xxh = (screen.height-xh)/2 }
  else { var xxw = 80; var xxh = 80; }
  window.open('http://www.oticon.com' + filename, windowname,'status=no,menubar=no,directories=no,resizable=yes,scrollbars=yes,width=' + w +',height=' + h + ',top=' + xxh + ',left=' + xxw );
}

//The JavaScript code for opening a choose country popup for the benefit of Oticon US
function DoChooseCountryPopup(){ //Run as <body  > onload event
var com_main_url1 = "http://www.oticon.com/eprise/main/oticon/com/_index";
var com_main_url2 = "http://oticon.com/eprise/main/oticon/com/_index";
var popup_page = '/eprise/main/Oticon/com/ChooseCountryPopup';
var keep_days = '0'; //If you use
var cookie_name = 'choose_country';
var cookie_content = 'Been there, done that!'; //Any text
var cookie_scope = ';path=/;domain=oticon.com'; //Scope of the cookie is root folder and all xxx.oticon.com sites.
var cookie_date;
var cookie_jar, cookie_count, i;
var a_cookie, my_cookie, found_cookie;
var the_date;
var cur_url = document.URL;
  if (cur_url.toLowerCase() != com_main_url1 && cur_url.toLowerCase() != com_main_url2) { return }; //We bail out if we are not on the .com and outside the product sites.
  //Make the cookie. DoDotComCountryPopup may contains an expiration date/time, then to be used.
  if (keep_days != '0') { //If we have an expiration date.
    the_date = new Date(); //This is now.
    the_date = Date.parse(the_date); //Addable format.
    the_date = the_date + parseInt(DoDotComCountryPopup,10)*24*60*60*1000; //Count of days to keep, measured in ms, added.
    the_date = new Date(the_date);
    the_date = the_date.toGMTString(); //Do the - almost - proper encoding. This does the new UMT encoding.
    //cookie_date = ';expires=' + the_date.substr(0,7) + '-' + the_date.substr(8,3) + '-' + the_date.substr(12,14) + 'GMT'; //Now we are sure, also on older JS implementations.
    cookie_date = ';expires=' + the_date; //This does the new UMT encoding.
    cookie_scope = cookie_scope + cookie_date; //Now we have both a scope and an expiration.
  }
  my_cookie = cookie_name + '=' + escape(cookie_content) + cookie_scope;
  //Test for cookies
  cookie_jar = document.cookie;
  if (cookie_jar == '') {
    //Now, is the jar empty because cookies are not supported?
    document.cookie = my_cookie;
    my_cookie = document.cookie;
    if (my_cookie != '') { //User DO support cookies, but as we found nothing, so poppety pop pop.
      window.open(popup_page,'win1','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resize=no,width=350,height=330');
    }
  }
  else { //Do we have a choose_country cookie in the jar? This is a bit more than strictly necessary.
    found_cookie = false;
    cookie_jar = cookie_jar.split(';'); // Get the cookies in an array
    cookie_count = cookie_jar.length;
    for (i = 0; i <= cookie_count - 1; i++) {
      a_cookie = unescape(cookie_jar[i]); //decoded content of cookie
      if (a_cookie.split('=')[0].indexOf(cookie_name) != -1) { //Search for my cookie. We may have a " " (space) in front of the cookie name if it is not the first cookie listed.
        found_cookie = true;
      }
    }
    if (!found_cookie) { //We found nothing, so poppety pop pop.
      document.cookie = my_cookie;
      window.open(popup_page,'win1','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resize=no,width=350,height=360');
    }
  }
}


function aPopUp_obs(filename,windowname,w,h) {
var xxw = 80; var xxh = 80;
  open(filename, windowname,'scrollbars=1,status=no,menubar=no,directories=no,resize=no,width=' +w +',height=' + h + ',top=' + xxh + ',left=' + xxw );
}

function aPopUp(filename,windowname,w,h) {
// aPopUp() v1.0 - opens a centered (4+) browser window. <alring@email.com>
// set unique windownames, and avoid multiples of the same popUp, focus() will bring it to the front (NS).
  var xw = w;  var xh = h;
  if(screen) { 
    var xxw = (screen.width-xw-20);
    var xxh = (screen.height-xh)/2;
  }
  else { 
    var xxw = 80;
    var xxh = 80;
  }
  open(filename, windowname,'scrollbars=1,status=no,menubar=no,directories=no,resizable=no,width=' + w +',height=' + h + ',top=' + xxh + ',left=' + xxw );
}


function errorSafe() {
  return true;
}

window.onerror = errorSafe;
name.window="menu";
var PopUpWindow = null;


function newWin(url,name,rs,sc,mn,tl,lo,wd,hi) {
  openWindow = window.open(url,name,'resizable='+rs+',scrollbars='+sc+',menubar='+mn+',toolbar='+tl+',location='+lo+',width='+wd+',height='+hi);
}


function open_window(url) {
  email = window.open(url,"","toolbar=no,location=left,directories=0,status=no,menubar=0,scrollbars=yes,resizable=yes,width=397,height=500");
}


function doBrowserPop(CurObjectId,CurCountry,SiteMapTxt) {
  if(navigator.appName == 'Netscape') {
    aPopUp('/EprOtiScripts/SiteMap/sitemap_frame.asp?ObjectId=' + CurObjectId + '&CurCountry=' + CurCountry + '&SiteMapTxt=' + SiteMapTxt,'NewSiteMapWindow',410,500);
  }
  else {
    aPopUp('/EprOtiScripts/SiteMap/sitemap_frame.asp?ObjectId=' + CurObjectId + '&CurCountry=' + CurCountry + '&SiteMapTxt=' + SiteMapTxt,'NewSiteMapWindow',410,500);
  }
}

function doSearchPop(CurObjectId,CurCountry,SiteMapTxt) {
  if(navigator.appName == "Netscape") {
    aPopUp('/EprOtiScripts/Search/Search_frame.asp?ObjectId=' + CurObjectId + '&CurCountry=' + CurCountry,'NewSiteMapWindow',510,500);
  }
  else {
    aPopUp('/EprOtiScripts/Search/Search_frame.asp?ObjectId=' + CurObjectId + '&CurCountry=' + CurCountry,'NewSiteMapWindow',510,500);
  }
}

function doSearchPopUp(CurObjectId,CurCountry,CurURL,SiteMapTxt,CurUserID) {
  aPopUp('/EprOtiScripts/Search/SearchPopUp.asp?ObjectId=' + CurObjectId + '&CurCountry=' + CurCountry+ '&CurURL=' + CurURL + '&CurUserID=' + CurUserID,'NewSiteMapWindow',510,500);
}


  
var imageFile;
function setBgImage(image) {
  imageFile = image;
  setBgImageRetry();
}  

function setBgImageRetry() {
var retryNav = true;
  if(top.menu) { // does the frame exist?
    if(top.menu.naviReady) { // is navi ready for go?
      top.menu.setBgImage(imageFile);
        retryNav = false;
    }
  }
  if(retryNav) { // if no-Go then retry in a while..
    setTimeout('setBgImageRetry();',1500);
  }
}



//Div. popup windows

function TipAFriend_window(url, wheight) {
  if (wheight == null) {
    window.open(url,'','toolbar=no,location=left,directories=0,status=no,menubar=0,scrollbars=yes,resizable=yes,width=390,height=600');
  }
  else {
    window.open(url,'','toolbar=no,location=left,directories=0,status=no,menubar=0,scrollbars=yes,resizable=yes,width=390,height=' + wheight);
  }
}


function Sumo_window(url) {
 // window.open(url,'','toolbar=no,location=left,directories=0,status=no,menubar=0,scrollbars=yes,resizable=yes,width=675,height=550');
  window.open(url,'','toolbar=no,location=left,directories=0,status=no,menubar=0,scrollbars=yes,resizable=yes,width=740,height=560');
}


function voicefinder_window(url) {
  window.open(url,'','toolbar=no,location=left,directories=0,status=no,menubar=0,scrollbars=yes,resizable=yes,width=475,height=600');
}


function Print_window(url) {
  window.open(url,'','toolbar=yes,location=left,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes');
}




// Cookie functions

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments

function setTheCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getTheCookie(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));
}

// 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)
// * path and domain default if assigned null or omitted if no explicit argument proceeds

function deleteTheCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixTheDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function ExpireFromDate(ExpMinutes)
{
  // create an instance of the Date object
  var now = new Date();
  // fix the bug in Navigator 2.0, Macintosh
  fixTheDate(now);
  // cookie expires in one year (actually, 365 days)
  // 365 days in a year
  // 24 hours in a day
  // 60 minutes in an hour
  // 60 seconds in a minute
  // 1000 milliseconds in a second
  now.setTime(now.getTime() + ExpMinutes * 1000); //*60
  return now;
}
// --- End Cookie Functions-

function onload_script() { //Generic onload handler. Whatever needed done at load time, put it here.
  DoChooseCountryPopup();
  if (window.placeMenu) { //Used on the Syncro webside main page. SCH 2004-05-05
    window.onresize = set_menu_left;
    set_menu_left();
  }
  if (window.runscroller) { //Used if page contains TEA16 scrolling text teaser. SCH 2004-12-16
    runscroller();
    window.onresize = placescroller;
    placescroller;
  }
}