function window_open(url, win_width, win_height) {
	
	var screen_width = window.screen.width;
	var screen_height = window.screen.height;
	
	var win_left = screen_width / 2 - win_width / 2;
	var win_top = screen_height / 2 - win_height / 2;
	
	var win = window.open(url, "popup", "width=" + win_width + ", height=" + win_height + ", scrollbars=1, location=0, menubar=0, resizable=0, status=0, titlebar=0, toolbar=0, screenX=100, left=" + win_left + ", screenY=30, top=" + win_top);
 	
	win.focus();
	
}

function popupWindow(w, h) {
	
	var sw = window.screen.width;
	var sh = window.screen.height;
	
	var l = sw / 2 - w / 2;
	var t = sh / 2 - h / 2;
	
	window.resizeTo(w, h);
	window.moveTo(l, t);
	
}

var curid = 0;

function selectImage(id) {
	if (curid == id) {
		return;
	}
	var img = document.getElementById('images[' + id + ']');
	if (img) {
		img.className = 'image_block';
	}
	var img = document.getElementById('images[' + curid + ']');
	if (img) {
		img.className = 'image_none';
	}
	curid = id;
}

function configureSubmit() {
	
	var action = '';
	
	var args = configureSubmit.arguments;
	
	for (var i = 1; i < args.length; i += 1) {
		
		var elems = document.getElementsByName(args[i]);
		var values = Array();
		
		for (var j = 0; j < elems.length; j += 1) {
			if (elems[j].type == "checkbox" && elems[j].checked) {
				values[j] = elems[j].value;
			}
			else if (elems[j].type == "text") {
				values[j] = elems[j].value;
			}
			else if (elems[j].type == "select-one") {
				values[j] = elems[j].value;
			}
		}
		
		var value = values.join(";");
		
		if (value.length >= elems.length) {
			action += args[i] + "/" + value + "/";
		}
		
	}
	
	window.location = args[0] + action;
	
	return false;

}

function changeImage(i) {
	
	var txtElem = document.getElementById('ctxt');
	
	if (txtElem == null) {
		return;
	}
	
	var imgElem = document.getElementById('cimg');
	
	if (imgElem == null) {
		return;
	}
	
	var infElem = document.getElementById('itxt');
	
	if (infElem != null) {
		infElem.style.display = 'block';
		imgElem.className = 'smooth';
	}
	
	var imgObj = new Image();
	imgObj.src = photoSrc[i];
	
	imgObj.onload = function() {
		imgElem.src = this.src;
		imgElem.className = '';
		if (infElem != null) {
			infElem.style.display = 'none';
		}
	};
	
	txtElem.innerHTML = photoTxt[i];
	
}