 /**
 * jsICON is (c) 2008 David Kretz 
 * jsICON select and apply choosen icon for later submisal

 /**  SPECIAL THANKS TOO
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

if(typeof mybytes == "undefined") var mybytes = new Object();

mybytes.jsiCON = function(id,url) {
	// jsiCON assumes that files are orded from 0 to n
	//alert(id);
	this.url = url;
	this.id = id;
	this.atPage=-1;
	this.generateSelector(id);
	
	// ICON LAYOUT STUFF
	this.show = 12;
	this.perline = 4;
	this.icons = 193;
	this.topPage = Math.ceil(this.icons/this.show);
	//alert(this.topPage);
	this.gotoPage(1);

}

mybytes.jsiCON.prototype = {
	generateSelector: function(id) {
		var div = getElement(id);
		//alert(div);
		if(div) {
			div.innerHTML='<div style="position:relative;left:10px;"><img src="./icons/backdrop.png" /></div><div style="position:relative;float:left;left:50px;top:-25px;"><table  width="180px"><tr><td><a href="javascript:jsi.gotoPage(1);"><img src="./icons/goto_start.png"  border=0 /></a></td><td><a href="javascript:jsi.gotoPage(jsi.atPage-1);"><img src="./icons/prev.png" border=0 /></a></td><td><div id="one"><a href="javascript:jsi.gotoPage(1);" style="text-decoration:none;color:#FF6D00;">1</a></div></td><td ><div id="two"><a href="javascript:jsi.gotoPage(2);" style="text-decoration:none;color:#000000;"> 2</a></div></td><td ><div id="three"><a href="javascript:jsi.gotoPage(3);" style="text-decoration:none;color:#000000;">3</a></div></td><td><div id="four"><a href="javascript:jsi.gotoPage(4);" style="text-decoration:none;color:#000000;">4</a></div></td><td><div id="five"><a href="javascript:jsi.gotoPage(5);" style="text-decoration:none;color:#000000;">5</a></div></td><td><a href="javascript:jsi.gotoPage(jsi.atPage+1);"><img src="./icons/next.png"  border=0/></a></td><td><a href="javascript:jsi.gotoPage(jsi.topPage);"><img src="./icons/goto_end.png" border=0 /></a></td></tr></table></div><br><div id="iconDisplay" style="position:relative;float:left;left:22px;top:-210px;width:235px;height:170px;"></div>';
		} 
	},
	getElement: function(el) {
		var elem
		if( document.getElementById ) elem = document.getElementById(el); // this is the way the standards work
		else if( document.all ) elem = document.all[el];// this is the way old msie versions work
		else if( document.layers ) elem = document.layers[el]; // this is the way nn4 works
		return elem;
	},
	gotoPage: function(page) {
		//alert(this.atPage+ " " + page);
		if(this.atPage != page && (page <= this.topPage && page > 0)) {
			this.atPage = page;
			var div=getElement('iconDisplay');
			var x = 0;
			var iconDisp = "";
			if(div) {
				for(x = 1; x <= this.show; x++) {
					iconDisp += '<a href="javascript:changeIcon('+(x+((this.atPage-1)*this.show)-1)+');"><img src="'+this.url+(x+((this.atPage-1)*this.show)-1)+'.jpg" border=0 /></a>';
					if(x%4!=0) iconDisp += '&nbsp;&nbsp;&nbsp;';
				}
				//alert(iconDisp);
				div.innerHTML = iconDisp;
			}
			div = getElement('one');
			div.innerHTML = '<a href="javascript:jsi.gotoPage('+this.atPage+');" style="text-decoration:none;color:#FF6D00;">'+this.atPage+'</a>';
			div = getElement('two');
			if(this.atPage+1<=this.topPage) div.innerHTML = '<a href="javascript:jsi.gotoPage('+(this.atPage+1)+');" style="text-decoration:none;color:#000000;">'+(this.atPage+1)+'</a>';
			else div.innerHTML='&nbsp;';
			div = getElement('three');
			if(this.atPage+2<=this.topPage) div.innerHTML = '<a href="javascript:jsi.gotoPage('+(this.atPage+2)+');" style="text-decoration:none;color:#000000;">'+(this.atPage+2)+'</a>';
			else div.innerHTML='&nbsp;';
			div = getElement('four');
			if(this.atPage+3<=this.topPage) div.innerHTML = '<a href="javascript:jsi.gotoPage('+(this.atPage+3)+');" style="text-decoration:none;color:#000000;">'+(this.atPage+3)+'</a>';
			else div.innerHTML='&nbsp;';
			div = getElement('five');
			if(this.atPage+4<=this.topPage) div.innerHTML = '<a href="javascript:jsi.gotoPage('+(this.atPage+4)+');" style="text-decoration:none;color:#000000;">'+(this.atPage+4)+'</a>';
			else div.innerHTML='&nbsp;';

		}
	}
}

var jsiCON = mybytes.jsiCON;