var marker;
var zeros = "000000";
var currentNavigation;

function initMarker() {
	marker = domID('marker');
	marker.newX = 0;
	marker.x = 0;
	marker.alpha = 0;
	marker.red = 255;
	marker.green = 255;
	marker.blue = 255;
	
	marker.apv = 0;
	marker.fcv = 0;
	
	currentMainMenuItem = domID('currentMainNaviagtion');
	
	if(currentMainMenuItem){
		marker.alpha = 100;
		var tempColor = new Array("0x"+metaColor.slice(1,3), "0x"+metaColor.slice(3,5), "0x"+metaColor.slice(5,7));
		
		marker.red = marker.newRed = Number(tempColor[0]);
		marker.green = marker.newGreen = Number(tempColor[1]);
		marker.blue = marker.newBlue = Number(tempColor[2]);
		
		marker.style.backgroundColor = metaColor;
		marker.style.left = currentMainMenuItem.offsetLeft+"px";
		marker.x = currentMainMenuItem.offsetLeft;
		marker.newX = currentMainMenuItem.offsetLeft;
	}
	marker.orgX = marker.x;
	marker.orgAlpha = marker.alpha;
	
	if (marker.runtimeStyle) {
		marker.runtimeStyle.filter="Alpha(Opacity="+marker.alpha+")";
	} else {
		marker.style.opacity=marker.alpha/100;
	}
}

function setMarkerTo(e) {
	if(e && e.className){
		var tempColor=getCSSRule('.'+e.className).style.color;
		if(tempColor.indexOf("#") == 0){
			e.baseColor=new Array("0x"+tempColor.slice(1,3),"0x"+tempColor.slice(3,5),"0x"+tempColor.slice(5,7));
		}else{
			e.baseColor=tempColor.replace(/[^\d,]/ig, "").split(",");
		}
		if(marker){
			marker.newRed = Number(e.baseColor[0]);
			marker.newGreen = Number(e.baseColor[1]);
			marker.newBlue = Number(e.baseColor[2]);
			marker.newX = e.offsetLeft;
			clearInterval(marker.apv);
			clearInterval(marker.fcv);
			clearInterval(marker.fav);
			marker.apv = setInterval('animateProperty(marker, "left", "px", "x", "newX", "apv")', 20);
			marker.fcv = setInterval('fadeColor(marker, "backgroundColor", .1, "fcv")', 20);
			marker.fav = setInterval('fadeAlpha(marker, 100, "fav")', 20);
		}
	}
}

function rollover(e) {
		var tempColor=e.style.color ? e.style.color : getCSSRule('.'+e.className).style.color;
		if(tempColor.indexOf("#") == 0){
			tempColor=new Array("0x"+tempColor.slice(1,3),"0x"+tempColor.slice(3,5),"0x"+tempColor.slice(5,7));
		}else{
			tempColor=tempColor.replace(/[^\d,]/ig, "").split(",");
		}
		e.red = Number(tempColor[0]);
		e.green = Number(tempColor[1]);
		e.blue = Number(tempColor[2]);
		e.newRed = 255;
		e.newGreen = 255;
		e.newBlue = 255;
		clearInterval(e.apv);
		clearInterval(e.fcv);
		clearInterval(e.fav);
		//e.fcv=setInterval(function() {fadeColor(byTAG(e, 'A')[0], "color", .2, "fcv")}, 20);
}
function rollout(e) {
		var tempColor=getCSSRule('.'+e.className).style.color;
		if(tempColor.indexOf("#") == 0){
			e.baseColor=new Array("0x"+tempColor.slice(1,3),"0x"+tempColor.slice(3,5),"0x"+tempColor.slice(5,7));
		}else{
			e.baseColor=tempColor.replace(/[^\d,]/ig, "").split(",");
		}
		e.newRed = Number(e.baseColor[0]);
		e.newGreen = Number(e.baseColor[1]);
		e.newBlue = Number(e.baseColor[2]);
		clearInterval(e.apv);
		clearInterval(e.fcv);
		clearInterval(e.fav);
		//e.fcv=setInterval(function() {fadeColor(byTAG(e, 'A')[0], "color", .2, "fcv")}, 20);
}

function markerOut() {
	if (marker) {
		var tempColor = new Array("0x"+newMetaColor.slice(1,3), "0x"+newMetaColor.slice(3,5), "0x"+newMetaColor.slice(5,7));
		marker.newRed = Number(tempColor[0]);
		marker.newGreen = Number(tempColor[1]);
		marker.newBlue = Number(tempColor[2]);
		clearInterval(marker.apv);
		clearInterval(marker.fcv);
		clearInterval(marker.fav);
		marker.apv = setInterval('animateProperty(marker, "left", "px", "x", "orgX", "apv")', 20);
		marker.fcv = setInterval('fadeColor(marker, "backgroundColor", .1, "fcv")', 20);
		marker.fav = setInterval('fadeAlpha(marker, marker.orgAlpha, "fav")', 20);
	}
}

function checkCurrentMainNavigation() {
	if (currentMainMenuItem && marker) {
		marker.orgAlpha = 100;
		marker.orgX = currentMainMenuItem.offsetLeft;
	}
}