/* Swftype */
function doSwftype(swftypeTag, swftypeSrc, cssSrc, swftypeWidth, swftypeHeight, txtUpper, txtSelect, resizeType, debug)
{
	var elClassName = "";

	if(swftypeTag.indexOf(".") != -1){	
		elClassName = swftypeTag.substring(swftypeTag.indexOf(".")+1, swftypeTag.length);
		swftypeTag = swftypeTag.substring(0, swftypeTag.indexOf("."));
		if(swftypeTag.length==0)
		swftypeTag=elClassName;
	}	

	if(
		(document.getElementsByTagName(swftypeTag)) || 
		(document.getElementsByClassName(swftypeTag))
		)
	{	
		if(document.getElementsByTagName(swftypeTag).length > 0)											
			var theSwftypeTag = document.getElementsByTagName(swftypeTag);												
		else if(document.getElementsByClassName(swftypeTag).length > 0 )
			var theSwftypeTag = document.getElementsByClassName(swftypeTag);		
		else
			;

		if (!!theSwftypeTag)
        {            for (var i = 0; i < theSwftypeTag.length; i++) {
                var obj = theSwftypeTag[i];
                var tagName = obj.tagName;
                var className = obj.className;

                if (obj.className.indexOf(elClassName) != -1) {
                    className = obj.className;
                    obj.setAttribute('id', 'Swftype' + swftypeTag + i); 	// Swftype + H2 + 0	
                    if (obj.innerHTML != null) {
                        /* Swftype Content */
                        var pageTxt = obj.innerHTML;
                        // search and add ' in classNames 
                        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 + '"');
                            }
                        }
                        var printAlt = document.createElement("span");
                        // printAlt.setAttribute("class", "printSwfType");   
                        printAlt.className = "printSwfType";
                        printAlt.innerHTML = pageTxt;
                        obj.parentNode.appendChild(printAlt);
                        pageTxt = pageTxt.replace(/"/g, "'");
                        pageTxt = pageTxt.replace(/&/g, "{and}");
                    }
                    else {
                        var pageTxt = "DEFAULT";
                    }
                }
                /* swfobject2 */
                var flashvars = {};
                flashvars.cssURL = cssSrc;
                flashvars.txtUpper = txtUpper;
                flashvars.tagName = tagName;
                flashvars.className = className;
                flashvars.txtWidth = swftypeWidth;
                flashvars.txtHeight = swftypeHeight;
                flashvars.txtSelect = txtSelect;
                flashvars.resizeType = resizeType;
                flashvars.pageText = pageTxt;
                flashvars.debug = debug;
                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, textHeight, textWidth)
{		
	document.getElementById(SwftypeId).style.width = textWidth + "px";	
	document.getElementById(SwftypeId).style.height = textHeight + "px";
}

document.getElementsByClassName = function(elClassName)
{
    var arrayList = new Array();
    var elements = document.getElementsByTagName("*");
    for(var i = 0;i < elements.length;i++)
	 {
        if(elements[i].className.indexOf(" ") >= 0)
		  {
            var classes = elements[i].className.split(" ");
            for(var j = 0;j < classes.length;j++)
				{
               if(classes[j] == elClassName)
					{
                  arrayList.push(elements[i]);
					}
            }
        }
			else if(elements[i].className == elClassName)
			{
				arrayList.push(elements[i]);
			}		
    }
    return arrayList;
}

