/* Swftype */
function doSwftype(swftypeTag, swftypeSrc, swftypeWidth, swftypeHeight,cssReference){	
	var theSwftypeTag = document.getElementsByTagName(swftypeTag);		
	for(var i=0; i<theSwftypeTag.length; i++){	
	
		var obj = theSwftypeTag[i];
		var tagName = obj.tagName;	
		var className= "";
		
		if(obj.className){
			className = obj.className;
		}
		
		obj.setAttribute('id', 'swftype'+swftypeTag+i);		

		if(obj.innerHTML != null){
			/* Swftype Content */
			var pageTxt = obj.innerHTML;
			
			if(pageTxt.indexOf('class=') != -1){
			
				var firstQuote = (pageTxt.indexOf('class=') + 6);
				var spanCloseTag = pageTxt.indexOf('>');
				var className = pageTxt.substr(firstQuote, (spanCloseTag - firstQuote));
				
				if(pageTxt.charAt(firstQuote) != '"'){
					pageTxt = pageTxt.replace(className,'"'+className+'"');
				}
			}		
			
			pageTxt = pageTxt.replace(/"/g, "'");
			pageTxt = pageTxt.replace(/&/g, "{and}");	
			// alert("Tag name: " + tagName + ", Class name: " + className + ", Page text: " + pageTxt);
		}else{
			var pageTxt = "DEFAULT";
		}
		/* swfobject2 */
		var flashvars = {};
		// flashvars.cssURL = '/css/swftype.css';
		flashvars.cssURL = cssReference;		
		flashvars.txtUpper = true;
		flashvars.tagName = tagName;
		flashvars.className = className;
		flashvars.txtWidth = swftypeWidth;
		flashvars.txtHeight = swftypeHeight;
		var params = {};
		params.allowScriptAccess = "always";
		params.menu = "false";
		params.wmode = "transparent";
		var attributes = {};		
		swfobject.embedSWF(swftypeSrc + "?pageTxt=" + pageTxt + "&swftypeID=swftype"+swftypeTag+i, "swftype" + swftypeTag + i, swftypeWidth, swftypeHeight, "8", "false", flashvars, params, attributes);			
	}
}

/* Swftype Resize */
function resizeSwftype(swftypeId, newHeight){
	document.getElementById(swftypeId).style.height = newHeight + "px";
}

