﻿
function WriteFlash(div, swf, width, height, flashvar, transparency, background)
{
    if (background != "")
        globalso = new SWFObject(globalswfpath + swf, "flash" + div, width, height, globalswfversion, background);
    else
        globalso = new SWFObject(globalswfpath + swf, "flash" + div, width, height, globalswfversion);
        
         
    if (transparency == "1")
        globalso.addParam("wmode", "transparent");
    if (transparency == "2")
        globalso.addParam("wmode", "opaque"); 
    if (flashvar != "")
    {
        globalso.addParam("flashVars", flashvar);
    }
	globalso.addParam("allowScriptAccess", "always");
	globalso.addParam("allowFullScreen","true");
    globalso.write(div);

}




//requires jquery
$(document).ready(function(){
});
    //run through list of divs with classnames to setup flash    
    SetupFlash(".assetThumb");
	
	function SetupFlash(classname)
	{
         $(classname).each(
            function(intIndex) {
                var flashVars = "";                
                //creates flashvars, any class with _ will be the key
                $(this).find("*[@class^='_']").each(
                    function(intIndex) {
                        if (flashVars != "")
                        {
                            flashVars += "&";
                        }
                        var value = "";
                        
                        //fall through check for values, should be cleaned up
                        value = $(this).attr("href");
                       
                        
                        if (value == "" || value == undefined) {
                            value = $(this).attr("src");
                            }
                            
                        if (value == "" || value == undefined) {
                            value = $(this).html();
                            }
                            
                        value = value.replace("&", "%26");
                        flashVars += $(this).attr("class") + "=" + value;
                    }
                );
                
                //gets swf, height and width
                var height = $(this).attr("height");
                var width = $(this).attr("width");
                var swf = $(this).attr("flash");
                if (swf == undefined)
                    swf = $(this).children("*[@class='swf']").html();
                    

                WriteFlash($(this).attr("id"), swf, width, height, flashVars, "1", "");
                
            }
         );
    }






