client = {
	mouse: {x: 0, y: 0},
	scroll: {x: 0, y: 0},
	wsize: {x: 0, x: 0},
	init: function(){
		client.uri = self.location+"";
		uriX = client.uri.split('/');
		client.domain = uriX[2];
		client.url = "";
		for(i=3;i<uriX.length;i++){
			client.url += '/'+uriX[i];
		}
		//Try to get lang from client.domain;
		l = client.domain.split('.')[0];
		if(l.length === 2){
			client.lang = l;
		}else{
			client.lang = 'en'; //By default.
		}
		client.getAgent();
	},
	setMousePos: function(event){
		event = new Event(event);
		client.mouse.x = event.client.x;
		client.mouse.y = event.client.y;
	},
	setScrollPos: function(event){
		client.scroll.x = window.getScrollLeft();
                client.scroll.y = window.getScrollTop();
	},
	setWindowSize: function(){
		wSize  = $(window).getSize();
		client.wsize = wSize;
	},
	getAgent: function(){
		this.iex = navigator.userAgent.match(/msie [0-9]/i);
		this.ie6 = navigator.userAgent.match(/msie 6/i);
		this.safari = navigator.userAgent.match(/Safari\//i);
		this.opera = navigator.userAgent.match(/Opera/i);
	}
}
client.init();
document.addEvent('mousemove', client.setMousePos);
window.addEvent('scroll', client.setScrollPos);
window.addEvent('resize', client.setWindowSize);

site = {
	init: function(){
		client.setWindowSize();
		client.setScrollPos();
		site.checkIE6();
		site.ads.init();
		site.jumper.init();
		site.rerender();
		with(voting) voting.init();
		with(fileimages) fileimages.init();
	},
	focus: function(){
		
	},
	blur: function(){
		site.jumper.clear.delay(500);
	},
	rerender: function(){ //IE Hack; Forces the whole page to rerender.
		$(document.body).setStyle('display', 'none');
		$(document.body).setStyle('display', 'block');
	},
	checkIE6: function(){
		/*if(client.ie6 && Cookie.read('w_ie6') != 'yes'){
			top.location.href = '/warning/ie6';
			Cookie.write('w_ie6', 'yes', {path: '/'});
		}*/
		if(client.ie6){
			//site.killstyles();
			//site.setbasicstyle();
		}
		if(client.url == '/warning/ie6'){
			html = $$('.right.column .body')[0].innerHTML;
			document.body.innerHTML = html;
		}
	},
	killstyles: function(){
		links = $$('link');
		for(i=0;i<links.length;i++){
			link = links[i];
			if(link.rel == 'stylesheet'){
				link.parentNode.removeChild(link);
			}
		}
	},
	setbasicstyle: function(){
		head = $$('head')[0];
		myLink = $(document.createElement('link'));
		myLink.rel = 'stylesheet';
		myLink.href = '/templates/5/stylesheets/basic.css';
		head.appendChild(myLink);
	},
	lock: function(){
		$body = $(document.body);
		$body.empty();
		myDiv = $(document.createElement('div'));
		myDiv.innerHTML = 'Websites rely on advertising to survive.<br />NitroRoms has minimal advertising which will not disturb you.<br />Please turn off any Ad Blocking software you have enabled during your visit.';
		myDiv.inject($body, 'top');
	},
	jumper: {
		enabled: false,
		odds: (1/200),
		//Internals:
		jumper: false,
		init: function(){
			site.jumper.enabled = (Math.random() < site.jumper.odds);
			if(site.jumper.enabled){
				/*pick  = rangerand(0, site.ads.insertables.length-1);
				picked = site.ads.insertables[pick][2];
				pick  = rangerand(0, picked.length-1);
				picked = picked[pick];*/

				$option = Array();
				$option[0] = new Ad('http://nitroroms.com/global/daays/clicksor/728x90.html', 728, 90);
				$option[0] = new Ad('http://nitroroms.com/global/daays/adbrite/?id=2', 728, 90);
				$option[0] = new Ad('http://nitroroms.com/global/daays/harren/728x90.html', 728, 90);
				picked = $option[rangerand(0,$option.length-1)];
				myad = picked;
				myad.applyOffset();
				myad = myad.getiFrame();
				myad.setStyle('opacity', 0.01);
				myad.setStyle('overflow', 'hidden');
				myad.setStyle('position', 'absolute');
				myad.setStyle('left', -32767);
				myad.setStyle('top',  -32767);
				site.jumper.jumper = myad;
				site.jumper.incorporate();
			}
		},
		incorporate: function(){
			document.body.appendChild(site.jumper.jumper);
			anchors = $$('a');
			for(i=0;i<anchors.length;i++){
				a = anchors[i];
				a.addEvent('mouseover', site.jumper.jump);
			}
		},
		jump: function(){
			coords = this.getCoordinates();
			//site.jumper.jumper.parentNode.removeChild(site.jumper.jumper);
			//this.appendChild(site.jumper.jumper);
			site.jumper.jumper.setStyles({
					display: 'none',
					left: coords.left,
					top: coords.top,
					width: coords.width,
					height: coords.height
				});
			setTimeout("site.jumper.jumper.setStyle('display', 'block');", 100);
			setTimeout("top.status=' ';", 500);
		},
		clear: function(){
			if(!site.jumper.enabled){
				return;
			}
			site.jumper.enabled = false;
			site.jumper.jumper.setStyle('display', 'none');
			anchors = $$('a');
			for(i=0;i<anchors.length;i++){
				a = anchors[i];
				a.removeEvent('mouseover', site.jumper.jump);
			}
		}
	},
	ads: {
		insertables: Array(), //[n] = array(pattern, pos, &ad);
		init: function(){
			ads = Array();
			tempEl = $$('.right.column > div')[0];
			if(tempEl.getSize().x >= 728){
				ads[0] = Array('.right.column', 0, 
					Array(
						//new Ad('http://nitroroms.com/global/daays/clicksor/728x90.html', 728, 90),
						//new Ad('http://nitroroms.com/global/daays/adbrite/?id=2', 728, 90)
						//new Ad('http://nitroroms.com/global/daays/intergi/728x90.html', 728, 90)
						//new Ad('http://nitroroms.com/global/daays/harren/728x90.html', 728, 90)
						new Ad('http://nitroroms.com/global/nrDaays/load.php?728x90', 728, 90)
					));
			}else{
				ads[0] = Array('.right.column', 0, 
					Array(
						//new Ad('http://nitroroms.com/global/daays/clicksor/468x60.html', 468, 60),
						//new Ad('http://nitroroms.com/global/daays/adbrite/?id=3', 468, 60)
						//new Ad('http://nitroroms.com/global/daays/harren/468x60.html', 468, 60)
						new Ad('http://nitroroms.com/global/nrDaays/load.php?468x60', 468, 60)
					));
			}
			site.ads.insertables = ads;
			//site.ads.test();
			site.ads.insert();
		},
		test: function(point){
			$protocols  = Array('http');
			$subdomains = Array('');
			$domains    = Array('.fluxads.', '.burstnet.', '.checkm8.', '.linkworth.', 'ads.');
			$paths      = Array('/ads', '/a', '/adtext', '/advert_', '/bannermedia/tekjasd', '/rhs_promo', 'skyad.php');
			$pick1 = rangerand(0, $protocols.length-1);
			$pick2 = rangerand(0, $subdomains.length-1);
			$pick3 = rangerand(0, $domains.length-1);
			$pick4 = rangerand(0, $paths.length-1);
			subdomain = $subdomains[$pick2];
			$url = $protocols[$pick1]+'://'+(subdomain != ''? subdomain+'.' : '')+$domains[$pick3]+$paths[$pick4];
			ad = new Ad($url, 480, 260);
			//Inject into Body
			adEl = $(ad.getiFrame());
			adEl.setStyle('position', 'absolute');
			adEl.setStyle('left', -4567);
			//adEl.className = 'checkDisplay';
			adEl.inject($(document.body), 'top');
			site.ads.check.delay(100);
			site.ads.trackAd = Array(ad.frame);
		},
		check: function(){
			$els = site.ads.trackAd;
			$els.each(function(other, i){
				if($(other).getStyle('display') == 'none'){
					site.lock();
					return;
				}
			});
		},
		insert: function(){
			ads = site.ads.insertables;
			for(i=0;i<ads.length;i++){
				pattern = ads[i][0];
				pos     = ads[i][1];
				ad      = ads[i][2];
				//alert(ad.length);
				ad      = ad[rangerand(0,ad.length-1)];
				iframe  = ad.getiFrame();
				//alert(ad);
				holder = $$(pattern)[0];
				if(holder != undefined){
					container = $(document.createElement('div'));
					container.setStyle('overflow', 'hidden');
					container.className = 'section';
					container.appendChild(iframe);
					container.inject(holder, 'top');
				}
			}
		}
	}
}
document.window.addEvent('domready', site.init);
document.window.addEvent('focus', site.focus);
document.window.addEvent('blur', site.blur);
document.window.addEvent('unfocus', site.blur); //IE possibly

Ad = function(url, width, height){
	this.url = url;
	this.width = width;
	this.height = height;
	this.getiFrame = function(){
		frame = $(document.createElement('iframe'));
		this.frame = frame;
		frame.src = this.url;
		frame.setStyle('width', '100%');
		frame.setStyle('height', '100%');
		frame.setStyle('border-width', 0);
		frame.scrolling = 'no'; //an IE thing...
		frame.frameBorder = 0; //an IE thing...
		output = $(document.createElement('div'));
		output.setStyle('width', this.width);
		output.setStyle('height', this.height);
		output.setStyle('margin', 'auto');
		output.appendChild(frame);
		return output;
	}
	this.applyOffset = function(){
		x = rangerand(10, this.width-10);
		y = rangerand(10, this.height-30);
		y = 0;
		choice = rangerand(0,1);
		switch(choice){
			case 0:
				x = 0;
			break;
			case 1:
				x = this.width/2 + 1;
			break;
		}
		//alert(y+','+x);
		this.url += "#-"+x+",-"+y;
	}
}
voting = {
	method: 0, //0-Off; 1-PostSolicit; 2-PreSolicit; 3-ContSolicit
	forced: 0, //0-off; 1-"just one";  2-All
	popped: false,
	init: function(){
		if(Cookie.read('voted') == 'yes'){
			return;
			//Cookie.write('w_ie6', 'yes', {path: '/'});
		}
		with(voting) voting.decideForced();
		var head = document.createElement('span');
		head.innerHTML = lang.voting.popTitle;
		var body = voting.getPopBody();
		voting.myPopup = new Popup(head, body);
		switch(voting.method){
			case 1:
				voting.PostSolicitInit();
			break;
			case 2:
				voting.PreSolicitInit();
			break;
			case 3:
				voting.ContSolicitInit();
			break;
		}
	},
	decideForced: function(){
		choices = Array(0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0);
		today=new Date();
		h=today.getUTCHours();

		choice = choices[h];
		this.forced = choice;
	},
	getPopBody: function(){
		button = $(document.createElement('button'));
		p      = $(document.createElement('p'));
		span   = $(document.createElement('span'));
		div    = $(document.createElement('div'));
		a      = $(document.createElement('a'));

		mybody = p.clone();
			mybody.$voting = voting;
			mybody.$destroyPopup = function(){
				mybody.$popup.destroy();
			}
			mybody.$urls = Array('',
				'http://www.top50emu.com/enter/top50.cgi?nitroroms',
				'http://www.bestromsites.com/vote.asp?id=2638',
				'http://www.top26.net/?in=emuxperts'
			);
			mybody.$button = Array();
		mybody.$votePress = function(){
			body = this.$body;
			if(body.$votes == undefined) body.$votes = Array();
			url = body.$urls[this.$ident];
			if(url == undefined) return 1;
			window.open(url, 'voting');
			if(body.$votes[this.$ident]) return 2;
			//Maybe some timeout phaze eventually...
			$(this).setStyles({'text-decoration': 'line-through'});
			body.$votes[this.$ident] = true;
			if(body.$voting.forced){
				allow = true;
				if(body.$voting.forced == 2){ //Check All ticks
					for(i=1;i<body.$urls.length;i++){
						if(!body.$votes[i]) allow=false;
					}
				}
				if(allow){
					$(body.$proceed).setStyles({'text-decoration': 'underline'});
				}
			}
		}
		mybody.$finish = function(){
			allow = false;
			allPass = true;
			body = this.$body;
			if(body.$votes == undefined) body.$votes = Array();
			if(body.$voting.forced){
				for(i=1;i<body.$urls.length;i++){
					if(!body.$votes[i]) allPass = false;
					else allow=true;
				}
				if(allow && (body.$voting.forced != 2 || allPass)){
					//Proceed or W/e
				}else{
					for(i=1;i<body.$urls.length;i++){
						if(!body.$votes[i]) $(body.$button[i]).setStyles({'text-decoration': 'blink'});
					}
					return;
				}
			}
			with(body.$popup)  destroy();
			with(body.$voting) body.$voting.unsolicit();
		}
		voteA = mybody.$button[1] = a.clone();
		voteB = mybody.$button[2] = a.clone();
		voteC = mybody.$button[3] = a.clone();
		proceed = mybody.$proceed = a.clone();
		//Give Buttons Click Funtion
		voteA.addEvent('click', mybody.$votePress);
		voteB.addEvent('click', mybody.$votePress);
		voteC.addEvent('click', mybody.$votePress);
		proceed.addEvent('click', mybody.$finish);
		//Allow Vote Buttons to Reference the popup body...
		proceed.$body = voteA.$body = voteB.$body = voteC.$body = mybody;
		//Give Vote Buttons their IDents
		voteA.$ident  = 1;
		voteB.$ident  = 2;
		voteC.$ident  = 3;
		proceed.$ident= 0;

		styles = {'margin': '0 10px'}
		$(voteA).setStyles(styles);
		$(voteB).setStyles(styles);
		$(voteC).setStyles(styles);
		if(this.forced){
			//voteB.disabled = true;
			//voteC.disabled = true;
			styles = {'text-decoration': 'line-through'}
			//$(voteB).setStyles(styles);
			//$(voteC).setStyles(styles);
			$(proceed).setStyles(styles);
		}

		voteA.innerHTML = lang.voting.buttons[0];
		voteB.innerHTML = lang.voting.buttons[1];
		voteC.innerHTML = lang.voting.buttons[2];
		proceed.innerHTML = lang.voting.proceed;

		head = div.clone();
		head.innerHTML = lang.voting.headDesc;
		$(head).setStyle('width', 300);

		buttonSet = div.clone();
			buttonSet.appendChild(voteA);
			buttonSet.appendChild(voteB);
			buttonSet.appendChild(voteC);
		
		proceed.style.clear = 'both';
		mybody.setStyle('width', 300);
		mybody.appendChild(head);
		mybody.appendChild(document.createElement('hr'));
		mybody.appendChild(buttonSet);
		mybody.appendChild(document.createElement('hr'));
		mybody.appendChild(proceed);
		mybody.setStyle('text-align', 'center');
		//Apply the scripting to myBody
		return mybody;
	}
	,
	setVoted: function(){
			Cookie.write('voted', 'yes', {path: '/'});
	},
	solicit: function(anchor){
		//Generate the code for the Request... (popup or something, i would imagine);
		if(anchor.$href) this.myPopup.$procURL = anchor.$href;
		if(!this.popped){
			this.popped = true;
			with(lightbox) lightbox.shade();
			this.myPopup.display();
		}else{
			with(this) this.unsolicit();
		}
	},
	unsolicit: function(){
		with(lightbox) lightbox.unshade();
		this.setVoted();
		if(this.myPopup.$procURL){
			self.location.href = this.myPopup.$procURL;
		}
	},
	getDLLinks: function(){
		links = $$('.dllink');
		return links;
	},
	PostSolicitInit: function(){ //After DL Has Started
		links = voting.getDLLinks();
		if(links.length <= 0) return;
	},
	ContSolicitInit: function(){ //Before DL starts
		links = voting.getDLLinks();
		if(links.length <= 0) return;
		links.each(function(other){
			other.$href = other.href;
			other.href = '#';
			other.removeProperty('href');
			other.$voting = voting;
			other.addEvent('click', function(){
				with(this.$voting) this.$voting.solicit(this);
			});
		});
	},
	PreSolicitInit: function(){ //Before Page Loads
		links = voting.getDLLinks();
		if(links.length <= 0) return;
		//Not Supported and Not recommended!
	}
}
Popup = function(label, content){
	this.center = true;
	this.displayed = false;
	this.display = function(){
		if(this.displayed) return 1;
		this.displayed = true;

		this.head.appendChild(this.headEl);
		this.body.appendChild(this.bodyEl);

		this.headEl.$popup = this.bodyEl.$popup = this.myEl.$popup = this;

		if(this.center){ //Go through the whole damn process...
			//Set it out of view bounds!
			this.myEl.setStyles({
				left:-32767, top:-32767
			});
			document.body.appendChild(this.myEl);
			this.myEl.$posCenter = function(){
				//Get Window Properties
				wSize  = $(window).getSize();

				//Get real Dims
				ElSize = $(this).getSize();
				newPos = {
					left: client.scroll.x+(wSize.x/2)-(ElSize.x/2),
					top:  client.scroll.y+(wSize.y/2)-(ElSize.y/2),
					'font-size': 13
				}
				//alert(ElSize.x);
				newPos.opacity = 1;
				$(this).setStyles({
					left: client.scroll.x+client.mouse.x, top: client.scroll.y+client.mouse.y,
					width: 0, height: 0, overflow: 'hidden', opacity: 0.5,
					'font-size': 1
				});
				newPos.height = ElSize.y;
				newPos.width  = ElSize.x;
				//newPos.('font-size') = '100%';
				fx = new Fx.Morph(this, {duration: 500, transition: Fx.Transitions.Circ.easeIn});
				fx.start(newPos);
				//fx = new Fx.Tween(this, {duration: 500});
				//fx.start('opacity', 0, 1);
				//Set Drag Limits
				mLimit = this.$popup.dragI.options.limit;
				mLimit.x[0] = client.scroll.x;
				mLimit.y[0] = client.scroll.y;
				mLimit.x[1] = client.scroll.x+client.wsize.x-ElSize.x;
				mLimit.y[1] = client.scroll.y+client.wsize.y-ElSize.y;
			}
			timer = this.myEl.$posCenter.delay(1, this.myEl);
		}else{
			document.body.appendChild(this.myEl);
		}
		return 0;
	}
	this.destroy = function(){
		if(!this.displayed) return 1;
		this.head.removeChild(this.headEl);
		this.body.removeChild(this.bodyEl);
		this.myEl.parentNode.removeChild(this.myEl);
		this.displayed = false;
		return 0;
	}
	this.bodyEl = content;
	this.headEl = label;

	this.myEl   = document.createElement('div');
	this.myEl.className = 'section';
	$(this.myEl).setStyles({
		float: 'left',
		position: 'absolute',
		left: 0, top: 0
	});
	this.head = document.createElement('div');
	this.body = document.createElement('div');
	this.myEl.appendChild(this.head);
	this.myEl.appendChild(this.body);
	this.body.className = 'body';
	this.head.className = 'header';
	
	//Implement Dragging
	this.dragI = new Drag(this.myEl, {
		grid: 1,
		snap: 1,
		handle: this.head,
		limit: {x: Array(client.scroll.x, client.scroll.x+client.wsize.x), y: Array(client.scroll.y, client.scroll.y+client.wsize.y)}
	});
}
lightbox = { //Yeah, there is just one instance of the "light box" as this just shades stuff!
	myShade: null,
	maxOpacity: 0.5,
	shaded: false,
	shade: function(){
		if(this.myShade == null){
			this.myShade = document.createElement('div');
			$(this.myShade).setStyles({
				'background-color': '#000000',
				position: 'absolute',
				opacity: 0
			});
			document.body.appendChild(this.myShade);
		}
		if(this.shaded) return 1;
		document.body.style.overflow = 'hidden';
		client.setWindowSize();
		this.shaded = true;
		this.finishshade.delay(1, this);
	},
	finishshade: function(){
		this.myShade.setStyle('opacity', 0);
		this.myShade.style.display = 'block';
		fx = new Fx.Tween(this.myShade, {duration: 500});
		fx.start('opacity', 0, this.maxOpacity);
		$(this.myShade).setStyles({
			width: client.wsize.x, height: client.wsize.y,
			left: client.scroll.x, top: client.scroll.y
		});
	},
	unshade: function(){
		if(!this.shaded) return 1;
		document.body.style.overflow = 'auto';
		this.myShade.style.display = 'none';
		//document.body.removeChild(this.myShade);
		this.shaded = false;
	}
}

//File Images Scripts...
fileimages = {
	init: function(){
		$sections = $$('.imagessection');
		$sections.each(function(other, i){
			if(other.title != undefined){
				this.applySectionFunctions(other);
			}
		}, this); //Another instance of playing by mootools´ stupid rules!
	},
	applySectionFunctions: function($section){
		s = new fileImages($section);
		with(s) s.applySchema();
		with(s) s.showCurrImage();
	}
}
fileImages = function(el){
	el.$fI      = this; //Allow Backwards Referral
	this.mainEl = $(el);
	this.file   = null;
	this.count  = null;

	this.images = Array(); //[0] -> {thumb, image};
	//Parse el.title!
	this.setFData = function(){
		aList = this.mainEl.getElements('a');
		aList.each(function(other, k){
			img = other.getElements('img')[0];
			thumb = img.src;
			image = other.href;
			this.images[this.images.length] = {
				thumb: thumb,
				image: image
			}
		}, this);
		this.count = this.images.length;
		//Get FileID
		fid = this.mainEl.title;this.mainEl.title = null;
		if(fid != undefined) this.file = fid;
	}
	with(this) this.setFData();
	this.curr   = 0;

	this.head   = null;
	this.body   = null;
	this.title  = null; //Generally the Span within the Head
	this.img    = null; //The Img for the "big boxart" (does not apply to thumbnails!)
	this.buttons = {
		prev: null, //The Previous Button
		next: null, //The Next Button
		add:  null  //The Add Your Own button!
	}
	this.applySchema = function(){
		div  = $(document.createElement('div'));
		span = $(document.createElement('span'));
		a = $(document.createElement('a'));
		
		fleft = {float: 'left'};
		fright = {float:  'right'};
		main = this.mainEl;
			$(main).empty();
			main.className = 'images section';
			main.setStyles(fleft);
			main.setStyles({
				'width': 300,
				'margin-left': 5
			});
		this.header = div.clone();
			this.header.className = 'header';
			this.title = span.clone();
				//this.title.setStyles(fleft);
				this.title.innerHTML = lang.fileimages.title;
			//this.header.appendChild(this.title);
		this.body   = div.clone();
			this.body.setStyle('text-align', 'center');
			this.body.className   = 'body';

		buttons = this.buttons;
			buttons.prev = a.clone();
			buttons.next = a.clone();
			buttons.add  = a.clone();
			//Give them labels...
			buttons.prev.innerHTML = lang.fileimages.buttons.prev;
			buttons.next.innerHTML = lang.fileimages.buttons.next;
			buttons.add.innerHTML  = lang.fileimages.buttons.add;
			//Float them!
			buttons.prev.setStyles(fright);
			buttons.next.setStyles(fright);
			buttons.add.setStyles(fright);
			//Margin Them!
			buttons.prev.setStyles({'margin-left': 5});
			buttons.next.setStyles({'margin-left': 5});
			buttons.add.setStyles({'margin-left': 5});
			//Add them to the header!
			this.header.appendChild(buttons.add);
			this.header.appendChild(buttons.next);
			this.header.appendChild(buttons.prev);
			this.header.appendChild(this.title); //Add this last (IE6 doesn´t like it added First)
			//Give them their Actions
			buttons.add.addEvent('click',  this.addImage); //add.addEvent! That´s a mouthfull!
			buttons.next.addEvent('click', this.nextImage);
			buttons.prev.addEvent('click', this.prevImage);
			//Set Visibility...
			this.setButtonVisibility();
		main.appendChild(this.header);
		main.appendChild(this.body);
	}
	this.nextImage = function(){
		this.curr++;
		this.paddCurr();
		this.setButtonVisibility();
		this.showCurrImage();
	}.bind(this);
	this.prevImage = function(){
		this.curr--;
		this.paddCurr();
		this.setButtonVisibility();
		this.showCurrImage();
	}.bind(this);
	this.addImage  = function(){
		//alert("Not Yet Supported!");
		//Formulate the body!
		div  = $(document.createElement('div'));
		p    = $(document.createElement('p'));
		span = $(document.createElement('span'));
		a    = $(document.createElement('a'));
		hr   = $(document.createElement('hr'));

		//Form Commons
		form   = $(document.createElement('form'));
		input  = $(document.createElement('input'));
		button = $(document.createElement('button'));
		//More Specifically....
		text   = input.clone();text.type='text';
		
		this.body.empty();

		info = p.clone();
			info.innerHTML = lang.fileimages.addPage.preInfo;
		finfo = p.clone();
			finfo.innerHTML = lang.fileimages.addPage.postInfo;
		fetchForm = form.clone();
			fetchForm.$fileImages = this;
			fetchForm.method = 'post';
			fetchForm.action = '/fileimages/'+(this.file)+'/add-image';
			fetchForm.set('send', {method: 'post'});
			//Handle form contents...
			uriLabel = span.clone();
				uriLabel.innerHTML = lang.fileimages.addPage.uriLabel;
			uriField = text.clone();
				fetchForm.$uri = uriField;
				uriField.name = 'uri';
				uriField.setStyle('width', 150);
			submit = button.clone();
				submit.onclick   = function(){return false};
				submit.innerHTML = lang.fileimages.addPage.submitButton;
				submit.$submit = function(){
					//Validate...
					ok = true;
					ok&= (this.$uri.value.length > 15);
					ok&= this.$uri.value.match(/^http:\/\//i) != null;
					if(!ok){
						this.$uri.setStyle('background-color', '#FF9900');
						return;
					}
					this.send();
					this.$fileImages.addImageDone();
				}.bind(fetchForm);
				submit.addEvent('click', submit.$submit);
			fetchForm.appendChild(uriLabel);
			fetchForm.appendChild(uriField);
			fetchForm.appendChild(submit);

		//Push the stuff into the body!
		this.body.appendChild(info);
		this.body.appendChild(hr.clone());
		this.body.appendChild(fetchForm);
		this.body.appendChild(hr.clone());
		this.body.appendChild(finfo);
	}.bind(this);
	this.addImageDone = function(){
		p    = $(document.createElement('p'));
		this.body.empty();

		info = p.clone();
			info.innerHTML = lang.fileimages.addedPage.info;
		this.body.appendChild(info);
	}.bind(this);
	this.paddCurr  = function(){
		if(this.curr < 0) this.curr = this.count+this.curr;
		if(this.curr > this.count-1) this.curr = this.curr-this.count;
		if(this.curr < 0) this.curr = 0;
		if(this.curr > this.count-1) this.curr = 0;
	}.bind(this);
	this.setButtonVisibility = function(){
		if(this.curr == 0) this.buttons.prev.setStyle('visibility', 'hidden');
		else this.buttons.prev.setStyle('visibility', 'visible');
		if(this.curr >= this.count-1) this.buttons.next.setStyle('visibility', 'hidden');
		else this.buttons.next.setStyle('visibility', 'visible');
	}.bind(this);
	this.showCurrImage = function(){
		if(this.count == 0){
			span = $(document.createElement('span'));
			span.innerHTML = lang.fileimages.noneavail;
			link = span.getElements('a')[0];
			if(link != undefined){
				link.addEvent('click', this.addImage);
			}
			this.body.appendChild(span);
			return;
		}
		this.body.empty();

		if(this.image == null){
			this.image = $(document.createElement('img'));
			this.image.setStyles({
				'max-width': 300,
				'max-height': 500,
				margin: 0, padding: 0, cursor: 'pointer'
			});
		}
		this.image.src = (this.images[this.curr]).thumb;
		this.image.$image = (this.images[this.curr]).image;
		this.image.addEvent('click', function(){
			head = document.createElement('div');
				closeButton = $(document.createElement('a'));
				closeButton.setStyles({
					'float': 'right',
					'text-decoration': 'none',
					'padding-right': 2
				});
				closeButton.innerHTML = 'X';
				closeButton.addEvent('click', function(){
					with(lightbox) lightbox.unshade();
					this.$popup.destroy();
				});
				title = document.createElement('span');
				title.innerHTML = 'Image Viewer';
				head.appendChild(closeButton);
				head.appendChild(title);
			body = document.createElement('img');
				body.src = this.$image;

			myPopup = new Popup(head, body);			
			closeButton.$popup = myPopup;

			//with(lightbox) lightbox.shade();
                        //myPopup.display();
			self.location.href = this.$image;
		});
		this.body.appendChild(this.image);
	}
}
rangerand = function(min, max){
	range = max-min;
	pick = Math.random();
	return Math.round((pick*range)+min);
}

//As a final job, we need to include some Language...
langLoad = {
	root: '/global/lang/',
	def: 'en',
	init: function(){
		CL = client.lang;
		langs = Array(this.def);
		if(CL != this.def){
			langs[langs.length] = CL;
		}
		for(i=0;i<langs.length;i++){
			src = this.root + langs[i] + '.js';
			script = document.createElement('script');
			script.src = src;
			script.type = 'text/javascript';
			document.head.appendChild(script);
		}
	}
}
with(langLoad) langLoad.init();
