/* 	
	File: homePage.js
	Description: Functions unique to the Fender.com home page.
	Author: Brad W. Traweek -- Web Architect

	Contents copyright 2001 Fender Musical Instruments Corporation.
	All rights reserved.
*/

function startMarquee(stopPromoTrack, promoName, promoLink) {
	if(stopPromoTrack) {
		stopMe();
/* Get rid of the marquee functionality for now.
		document.images['PROMO_COPY'].src = '/home/track/' + promoName + '_copy.gif';
		if(ie) {
			document.all.promo_link.href = promoLink;
		} else if(ns4) {
			document.links[0].href = promoLink;
		} else if(ns6) {
			document.links[0].href = promoLink;
		}
*/
	}
/*
	if(ie) {
		document.all.marquee.background = "/home/images/marquee_anim.gif";
	}
*/	
}
function stopMarquee(startPromoTrack) {
/* Get rid of the marquee functionality for now.
	if(ie) {
		document.all.marquee.background = "/home/images/spacer.gif";
	}
*/
	if(startPromoTrack)
		startSlide(lastDir, 2);
}

function setPromoWidth(){
 	if(ie){
		document.all.promos.style.clip = "rect(" + 10 + "," + 1500 + "," + 200 + "," + 0 + ")" ;
		document.all.promos.style.width = 800;
		document.all.promos.style.visibility = "visible";
		document.all.dummypd.style.visibility = "hidden";
	} else if(ns4){
		document.layers.promos.document.width = 800;
		document.layers.promos.clip.right = 800;
		document.layers.promos.visibility = "show";
		document.layers.dummypd.visibility = "hidden";
  	} else if(ns6){
		document.getElementById('promos').style.width = 800;
		document.getElementById('promos').style.visibility = "visible";
		document.getElementById('dummypd').style.visibility = "hidden";
	}
}

var blinks = 0;
var ticker_text = '';
var ticker_link = '';

var count = 0;
var tk_id = 0;
var lap = 0;
var mta = new Array();
for (i=0, j=0;  i<21; i++, j+=30) {
	mta[i] = 600 - j ;
	//alert(mta[i])
}

function test_write() {
	wtl = document.layers['myTicker'].document.layers['myTickerInput'].document;
	wtl.open();
	wtl.write('<span class="txt">rewrite<\/span>');
	wtl.close();
}

function tk_ready() {
	var timeout; 
	if(count != 0)
		timeout = 3000;
	else
		timeout = 20;
		
	count = 0;
	(ie)?document.all.tickerInput.style.pixelLeft = 600 : (ns4)?document.layers['ticker'].document.layers['tickerInput'].left = 600 :document.getElementById('tickerInput').style.left = 600;

	ticker_normal = "<TABLE CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\"><TR><TD VALIGN=\"TOP\" NOWRAP CLASS=\"txt\"><A HREF=\"" + tk_link[tk_id] + "\">" + tk_array[tk_id] + "</A></TD><TD WIDTH=\"10\"><IMG SRC=\"/home/images/spacer.gif\" WIDTH=\"10\"></TD><TD CLASS=\"txt\"><A HREF=\"" + tk_link[tk_id] + "\"><IMG SRC=\"/home/images/click_tiny.gif\" WIDTH=\"56\" HEIGHT=\"16\" BORDER=\"0\"></A></TD></TR></TABLE>";

	if(ie) {
		document.all.tickerInput.innerHTML = ticker_normal;
	} else if (ns4) {
		wtl = document.layers['ticker'].document.layers['tickerInput'].document;
		wtl.open();
		wtl.write('<span class="txt">' + ticker_normal + '<\/span>');
		wtl.close();
	} else if (ns6) {
		document.getElementById('tickerInput').innerHTML = ticker_normal;
	}

	if(tk_id < tk_array.length-1) {
		setTimeout('runTicker()', timeout);
		tk_id++
	} else {
		tk_id = 0
		setTimeout('runTicker()', timeout);
	}
}

function runTicker(){
	var lpos = (ie)?document.all.tickerInput.style.pixelLeft : (ns4)?document.layers['ticker'].document.layers['tickerInput'].left : document.getElementById('tickerInput').style.left;
// alert('this is tkr-leftpos   ' + lpos)
	if(count <  21){
		(ie)?document.all.tickerInput.style.pixelLeft = mta[count] : (ns4)?document.layers['ticker'].document.layers['tickerInput'].left = mta[count]: document.getElementById('tickerInput').style.left= mta[count];
		count++;
		lap = setTimeout('runTicker()', 10);
	} else {
		clearTimeout(lap);
		blinks = 0;
		setTimeout('tk_ready()', 2500);
	}
}

