<!--
/*
	============================================================
	CompetitionEdit fce
	============================================================
	Copyright: www.eastburger.cz (c) 2009 All rights reserved.
	============================================================
 	Spoluprace:
	------------------------------------------------------------
*/

function CompetitionEditSetType(){
	var iTypeValue = GetRadioValue(document.getElementById('form_competitionedit').elements['competitionedit_id_type']);
	var oInvoice = document.getElementById('competitionedit_invoice');
	if(iTypeValue > 1) oInvoice.style.display = 'block';
	else oInvoice.style.display = 'none';
}

function CompetitionEditChangeType(id){
	var iTypeValue = document.getElementById('competitionedit_id_type_'+id).value;
	var oInvoice = document.getElementById('competitionedit_invoice');
	if(iTypeValue > 1) oInvoice.style.display = 'block';
	else oInvoice.style.display = 'none';
}

function CompetitionEditValidate(){
	var sMsgAlert = '';

	if(document.getElementById('competitionedit_url').value == 'http://') document.getElementById('competitionedit_url').value = '';

	tmp = CheckEmptyElement('competitionedit_name');
	if(tmp != true){
		document.getElementById('competitionedit_name').focus();
		sMsgAlert += tmp + '\n';
	}

	tmp = CheckEmptyElement('competitionedit_description1');
	if(tmp != true){
		document.getElementById('competitionedit_description1').focus();
		sMsgAlert += tmp + '\n';
	}

	sMsg = '';
	oLabel = document.getElementById('lb_competitionedit_category');
	sLabel = '';
	radioValue = GetRadioValue(document.getElementById('form_competitionedit').elements['competitionedit_category[]']);
	if(radioValue == null){
		sLabel = GetLabelDesc(oLabel);
		SetLabel(oLabel, 'err');
		tmp = lgValidateEmptyElement + ': ' + sLabel + '.';
	}
	else{
		SetLabel(oLabel);
		tmp = true;
	}
	if(tmp != true) sMsgAlert += tmp + '\n';

	tmp = CheckEmptyElement('competitionedit_url');
	if(tmp != true){
		document.getElementById('competitionedit_url').focus();
		sMsgAlert += tmp + '\n';
	}

	tmp = CheckEmptyElement('competitionedit_date_start');
	if(tmp != true){
		document.getElementById('competitionedit_date_start').focus();
		sMsgAlert += tmp + '\n';
	}
	else{
		tmp = CheckFormat('competitionedit_date_start', '^(([1-9])|([1-2][0-9])|(3[0-1]))\.(([1-9])|(1[0-2]))\.([0-9]{4})$');
		if(tmp != true){
			document.getElementById('competitionedit_date_start').focus();
			sMsgAlert += tmp + '\n';
		}
	}

	tmp = CheckEmptyElement('competitionedit_date_end');
	if(tmp != true){
		document.getElementById('competitionedit_date_end').focus();
		sMsgAlert += tmp + '\n';
	}
	else{
		tmp = CheckFormat('competitionedit_date_end', '^(([1-9])|([1-2][0-9])|(3[0-1]))\.(([1-9])|(1[0-2]))\.([0-9]{4})$');
		if(tmp != true){
			document.getElementById('competitionedit_date_end').focus();
			sMsgAlert += tmp + '\n';
		}
	}

	tmp = CheckEmptyElement('competitionedit_prix');
	if(tmp != true){
		document.getElementById('competitionedit_prix').focus();
		sMsgAlert += tmp + '\n';
	}

	tmp = CheckEmptyElement('competitionedit_email');
	if(tmp != true){
		document.getElementById('competitionedit_email').focus();
		sMsgAlert += tmp + '\n';
	}
	else{
		tmp = CheckFormat('competitionedit_email', '^[^.]+(\.[^.]+)*@([^.]+[.])+[a-zA-Z]{2,4}$');
		if(tmp != true){
			document.getElementById('competitionedit_email').focus();
			sMsgAlert += tmp + '\n';
		}
	}

	tmp = CheckEmptyRadio('form_competitionedit', 'competitionedit_id_type_1');
	if(tmp != true) sMsgAlert += tmp + '\n';

	iTypeValue = GetRadioValue(document.getElementById('form_competitionedit').elements['competitionedit_id_type']);
	if(iTypeValue > 1){
		tmp = CheckEmptyElement('competitionedit_invoice_firm');
		if(tmp != true){
			document.getElementById('competitionedit_invoice_firm').focus();
			sMsgAlert += tmp + '\n';
		}
		tmp = CheckEmptyElement('competitionedit_invoice_street');
		if(tmp != true){
			document.getElementById('competitionedit_invoice_street').focus();
			sMsgAlert += tmp + '\n';
		}
		tmp = CheckEmptyElement('competitionedit_invoice_town');
		if(tmp != true){
			document.getElementById('competitionedit_invoice_town').focus();
			sMsgAlert += tmp + '\n';
		}
		tmp = CheckEmptyElement('competitionedit_invoice_postcode');
		if(tmp != true){
			document.getElementById('competitionedit_invoice_postcode').focus();
			sMsgAlert += tmp + '\n';
			//tmp = CheckFormat('competitionedit_invoice_postcode', '^([0-9]{3} [0-9]{2})$');
		}
	}

	tmp = CheckFileImg('competitionedit_photo1');
	if(tmp != true) sMsgAlert += tmp + '\n';

	tmp = CheckFileImg('competitionedit_photo2');
	if(tmp != true) sMsgAlert += tmp + '\n';

	tmp = CheckFileImg('competitionedit_photo3');
	if(tmp != true) sMsgAlert += tmp + '\n';

	tmp = CheckFileImg('competitionedit_photo4');
	if(tmp != true) sMsgAlert += tmp + '\n';

	tmp = CheckFileImg('competitionedit_photo5');
	if(tmp != true) sMsgAlert += tmp + '\n';

	if(sMsgAlert == '') return true;
	else{
		alert(lgValidate + '\n\n' + sMsgAlert);
		return false;
	}
}

//-->