/*
iFusion Portal v4.5
Created by iFusion
*/

document.write('<script type="text/javascript" src="http://www.ifcode.com/forum/scripts/MoodalBox/js/mootools.js"><\/script>');

function getTextQuote(){
	var myQuote = new Array();
	myQuote[0] = "iFusion: InvisionFree Your Mind";
	myQuote[1] = "iFusion: The Place For Codes";
	myQuote[2] = "iFusion: InvisionFree and ZetaBoards #1 Coding Forum";
	myQuote[3] = "iFusion: Thousands of Codes for <strong>your</strong> forum";
	myQuote[4] = "iFusion: What's Your Dream Code?";
	myQuote[5] = "iFusion: The Last Word In Codes";
	
	var n = Math.floor( Math.random() * myQuote.length);
	return myQuote[n];
}

var iTable = document.getElementsByTagName('TABLE');
for(i=0;i<iTable.length;i++){
	if(iTable[i].getAttribute('width') == "100%" && iTable[i].className=='tableborder' && iTable[i].getElementsByTagName('TD')[0].getAttribute('width') == "200"){
		iTable[i].style.display="none";
		iTable[i].setAttribute('id','portaltable');
		
		var iRow = document.getElementById('submenu').insertRow(1);
		iRow.id = "loadportal";
		
		var iCell = iRow.insertCell(0);
		iCell.colSpan="2";
		iCell.width="100%;"
		iCell.style.textAlign="center";
		iCell.innerHTML = '<span style="font-weight: bold;"><BR /><BR /><BR />Please Wait, Loading Portal v4.5 ....<BR /><BR />' + getTextQuote() + '<BR /><BR /><BR /><BR /><BR /><BR /></span>';
		
		break;
	}
}


function getUser(url,obj){
	obj.style.display="none";
	var onUser = new Ajax(
		fusURL + "showuser=" + url,
		{ 
		onComplete:function(onUser){
			if(onUser.match(/mem options/i) != null){
				var nArr = [];	
				var xDiv = document.createElement('DIV');
				document.body.appendChild(xDiv);
				xDiv.style.display="none";
				
				xDiv.innerHTML = onUser.split(/mem options/i)[1];
				
				var iTD = xDiv.getElementsByTagName('TD');
				for(i=0;i<iTD.length;i++){
					if(iTD[i].className=="row1" && iTD[i].getAttribute('align') == "left"){
						nArr[nArr.length++] = iTD[i].innerHTML;
					}
				}	
			}
			document.getElementById('portalPad').innerHTML += "<u><b>Further Info</b></u><BR /><BR /><B>Posts:</b> " + nArr[0] + "<BR /><b>Posts Per Day:</b> " + nArr[1] + "<BR /><b>Date Registered</b>: " + nArr[2] + "<BR /><b>Last Activity:</b> " + nArr[3] + "<BR /><BR /><b>AIM:</b> " + nArr[6] + "<BR /><b>MSN:</b> " + nArr[9] + "<BR /><BR />PM This User: " + nArr[10] + "<BR /><BR /><b>Birthday:</b> " + nArr[12] + "<BR /><b>Location</b> " + nArr[13]; 
		}
	}).request();
}

function nameMe(obj){
	document.getElementById('portalPad').innerHTML = "<b>User Information</b><BR /><BR />Full View: <a href='" + obj.href + "'><i>Here</i></a><BR />Name: " + obj.innerHTML + "<BR />Group: " + checkGroup(obj) + "<BR /><BR /><a href='javascript:void(0);' onclick='getUser(" + obj.href.split(/showuser=/i)[1] + ",this);'>Scan User</a>";
}

function checkGroup(theHTML){
	if( theHTML.getElementsByTagName('SPAN').length == 1){
		switch(theHTML.getElementsByTagName('SPAN')[0].className){
		 case 'codingteam':
		   return 'iFusion Coding Team'; break;
		 case 'moderators':
		   return 'iFusion Moderators'; break;
		 case 'ifstaff':
		   return 'invisionFree Support Staff'; break;
		 case 'adminclass':
		   return 'Administrator / Owner'; break;
		 default: 
		   return 'Members'; break;
		}
	} else {
		return 'Members';
	}
}

function portalv4(){
	document.getElementById('portaltable').getElementsByTagName('TR')[0].style.display="none";
	var iDiv = document.getElementById('portaltable').getElementsByTagName('TD')[0].getElementsByTagName('DIV');
	txtDisc = document.getElementById('portaltable').getElementsByTagName('TD')[2].innerHTML
	var txtLeft = ''; var txtUsers = ''; var txtLogin = '<form action="' + fusURL + 'act=Login&amp;CODE=01&amp;CookieDate=1" method="post">';
	iDiv[0].getElementsByTagName('DIV')[0].style.display="none";
	txtLogin += iDiv[0].innerHTML
	for(n=0;n<iDiv.length;n++){
		if(iDiv[n].className=='maintitle' && iDiv[n].innerHTML.match(/latest discussions/i) != null){
		  iDiv[n].style.display="none";
		  txtLeft = iDiv[n].parentNode.innerHTML;
		}
		if(iDiv[n].className=='maintitle' && iDiv[n].innerHTML.match(/online users/i) != null){
			iDiv[n].style.display="none";
			var iMem = iDiv[n+1].getElementsByTagName('A');
			for(j=0;j<iMem.length;j++){
				if(iMem[j].href.match(/showuser=/i) != null){
					iMem[j].setAttribute('onmouseover',"nameMe(this);"); 
				} 
			}
			 txtUsers = iDiv[n].parentNode.innerHTML;
		}
	}
	txtLogin += '</form>'
	var iRow = document.getElementById('portaltable').insertRow(0);
	var iCell = iRow.insertCell(0);
	iCell.colSpan = "3";
	iCell.className = "row4";
	var mainCellContent = "<TABLE cellpadding='3' cellspacing='5' width='100%'><TR><TD colSpan='3'>";
	
	/* First Navibar */
	mainCellContent += "<span style='font-weight: bold;'><a href='http://site.ifcode.com' target='_blank'>iFCode.com</a></span> | ";
	mainCellContent += "<a href='" + fusURL + "act=idx'>iFusion Forums</a> | ";
	mainCellContent += "<a href='" + fusURL + "act=Online&CODE=listall&sort_key=click'>Who's Online</a> | ";
	mainCellContent += "<a href='" + fusURL + "act=Search&CODE=getactive'>Today's Active Topics</a> | ";
	mainCellContent += "<a href='http://index.ifcode.com' target='_blank'><b>Code Index</b></a> | ";
	mainCellContent += "<a href='" + fusURL + "act=Games'>iFusion Arcade</a></TD></TR>";
	
	mainCellContent += "<TR><TD width='25%' vAlign='top'><div class='tableborder'><div class='maintitle'>RSS Feed</div><div class='tablepad'><b>Latest iFCode.com Registrations:</b><BR />";
	mainCellContent += "1. <i>Amberon</i><BR />2. <i>Oracle</i><BR />3. <i>AllBucDUp</i><BR />4. <i>golddragons</i><BR />5. <i>CrackFlash</i>";
	mainCellContent += "</div></div><BR /><div class='tableborder'><div class='maintitle'>My Account Information</div><div class='tablepad'>" + txtLogin + "</div></div><BR /><div class='tableborder'><div class='maintitle'>Users Online</div><div class='tablepad'>" + txtUsers + "</div></div><BR />";
	mainCellContent += "<div class='tableborder'><div class='maintitle'>Latest Discussions</div><div class='tablepad'><BR />" + txtLeft + "<BR /></div></div><BR /></TD><TD width='55%' vAlign='top'>";
	
	var myAffiliates = new Array();
	myAffiliates[0] = "<a href='http://www.n-sane.net'><img src='http://www.ifcode.com/main/affiliates/n-sane.gif' alt='nSane Art' title='nSane Art'  width='88' height'31' /></a>";
	myAffiliates[1] = "<a href='http://www.dabomgfx.com/forums'><img src='http://img.photobucket.com/albums/v376/jpstoneman/affiliatebutton.gif' alt='DaBom GFX' title='DaBom GFX'  width='88' height'31'/></a>";
	myAffiliates[2] = "<a href='http://www.sc-photos.co.uk'><img src='http://site.ifcode.com/affiliates/scphotos.gif' width='88' height='31' /></a>";
	myAffiliates[3] = "<a href='http://expertsonline.pixeldepth.net'><img src='http://iycatacombs.com/sz/pDminibanner.gif' width='88' height'31' alt='Experts Online' title='Experts Online' /></a>";
	
	var buildAffiliates="";
	for(build=0;build<myAffiliates.length;build++){
		buildAffiliates+=myAffiliates[build] + "<BR /><BR />"; 
	}
	mainCellContent += "<!-- Middle --><div class='tableborder'><div class='maintitle' style='text-align: center;'>iFusion Portal v4.5</div><div class='tablepad' style='text-align: center;'><img src='http://www.ifcode.com/forum/scripts/iFusionv4.png'></div></div><BR /><div id='LatestDiscussions'><!-- Installed Here --></div><BR />" + txtDisc + "</TD><TD width='20%' vAlign='top'>";
	mainCellContent += "<!-- Right --><div class='tableborder'><div class='maintitle'>Board Statistics</div><div class='tablepad'>Created: 26th Feb 2005<BR />Member Count: <span id='mem_count'>N/A</span><BR />Posts: <span id='the_posts'>N/A</span><BR />Most Users Online: <span id='the_online'>N/A</span></div></div><BR /><div class='tableborder'><div class='maintitle'>Affiliates</div><div class='tablepad' style='text-align: center;'><!--" + buildAffiliates + "-->iFusion Affiliates will reopen soon!<BR /></div></div><BR /><div class='tableborder'><div class='maintitle'>Information Box</div><div class='tablepad' id='portalPad'><BR /><BR /><BR /></div></div><BR /></TD></TR></TABLE>";

	iCell.innerHTML = mainCellContent;

	var collect_stats = new Ajax(
		fusURL + "c=4",
		{ 
		onComplete:function(collect_stats){
			if(collect_stats.match(/IBF.QUICK_LOG_IN/i) == null) return false;
			var xDiv = document.createElement('DIV');
			document.body.appendChild(xDiv);
			xDiv.style.display="none";
			
			xDiv.innerHTML = collect_stats.split(/IBF.QUICK_LOG_IN/i)[1];
			
			if(xDiv.innerHTML.match(/we have (.*) registered members/i) != null){
				document.getElementById('mem_count').innerHTML = RegExp.$1;
			}
			if(xDiv.innerHTML.match(/ever online was (.*) on/i) != null){
				document.getElementById('the_online').innerHTML = RegExp.$1;
			}
			if(xDiv.innerHTML.match(/made a total of (.*) posts/i) != null){
				document.getElementById('the_posts').innerHTML = RegExp.$1;
			}
		}
	}).request();

	document.getElementById('loadportal').style.display="none";
	document.getElementById('portaltable').style.display="";
}

