/*
	Automated Script Installer v1.0.1 (formely known as imvucodes framework system)
	+ by www.imvucodes.net
	+ Author: Benjamin Philipp
	+ Avatar: Productions
	
	- last change: 25th June 2008
	
	COPYRIGHT BY IMVUCODES.NET
	DO NOT COPY/CHANGE WITHOUT PERMISSIONS
*/
function icfwSystem() {
	this.MenuLoaded = false;
}

icfwSystem.prototype.Init = function() {
	if(icfw.PageLoaded()==true) {
		document.getElementById('footerBanner').innerHTML+='<br><center>This page is using the <a href="http://www.imvucodes.net/code/imvucodes_interface__easy_efficient-155" target="_blank">imvucodes framework system</a></center>';
		document.getElementById('footerBanner').innerHTML+='<style type="text/css">#mininav_body,#footerBanner{display:static!important;}.ic_button{cursor:pointer;}.ic_menuwindow{position:absolute;top:50%;left:50%;margin-top:-250px;margin-left:-450px;height:500px;overflow:auto;margin-bottom:15px;background:#FFF;width:900px;z-index:9999;font-size:12px;color:#FFF;text-align:center;}.ic_iframe{height:480px;background:#FFF;width:98%;border:0px;}#icMenuWindow{background:url(\'http://www.imvucodes.net/fw/shadow.png\') center top no-repeat;}.highlighted {background: yellow;}</style>';
		//document.getElementById('footerBanner').innerHTML+='<style type="text/css">@import url(\'http://www.imvucodes.net/fw/style.css\');</style>';
		
		if(icfw.UserIsOwner()==true) {
			var icMenuButton = document.createElement('div');
			icMenuButton.setAttribute('style', 'width:231px;height:44px;position:absolute;');
			icMenuButton.setAttribute('id', 'icMenuButton');
			icMenuButton.innerHTML='<img class="ic_button" src="http://www.imvucodes.net/fw/icmenu.png" onclick="icfw.ShowSettings();"> ';
			document.getElementById('mininav_body').appendChild(icMenuButton);
		}		
	} else {
		document.getElementById('LoadingPage').innerHTML+='...';
		window.setTimeout('icfw.Init()',1000);
	}
}

icfwSystem.prototype.ReloadPage = function() {
	this.CloseSettings();
	location.href=location.href;
}

icfwSystem.prototype.PageLoaded = function() {
	return (document.getElementById('LoadingPage').style.display=='none');
}

icfwSystem.prototype.UserIsOwner = function() {
	try {
		var test=document.getElementById('send_message_link').href;
		return false;
	} catch(e) {
		return true;
	}
}

icfwSystem.prototype.ThisUser = function() {
	if(icfwSystem.prototype.UserIsOwner()==true) {
		return IMVU.data.customerID;
	} else {
		var userId = document.getElementById('send_message_link').href.split('=')[1];
    if (typeof userId == 'undefined') {
      var userId = document.getElementById('send_message_link').href.split(':')[2];
      userId = userId.substring(0, userId.length - 2);
    }
    return userId;
	}
}

icfwSystem.prototype.ShowSettings = function() {
	if(this.MenuLoaded==true) {
		document.getElementById('icMenuWindow').style.display='block';
		document.getElementById('ic_iframe').src='http://www.imvucodes.net/fw/interface.php?userid='+IMVU.data.customerID;
	} else {
		document.getElementById('footerBanner').innerHTML+='<div id="icMenuWindow" class="ic_menuwindow"><span class="ic_button" onclick="icfw.ReloadPage();">Reload</span> | <span class="ic_button" onclick="icfw.CloseSettings();">Close</span><br><iframe frameborder="0" class="ic_iframe" id="ic_iframe" src="http://www.imvucodes.net/fw/interface.php?userid='+IMVU.data.customerID+'"></iframe></div>';
		this.MenuLoaded = true;
	}
}

icfwSystem.prototype.CloseSettings = function() {
	document.getElementById('icMenuWindow').style.display='none';
}

var icfw = new icfwSystem;

icfw.Init();

//Load JS
window.onload = function() { include('http://www.imvucodes.net/fw/framework.js.php?userid='+icfwSystem.prototype.ThisUser()+'&c='+Math.floor(Math.random()*99999)); }

function include(file) {
    var script = document.createElement('script');
    var type = document.createAttribute('type');
    type.nodeValue = 'text/javascript';
    script.setAttributeNode(type);
    var source = document.createAttribute('src');
    source.nodeValue = file;
    script.setAttributeNode(source);
    //var head = document.getElementsByTagName('head')[0];
	var footer = document.getElementById('footerBanner');
    footer.appendChild(script);
}