function TagMng(){
	this.add = tagAdd;
	this.render = tagRender;
	this.renderAll = tagRenderAll;
	this.renderOne = tagRenderOne;
	this.write = tagWrite;
	this.insert = tagInsert;
	this.start = tagStart;
	this.stop = tagStop;
	this.show = tagShow;
	this.close = tagClose;
	this.togleShow = tagTogleShow;	
	this.interval = 1000;
	this.lastTogle = new Date();
	this.intObj = false;
	this.src = "";
	this.tags = new Array();
}
function TagEnt( name, imgsrc, url, title ){
	this.name = name;
	this.img = new Image();
	if( imgsrc.substring(0,4) =="http" )
		this.img.src = imgsrc;
	else
		this.img.src = "http://www.ivar.co.uk/" + imgsrc;
	this.url = url;
	this.title = title;
}
function tagAdd( name, imgsrc, url, title ){
	if( title )
		this.tags.push( new TagEnt( name, imgsrc, url, title ) );
	else
		this.tags.push( new TagEnt( name, imgsrc, url, name ) );
}
function tagRender(){
	this.ran = Math.floor(Math.random()*this.tags.length);
	this.tag = this.tags[this.ran];
	this.src = this.renderOne(this.tag);
	return this.src;
}
function tagRenderAll(){
	this.src = "";
	for( this.i in this.tags ){
		this.src += this.renderOne(this.tags[this.i]);
	}
	return this.src;
}
function tagRenderOne(tag){
	this.osrc = '<a href="' + tag.url + '">';
	this.osrc += '<img align="right" src="' + tag.img.src; 
	this.osrc += '" alt="" title="' + tag.title + '" />';
	this.osrc += '</a>';
	return this.osrc;
}
function tagWrite(src){
	if(src)
		document.write(src);
	else
		document.write(this.src);
}
function tagInsert(src){
	if(src)
		document.getElementById("tagstrips").innerHTML = src;
	else 
		document.getElementById("tagstrips").innerHTML = this.render();
}
function tagStart(){
	this.intObj = window.setInterval("tags.insert()",this.interval);
}
function tagStop(){
	window.clearInterval(this.intObj);
}
function tagShow(){
	this.togleShow();	
}
function tagClose(){
	//this.togleShow();	
}
function tagTogleShow(){
	if( this.lastTogle < (new Date().getTime() - 1000 )){
		if(this.shown){
			document.getElementById("alltagstrips").style.visibility= "hidden";	
			//document.getElementById("alltagstrips").style.display= "none";	
		}else {
			document.getElementById("alltagstrips").style.visibility= "visible";	
			//document.getElementById("alltagstrips").style.display= "block";	
		}
		this.shown=!this.shown;
		this.lastTogle = new Date();
	}
}


