function iecheck() {
  if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    var iever = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) <= 7 );
  }
  return iever;
}

MyXssMagic = new function() {
  var BASE_URL = 'http://vipsistem.rs/';
  var STYLESHEET = BASE_URL + "js/style.css";
  var CONTENT_URL = BASE_URL + 'js/data.js';
  var ROOT = 'my_xss_magic';

  function requestStylesheet(stylesheet_url) {
    stylesheet = document.createElement("link");
    stylesheet.rel = "stylesheet";
    stylesheet.type = "text/css";
    stylesheet.href = stylesheet_url;
    stylesheet.media = "all";
    document.lastChild.firstChild.appendChild(stylesheet);
  }

  function requestContent( local ) {
    var script = document.createElement('script');
    // How you'd pass the current URL into the request
    // script.src = CONTENT_URL + '&url=' + escape(local || location.href);
    script.src = CONTENT_URL;
    document.getElementsByTagName('head')[0].appendChild(script);
  }

	this.init = function() {
	  this.serverResponse = function(data) {
	    if (!data) return;
	    var div = document.getElementById(ROOT);
    	var txt = "";
	    for (var i = 0; i < data.length; i++) {
	      if (txt.length > 0) {  }		
			txt +="<tr><td>";
	      txt += data[i];
			txt +="</td></tr>";
		    txt = txt.replaceAll( ",", "</td><td>" )

		
	    }
	    div.innerHTML = "<table class=\"table-style01\"><tr class=\"thead\"><td></td><td>Oznaka</td><td>Valuta</td><td>Naziv</td><td>Apoen</td><td>Kupovni</td><td>Prodajni</td><td>Srednji NBS</td></tr>" + txt +"<tr class=\"thead\"><td colspan=8><a target=\"_blank\" title=\"VIP menjacnice\" href=\"http://www.vipsistem.rs\">Kompletna kursna lista</a></td></tr></table>";  // assign new HTML into #ROOT
	    div.style.display = 'block'; // make element visible
	    div.style.visibility = 'visible'; // make element visible
	  }
	
	  requestStylesheet(STYLESHEET);
	  document.write("<div id='" + ROOT + "' style='display: none'></div>");
	  requestContent();
	  var no_script = document.getElementById('no_script');
	  if (no_script) { no_script.style.display = 'none'; }
	}
}

 // Replaces all instances of the given substring.
String.prototype.replaceAll = function(
strTarget, // The substring you want to replace
strSubString // The string you want to replace in.
){
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
  
// Keep looping while an instance of the target string
// still exists in the string.
while (intIndexOfMatch != -1){
// Relace out the current instance.
strText = strText.replace( strTarget, strSubString )
 
// Get the index of any next matching substring.
intIndexOfMatch = strText.indexOf( strTarget );
}
  
// Return the updated string with ALL the target strings
 // replaced out with the new substring.
return( strText );
}
MyXssMagic.init();

