function check() {
	var links = $("#links").val();
	if(links=='') {
		$('#links').css('border-color', '#f4695c' );
		return false;
	} else {
		if(links.indexOf("http://")) {
			$('#links').css('border-color', '#f4695c' );
			return false;
		} else {
			getrsname(links);
			$('#links').css('border-color', '#CCCCCC' );
		}
	}
	
	return true;
}
function submit() {
	if(check()) {
		$("#lc_form").submit(); 
	}
}
function ajaxsubmit() {
	if(check()) {
		$("#msgbox").show('slow');
		$("#msgbox").html('<center><img src="'+DOMAIN+'image/loading.gif" /></center>');
		$.ajax({ // AJAX Request auslösen
			type: "POST",
			url: DOMAIN + "add/",
			timeout: 100000,
			data:"titel="+$('#titel').val()+"&dateipassword="+$('#dateipassword').val()+"&links="+$('#links').val()+"&passwort="+$('#passwort').val()+"&captx="+$('#captx:checked').val()+"&colorx="+$('#colorx:checked').val()+"&textx="+$('#textx:checked').val()+"&weblinks="+$('#weblinks:checked').val()+"&ccf="+$('#ccf:checked').val()+"&dlc="+$('#dlc:checked').val()+"&rsdf="+$('#rsdf:checked').val()+"&cnl="+$('#cnl:checked').val()+"&kategorie="+$('#kategorie option:selected').val()+"&info="+$('#info').val()+"&cover="+$('#cover').val()+"&ajax=1",
			
			success: function(xml) {
			$("#msgbox").html(unescape(xml));
		}
		}); 
	}
}
function getrsname(url) {
url=substr(url,0,strpos(url,'\n')+1);
if($("#fname").val()=="Unbenannter Ordner") {
	if(strrpos(url,'rapidshare.com')) {
	var dname=substr(url,strrpos(url,'/')+1);
	dname = dname.replace('.html', '');
	dname = dname.replace('.rar', '');
	dname = dname.replace('.part01', '');
		$("#fname").val(dname);
	}
}
}
function speichern() {
	$.cookie('dateipassword', $('#dateipassword').val(), { expires: 7,path: '/'});
	if($('#captx:checked').val()==1) {
		$.cookie('captx', '1', { expires: 7,path: '/'});
	} else {
		$.cookie('captx', '2', { expires: 7,path: '/'});
	}
	if($('#colorx:checked').val()==1) {
		$.cookie('colorx', '1', { expires: 7,path: '/'});
	} else {
		$.cookie('colorx', '2', { expires: 7,path: '/'});
	}
	if($('#textx:checked').val()==1) {
		$.cookie('textx', '1', { expires: 7,path: '/'});
	} else {
		$.cookie('textx', '2', { expires: 7,path: '/'});
	}
	if($('#weblinks:checked').val()==1) {
		$.cookie('weblinks', 2, { expires: 7,path: '/'});
	} else {
		$.cookie('weblinks', 1, { expires: 7,path: '/'});	
	}
	if($('#dlc:checked').val()==1) {
		$.cookie('dlc', 2, { expires: 7,path: '/'});
	} else {
		$.cookie('dlc', 1, { expires: 7,path: '/'});
	}
	if($('#cnl:checked').val()==1) {
		$.cookie('cnl', 2, { expires: 7,path: '/'});
	} else {
		$.cookie('cnl', 1, { expires: 7,path: '/'});
	}
	$.cookie('passwort', $('#passwort').val(), { expires: 7,path: '/'});

	alert('Speichern Erfolgreich');
}
function save_as_home() {
	$.cookie('home_start', '1', { expires: 7,path: '/'});
	alert('Formular wurde als Startseite eingerichtet');
}
function dell_home() {
	$.cookie('home_start', null);
}
