var aRegistry = new Array();
var BROWSER_IE6 = $.browser.msie && $.browser.version.indexOf('6.') >= 0;

$(launch);

function launch() {
	if ( BROWSER_IE6 )
		setTimeout(function(){
		 	$(".messages, .errors").remove();
		 }, 2000);
	
	if ( $('body .main').is('.not-logged') ) {
		user_not_logged_in();
	} else {
		user_logged_in();
	}
}

function user_not_logged_in() {
	loginbox();
	dyn_layout('.not-logged');
}

function user_logged_in() {		
	profile_edit();
	groups_edit();
	group_links();
	bookmarks();
	layout();	
	link_edit_account_settings();	
	link_edit_icon();	
	link_edit_avatar();	
	search();	
	
	if (in_admin()) {
		avatar_menu();
		admin_open();
		admin_defaultwidgets();
	}
	else {
		contact_add_remove();
	}
	
	//panneau edition avatar
	if ( EDITICON_ONLOAD )
		$('.toggle-edit-icon').click();
	
	widgets_layout();	
	
	$(".widget-latestcontributions").find(".breadcrumbs").each(function(){
		$(this).find('a:first').addClass('first');
		$(this).find('a:last').addClass('last');
	})
	
}


/* cropping tool */
var EDITICON_ONLOAD = false;
var USER_MASTER_IMAGE;
var EDIT_ICON_ID = '';

$(window).load(	function(){
	editicon_init();
});

//variables for the newly cropped avatar
var $x1, $y1, $x2, $y2, $w, $h;

function editicon_init() {	
	if ( $.trim( EDIT_ICON_ID ) == '' )
		return;
		
	aRegistry['wiki-edit-img'] = new Array();

	if ( 	! $('#' + EDIT_ICON_ID + '_preview').is('div')	
			&& 	! $('#' + EDIT_ICON_ID + '_preview_title').is('div') 
		) {
			
		$('<div id="' + EDIT_ICON_ID + '_preview" class="current-image-preview"><img src="' + USER_MASTER_IMAGE + '" /></div>').insertAfter($('#' + EDIT_ICON_ID));    
   	 	//$('<div id="' + EDIT_ICON_ID + '_preview_title"><label>Preview</label></div>').insertBefore($('#' + EDIT_ICON_ID + '_preview'));
	}
	//this produces the coordinates
	editicon_img();
}

function editicon_img() {	
	$('#' + EDIT_ICON_ID).imgAreaSelect({ selectionOpacity: 0, onSelectEnd: editicon_selectChange });
		//show the preview
		//aspectRatio: '1:1',
		
	if (EDIT_ICON_ID == 'user_avatar')	{
		var options = { aspectRatio: '1:1', onSelectChange: editicon_preview }
	} else {
		var options = { onSelectChange: editicon_preview }
	}
		
	$('#' + EDIT_ICON_ID).imgAreaSelect( options );
	
	$('.imgAreaSelect-element').show();
	
}

function editicon_preview(img, selection) {
    var origWidth = $('#'+EDIT_ICON_ID).width(); //get the width of the users master photo
    var origHeight = $('#'+EDIT_ICON_ID).height(); //get the height of the users master photo
    var scaleX = 100 / selection.width; 
    var scaleY = 100 / selection.height; 
	
    $('#'+EDIT_ICON_ID+'_preview > img').css({ 
        width: Math.round(scaleX * origWidth) + 'px', 
        height: Math.round(scaleY * origHeight) + 'px', 
        marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', 
        marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' 
    }); 
} 
						        
function editicon_selectChange(img, selection){
	//populate the form with the correct coordinates once a user has cropped their image
	document.getElementById(EDIT_ICON_ID+'_x_1').value = selection.x1;
	document.getElementById(EDIT_ICON_ID+'_x_2').value = selection.x2;
	document.getElementById(EDIT_ICON_ID+'_y_1').value = selection.y1;
	document.getElementById(EDIT_ICON_ID+'_y_2').value = selection.y2;
}    

/* end cropping tool */

function group_links() {
	if ( ! inURL('/groups/'))
		return;

	if ( window.location.href.indexOf('pg/groups/new') != -1 )$('.embed_media').remove();
	
	$('#groups_info_wide').remove(); var i=0;
	
	$('#group-links').each(function() {
		//TODO:php
		var $menu = $('<div id="group-menu"></div>');
		
		$(this).find('a').each(function() {			
			if (i==0)
				$(this).addClass('first')
			
			// si on peux associer des fichiers a des fils de discussion on supprime le lien 
			if ($(this).text() =="Group files" ){
				$(this).remove();
			}else{
				$menu.append($(this));
			}
			i++;	
		})
		
		$menu.append($('<div class="clear-both"></div>'));		
		$menu.insertAfter($('#content_area_group_title'));
	});
}

function bookmarks() {
	if ( !inURL('/bookmarks/') )
		return;
			
	$('#content .bookmark-url:eq(0)').each(function() {
		//TODO:php
		$('#content').addClass('layout-bookmarks');
	});	
	
	$('#bookmarks-add-form [name=title]').focus(form_field_value_listener);
	
	$('#bookmarks-add-form').submit(function() {
		var $title = $(this).find('[name=title]');
		if ( $.trim($title.val())=='' ||	! $title.is('.modified') ) {
			messages_pop('Please add a title', '.messages_error');
			return false;
		}
	});
}

function loginbox() {
	$('#login-box #username').each(function() {
		this.blur();
		this.focus();
	});
}

function link_edit_account_settings() {
	$('.toggle_customise_edit_account_settings').click(function(){
			$('.edit-widgets-panel').hide();
			$('.edit-icon-panel').hide();
			$('.edit-users-settings-panel').show();
			return false;
		}
	);
}

function link_edit_icon() {
	$('.toggle-edit-icon').click(function(){
			$('.edit-widgets-panel').hide();
			$('.edit-icon-panel').show();			
			//dyn_layout('.edit-icon-panel');
			$('.edit-users-settings-panel').hide();
			$('.imgAreaSelect-element').show();
			editicon_init();
			
			// on test la taille de l image, on verifie quelle 
			// a une taille minimun
			img = $('.imgAreaSelect-element:eq(2)');
			large =  img.width();
			haut =  img.height();
			if (large < 100 || haut < 100){
				$("#profile_picture_croppingtool").html("<p>The minimun size for an image is 100*100, please upload a bigest image</p>").css('color','red');
			}
			
			return false;
		}
	);
}

function profile_edit() {
	if ( ! inURL('/profile/') )
		return;
	
	$('#profile-edit').each(function () {
		var $infos = $(this).find('.add17:eq(0)');
		$infos.append('<ul></ul>');
		var $ul = $infos.find('ul');
		var $li_function = $(this).find('.admin_defined_profile_0');
		$li_function.appendTo($ul);
		var $li_location = $(this).find('.admin_defined_profile_1');
		$li_location.appendTo($ul);	
		
		form_fields_of_interest( $(this).find('[name=admin_defined_profile_6]') );
	});
}

function groups_edit() {
	if (! inURL('/groups/') )
		return;
	
	$('#groups-form-edit').each(function() {
		form_fields_of_interest( $('#groups-fields-of-interest') );
	});
	
	$('#groups-forum-add-topic [name=topictitle]').focus(form_field_value_listener);
	
	$('#groups-forum-add-topic').submit(function() {
		var $title = $(this).find('[name=topictitle]');
		
		if ( $.trim( $title.val() ) == '' || ! $title.is('.modified') ) {
			messages_pop('Please add a topic title', '.messages_error');
			return false;
		}
	});
}

function form_field_value_listener() {
	if ( !$(this).is('.modified') ) {
		$(this).val('');
		$(this).addClass('modified');
	}		
}

function form_fields_of_interest($fields) {
	$fields.hide();
	var fields 	= $fields.val().split("||");		
	var $form 	= $fields.parents('form');
	
	var $selectCat = select_categories();
	$selectCat.insertAfter($fields);
	$selectCat.find('select').dropdownchecklist({ maxDropHeight: 200, width: 226 });
	
	for (var i=0; i<fields.length; i++) {
		//console.log('.ui-dropdownchecklist-dropcontainer-wrapper input[value='+$.trim(fields[i])+']')
		$('.ui-dropdownchecklist-dropcontainer-wrapper input').each(function() {
			var value = $(this).val();
			if (value == fields[i]) {
				$(this).attr('checked', true);
			}
		});
	}
	
	$form.submit(function() {
		var fields = '';
		
		$('.ui-dropdownchecklist-dropcontainer-wrapper input').each(function() {
			var checked = $(this).attr('checked');
			var value = $.trim($(this).val());
			
			if (checked)
				fields += value+'||';
		});
						
		$fields.val(fields);
	});
}

function search() {
	$('#searchText').focus(function() {
		$('.adv-search').each(function() {
			$(this).appendTo('.main');
			$(this).show();
			$(this).find('a').click(function() {
				$('.adv-search').hide();
				return false;
			})
		});
		
		$(this).val('');
	});
	
	$('#search').submit(function() {
		var search_mode = $('input[name=search-mode]').val();
		var search_value= $('#searchText').val();
		var action = '';
				
		$('#search-mode-2:checked').each(function() {
			action = '/mod/members/?tag='+encodeURI(search_value)+'&subtype=&object=user&filter=search';
		});
		
		$('#search-mode-3:checked').each(function() {
			action = '/search/?tag='+encodeURI(search_value)+'&subtype=&object=group&tagtype&filter=search&owner_guid=0';
		});
		
		if (action=='') {
			return true;
		} else {
			 window.location = action;
			 return false;
		}
	});
	
	$('.mw-searchresult:eq(0)').each(function() {
		$('#content .add15').hide();
		$('#content .content-add06 h3').text('Search results');
		var $search = $('#contentSub b').text();
		search = $.trim($search.replace("-draft]",""));
		$('#contentSub p').html('<span class="you-searched-for">You searched for <strong>&quot;' + search + '&quot;</strong>.</span>');
		$(this).hide();
		
		$('#comments-wrapper, #bt-edit-bottom').hide();
	});
}

function layout() {	
	if (inURL('/wiki/'))
		layout_wiki();		
}

function layout_widget($widget) {
	$widget.find('ul').each(function() {
		//	$(this).find('li:eq(0)').addClass('first');
	});
}

function layout_wiki() {
	$('#content .content-add07 .contents').each(function() {
		$summary = $(this);
		$summary.prependTo('#widgets_right');
		$summary.find('.hide').click(function() {
			var $menu	= $summary.find('.menu');
			var $header	= $(this).parent();
			
			if ($(this).text()=='| Hide |') {
				$summary.find('.menu').hide();
				$(this).text('| Show |');
				$header.css({paddingBottom:'5px', borderBottom:'none'});
			} else {
				$summary.find('.menu').show();
				$(this).text('| Hide |');
				$header.css({paddingBottom:'11px', borderBottom:'1px solid #C6CDD6'});
			}
			return false;
		});
		$(this).show();
	})	
	
	$('.wiki-page-questions_and_answers').each( function() {	
		/*$(this).find('#wiki-contents p:eq(0)').each(function() {
			var $person = $('#content .add15 .person01');		
			$(this).insertBefore($person);
			$(this).addClass('question');
		});	*/
		
		if ( $(this).is('.wiki-admin-content_type_question') )	{
			$('#expert-answer .answer .text').click(edit_full_page);
		}
	});
	
	//$('.wiki-page-questions_and_answers #wiki-contents b:eq(0)').remove();
	
	/*$('#content.wiki-page-questions_and_answers .content-add06 .image07').each(function() {
		$(this).html('<a href="/pg/profile/boutheina"><img border="0" title="Boutheina Trabelsi" src="/mod/profile/icondirect.php?lastcache=1251884300&amp;username=boutheina&amp;size=small"/></a>');
	});
	
	$('#content.wiki-page-questions_and_answers .content-add06 .add13 p').each(function() {
		$(this).html('<span class="info-0"><a href="/pg/profile/boutheina">Boutheina Trabelsi</a></span><span class="info-1">, Tunisia - Tunis</span><span class="info-2">, HR Assistant</span>');
	});*/
	
	//image pour les liens vers des fichiers
	$('#wiki-contents p>a:only-child').each(function() {
		if (! $(this).is('.image') ) {
			$(this).addClass('download-file');
		}
	});
	
	layout_overview();
	layout_comments();		
	page_end();
	img_legends();
	edit_layout();
	fix_file_links();
}

function layout_overview() {
}

function layout_dashboard_zoom() {
	$('#content .widget-latestcasestudy').each(function() {		
		var $box1add = $(this).find('.box01-add');
		$box1add.prepend('<div id="zoom-tab-buttons"><ul class="tab"></ul></div>');
		var $zoomTabButtons = $('#zoom-tab-buttons');
		
		var i=0;
		
		$box1add.find('.tab-contents h3').each(function() {
			$zoomTabButtons.find('.tab').append('<li><a href="#" class="tab-link" rel="'+i+'">'+$(this).text()+'</a></li>');
			$(this).remove();
			i++;
		});	
				
		$zoomTabButtons.find('.tab-link').click(function() {
			var rel=$(this).attr('rel');
			$zoomTabButtons.find('.tab-link').removeClass('active');
			$(this).addClass('active');
			$box1add.find('.tab-contents li').hide();
			$box1add.find('.tab-contents li:eq('+rel+')').show();	
			return false;
		})	
		
		$zoomTabButtons.find('.tab-link:eq(0)').click();	
	});
}

function layout_comments() {
	$('#content .content-add07').each(function() {
		$(this).append('<div id="comments-wrapper"></div>');
		$('body').append('<div id="comments-memory"></div>');
		
		$(this).find('.comment-box-processed:eq(0)').each(function() {			
			$('#comments-wrapper').append(	'<div id="comments-list" class="content-box01">'
									+			'<div class="top"></div>'
									+			'<div class="center">'
									+				'<div class="box01">'
									+					'<div class="add01"><h3>Comments</h3></div>'
									+					'<div class="add02"></div>'
									+				'</div>'
									+			'</div>'
									+			'<div class="bottom"></div>'
									+		'</div>'
								);
								
			$('#wiki-contents .comment-box').appendTo('#comments-memory');
		});									
											
		$(this).find('.comment-box-processed').appendTo($('#comments-list .add02'));
		$(this).find('.comment-add-box').appendTo($('#comments-wrapper'));
	});
}

function layout_columns_fix() {
	var wrh 	= $('#widgets_right').height();
	var comh	= $('#comments-wrapper').height();
	var wch 	= $('#wiki-contents').height();
	var cah		= $('#content .content-add06').height();
	var inNews	= $('#content').is('.wiki-page-news');
	
	if ( wrh > wch+comh+20 ) {
		$('#comments-wrapper').height(wrh-(inNews ? wch+comh+cah : wch+comh));
	}
}

function dyn_layout(start) {
	$(start + ' .dyn-box-corners').each(function() {	
		if ( $(this).parents('.edit-widgets-panel').is('div') )
			return;
			
		$(this).html(dyn_layout_box_corners($(this)));
		
		$(this).find('.dyn-inner-box').each(function() {
			$(this).html(dyn_layout_box_corners($(this)));
		})
	});
}

function dyn_layout_box_corners($box) {
	var html = $box.html();
	return 	'<div class="row-head"><div class="bg1"><div class="bg2"><div class="bg3"></div></div></div></div>'
			+ 	'<div class="row-body"><div class="row-body-wrapper">' 
			+ 	html 
			+ 	'<div class="clear-both"></div></div></div>'
			+	'<div class="row-foot"><div class="bg1"><div class="bg2"><div class="bg3"></div></div></div></div>';
}

function link_edit_avatar() {
	$('.toggle-edit-icon-feature').click(function() {
		$('.admin-panel-edit-icon-feature').show();		
		$('.admin-panel-edit-user-settings-feature').hide();
		return false;
	})
}

function admin_panel_close() {	
	$('.edit-widgets-panel').hide();
	$('.edit-icon-panel').hide();
	$('.edit-users-settings-panel').hide();
	$('.imgAreaSelect-element').hide();
	return false;
}

/* asynchrone */

function widget_ajax_all_callbacks() {
	$(this).each(widget_bottom_links);
	$(this).each(widget_ajax_callback);
}

function widget_ajax_callback() {
	$(this).find('.ajax-callback').each(function() {		
		var func = eval('window.'+$(this).val());
		if (func)
			func();
	});
}

function in_admin(){	
	if ( window.location.href.indexOf('pg/defaultwidgets') >= 0
			|| window.location.href.indexOf('/admin/') >=0	
	) {
		return true;
	}
}

function widget_bottom_links(){
	//#MODIF Coop Com# les liens du bas sont évalués en JS
	
	
	$widget = $(this).parents('.widget');
	var id = $widget.attr('id');
	
	$(this).find(".js-to-eval").each(function(){
		var js = $(this).val();
		
		if ($.trim(js) != '') {
			var $bottom = $widget.find(".bottom");
			$bottom.append('<ul></ul>');
			
			var $bottom_ul = $bottom.find('ul');
			var opts = js.split("|");
			
			var j = 0;
			
			for (i in opts) {
				var opt = opts[i];
				if ($bottom_ul.find('.' + opt).is('li')) {
					continue;
				}
				else {
					switch (opt) {
						case 'see-more-contributions':
							$bottom_ul.append('<li class="see-more-contributions"><a class="more" href="/wiki/index.php?list=Contributions">See more</a></li>');
							break;
						case 'contribute':
							//$bottom_ul.append('<li class="contribute"><a class="contribute" href="#">Contribute</a></li>');
							break;
						case 'view-all-questions':
							$bottom_ul.append('<li class="view-all-questions"><a href="/wiki/index.php?list=Content_type_question" class="no-bg">View all questions with no answer</a></li>');
							break;
					}
					
					j++;
				}
			}
		}
	});
	
	layout_widget($widget);
	
	
	if ( $widget.is('.widget-mycontacts') ) {
		widget_mycontacts();
	}
	
	if ( $widget.is('.widget-mygroups') ) {
		widget_mygroups();
	}
	
	if ( $widget.is('.widget-news') ) {
		widget_news();
	}
	
	if ( $widget.is('.widget-questionsandanswers')) {
		widget_faq($widget);
	}
		
	if (BROWSER_IE6)
		layout_columns_fix();
}

function widget_mycontacts($widget) {
	//$widget.find('.bottom').append('<ul><li class="view-all"><a class="more" href="/mod/members/">View all members</a></li></ul>');
}

function widget_mygroups($widget) {
	//$widget.find('.bottom').append('<ul><li class="view-all"><a class="more" href="/pg/groups/world">View all groups</a></li></ul>');
}

function widget_news($widget) {
}

function widget_form_submit() {
	var action 			= $(this).attr("action");
	var variables 		= $(this).serialize();			
	var guid 			= $(this).attr('id').replace(/^[^\d+]+(\d+)$/,'$1');
	var $form 			= $(this);
	var $submit 		= $('#submit'+guid);
	var $widgetcontent 	= $('#widgetcontent'+guid+' .center');
		
	$submit.attr("disabled","disabled");
	$submit.attr("value","Saving...");	
			
	$widgetcontent.html('<div align="center" class="ajax_loader"></div>');
	
	$.post(action, variables, function(data) {
		$submit.attr("disabled","");
		$submit.attr("value","Saving...");
		$widgetcontent.html( data );
		$form = $('#widgetform'+guid);
		$form.submit(widget_form_submit);
	});
	
	return false;
}

function page_end() {	
	$('#wiki-contents').find('a.external').attr('target','_blank');
	
	$('#wiki-contents .clear-both').each(function() {
		if (! $(this).is('.injected') )
			$(this).remove();
	});	
	$('#overview').prependTo($('#wiki-contents'));
	$('.wiki-page-case_study #widgets_right').prependTo($('#wiki-contents'));
	$('#expert-answer').prependTo('#wiki-contents');
	$('#content .widgets_middle').appendTo($('#wiki-contents'));
	$('#comments-wrapper').prev('.clear-both').remove();	
	
	//GUID de l'auteur	
	$('#author_GUID,#expert_GUID').appendTo($('#comments-wrapper form'));
}

function img_legends() {
	$('#wiki-contents .image').each(function() {
		var $p = $(this).parent();
		
		if (! $p.find('.legend').is('span') ) {
			var title = $(this).attr('title');		
			var $img = $(this).find('img');		
			
			//dimensions new Image
			//var img = new Image();
							
			//$p.width( $img.width() );
			$p.addClass('bloc-image');
			$p.append('<br/><span class="legend">'+title+'</span>');
		}
	});
}

function admin_open() {
	
}

function admin_defaultwidgets() {

	$('#defaultwidgets-form-submit').click(function(){
		$(this).parents('form').attr('action', '/admin/apply_default_widgets.php');
	});
}

var TYPE_ALERT;

function messages_pop( msg, type ) {
	messages_add( msg, type );
	messages_alert( type );
}

function messages_add(msg, type) {	
	if ( ! $('.main ' + type).is('div') ) {	
		type = type.substring(1, type.length);
		$('.main').append('<div class="'+type+'"><span class="closeMessages"><a href="#">Close</a></span><div class="message">' + msg + '</div></div>');	
	} else {
		$('.main ' + type + ' .message').text(msg);
	}
}

function messages_alert(type){
	TYPE_ALERT = type;
	
	$(type).each(function(){
		if ( !$(this).parent().is('.main') ) {
			$(this).prependTo('.main');
		}
	});
	
	$(type).fadeIn();
	
	var ie6 = $.browser.msie && $.browser.version.indexOf('6.0') >= 0;
	
	if (ie6) {
		$(type).each(function(){
			$(this).css({
				display: 'block'
			});
			setTimeout(messages_close, 5000);
		});
		
		$(type + ' span.closeMessages a').click(function(){
			messages_close();
		});
	}
	else {
		$(type).animate({
			opacity: 1.0
		}, 1000);
		$(type).animate({
			opacity: 1.0
		}, 5000);
		$(type).fadeOut('slow');
		
		$(type + ' span.closeMessages a').click(function(){
			$(TYPE_ALERT).stop();
			$(TYPE_ALERT).fadeOut('slow');
			return false;
		});
		
		$(type).click(function(){
			$(TYPE_ALERT).stop();
			$(TYPE_ALERT).fadeOut('slow');
			return false;
		});
	}
}

function widget_faq($widget) {
	$widget.find('.input-textarea, .input-text').focus(form_field_value_listener);
}

function widgets_layout() {	
	$('#sidebar .widget, #content .widgets_middle .widget-latestcasestudy, #content .widgets_middle .widget, #widgets_right .widget').each(function() {
		var $widget = $(this);
		var id = $widget.attr('id');			
		layout_widget($widget);
		
		if ( $widget.is('.widget-mycontacts') ) {
			widget_mycontacts($widget);
		}
		
		if ( $widget.is('.widget-mygroups') ) {
			widget_mygroups($widget);
		}
		
		if ( $widget.is('.widget-news') ) {
			widget_news($widget);
		}
		
		if ( $widget.is('.widget-questionsandanswers')) {
			widget_faq($widget);
		}
		
		if ( $widget.is('.widget-latestcasestudy')) {
			layout_dashboard_zoom();
		}
	});		
		
	if (BROWSER_IE6)
		layout_columns_fix();
}

function messages_close() {
	$(TYPE_ALERT).css({display:'none'});
}

function session_force_logout() {
}

function fix_file_links() {
	
}

function inURL(str) {
	return window.location.href.indexOf(str)>=0;
}

/* group_alert_subscription est appelee dans la vue de page d'accueil du groupe */

var MSG_GROUP_ALERT_SUBSCRIPTION = 'You will now receive notifications from this group.';
var MSG_GROUP_ALERT_UNSUBSCRIPTION = 'You will no longer receive notifications from this group.';

function group_alert_subscription(group_id) {		
	$('#group_alert_subscription').load(
			'/wiki/index.php',
			{'page':'ajax','action':'group_alert_subscription','group_id':group_id},function() {
				group_alert_subscription_submit(group_id);
			}
	);
	
}

function group_alert_subscription_submit(group_id) {
	$('#group_alert_subscription #emailcheckbox').click(function() {
		var chk = $(this).is(':checked') ? 1 : 0;
		
		$.ajax({
		   type: 'POST',
		   url: '/wiki/index.php',
		   data: {'checked':chk,'page':'ajax','action':'group_alert_subscription','group_id':group_id},
		   success: function(x){
			   $('#group_alert_subscription').html(x);	   
			   group_alert_subscription_submit(group_id);
			   
			   if (chk) {
				   messages_pop(MSG_GROUP_ALERT_SUBSCRIPTION,'.messages');
			   }
			   else {
				   messages_pop(MSG_GROUP_ALERT_UNSUBSCRIPTION,'.messages');
			   }
			   
			   window.location='#main';
		   },
		   error: function(e){
			     alert( "Ajax error ,  are you connected ?" );
			}
		 });
		
		return false;
	});
}

/* fix MW */
function fillDestFilename() {}
function attachMetadataToggle() {}
function wgUploadWarningObj() {}
function toggleFilenameFiller() {}

