function is_e_mail(the_mail) {
	if (the_mail=='') return 0;
	var i = the_mail.indexOf("@");
	if (i<1) return 0;
	var end = the_mail.substring(i+1,the_mail.length);
	if (end.length < 4) return 0;
	if (end.indexOf(".")==-1) return 0;
	return 1;
} 
	
function check_mail_list() {
	if (!is_e_mail(document.mailinglist_form.detail_101.value)) {
		alert('Netfangið er ógilt!');
		return false;
	}
}

function change_select(the_id) {
	for (i=0; i < document.ticket_search.event_date_drop_id.options.length; i++) {
		if (document.ticket_search.event_date_drop_id.options[i].value == the_id)
			document.ticket_search.event_date_drop_id.options[i].selected = true;
	}
}

function change_radio(the_id) {
	for (i=0; i < document.ticket_search.event_date_id.length; i++) {
		if (document.ticket_search.event_date_id[i].value == the_id)
			document.ticket_search.event_date_id[i].checked = true;
	}
}

function confirm(order) {
	document.confirm_form.order.value = order;
	document.confirm_form.submit();
}	

function email_check(str) 
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1)
   		return false;

	else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	   	return false;

	else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	   	return false;

	else if (str.indexOf(at,(lat+1))!=-1)
	    	return false;
	 
	else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	    	return false;
	
	else if (str.indexOf(dot,(lat+2))==-1)
	   	return false;	
	
	else if (str.indexOf(" ")!=-1)
	    	return false;
	else
	 	return true;
}

// the_user is the first part of the email address i.e. "bill"
function WriteAddress(the_user,the_company,the_domain) {
	document.write("<a href='mail");
	document.write("to:");
	document.write(the_user);
	document.write("@");
	document.write(the_company);
	document.write(".");
	document.write(the_domain);
	document.write("' title='Senda póst'>");
	document.write(the_user);
	document.write("@");
	document.write(the_company);
	document.write(".");
	document.write(the_domain);
	document.write("</a>");
}
