//window.addEvent('load', function(){

function initFancyUpload(){
    // For testing, showing the user the current Flash version.
    //document.getElement('#tester').appendText(' Detected Flash ' + Browser.Plugins.Flash.version + '!');
    
    // sets get values to action url of form
	myForm = $('dropoffForm').action;
	myForm += '?mytargethidden=' + escape(document.getElementById('mytargethidden').value);
	myForm += '&myteamhidden=' + escape(document.getElementById('myteamhidden').value);
	myForm += '&mycpemailhidden=' + escape(document.getElementById('mycpemailhidden').value);
	myForm += '&mycommenthidden=' + escape(document.getElementById('mycommenthidden').value);
	myForm += '&mynamehidden=' + escape(document.getElementById('mynamehidden').value);
	myForm += '&myemailhidden=' + escape(document.getElementById('myemailhidden').value);
	myPhoneNumber = document.getElementById('myphonehidden').value.replace("+","00");
	myForm += '&myphonehidden=' + escape(myPhoneNumber);
	
	$('dropoffForm').action = myForm;

    var swiffy = new FancyUpload2($('demo-status'), $('demo-list'), {
        url: $('dropoffForm').action,
        fieldName: 'Filedata',
        path: '/Swiff.Uploader.swf',
        limitSize: 2000000 * 1024 * 1024, // 2Mb
        onLoad: function(){
            $('demo-status').removeClass('hide');
            $('demo-fallback').destroy();
        },
		onAllComplete: function(){
			document.getElementById('demo-startover').style.display = "";
			document.getElementById('demo-upload').style.display = "none";
		},
        // The changed parts!
        debug: true, // enable logs, uses console.log
        target: 'demo-browse' // the element for the overlay (Flash 10 only)
    });

    /**
     * Various interactions
     */
    $('demo-browse').addEvent('click', function(){
        /**
         * Doesn't work anymore with Flash 10: swiffy.browse();
         * FancyUpload moves the Flash movie as overlay over the link.
         * (see opeion "target" above)
         */
        swiffy.browse();
        return false;
        
    });

    /**
     * The *NEW* way to set the typeFilter, since Flash 10 does not call
     * swiffy.browse(), we need to change the type manually before the browse-click.
     */
	/*
    $('demo-select-images').addEvent('change', function(){
    
        var filter = null;
        if (this.checked) {
            filter = {
                'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png'
            };
        }
        swiffy.options.typeFilter = filter;
        
    });*/
    
    
    $('demo-clear').addEvent('click', function(){
        swiffy.removeFile();
        return false;
    });
    
    $('demo-upload').addEvent('click', function(){
        swiffy.upload();
        return false;
    });
    
    
    
}