
function trep(tagName,class_name,src,height,opt_align,strCase) {
	
	var flashvars;
	var params;
	var attributes;
	var el;
	var content;
	var width;
	var height;
	var cur_href;
	
	var els = new Array();
	els = document.getElementsByTagName(tagName);
	
	var len = els.length;
	
	for (var i=0; i < len; i++) {
		
		el = els[i];
		if (class_name == "" || (el.className.search(class_name) != -1)) {			
			
			cur_href = "";
			if (el.href != "undefined") {
				cur_href = el.href;
			}
			
			content = el.innerHTML;
			if (strCase == "u") {
				content = content.toUpperCase();
			}
			if (strCase == "l") {
				content = content.toLowerCase();
			}
			content = content.replace("&amp;","&").replace("&","%26");
			
			width = el.offsetWidth;
			width += Math.round(content.length * 2);
			
			if (opt_align == "c") {
				flashvars = {replace: content, href:cur_href};
				params = {wmode:"transparent", scale:"noscale", salign: "t"};
				attributes = {wmode:"transparent", align: "t"};
			} else {
				flashvars = {replace: content, href:cur_href};
				params = {wmode:"transparent", scale:"noscale", salign: "t"+opt_align};
				attributes = {wmode:"transparent", align: "t"+opt_align};
			}
			
			marginL = el.style.marginLeft;
			
			el.style.outline = "none";
			el.style.backgroundImage = "none";
			el.style.height = height+"px";
			el.style.margin = 0+"px";
			if (marginL != undefined && marginL != "") {
				el.style.marginLeft = marginL;
			}
			if (class_name == "nav-item") {
				el.style.float = "left";
				el.style.display = "block";
				el.style.width = 160+"px";
				el.style.padding = 0+"px";
				el.style.lineHeight = 26+"px";
				el.style.height = 26+"px";
				width += 5;
				var ua = navigator.userAgent.toLowerCase();
				if (ua.indexOf('safari/') != -1 || ua.indexOf('chrome') != -1) {
					el.style.margin = 0+"px";
				} else {
					el.style.margin = "0px 0px -5px 0px";
				}
			}			
			
			if (el.style.color != "") {
				if (el.style.color.search(/rgb/) != -1) {
					elRGB = el.style.color.replace("rgb(","").replace(")","").split(",");
					colorHex = RGBtoHex(elRGB[0],elRGB[1],elRGB[2]);
				} else {
					colorHex = el.style.color.replace("#","");
				}
				flashvars = {replace:content, color:colorHex, href:cur_href};
			}
			
			el.innerHTML = '<span id="'+tagName+'_'+i+'_content"></span>';
			
			swfobject.embedSWF(src, tagName+"_"+i+"_content", width, height, "8.0.0","expressInstall.swf",flashvars,params,attributes);	
		}
		
	}
	
}
function trep_init() {
	// H1
	trep("h1","","/H1.swf",21,"l","");
	// H2
	trep("h2","","/H2.swf",20,"l","");
	// Nav
	trep("a","nav-item","/NAV.swf", 22,"l","");
	
}

function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}