
/************************************
           Font Replacement  
   Flash Actionscipt and javascript 
      developed by N. Ben Layton
            for StoresOnline 
		     Copyright 2009	  
*************************************/

function changeFont(hT,hSize){
		// Get the tag
	var htags = document.getElementsByTagName(hT);
	var numOfh = htags.length;
		// approx height of flash - based on letter size
	var hHeight = eval(hSize) + 10;
			// Loop through the tags
		for(i=0;i<numOfh;i++){
					// gather content of the tag
				var content = htags[i].innerHTML;
				var contentLength = content.length;
					//determine number of CAPITALS
				var txt1 = content.replace(/[^A-Z]/g,"");
				var upperLetters = txt1.length;
					//determine number of lowercase
				var lowerLetters = contentLength - upperLetters;
					//The width of the letters according to their size. These may change depending on the font
				var upperSpan = upperLetters*hSize/1.2/contentLength
				var lowerSpan = lowerLetters*hSize/1.5/contentLength
					// Add the two
				var multiplier = upperSpan + lowerSpan ;
					// define the total width of the flash
				var stageWidth = content.length*multiplier
					//Keep it within 850px
					if(stageWidth > 850){
						stageWidth = 850;
						}
					// determine where the text will be placed inside the flash file
				var placementX = -stageWidth/2;
				var placementY = -hHeight/2;
						//putting it all together
				htags[i].innerHTML = '<embed src="http://www.storesonlinepro.com/store/1234/flash/helvaNue.swf" wmode="transparent" FlashVars="titleText='+content+'&hWidth='+stageWidth+'&hSize='+hSize+'&hPlaceX='+placementX+'&hPlaceY='+placementY+'" width="'+stageWidth+'" height="'+hHeight+'" allowScriptAccess="sameDomain" />';
		}
	}

// The following is just to allow multiple functions onLoad
function womOn(){
  window.onload = womGo;
}

function womGo(){
  for(var i = 0;i < woms.length;i++)
    eval(woms[i]);
}

function womAdd(func){
  woms[woms.length] = func;
}


// Change tags and sizes here
var woms = new Array();
womAdd('changeFont("h1","28")');
womAdd('changeFont("h2","24")');
womAdd('changeFont("h3","20")');
womAdd('changeFont("h4","18")');
womAdd('changeFont("h5","14")');
womOn();