



//Update the select lists for instrument, exchange etc
function updateSelectLists(url, replaceWith) {

  //alert(url);
  //alert(updateListsUrl);

  url = url.replace("*", replaceWith);

  $.get(url, {},
    function(data){
      document.getElementById("divAjaxSelectList").innerHTML = data;
  });

  //updateLists(updateListsUrl);

}

//Update stocklists,indexlists etc
function updateLists(url) {

  $.get(url, {},
    function(data){
      document.getElementById("divAjaxList").innerHTML = data;
  });
  
}


function ajaxLogin(url, id) {

  var email = document.getElementById("email_id").value;
  var password = document.getElementById("password_id").value;


  $.ajax({
    type: "GET",
    url: url,
    data: "email="+email+"&password="+password,
    beforeSend: function(xhr) {
      xhr.setRequestHeader("Content-type",
                           "text/html; charset=ISO-8859-1");
    },
    dataType: "html",
    success: function(returnHtml){

      if(returnHtml=="redirect") {
        window.location.href="/e24.no/site/secure/portfolio/listPortfolios.page";
      }
      else {
        document.getElementById(id).innerHTML = returnHtml;
      }
            
    }
  });


}


function ajaxSignup(url, id) {

  var email = document.getElementById("email_id").value;
  var password = document.getElementById("password_id").value;
  var password2 = document.getElementById("password2_id").value;


  $.ajax({
    type: "GET",
    url: url,
    data: "email="+email+"&password="+password+"&password2="+password2,
    beforeSend: function(xhr) {
      xhr.setRequestHeader("Content-type",
                           "text/html; charset=ISO-8859-1");
    },
    dataType: "html",
    success: function(returnHtml){

      if(returnHtml=="redirect") {
        window.location.href="/e24.no/site/mypage/login.page?newUser=true";
      }
      else {
        document.getElementById(id).innerHTML = returnHtml;
      }
            

    }
  });


}


function ajaxRemindPass(url, id) {

  var email = document.getElementById("email_remind_id").value;



  $.ajax({
    type: "GET",
    url: url,
    data: "email="+email,
    beforeSend: function(xhr) {
      xhr.setRequestHeader("Content-type",
                           "text/html; charset=ISO-8859-1");
    },
    dataType: "html",
    success: function(returnHtml){

      document.getElementById(id).innerHTML = returnHtml;

    }
  });

  
}




//Arguments: url - url to get, id - id of element to place response in
function ajaxGet(url, id) {

  $.get(url, {},
    function(data){
      document.getElementById(id).innerHTML = data;
  });

}
//Arguments: url - url to get
function ajaxGetURL(url) {

  $.get(url, {},
    function(){

  });

}

function lightbox_login() {

  var url ="/e24.no/site/mypage/login_ajax.page";


  $.ajax({
    type: "GET",
    url: url,
    success: function(returnHtml){


      //if(substr(returnHtml,))

      if(returnHtml.substring(0,8)=="redirect") {
        window.location.href="/e24.no/site/secure/portfolio/listPortfolios.page";
      }
      else {
        document.getElementById("lightbox").innerHTML = returnHtml;
      }

    }
  });

  
}


function lightbox_excel(magic) {

  var url ="/e24.no/site/mypage/excel_ajax.page?magic=" + magic;


  $.ajax({
    type: "GET",
    url: url,
    success: function(returnHtml){
        document.getElementById("lightbox").innerHTML = returnHtml;
    }
  });

}

  function periodChange(select)
     {
       var e = document.getElementById('form_period_manual');
       if(select.options[select.selectedIndex].value=='manual')
       {
         e.style.visibility = 'visible';
       }
       else
       {
         e.style.visibility = 'hidden';
       }
       return true;
     }