
  var top=left=0;
  left=(screen.width-408)/2+"px";
  top=(screen.height-408)/2+"px";
  var flag = "";
  var browser=navigator;
  var getCookieVal = readCookie('sitechoice_popup');// used for to avoid show popup
  var getDirectUrlVal = readCookie('always_direct_var');//to get redirecting(default) url value
  if(getDirectUrlVal && getDirectUrlVal != "http://www.rosettastone.co.uk"){          
    window.location.href = getDirectUrlVal; //redirecting to the default site
  }
  else{
    if(!getCookieVal){
      //flag = <r:client_ip />     //getting client IP flag value (whether the user is from UK or DE)
	  flag = client_ip_address;
    }
    if(flag == 1){
      var getDirectUrlVal = readCookie('always_direct_var');//to get redirecting(default) url value
      if(!getDirectUrlVal)
        popup_block();
    }
  } 

  function close_pop(){
    if(document.getElementById('popup_frame')){
      document.getElementById('popup_frame').style.display='none'; 
    }
  }
  function popup_block(){
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
      var ieversion=new Number(RegExp.$1)
      if(ieversion == 6){
        agewindow=dhtmlmodal.open('popup', 'div', 'question', '','width=408px,height=321px,left='+left+',top='+top+',resize=0,scrolling=0');
      }
      else{
        agewindow=dhtmlmodal.open('popup', 'div', 'question', '','width=408px,height=343px,left='+left+',top='+top+',resize=0,scrolling=0');
      }
    }
    else{
      agewindow=dhtmlmodal.open('popup', 'div', 'question', '','width=408px,height=359px,left='+left+',top='+top+',resize=0,scrolling=0');
    }
    if(document.getElementById('popup_frame')){
      document.getElementById('popup_frame').style.display='block'; 
    }
    if(browser.platform == "MacPPC"){
      if(browser.appName == "Opera")
        agewindow=dhtmlmodal.open('popup', 'div', 'question', '','width=408px,height=289px,left=470px,top=230px,resize=0,scrolling=0');
      else
        agewindow=dhtmlmodal.open('popup', 'div', 'question', '','width=408px,height=355px,left=470px,top='+top+',resize=0,scrolling=0');
    }
  }
 
  function delay_popup(){                 
    // creating object for creating window     
    win = new Window({className: "mac_os_x", width:275, height:260, destroyOnClose: true, recenterAuto:false});
    // creating object for creating window
    display_content = document.getElementById('hide_popup').innerHTML; // getting POPUP content
    win.getContent().update(display_content); //passing the POPUP content
    win.showCenter();  // function to display the POPUP window
  }
  //function is used to not showing the POPUP window once the user do not want to see again the POPUP window
  function donotshow_popup(){
    agewindow.hide();
    createCookie("sitechoice_popup","Y",360);
  }
  // to set cookie name, value
  function createCookie(name,value,days) {
    if(days){
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
  }
  // to get cookie values
  function readCookie(name){
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++){
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
  }
  // redirecting once the continue button has been clicked
  function RedirectChoicePopUp(){
    var url = site_id = radio_obj = site_value = user_input = '';
    default_url = "http://www.rosettastone.co.uk";
    var length = document.popupsitechoice.site.length;
    for (var i=0;i < length; i++){
      if(document.popupsitechoice.site[i].checked){
        user_input = document.popupsitechoice.site[i].value;
        url = user_input
    }
  }
  if(url == ""){alert("Please select the country");return;}
  // if the user selected US no action will take place , simply close the POPUP window
  if(default_url == url){
    if(document.getElementById("always_direct").checked){
      // setting cookie for directing always to the selected site
      if(document.getElementById("always_direct").value == "Y"){
        createCookie("always_direct_var",url,360);
      }
    }
    agewindow.hide();
    document.getElementById('interVeil').style.display = 'none';
  }
  else{
    if(document.getElementById("always_direct").checked){
    // setting cookie for directing always to the selected site
      if(document.getElementById("always_direct").value == "Y"){
        createCookie("always_direct_var",url,360);
      }
    }
    if(url != ""){
      window.location.href = url;
    }
    else{alert("Please select the country");return;}
  }
  if(document.getElementById('popup_frame')){
    document.getElementById('popup_frame').style.display='none'; 
  }
}

