
var isIE = 0;      // MS IE
var isMozilla = 0; // Mozilla, Firefox, ..
var isOpera = 0;   // Opera
var isOther = 0;   // Other Browsers

var user_agent = navigator.userAgent.toLowerCase();

if(user_agent.indexOf('opera') != -1) {
	isOpera = 1;
} else if(user_agent.indexOf('msie') != -1) {
	isIE = 1;
} else if(user_agent.indexOf('compatible') != -1) {
	isOther = 1;
} else {
	isMozilla = 1;
}

function change_division()
{
	var ids;
	var i;
	var index;

	ids = [];
	for(i=1;i<document.getElementById('division').options.length;i++) {
		ids[i-1] = document.getElementById('division').options[i].value;
	}
	for(i=0;i<ids.length;i++) {
		document.getElementById(ids[i]+'_win').style.display = 'none';
	}
	index = document.getElementById('division').selectedIndex;
	index--;
	if(index >= 0) {
		document.getElementById(ids[index]+'_win').style.display = 'block';
	}
}

function change_water_analysis()
{
	if(document.getElementById('water_analysis').selectedIndex==1) {
		document.getElementById('water_analysis_attach_by_row').style.display = '';
		change_water_analysis_attach_by();
	} else {
		document.getElementById('water_analysis_attachment_row').style.display = 'none';
		document.getElementById('water_analysis_attach_by_row').style.display = 'none';
	}
}

function change_water_analysis_attach_by()
{
	if(document.getElementById('water_analysis_attach_by').selectedIndex==0) {
		document.getElementById('water_analysis_attachment_row').style.display = '';
	} else {
		document.getElementById('water_analysis_attachment_row').style.display = 'none';
	}
}

function check_demand_form()
{
	var email_regexp = new RegExp('^[a-zA-Z0-9._-]+\@[a-zA-Z0-9.-]+$');
	var email;

	if(document.getElementById('message').value.length==0) {
		alert('Zadejte text zprávy.');
		document.getElementById('message').focus();
		return false;
	}
	email = document.getElementById('email').value;
	if(email.length>0 && email != '@' && !(email_regexp.exec(email) != null)) {
		alert('Zadaný e-mail není korektní.');
		document.getElementById('email').focus();
		return false;
	}
	return true;
}

function nav_button_over(button, i)
{
	button.src='/img/button'+i+'-active.gif';
}

function nav_button_out(button, i)
{
	button.src='/img/button'+i+'.gif';
}

