var cOBj;

var responseSuccess = function(o) {
	var data = o.responseXML;
	if (data) {
		var errors = data.getElementsByTagName('error');
		var isError = ((errors.length > 0) || (getSelectValue('address') == ''));
		if (isError) {
			var eText = '';
			if (getSelectValue('address') == '') eText = 'Please choose an address.<br />';
			for (i = 0; i < errors.length; i++ ) {
				var errorValue = errors[i].getAttribute('name');
				if (errorValue == 'firstname') eText = eText + 'Please fill in the box "First name".<br />';
				else if (errorValue == 'lastname') eText = eText + 'Please fill in the box "Last name".<br />';
				else if (errorValue == 'email') eText = eText + 'Please check your E-Mail.<br />';
			}
			changeDiv('errorText',eText);
		}
		else document.location.href = '/next08/kontakt2.html';
	}
}

var responseSuccess2 = function(o) {
	var data = o.responseXML;
	if (data) {
		var errors = data.getElementsByTagName('error');
		var isError = (errors.length > 0);
		if (isError) {
			var eText = '';
			for (i = 0; i < errors.length; i++ ) {
				var errorValue = errors[i].getAttribute('name');
				if (errorValue == 'company') eText = eText + 'Please fill in the box "Company".<br />';
				else if (errorValue == 'street') eText = eText + 'Please fill in the box "Street Address".<br />';
				else if (errorValue == 'city') eText = eText + 'Please fill in the box "City".<br />';
				else if (errorValue == 'zip') eText = eText + 'Please fill in the box "Zip".<br />';
				else if (errorValue == 'country') eText = eText + 'Please fill in the box "Country".<br />';
				else if (errorValue == 'website') eText = eText + 'Please fill in the box "Website".<br />';
				else if (errorValue == 'ceo') eText = eText + 'Please fill in the box "CEO Name".<br />';
				else if (errorValue == 'background') eText = eText + 'Please fill in the box "Company Background".<br />';
				else if (errorValue == 'firstname') eText = eText + 'Please fill in the box "First Name".<br />';
				else if (errorValue == 'lastname') eText = eText + 'Please fill in the box "Last Name".<br />';
				else if (errorValue == 'title') eText = eText + 'Please fill in the box "Title".<br />';
				else if (errorValue == 'email') eText = eText + 'Please check your E-Mail.<br />';
				else if (errorValue == 'phone') eText = eText + 'Please fill in the box "Phone".<br />';
				else if (errorValue == 'mobile') eText = eText + 'Please fill in the box "Mobile".<br />';
				else if (errorValue == 'idea') eText = eText + 'Please fill in the box "Product or Service Name".<br />';
				else if (errorValue == 'web_address') eText = eText + 'Please fill in the box "Specific web address".<br />';
				else if (errorValue == 'description') eText = eText + 'Please fill in the box "Product / Service description".<br />';
				else if (errorValue == 'competitors') eText = eText + 'Please fill in the box "Competitors".<br />';
				else if (errorValue == 'why') eText = eText + 'Please fill in the box "Why shall we select your idea for next08?".<br />';
			}
			changeDiv('errorText',eText);
		}
		else document.location.href = '/next08/businessidea2.html';
	}
}

var responseFailure = function(o) {
	alert('Es ist leider ein Fehler aufgetreten. Bitte probieren Sie es sp&auml;ter erneut.');
}

var callback = {
	failure: responseFailure,
	success: responseSuccess,
	scope: this
}

var callback2 = {
	failure: responseFailure,
	success: responseSuccess2,
	scope: this
}

function send() {
	var link = 'http://nextconf.eu/next08/kontakt.php?address=' + getSelectValue('address') + '&firstname=' + getValue('firstname') + '&lastname=' + getValue('lastname') + '&email=' + getValue('email') + '&company=' + getValue('company') + '&feedback=' + getValue('feedback');
	cOBj = YAHOO.util.Connect.asyncRequest('GET',link,callback,null);
}

function send2() {
	var post_data =
		'company=' + getValue('company') +
		'&street=' + getValue('street') +
		'&city=' + getValue('city') +
		'&zip=' + getValue('zip') +
		'&country=' + getValue('country') +
		'&website=' + getValue('website') +
		'&ceo=' + getValue('ceo') +
		'&background=' + getValue('background') +
		'&firstname=' + getValue('firstname') +
		'&lastname=' + getValue('lastname') +
		'&title=' + getValue('title') +
		'&email=' + getValue('email') +
		'&phone=' + getValue('phone') +
		'&mobile=' + getValue('mobile') +
		'&idea=' + getValue('idea') +
		'&web_address=' + getValue('web_address') +
		'&description=' + getValue('description') +
		'&competitors=' + getValue('competitors') +
		'&why=' + getValue('why')
	;
	cOBj = YAHOO.util.Connect.asyncRequest('POST','http://nextconf.eu/next08/businessidea.php',callback2,post_data);
}

function getValue(element) {
	return document.getElementById(element).value;
}

function getSelectValue(element) {
	return document.forms[0].elements[element].options[document.forms[0].elements[element].selectedIndex].value;
}

