var timer = null;
var n = 0;
var obj = null;
var delay = 20000;

var cText = 0x606060;
var cQLeft = 0xd2d2d2;
var cQRight = 0xd2d2d2;

var imgs = new Array();

//==================================================================================================
//
//==================================================================================================
function init(header)
{
	imgs[0] = new Image;
	imgs[0].src="img/bookmark.gif";

	imgs[1] = new Image;
	imgs[1].src="img/bookmarkLight.gif";

	var home = document.getElementById("Home");
	var contact = document.getElementById("Contact");
	var siteMap = document.getElementById("Sitemap");

	home.onmouseover = contact.onmouseover = siteMap.onmouseover = function()
		{
			this.parentNode.getElementsByTagName("img")[0].src = imgs[1].src;
			this.style.textDecoration = "underline";
		};
	home.onmouseout = contact.onmouseout = siteMap.onmouseout = function()
		{
			this.parentNode.getElementsByTagName("img")[0].src = imgs[0].src;
			this.style.textDecoration = "none";
		};
	insertFlashContent(header);
	timer = setInterval(startFadeOut, delay);
}

function insertFlashContent(flashHeader)
{
	var str = '';
		str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="572" height="186" id="menu" align="middle">';
		str += '<param name="allowScriptAccess" value="sameDomain" />';
        str += '<param name="movie" value="flash/menu02/loader.swf?header=' + flashHeader +  '"/>';
		str += '<param name="quality" value="high" />';
		str += '<param name="bgcolor" value="#ffffff" />';

		str += '<embed ';
		str += 'src="flash/menu02/loader.swf?header=' + flashHeader + '" ';
		str += 'quality="high" ';
		str += 'bgcolor="#ffffff" ';
		str += 'width="572" ';
		str += 'height="186" ';
		str += 'id="menu" ';
		str += 'name="menu" ';
		str += 'align="middle" ';
		str += 'allowScriptAccess="sameDomain" ';
		str += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
		str += '</embed>';
		str += '</object>';

	document.getElementById("flash").innerHTML = str;
}

//==================================================================================================
//
//==================================================================================================
function startFadeOut() {
	clearInterval(timer);
	timer = setInterval(fadeOut, 50);
}

//==================================================================================================
//
//==================================================================================================
function startFadeIn() {
	clearInterval(timer);
	timer = setInterval(fadeOut, 50);
}

//==================================================================================================
//
//==================================================================================================
function changeText()
{
	hipImg.src = "img/testimonials/" + arrHipLogos[pLogos++];
	hipText.innerHTML = arrHipText[pHip];
	hipSign.innerHTML = arrHipSigns[pHip++]

	if (pLogos == arrHipLogos.length)
		pLogos = 0;

	if (pHip == arrHipText.length)
		pHip = 0;

	timer = setInterval(fadeIn, 50);
}

//==================================================================================================
//
//==================================================================================================
function fadeOut()
{
	cText += 0x080808;
	cQLeft += 0x020202;
	cQRight += 0x020202;

	hipText.style.color = cText.toString(16);
	qLeft.style.backgroundColor = cQLeft.toString(16);
	qRight.style.backgroundColor = cQRight.toString(16);
	hipSign.style.color = cText.toString(16);;

	//window.status = cText.toString(16);

	if (cText.toString(16) == "f8f8f8") {
		clearInterval(timer);
		changeText();
	}
}

//==================================================================================================
//
//==================================================================================================
function fadeIn()
{
	cText -= 0x080808;
	cQLeft -= 0x020202;
	cQRight -= 0x020202;

	hipText.style.color = cText.toString(16);
	qLeft.style.backgroundColor = cQLeft.toString(16);
	qRight.style.backgroundColor = cQRight.toString(16);
	hipSign.style.color = cText.toString(16);;

	//window.status = cText.toString(16);

	if (cText.toString(16) == "606060") {
		clearInterval(timer);
		timer = setInterval(startFadeOut, delay);
	}
}