function createRequestObject(){
	var request_o; 
	var browser = navigator.appName; 
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o = new XMLHttpRequest();
	}
	return request_o; 
}
var http = createRequestObject(); 
function artists_load(){
	http.open('get', "/contact/artists.php");
	if(http.readyState == 1){
		$("#loader2").show('fast');
	}
	http.onreadystatechange = handle_artists_load; 
	http.send(null);
}
function handle_artists_load(){
	if(http.readyState == 4){ 
	 
		var response = http.responseText;
		$("#artist").empty()
		$("#artist").html(response);
		$("#loader2").hide('fast');
	}
}
function send_mail (sconcern,simage_id,semail,sname,scompany,saddress,szip,scity,scountry,smessage){
	forconcern = "?concern="+sconcern;
	foremail = "&email="+semail;
	forimage_id = "&image_id="+simage_id;
	forname = "&name="+sname;
	forcompany = "&company="+scompany;
	foraddress = "&address="+saddress;
	forzip = "&zip="+szip;
	forcity = "&city="+scity;
	forcountry = "&country="+scountry;
	corrected_message = stupid_chars(smessage);
	corrected_message = corrected_message.replace(/\n/g, "<br />");
	formessage = "&message="+corrected_message;
	//alert(corrected_message);
	http.open('get', "/contact/send_mail.php"+forconcern+foremail+forname+forcompany+foraddress+forzip+forcity+forcountry+formessage+forimage_id);
	if(http.readyState == 1){
		if ((NS) || (IE)) {
			$("#zebra").html("<img src='/contact/ajax-loader.gif'>");
			showLayer(zebra);
		}
	}
	http.onreadystatechange = handle_send_mail; 
	http.send(null);
}
function handle_send_mail(){
	if(http.readyState == 4){ 
	 $("#loader2").hide('fast');
		var response = http.responseText;
		if (response=="Mail sent!"){
			clear_fields ();
		}
		if ((NS) || (IE)) {
			$("#zebra").html(response+"<br /><br /><br /><span style='font-size:12px;'>Click to close!</span>");
		} else {
			$("#msg").html(response);
			$('#msg').fadeIn('slow')
			window.setTimeout("$('#msg').fadeOut('slow')",2000);
		}	
	}
}

function stupid_chars(text){
	text=text.replace(/ü/g, "&uuml;");
	text=text.replace(/Ü/g, "&Uuml;");
	text=text.replace(/ä/g, "&auml;");
	text=text.replace(/Ä/g, "&Auml;");
	text=text.replace(/ö/g, "&ouml;");
	text=text.replace(/Ö/g, "&Ouml;");
	return text;
}
function save_mail (hostemail){
	foremail = "?email="+hostemail;
	http.open('get', "/contact/admin/save_mail.php"+foremail);
	if(http.readyState == 1){
		if ((NS) || (IE)) {
			$("#zebra").html("<img src='/contact/ajax-loader.gif'>");
			showLayer(zebra);
		}
	}
	http.onreadystatechange = handle_save_mail; 
	http.send(null);
}
function handle_save_mail(){
	if(http.readyState == 4){ 
	var response = http.responseText;
		if ((NS) || (IE)) {
			$("#zebra").html(response+"<br /><br /><br /><span style='font-size:12px;'>Click to close!</span>");
		} else {
			$("#msg").html(response);
			$('#msg').fadeIn('slow')
			window.setTimeout("$('#msg').fadeOut('slow')",2000);
		}	
	}
}