<html>
<head>
<title>Open URLs Passed In - RJM Programming - July, 2016</title>
<script type='text/javascript'>

var urls=[];
var wourls=[];
var nowbw=0;
var nowbh=0;
var perline=1;
var powerline=1;
var delim='';
var cnt=1;
var urlslength=0;

function urlarray() {
var itop=0, ileft=0, prefix='';
urls=decodeURIComponent(location.search.split('urls=')[1] ? location.search.split('urls=')[1].split('&')[0] : '').split(',http');
if (urls.length >= 1) {
if (nowbh == 0) nowbh = eval(top.window.getComputedStyle(top.document.body, null).getPropertyValue('height').replace('px',''));
if (nowbw == 0) nowbw = eval(top.window.getComputedStyle(top.document.body, null).getPropertyValue('width').replace('px',''));
for (var ii=1; ii<=urls.length; ii++) {
if (urls[ii - 1] != '') {
urlslength=ii;
if (urls[ii - 1].indexOf('%3A') != -1) urls[ii - 1]=decodeURIComponent(urls[ii - 1]);
}
}
if (urlslength > powerline) {
while (urlslength > powerline) {
perline++;
powerline=perline * perline;
}
if (urlslength <= eval(powerline - perline)) itop += eval(nowbh / perline);
//alert(itop + ' ' + powerline + ' ' + perline + ' ' + urls.length + ' ' + nowbh + ' ' + window.innerHeight);
}
if (urls[0] != '') {
for (var i=1; i<=urls.length; i++) {
if (urls[i - 1] != '') {
urlslength=i;
//alert(urls[i - 1]);
wourls[i - 1] = window.open(prefix + urls[i - 1],'_blank','top=' + itop + ',left=' + ileft + ',width=' + eval(nowbw / perline) + ',height=' + eval(nowbh / perline));
if ((i % perline) == 0) {
ileft=0;
itop += eval(nowbh / perline);
} else {
ileft += eval(nowbw / perline);
}
prefix='http';
}
}
if (urlslength == urls.length) setTimeout(allclosedcheck, 1000);
} else if (document.URL.indexOf('urls=') != -1) {
showthings();
}
}
}

function allclosedcheck() {
var doit=true;
for (var i=1; i<=urlslength; i++) {
if (wourls[i - 1].closed) {
doit=doit;
} else {
doit=false;
}
}
if (doit) {
showthings();
} else {
setTimeout(allclosedcheck, 1000);
}
}

function showthings() {
document.getElementById('mydiv').style.display='block';
document.getElementById('myh1').style.display='block';
document.getElementById('mydivongoing').style.display='block';
document.getElementById('mydivongoing').innerHTML+="Url " + cnt + ": <input tabindex=" + cnt + " style='width:40%;' type='text' id='url" + cnt + "' type='text' value='' onblur='addurl(this.value);'></input><br><div id='mydivongoing" + (cnt + 1) + "' style='text-align: center; width: 100%;'></div>";
document.getElementById('url' + cnt).focus();
document.getElementById('url' + cnt).select();
}

function addurl(thisu) {
if (thisu != '') {
if (thisu.toLowerCase().indexOf('http') != 0) return false;
cnt++;
document.getElementById('urls').value+=delim + 'http' + thisu.replace('HTTPS:','https:').substring(4);
document.getElementById('mysubmit').style.display='block';
delim=',';
document.getElementById('mydivongoing' + cnt).innerHTML+="Url " + cnt + ": <input tabindex=" + cnt + " style='width:40%;' type='text' id='url" + cnt + "' type='text' value='' onblur='addurl(this.value);'></input><br><div id='mydivongoing" + (cnt + 1) + "' style='text-align: center; width: 100%;'></div>";
document.getElementById('url' + cnt).focus();
document.getElementById('url' + cnt).select();
}
return true;
}

</script>
</head>
<body id='xbod' onresize="nowbw=top.window.innerWidth; nowbh=top.window.innerHeight;" onload="nowbw=top.window.innerWidth; nowbh=top.window.innerHeight; urlarray();" style='text-align:center;width:100%; background-color: yellow;'>
<div id='mydiv' style='display:none; text-align: center; width: 100%;'>
<h1 id='myh1' style='display:none; text-align: center; width: 100%;'>Open URLs Passed In</h1>
<form style='text-align: center; width: 100%;' method='GET' action='./windowopens.html'>
<div id='mydivongoing' style='display:none; text-align: center; width: 100%;'>
</div>
<span><input tabindex=998 style='display:none; margin-left: 45%; width: 10%;' id='mysubmit' type='submit' value='Show'></input><input style='width:1px;margin-left:-9000px;' type='text' name='urls' id='urls' type='text' value=''></input></span>
</form>
</div>
</body>
<html>