function populateSettings() {
	document.all.wallpaper[opener.wallpaper].checked = true;

	document.all.wallpaperPath.value=opener.wallpaperPath;
	document.all.wallpaperDir.value=opener.wallpaperDir;

	document.all.BGColor.value=opener.BGColor;

	document.all.headingColor.value=opener.headingColor;
	document.all.headingBGColor.value=opener.headingBGColor;
	document.all.headingOpacity.value=opener.headingOpacity;

	document.all.linkColorDormant.value=opener.linkColorDormant;
	document.all.linkBGColorDormant.value=opener.linkBGColorDormant;
	document.all.linkOpacityDormant.value=opener.linkOpacityDormant;
	document.all.linkColorActive.value=opener.linkColorActive;
	document.all.linkBGColorActive.value=opener.linkBGColorActive;
	document.all.linkOpacityActive.value=opener.linkOpacityActive;

	document.all.textareaColorDormant.value=opener.textareaColorDormant;
	document.all.textareaBGColorDormant.value=opener.textareaBGColorDormant;
	document.all.textareaOpacityDormant.value=opener.textareaOpacityDormant;
	document.all.textareaColorActive.value=opener.textareaColorActive;
	document.all.textareaBGColorActive.value=opener.textareaBGColorActive;
	document.all.textareaOpacityActive.value=opener.textareaOpacityActive;

	document.all.inputColorDormant.value=opener.inputColorDormant;
	document.all.inputBGColorDormant.value=opener.inputBGColorDormant;
	document.all.inputOpacityDormant.value=opener.inputOpacityDormant;
	document.all.inputColorActive.value=opener.inputColorActive;
	document.all.inputBGColorActive.value=opener.inputBGColorActive;
	document.all.inputOpacityActive.value=opener.inputOpacityActive;

}


function wallpaperAlign(v, h) {
	opener.wallpaperX = h;
	opener.wallpaperY = v;

	var BGstyle = opener.document.all.bg.style;
	
	if (v == 'top') {
		BGstyle.top = '0px';
	} else {
		var y = screen.height - opener.document.background.clientHeight;
		if (v == 'center')
			BGstyle.top = y / 2;
		else if (v == 'bottom')
			BGstyle.top = y;
	}

	if (h == 'left') {
		BGstyle.left = '0px';
	} else {
		var x = screen.width - opener.document.background.clientWidth;
		if (h == 'center')
			BGstyle.left = x / 2;
		else if (h == 'right')
			BGstyle.left = x;
	}

    opener.document.body.style.backgroundPosition = v + ' ' + h;
}

function wallpaperRepeat(r) {
	opener.wallpaperRepeat = r;
	opener.document.body.style.backgroundRepeat = r;
	opener.document.body.background = opener.activeWallpaper;
	opener.document.background.style.visibility = 'hidden';
}

function wallpaperStretch(w, h) {
	opener.wallpaperHeight = h;
	opener.wallpaperWidth = w;

	opener.document.body.background = '';
	opener.document.background.style.width = w;
	opener.document.background.style.height = h;
	opener.document.background.style.visibility = 'visible';
	wallpaperAlign('center', 'center');
	opener.document.background.style.visibility = 'visible';
}

function wallpaperIn(){
	if ((opener.document.background.height/opener.document.background.width)>=(screen.height/screen.width))
		wallpaperStretch('auto', screen.height);
	else
		wallpaperStretch(screen.width, 'auto');
}

function wallpaperOut(){
	if ((opener.document.background.height/opener.document.background.width)<=(screen.height/screen.width))
		wallpaperStretch('auto', screen.height);
	else
		wallpaperStretch(screen.width, 'auto');
}