<!--

// Example of use:
//topimg = new iwith_topimgs();
//topimg.setdimensions(468,60);
//topimg.add("/Pix/topimg-01.jpg","http://www.iwith.org/en/");
//topimg.add("/Pix/topimg-02.jpg","http://www.iwith.org/es/");
//topimg.add("/Pix/topimg-03.jpg","http://www.iwith.org/fr/");
//topimg.add("/Pix/topimg-04.jpg","http://www.iwith.org/ct/");
//topimg.show();


// Class definition
function iwith_topimgs() {
	// Class private properties
	i=0;
	img=new Array();
	lnk=new Array();
	align=new Array();
	alt=new Array();
	bgcolor=new Array();
	flash=new Array();
	width=0;
	height=0;
	wcmd='';
	hcmd='';

	randomnumber = Math.random();

	// Object adder.
	// adds a new image to the class
	function add(im,ln,al,an) {
		img[i]=im;
		lnk[i]=ln;
		if (al) alt[i]='alt="'+al+'" ';
		else alt[i]='';
		if (an) align[i]='align="'+an+'" ';
		else align[i]='';
		flash[i]=false;
		bgcolor[i]='#ffffff';
		i++;
	};

	// Set banner dimensions
	// If this function is called, all banners will be resized to this dimensions
	function setdimensions(w,h) {
		width=w;
		height=h;

		if (width>0) wcmd=" width="+width+" ";
		if (height>0) hcmd=" height="+height+" ";

	}

	// Flash object adder
	// Adds a new falsh object
	function addflash(obj, al, an, bg) {
		img[i]=obj;
		lnk[i]='';
		if (al) alt[i]='"'+al+'" ';
		else alt[i]='""';
		if (an) align[i]='align="'+an+'" ';
		else align[i]='align="middle" ';
		flash[i]=true;
		if (bg) bgcolor[i]='bgcolor="'+bg+'" ';
		bgcolor[i]= '#ffffff" ';
		i++;
	}

	// Random selection of a Top IMG and display
	function show() {
		var r = Math.floor( i * randomnumber) ;

		document.writeln('<!--iwith-snippet-begin-->\n');

		if (flash[r]) {
			document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ');
			document.write ('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ');
			document.writeln ('width="'+width+'" height="'+height+'" id='+alt[r]+' '+align[r]+'>');
			document.writeln ('<param name="allowScriptAccess" value="sameDomain" />');
			document.writeln ('<param name="movie" value="'+img[r]+'" />');
			document.writeln ('<param name="quality" value="high" />');
			document.writeln ('<param name="bgcolor" value="'+bgcolor[r]+'" />');
			document.writeln ('<embed src="'+img[r]+'" quality="high" bgcolor="'+bgcolor[r]+'" ');
			document.write   ('width="'+width+'" height="'+height+'" name='+alt[r]+' '+align[r] );
			document.write   ('allowScriptAccess="sameDomain" type="application/x-shockwave-flash"');
			document.write   (' pluginspage="http://www.macromedia.com/go/getflashplayer" />');
			document.writeln ('</object><br clear=all>');


		} else if (lnk[r]) {
			document.write ('<a href="'+lnk[r]+'" target="_blank"><img src="'+img[r]+'" ');
			document.writeln (align[r]+alt[r]+' border=0 '+wcmd+hcmd+'></a>');
		} else 	{
			document.writeln ('<img src="'+img[r]+'" '+align[r]+alt[r]+' border=0 '+wcmd+hcmd+'>');
		}

		document.writeln('<!--iwith-snippet-end-->');
	};

	// Class Public methods
	this.setdimensions=setdimensions;
	this.addflash=addflash;
	this.add=add;
	this.show=show;
}

-->


