var tickBrief=[];



var tcontent="<font size="+ticker_font_size+"><img src=http://www.tennisinterview.com/ticker/icons/tn.jpg align=absmiddle /> <span  onmouseover=countClick(185,3);>Ana Ivanovic signs a lifetime contract with adidas</span>    <img src=http://www.tennisinterview.com/ticker/icons/tn.jpg align=absmiddle /> <span  onmouseover=countClick(188,3);>Justine Henin gets a wildcard for Indian Wells</span>    <img src=http://www.tennisinterview.com/ticker/icons/tn.jpg align=absmiddle /> <span  onmouseover=countClick(187,3);>Kim Clijsters will play Serena Williams in Madison Square Garden March 1</span>    <img src=http://www.tennisinterview.com/ticker/icons/tn.jpg align=absmiddle /> <span  onmouseover=countClick(186,3);>Several stars are skipping Rotterdam</span>    </font>";

ticker_speed = (document.all) ? ticker_speed : Math.max(1, ticker_speed-1);
var copyspeed = ticker_speed;
var pausespeed = (ticker_pause_onhover == 0) ? copyspeed : 0;
var ticker_pause_onhover = 1;
var ticker_position='';
if(ticker_center){
	var ticker_position='margin:auto;';
} else {
	var ticker_position='';
	var ticker_center='';

}

if(!ticker_brief_width){
	var ticker_brief_width='350';
}
if(!ticker_font_family){
	var ticker_font_family="arial";

}

function countClick(id, t){	
	document.getElementById('ticker_clicks').innerHTML="<iframe src='http://www.tennisinterview.com/ticker/functions/count.php?tid="+id+"&t="+t+"'></iframe>"; 
} 

function close_brief(){
	document.getElementById('ticker_news_brief').style.display='none';
} 
	
function fetch_brief(e, num){	
	
	var brief=document.getElementById('ticker_news_brief');
	
	if(!ticker_brief_width) return false; 
	
	brief.innerHTML='<img style="position:absolute; left:'+((parseInt(ticker_brief_width)/2)-10)+'px; top:-14px;" src=http://www.tennisinterview.com/point.gif />' + tickBrief[num];
	var xPos=mouseX(e)-((parseInt(ticker_brief_width)+8)/2);
	var divLeft=divX(document.getElementById('ticker_wrapper'));
	var boxPos=xPos-divLeft;
	brief.style.marginLeft=boxPos + 'px';
	brief.style.display='block';
	
	countClick(num,2); 
	
	return true;
	
}	

function divX(obj){
	var curleft=0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}
	return curleft;
}

function mouseX(evt) {
	if (evt.pageX){ 
		return evt.pageX;
	}else if (evt.clientX){
	   return evt.clientX + (document.documentElement.scrollLeft ?
	   document.documentElement.scrollLeft :
	   document.body.scrollLeft);
	} else {
		return null; 
	}
}

var actualwidth="";
var ticker_obj;

function ticker_build(){ 
	ticker_obj = document.getElementById("ticker_ticks");
	ticker_obj.style.left = parseInt(ticker_width)+8+"px";
	ticker_obj.innerHTML = tcontent;
	actualwidth = document.all ? ticker_width_test.offsetWidth : document.getElementById("ticker_width_test").offsetWidth;
	var w=parseInt(ticker_obj.style.left)+actualwidth;
	ticker_obj.style.width=w+'px';
	var lefttime = setInterval("ticker_scroll()",20); 
}

function ticker_scroll(){
    if (parseInt(ticker_obj.style.left) > (actualwidth*(-1)+8)) {
      ticker_obj.style.left=parseInt(ticker_obj.style.left)-copyspeed+"px"; 
    } else {
      ticker_obj.style.left=parseInt(ticker_width)+8+"px"; 
    }
} 

function display_ticker(){
	with (document) {
		write('<span id="ticker_width_test" style="visibility:hidden; position:absolute; top:-100000px;left:-100000px">'+tcontent+'</span>');
			
			write('<div id="ticker_wrapper" style="width:'+parseInt(ticker_width)+'px; font-family:'+ticker_font_family+'; color:'+ticker_text_color+';height:'+parseInt(ticker_height)+'px;background-color:'+ticker_bg_color+'; border:1px solid '+ticker_border_color+';overflow:hidden;position:relative;">');
				write('<div style="'+ticker_position+'; width:'+parseInt(ticker_width)+'px;">');	
					write('<div id="ticker_ticks" style="position:absolute;" onmouseover="copyspeed=pausespeed" onmouseout="copyspeed=ticker_speed"></div>');
					write('<div id="ticker_clicks" style="visibility:hidden; position:absolute; top:-9999px; left:-9999px; width:1px;height:1px; overflow:hidden;"></div>');
				write('</div>');
			write('</div>');		
			write('<div id="ticker_news_brief" style="position:absolute; z-index:1000; display:none; font-family:'+ticker_font_family+'; margin-top:10px; width:'+parseInt(ticker_brief_width)+'px; background-color:white; border:1px solid black; padding:10px;"></div>');
		getElementById('ticker_clicks').innerHTML="<iframe src='http://www.tennisinterview.com/ticker/functions/impression.php?id=12'></iframe>";	

		
	}
	
	
}	