function createRequestObject(){
	var request_o;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	} else{
		request_o = new XMLHttpRequest();
	}
	return request_o;
}

var http = createRequestObject();

function showLoadingAnimation(div) {
   document.getElementById(div).innerHTML = '<br/><br/><br/><center><span style="color:#ffffff;font-weight:bold;">Loading...</span></center>';

}

function gotoRNCM() {
    var answer = confirm("You are now leaving the RiverNorth Funds web site and will be redirected to www.rivernorth.com. Okay to continue?");
    if (answer) window.location='http://www.rivernorth.com';
    else return;
}

function printToConsole(message) {
  var messageString = document.getElementById('console').innerHTML;
  messageString += '<br/>' + message;
  document.getElementById('console').innerHTML = messageString;
}

function CountLeft(field, count, max) {
if (field.value.length > max)
 field.value = field.value.substring(0, max);
else
 count.value = max - field.value.length;
}

function fieldHighlight(field) {
  field.style.background = '#ff5555';
  field.style.color = '#ffffcc';
}

function removeFieldHighlight(field) {
  field.style.background = '#ffffcc';
  field.style.color = '#000000';
}

function validateEmail(email) {
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  if (reg.test(email)==false) {
    return 0;
  } else {
     return 1;
   }
}

function refreshTestimonials() {
  showLoadingAnimation('testimonials');
  http.open('get','process_ajax2.php?action=refreshTestimonials');
    http.onreadystatechange = function() {
    if(http.readyState == 4){
      var response = http.responseText;
      document.getElementById('testimonials').innerHTML = response;
    }
  };
  http.send(null);
}

function showPerformance(type) {
  showLoadingAnimation('performanceDiv');
  if (type=='annual') http.open('get','process_ajax2.php?action=showAnnualReturns');
  else http.open('get','process_ajax2.php?action=showPerformanceChart');

    http.onreadystatechange = function() {
    if(http.readyState == 4){
      var response = http.responseText;
      document.getElementById('performanceDiv').innerHTML = response;
    }
  };
  http.send(null);
}

function showComposition(type) {
  showLoadingAnimation('compositionDiv');
  http.open('get','process_ajax2.php?action=showComposition&type='+type);

    http.onreadystatechange = function() {
    if(http.readyState == 4){
      var response = http.responseText;
      document.getElementById('compositionDiv').innerHTML = response;
    }
  };
  http.send(null);
}


