function winOpen(URL, width, height) {
	var windowFeatures;
	windowFeatures = 'toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no,';
	if(width != '' && width != null) {
		windowFeatures = windowFeatures + 'width=' + width + ',';
	}
	if(height != '' && height != null) {
		windowFeatures = windowFeatures + 'height=' + height + ',';
	}
	var swidth = screen.width;
	var sheight = screen.height;
	var left = (swidth - width) / 2;
	var top = (sheight - height) / 2;
	windowFeatures = windowFeatures + 'left=' + left + ',top=' + top + ',';
	window.open(URL, '', windowFeatures);
}

function select_plan() {
	var hosting = 'ASMENINIS';
	if(document.getElementById('articles_yes').checked ||
		document.getElementById('gallery_yes').checked ||
		document.getElementById('langcfg_yes').checked ||
		document.getElementById('search_yes').checked ||
		document.getElementById('banner_yes').checked) {
		hosting = 'VERSLAS';
	}
	var plan = 10;
	if(hosting == 'VERSLAS') {
		plan = 11;
	}
	document.getElementById('plan_button').href = 'javascript:user_plan(' + plan + ');';
	document.getElementById('hosting').innerHTML = hosting;
	document.getElementById('result').style.display = 'none';
	document.getElementById('solution').style.display = 'block';
}

function form_reset() {
	document.getElementById('solution').style.display = 'none';
	document.getElementById('result').style.display = 'block';
}

function user_plan(plan) {
	window.opener.document.getElementById('form_plans_' + plan).submit();
	window.close();
}

function validateForm(forma) {
	if(forma.name.value == '') {
		alert('Nurodykite savo vardą.');
		return false;
	}
	if(forma.email.value == '') {
		alert('Nurodykite savo el. pašto adresą.');
		return false;
	}
	var emailPattern = /^[a-z0-9]+([-_\.]?[a-z0-9])*@[a-z0-9]+([-\.]?[a-z0-9])+\.[a-z]{2,6}$/;
	if(!emailPattern.test(forma.email.value)) {
		alert('Neteisingai nurodytas el. pašto dėžutės adresas');
		return false;
	}
	if(forma.text.value == '') {
		alert('Nurodykite savo klausimą.');
		return false;
	}
	forma.submit();
	return true;
}

function select(element) {
	element.focus();
	element.select();
}

function browserVersion() {
	ua = navigator.userAgent.toLowerCase();
	var match = /(webkit)[ \/]([\w.]+)/.exec(ua) ||
		/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(ua) ||
		/(msie) ([\w.]+)/.exec(ua) ||
		!/compatible/.test(ua) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(ua) || [];
	return {browser: match[1] || "", version: match[2] || "0"};
}
