function check() {
	var links = jQuery.trim($("#links").val());
	links = links.replace('https://','http://');
	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()+"&minCheck="+$('#minCheck option:selected').val()+"&replaceAfterDays="+$('#replaceAfterDays option:selected').val()+"&mirror_type="+$('#mirror_type:checked').val()+"&mirror1="+$('#mirror1').val()+"&mirror2="+$('#mirror2').val()+"&mirror3="+$('#mirror3').val()+"&ajax=1",
			
			success: function(xml) {
			$("#msgbox").html(unescape(xml));
		}
		}); 
	}
}
function getrsname(url) {
	if(strpos(url,"\n"))
	{
		url=substr(url,0,strpos(url,"\n")+1);
	}

	if($("#titel").val()=="Unbenannter Ordner" || $("#titel").val()=="Unnamed folder") {
		if(strrpos(url,'.rar') || strrpos(url,'.part01')) {
		var dname=substr(url,strrpos(url,'/')+1);
		dname = dname.replace('.html', '');
		dname = dname.replace('.htm', '');
		dname = dname.replace('.rar', '');
		dname = dname.replace('.part01', '');
			$("#titel").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: '/'});
	}
	if($('#mirror_type:checked').val()) {
		$.cookie('mirror_type', $('#mirror_type:checked').val(), { expires: 7,path: '/'});
	}
	if($('#minCheck option:selected').val()) {
		$.cookie('minChecked', $('#minCheck:selected').val(), { expires: 7,path: '/'});
	}
	if($('#replaceAfterDays  option:selected').val()) {
		$.cookie('replaceAfterDays', $('#replaceAfterDays:selected').val(), { 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);
}

function show_mirror() {
	if($('#m1').css('display')!='table-row')
	{
		$('#m1').css('display', '');
		$('#m2').css('display', '');
		$('#m3').css('display', '');
		$('#m4').css('display', '');
		$('#m5').css('display', '');
		$('#m6').css('display', '');
	}
	else
	{
		$('#m1').css('display', 'none');
		$('#m2').css('display', 'none');
		$('#m3').css('display', 'none');
		$('#m4').css('display', 'none');
		$('#m5').css('display', 'none');
		$('#m6').css('display', 'none');
	}
		
	
	return false;
}

