;(function() {
    var $$ = jQuery.fn.flash=function(htmlOptions,pluginOptions,replace,update) {
        var block=replace||$$.replace;
        pluginOptions=$$.copy($$.pluginOptions,pluginOptions);
        if(!$$.hasFlash(pluginOptions.version)) {
            if(pluginOptions.expressInstall&&$$.hasFlash(6,0,65)) {
                var expressInstallOptions= {
                    flashvars: {
                        MMredirectURL:location,
                        MMplayerType:'PlugIn',
                        MMdoctitle:jQuery('title').text()
                    }
                };
            } else if (pluginOptions.update) {
                block=update||$$.update;
            } else {
                return this;
            }
        }
    htmlOptions=$$.copy($$.htmlOptions,expressInstallOptions,htmlOptions);
    return this.each(function() {
        block.call(this,$$.copy(htmlOptions));
    });
};
$$.copy=function() {
    var options={},flashvars={};
    for(var i=0;i<arguments.length;i++) {
        var arg=arguments[i];
        if(arg==undefined)continue;
        jQuery.extend(options,arg);
        if(arg.flashvars==undefined)continue;
        jQuery.extend(flashvars,arg.flashvars);
    }
    options.flashvars=flashvars;
    return options;
};
$$.hasFlash=function() {
    if(/hasFlash\=true/.test(location))return true;
    if(/hasFlash\=false/.test(location))return false;
    var pv=$$.hasFlash.playerVersion().match(/\d+/g);
    var rv=String([arguments[0],arguments[1],arguments[2]]).match(/\d+/g)||String($$.pluginOptions.version).match(/\d+/g);
    for(var i=0;i<3;i++) {
        pv[i]=parseInt(pv[i]||0);
        rv[i]=parseInt(rv[i]||0);
        if(pv[i]<rv[i])return false;
        if(pv[i]>rv[i])return true;
    }
    return true;
};
$$.hasFlash.playerVersion=function() {
    try{
        try {
            var axo=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
            try {
                axo.AllowScriptAccess='always';
            } catch(e) { return'6,0,0'; }
        } catch(e){}
        return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g,',').match(/^,?(.+),?$/)[1];
    } catch(e) {
        try {
            if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){return(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g,",").match(/^,?(.+),?$/)[1];}
        } catch(e){}
    }
    return'0,0,0';
};
$$.htmlOptions= {
    height:'100%',
    flashvars:{},
    pluginspage:'http://www.adobe.com/go/getflashplayer',
    src:'#',
    type:'application/x-shockwave-flash',
    width:'100%'
};
$$.pluginOptions= {
    expressInstall:false,
    update:true,
    version:'6.0.65'
};
$$.replace=function(htmlOptions) {
	this.innerHTML = $$.transform(htmlOptions)+'<div class="alt">'+this.innerHTML+'</div>';
	jQuery(this)
		.addClass('flash-replaced')
};
$$.update=function(htmlOptions) {
    var url=String(location).split('?');
    url.splice(1,0,'?hasFlash=true&');
    url=url.join('');
    var msg='<p>This content requires the Flash Player. <a href="http://www.adobe.com/go/getflashplayer">Download Flash Player</a>. Already have Flash Player? <a href="'+url+'">Click here.</a></p>';
    this.innerHTML='<span class="alt">'+this.innerHTML+'</span>';
    jQuery(this)
        .addClass('flash-update')
        .prepend(msg);
};
function toAttributeString() {
    var s='';
    for(var key in this)
        if(typeof this[key]!='function')
            s+=key+'="'+this[key]+'" ';
    return s;
};
function toFlashvarsString() {
    var s='';
    for(var key in this)
        if(typeof this[key]!='function')
            s+=key+'='+encodeURI(this[key])+'&';
        return s.replace(/&$/,'');
};
$$.transform=function(htmlOptions) {
    htmlOptions.toString=toAttributeString;
    if(htmlOptions.flashvars)htmlOptions.flashvars.toString=toFlashvarsString;
    return'<embed '+String(htmlOptions)+'/>';
};
if(window.attachEvent) {
    window.attachEvent("onbeforeunload",function() {
        __flash_unloadHandler=function(){};
        __flash_savedUnloadHandler=function(){};
    });
}
})();

function setFlashWidth(newWidth){
    divid = 'collage-image';
    $('#'+ divid).animate({height: newWidth}, "slow");
//    $('#'+ divid).css('width', newWidth+'px');
//    $('#'+ divid).animate({height: newHeight}, 'normal');
}
function setFlashHeight(newHeight){
    divid = 'collage-image';
//    $('#'+ divid).animate({height: newHeight}, "slow");
   $('#'+ divid).css('height', newHeight+'px');
//    $('#'+ divid).animate({height: newHeight}, 'normal');
}
function setFlashSize(newWidth, newHeight){
	setFlashWidth(divid, newWidth);
	setFlashHeight(divid, newHeight);
}

$(function(){
    if(document.URL.match('/index4.html','i') ) {
        $('#media-inner').flash({
            wmode: 'transparent',
		    src: '/momenta/jostein/includes/flash/ddip_v2.swf',
    		width: 777,
	    	height: 329
    	},
	    {
	        version: 8
    	});
    } else if(document.URL.match('/index3.html','i') ) {
        $('#media-inner').flash({
            wmode: 'transparent',
		    src: '/momenta/jostein/includes/flash/verdikjede.swf',
    		width: 777,
	    	height: 329
    	},
	    {
	        version: 8
    	});
    }else if(document.URL.match('/index2.html','i') ) {
        $('#media-inner').flash({
            wmode: 'transparent',
		    src: '/momenta/jostein/includes/flash/levSubterranean.swf',
    		width: 777,
	    	height: 329
    	},
	    {
	        version: 8
    	});
    }else if(document.URL.match('Futuragruppen','i') ) {
        $('#media-left').flash({
            wmode: 'transparent',
		    src: '/momenta/jostein/includes/flash/straws.swf',
    		width: 580,
	    	height: 329
    	},
	    {
	        version: 8
    	});
    } else if(0){
//		    src: '/momenta/jostein/includes/flash/levTextSpace.swf',
        $('#media-inner').flash({
            wmode: 'transparent',
		    src: '/momenta/jostein/includes/flash/levTextSpace.swf',
    		width: 777,
	    	height: 329
    	},
	    {
	        version: 8
    	});
    }
});

