function connect(){
	var xmlhttp = false
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(ex){
			xmlhttp = false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
function actual(){
	xmlhttp = connect();
	xmlhttp.open("GET", "time.php");
	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4){
			document.getElementById("uhr").innerHTML= xmlhttp.responseText; 
		}
	}
	xmlhttp.send(null);			
}
setInterval("actual()", 1000)


function checkValidUrl(id,url){
	var toCheck = document.getElementById(id);
	xmlhttp = connect();
	xmlhttp.open("GET", "check.php?w=checkValidUrl&url="+url);
	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4){
			if(xmlhttp.responseText == 1){
				toCheck.style.background = "#990000";
				toCheck.style.color="#FFFFFF";
				document.getElementById('msg_'+id).innerHTML="Urlformat ok.";
			}else{
 				toCheck.style.background="#ffffff";
				toCheck.style.color="#990000";
				document.getElementById('msg_'+id).innerHTML="Url muss mit http:// geginnen";
			} 
		}
	}
	xmlhttp.send(null);	
}

function checkEnd(id,laenge,was){
	var toCheck = document.getElementById(id);
	toCheck.style.background="#ffffff";
	toCheck.style.color="#990000";
	if(was == 'max'){
		var n = laenge-toCheck.value.length;
		if(n < 2){
			toCheck.readOnly = true;
			document.getElementById('msg_'+id).innerHTML="noch erlaubte Zeichen: 0 ";
			toCheck.style.background = "#990000";
			toCheck.style.color="#FFFFFF";
		}else{
		document.getElementById('msg_'+id).innerHTML="noch erlaubte Zeichen: "+n;
		}
	}
	if(was == 'min'){
		var n = laenge-toCheck.value.length;
		if(n < 2){
			toCheck.style.background = "#990000";
			toCheck.style.color="#FFFFFF";
			document.getElementById('msg_'+id).innerHTML="Mindestlänge erreicht";
		}else{
			document.getElementById('msg_'+id).innerHTML="mindestens noch "+n+" Zeichen";
		}

	}
	
}

function checkBacklink(id,url){
	var toCheck = document.getElementById(id);
	xmlhttp = connect();
	xmlhttp.open("GET", "check.php?w=checkBacklink&url="+url);
	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4){
		document.getElementById('msg_'+id).innerHTML=xmlhttp.responseText;
			if(xmlhttp.responseText == 1){
				toCheck.style.background = "#990000";
				toCheck.style.color="#FFFFFF";
				document.getElementById('msg_'+id).innerHTML="Backlink gefunden.";
			}else{
 				toCheck.style.background="#ffffff";
				toCheck.style.color="#990000";
				//document.getElementById('msg_'+id).innerHTML="Backlink nicht gefunden";
			} 
		}
	}
	xmlhttp.send(null);
}
