/*Smiley Drop Down*/
if (get('smilies_buttons','id')) {
    var w_ub = [];
    var c_ub = [];
    var i_ub = get('smilies_buttons','id').firstChild.getElementsByTagName('A');
    var d_ub = document.createElement('SELECT');
    d_ub.options[0] = new Option('Smilies', null, null, null);
    d_ub.onchange = function() {
        eval(this.options[this.options.selectedIndex].value);
    }
    for (i=i_ub.length-1;i>= 0;i--) {
        c_ub.push(i_ub[i].getAttribute('onClick'));
        w_ub.push(i_ub[i].getElementsByTagName('IMG').item(0).alt);
        i_ub[i].parentNode.removeChild(i_ub[i]);
    }
    for (i=0;i<w_ub.length;i++) {
        d_ub.options[d_ub.options.length] = new Option(w_ub[i], c_ub[i], null, null);
    }
    get('smilies_buttons','id').replaceChild(d_ub, get('smilies_buttons','id').firstChild);
}
/* Code for user's display name in posts or PMs*/
var usercode="\\[#username\\]";
var td=document.getElementsByTagName("td");
var re = new RegExp(usercode,"g");
if(!location.href.match(/headers_footers/) && !document.postForm && !document.ammForm && !location.href.match(/welcome_message/)){
    if(document.title.match(re)){
        document.title=document.title.replace(re, pb_displayname);
    }
    for(i=0;i<td.length;i++){
        if(td[i].innerHTML.match(re)){
            td[i].innerHTML = td[i].innerHTML.replace(re, vf_displayname);
        }
    }
}
/*Avatar Anywhere*/
if(location.href.match(/\/modify_profile\/user\/(.+?)($|\/$)/) && RegExp.$1 == vf_username){
    var f = document.profile_form
    if(document.addEventListener){
        f.addEventListener('submit', function(){ functions.save('av-url','['+get("avatar_url","name")[0].value+']','hidden'); functions.save('av-width', '['+get("avatar_width","name")[0].value+']', 'hidden'); functions.save('av-height', '['+get("avatar_height","name")[0].value+']', 'hidden');} , false);
    }else{
        f.attachEvent('onsubmit', function(){ functions.save('av-url','['+get("avatar_url","name")[0].value+']','hidden'); functions.save('av-width', '['+get("avatar_width","name")[0].value+']', 'hidden'); functions.save('av-height', '['+get("avatar_height","name")[0].value+']', 'hidden');});

    }
}
functions.build();
/*wImg Host Uploader*/

var up = {
	max_size: '10MB',
	file_types: '.abr, .apng, .bmp, .css, .gif, .ico, .jpg, .js, .pdf, .png, .psd, .pspimage, .rar, .tga, .tif, .txt, .xcf, .zip',
	i: function(){
		if(document.post_form && vf_username != 'guest'){
			this.post();
		}
	},
	win: function(){
		var xWin = window.open('',"wImgUploader","directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,top=100,left=100,width=440,height=200");
		xWin.focus();
	},
	post: function(){
		var m = document.getElementsByName('subject')[0].parentNode.parentNode.parentNode;
		var r = m.cloneNode(true);
		r.firstChild.firstChild.innerHTML = '<b>wImg Uploader:</b>';
		r.firstChild.nextSibling.innerHTML = '<font size = "1"><form action = "http://wimg.co.uk/popup.php?id=vforums" method = "post" enctype = "multipart/form-data" target="wImgUploader" style = "margin: 0; padding: 0;"><input type = "file" name = "image" maxlength = "100" size = "50"> ' + ' ' + ' <input type = "submit" value = "Upload!" name = "buttom" onclick="return up.win();"></form> <b>' + this.max_size + ' | ' + this.file_types + '</b></font>';
		m.parentNode.insertBefore(r, m.nextSibling.nextSibling);
	}
};
up.i();