
// *-------------------------------------------------------------------------
// * iBanknet SEC Filings Widget Tools Javascript 
// *  
// * copyright:  iBanknet.com 
// *             (http://www.ibanknet.com)
// *-------------------------------------------------------------------------

// Does this browser support try-catch?
var tc = false;
try {
    tc = true;
} catch(f) { }

var xmlHttpError = 'XML HTTP Request: OK';  // for trouble shooting
var seltab = '';

// * Get the xmlhttp request object depending on the browser
function get_RequestObject() {
    var objRequest;
    if (window.ActiveXObject) {
        if (tc) {
            try {
                objRequest = new ActiveXObject('Msxml2.XMLHTTP');  // IE 6+
            }
            catch(e) {
                try {
                    objRequest = new ActiveXObject('Microsoft.XMLHTTP');  // IE 5.5
                }
                catch(f) { } 
            }
        } else {
            objRequest = new ActiveXObject('Microsoft.XMLHTTP');  // ? IE 5.0 ?
        }
    } else if (window.XMLHttpRequest) {
        objRequest = new XMLHttpRequest();  // All other browsers, inc. IE 7 and DOM 3
    }
    return objRequest;
} // end get_RequestObject function

// * Get the content using xmlhttp
function do_xmlhttp() {  
  var ticker = document.getElementById( "ticker" ).value;
  var formtype = "";
	formtype = document.getElementById( "formtype" ).value;

	// do the xmlhttp to get the ibanknet content  
	get_secfilings(ticker, formtype);

} // end do_xmlhttp function


// * Get the SEC filings content using xmlhttp
function get_secfilings(ticker, formtype) {  
  var xmlhttp = get_RequestObject();  // create a new request object
  var tab1html = '';
  var tab1contentdiv = document.getElementById("tab1content");
    // Display loading message before fetching feed.
    tab1content.innerHTML = '<div class="loadingLabel">Loading...</div>';

	// do the xmlhttp to get the content  
	xmlhttp.open("GET", "/scripts/widgets/secfilingswidget.asp?ticker=" + ticker + "&formtype=" + formtype,true);
	xmlhttp.onreadystatechange=function() {
	  if (xmlhttp.readyState==4) {
		tab1contentdiv.innerHTML = xmlhttp.responseText;
	  }
	}
	xmlhttp.send(null)
} // end get_secfilings function

