var objs=new Array();
function FadeCreator() {this.frame=null;this.time=FADE;this.delay=DELAY;this.transition=false;this.initialized=false;this.reverse=false;this.mainTimer=null;this.fadeTimer=null;this.children=null;this.ss=null;this.current_slide=0;this.last_slide=0;this.max_slides=0;this.slide_counter=null;this.slide_counter_table=null;index=-1;
	this.start=function(){ if(this.ss==null||this.children==null||!this.ss) return;if(this.children.length==2&&this.frame!=this.ss.firstChild) return;if (!this.frame) return;
		if (document.all) { this.ss.filters[0].apply();if(this.frame.style) this.frame.style.display="none";this.ss.filters[0].play(this.duration=this.time);this.fadeTimer=window.setTimeout("objs["+this.index+"].finish()",this.time*1000);this.transition=true;}
		else {this.next();this.mainTimer=window.setTimeout("objs["+this.index+"].start()",this.delay);}
	};
	this.finish=function(){if(this.ss==null||this.ss.children==null||!this.ss) return;this.transition=false;
		if(this.reverse){this.last_slide = this.current_slide;this.current_slide--;if (this.current_slide < 0) this.current_slide = this.children.length-1;this.frame=this.children[current_slide];if(this.frame==null||(this.IS_INTRO!='no'&&this.frame==this.ss.firstChild)) this.frame=this.children[this.children.length-1];this.reverse=false;}
		else{this.last_slide = this.current_slide;this.current_slide++;if (this.current_slide >= this.children.length) this.current_slide = 0;this.frame=this.children[this.current_slide];if(this.frame==null){ this.frame=children[0];if(this.IS_INTRO!='no') this.frame=this.children[1];}}
		this.update_number();this.parseDelay();this.ss.filters[0].apply();if(this.frame.style) this.frame.style.display="block";this.ss.filters[0].play(this.duration=this.time);this.mainTimer=window.setTimeout("objs["+this.index+"].start()",this.time*1000+this.delay);this.time=FADE;
	};
	this.pause=function(){ if(!this.transition && document.all){ window.clearTimeout(this.fadeTimer);window.clearTimeout(this.mainTimer);this.mainTimer=window.setTimeout("objs["+this.index+"].start()",(this.time*1000+this.delay));}};
	this.next=function(){if(!this.transition){window.clearTimeout(this.fadeTimer);window.clearTimeout(this.mainTimer);} this.last_slide=this.current_slide;this.frame.style.display='none';this.current_slide++;if (this.current_slide==this.children.length)this.current_slide=0;this.play();return false;};
	this.prev=function(){ if(!this.transition){window.clearTimeout(this.fadeTimer);window.clearTimeout(this.mainTimer);} this.last_slide=this.current_slide;this.frame.style.display='none';this.current_slide--;if (this.current_slide<0)this.current_slide=this.children.length-1;this.play();return false;};
	this.play=function() { this.frame=this.children[this.current_slide];if (this.frame.style) this.frame.style.display = 'block';this.update_number();if (!this.transition&&document.all) { this.parseDelay(); this.mainTimer=window.setTimeout("objs["+this.index+"].start()",this.time*1000+this.delay);}};
	this.change_slide=function(n) {if(!this.transition){window.clearTimeout(this.fadeTimer);window.clearTimeout(this.mainTimer);} this.last_slide=this.current_slide;this.current_slide=n;if(this.current_slide<0||this.current_slide>=this.children.length)this.current_slide=0;this.frame.style.display = 'none';this.play();};
	this.create_counter=function() { 
		var elm;
		if (!(elm=sister_or_parent(this.ss,'slide_counter'))) return;
		if (elm[1]) {this.slide_counter_table=elm[0];this.slide_counter=elm[1];} else{this.slide_counter_table=this.slide_counter=elm[0];}
		this.max_slides=this.children.length;
		for (var i=1;i<=this.max_slides;i++) this.slide_counter.innerHTML+='<span href="javascript:void(0);" id="slide_'+i+'" class="MainPromoFooter'+(i==1?'_Bold':'')+'"><a href="javascript:void(0);" onclick="objs['+this.index+'].change_slide('+(i-1)+');">&nbsp;'+i+'&nbsp;</a></span>';
		if (this.slide_counter_table) {
			if ((elm=get_childById(this.slide_counter_table,'previous_link'))) {elm.obj=this;elm.onclick=function() {this.obj.prev();return false;}}
			if ((elm=get_childById(this.slide_counter_table,'next_link'))) {elm.obj=this;elm.onclick=function() {this.obj.next();return false;}}
		}
		else {
			if ((elm=sister_or_parent(this.slide_counter, 'previous_link'))) {if (elm[1])elm=elm[1];else elm=elm[0]; elm.obj=this;elm.onclick=function(){this.obj.prev();return false;}}
			if ((elm=sister_or_parent(this.slide_counter, 'next_link'))) {if (elm[1])elm=elm[1];else elm=elm[0]; elm.obj=this;elm.onclick=function(){this.obj.next();return false;}}
		}
	};
	this.update_number=function() {if (!this.slide_counter) return;get_childById(this.slide_counter,'slide_'+(parseInt(this.last_slide)+1)).className = 'MainPromoFooter';get_childById(this.slide_counter,'slide_'+(parseInt(this.current_slide)+1)).className = 'MainPromoFooter_Bold';};
	this.parseDelay=function(){try {this.delay=parseInt(this.frame.delay);}catch(ex) {this.delay=DELAY;}if(FADE>this.delay) this.delay=DELAY;};
	this.init=function() {this.children = document.all?this.ss.all.tags('div'):this.ss.getElementsByTagName('DIV');if(this.ss==null||this.children==null) return;this.current_slide=0;this.frame=this.children[this.current_slide];this.parseDelay();this.ss.onmousemove=function() {this.obj.pause();return false;};this.mainTimer=window.setTimeout("objs["+this.index+"].start()",this.delay);this.create_counter();}
}

function get_childById(elm, id) {
  var node;var ret;
	for (var i=0;i<elm.childNodes.length;i++) {
	 if (i==0) node=elm.firstChild;else node=node.nextSibling;
	 if (node.nodeName.toLowerCase()=="#text")continue;
		if (node.id.toLowerCase()==id.toLowerCase()) {return node;}
		else if (node.id.toLowerCase()!=id.toLowerCase()) {if (node.childNodes.length>0) ret=get_childById(node, id);if (ret) return ret;}
	}
	return null;
}
function sister_or_parent(elm, id) {
  var test=elm;var test2;
	while(test&&test.nodeName!="TABLE") test=test.nextSibling;
	if (test&&(test.id==id||(test2=get_childById(test, id)))) return Array(test, test2);
	test=elm;
	while(test&&test.nodeName!="TABLE")test=test.parentNode;
	if (test&&(test.id==id||(test2=get_childById(test, id)))) return Array(test, test2);
	return null;
}

function initialize(){
  var ss;
	if (!document.getElementById && !document.all) return;
	if (!(ss=document.getElementsByName ('ss'))) return;
	if (ss.length) {for (var i=0;i<ss.length;i++) init_creator(ss[i]);}
	else {init_creator(ss);}
}
function init_creator(elm) {
		objs[objs.length]=elm.obj=new FadeCreator();elm.obj.index=objs.length-1;elm.obj.ss=elm;elm.obj.init();
}

window.onload=initialize;