var ErrorImg = ErrorImg || function(src){
	var defimg = '/images/nopic.gif';
	if(src.match(/\/thumbs\//)){
		var bigimg = src.replace(/\/thumbs\//, '/');
		if(bigimg != src){
			defimg = bigimg;
		}
	}
	event.srcElement.src = defimg;
}

if(!document.all){
	HTMLElement.prototype.__defineGetter__("children", 
		function () { 
			var returnValue = new Object(); 
			var number = 0; 
			for (var i=0; i<this.childNodes.length; i++) { 
				if (this.childNodes[i].nodeType == 1) { 
					returnValue[number] = this.childNodes[i]; 
					number++; 
				} 
			} 
			returnValue.length = number; 
			return returnValue; 
	});
}

var Marquee = Marquee || function(demo, direction){
	var _this = this;
	var handel, demo1;
	var speed = 30;

	var posSuffix = direction == 'left' || direction == 'right' ? 'Left' : 'Top';
	var sizeSuffix = direction == 'left' || direction == 'right' ? 'Width' : 'Height';

	if(typeof(demo) == 'string') 
		demo = document.getElementById(demo);
	if(!demo) 
		return;

	this.start = function(nid){
		demo1 = this.getCntNode(nid);
		if(eval('demo.offset' + sizeSuffix + ' < demo1.scroll' + sizeSuffix)){
			demo1.parentNode.insertBefore(demo1.cloneNode(true), demo1.nextSibling);

			var step;
			step = direction == 'right' || direction == 'bottom' ? _this.marquee1 : _this.marquee;
			handel = setInterval(step, speed);
			demo.onmouseover = function(){ clearInterval(handel); };
			demo.onmouseout = function(){ handel = setInterval(step, speed); }
		}
	};
	
	this.marquee = function(){
		if(eval('demo.scroll' + posSuffix + ' >= demo1.scroll' + sizeSuffix)){
			eval('demo.scroll' + posSuffix + ' = 0');
		}else{ 
			eval('demo.scroll' + posSuffix + '++');
		}
	};

	this.marquee1 = function(){
		if(eval('demo.scroll' + posSuffix + ' <= 0')){
			eval('demo.scroll' + posSuffix + ' = demo1.scroll' + sizeSuffix);
		}else{ 
			eval('demo.scroll' + posSuffix + '--');
		}
	};

	this.getCntNode = function(nid){
		if(typeof(nid) != 'undefined' && (node = document.getElementById(nid))){
			return node;
		}else{
			return demo.children[0];
		}
	};
}

var Flash = Flash || function(src, width, height){
	this.src = src;
	this.version = '7,0,19,0';
	this.params = {};
	this.vars = {};
	this.oattrs = {
		'classid' : 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
		'codebase' : 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version,
		'width' : width,
		'height' : height
	};
	
	this.eattrs = {
		'pluginspage' : 'http://www.macromedia.com/go/getflashplayer',
		'type' : 'application/x-shockwave-flash',
		'quality' : 'high',
		'src' : src,
		'width' : width,
		'height' : height
	};
	
	this.pattrs = {
		'movie' : src,
		'menu' : 'false',
		'quality' : 'high'
	};
	
	this.setVar = function(k, v){
		this.vars[k] = v;
	}; 
	
	this.setParam = function(k, v){
		if(k == 'movie'){
			k = 'src';	
		}
		if(k == 'src'){
			this.eattrs[k] = v;	
			this.eattrs['movie'] = v;
			return;
		}
		
		if(typeof this.oattrs[k] != 'undefined'){
			this.oattrs[k] = v;
		}
		if(typeof this.eattrs[k] != 'undefined'){
			this.eattrs[k] = v;
		}
		if(typeof this.pattrs[k] != 'undefined'){
			this.pattrs[k] = v;
		}
	};
	
	this.__object = function(){
		var html = '';
		for(var k in this.oattrs){
			html += ' ' + k + '="' +  this.oattrs[k] + '"';
		}
		return '<object' + html + '>';
	}
	
	this.__params = function(){
		var html = '';
		for(var k in this.pattrs){	
			html += '<param name="' + k + '" value="' + this.pattrs[k]  + '" />'
		}
		for(k in this.vars){
			html += '<param name="' + k + '" value="' + this.vars[k]  + '" />'
		}
		return html;
	}
	
	this.__embed = function(){
		var html = '';
		for(var k in this.eattrs){	
			html += ' ' + k + '="' +  this.eattrs[k] + '"';
		}
		for(k in this.vars){	
			html += ' ' + k + '="' +  this.vars[k] + '"';
		}
		return '<embed' + html + '></embed>';
	}
	
	this.write = function(id){
		//alert(this.__object() + this.__params() + this.__embed() + '</object>');
		if(typeof id == 'string'){
			id = document.getElementById(id);
		}
		if(id == undefined || !id){
			document.write(this.__object() + this.__params() + this.__embed() + '</object>');
		}else{
			id.innerHTML = this.__object() + this.__params() + this.__embed() + '</object>';
		}
	}
}

