
function checksubscribe(formname) {

submitflag = true;
if ( formname.user_anrede.selectedIndex == 0 ) {
    formname.user_anrede.className = 'kv01inputError';	
	submitflag = false
}
else {
    formname.user_anrede.className = 'kv01input';
}

if ( ! formname.user_email.value ){
    formname.user_email.className = 'kv01inputError';
	submitflag = false;
}
else {

      var usr = "([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
      var domain = "([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
      var regex = "^"+usr+"\@"+domain+"$";
      var myrxp = new RegExp(regex);
      var check = (myrxp.test(formname.user_email.value));
        if (check!=true) {
          submitflag = false;
          formname.user_email.className = 'kv01inputError';
        }
		else {
			validateMail(formname.user_email.value);
			//formname.user_email.style.background='';
			if (formname.user_email.className == 'kv01inputError') {
				submitflag = false;
				if (formname.command){
					if (formname.command.value=='update') {
						submitflag = true;
					}
				}			
				
			}			

		}

}

if ( ! formname.user_name.value ){
    formname.user_name.className = 'kv01inputError';
	submitflag = false;
}
else {
    formname.user_name.className = 'kv01input';
}
/*
if ( ! document.subscribeform.user_name.value ){
	document.subscribeform.user_name.style.background='#ee0000';
	submitflag = false;
}
else {
	document.subscribeform.user_name.style.background='';
}
*/
if ( ! formname.user_vorname.value ){
    formname.user_vorname.className = 'kv01inputError';
	submitflag = false;
}
else {
    formname.user_vorname.className = 'kv01input';
}

if ( !submitflag ) {
    $('#subscribealert').show();
}

	return submitflag;
}


function checkversandform(formname){
	submitflag=true;
	if ( ! formname.job_name.value ){
		formname.job_name.style.background='#ffff33';
		submitflag = false;
	}
	else {
		formname.job_name.style.background='';
	}
	if ( ! formname.job_starttime.value ){
		formname.job_starttime.style.background='#ffff33';
		submitflag = false;
	}
	else {
		formname.job_starttime.style.background='';
	}		
	if ( ! formname.job_subject.value ){
		formname.job_subject.style.background='#ffff33';
		submitflag = false;
	}
	else {
		formname.job_subject.style.background='';
	}		
	return submitflag;
}


function createRequestObject() { 
    var ro; 
    var browser = navigator.appName; 
    if(browser == "Microsoft Internet Explorer"){ 
        ro = new ActiveXObject("Microsoft.XMLHTTP"); 
    }else{ 
        ro = new XMLHttpRequest(); 
    } 
    return ro; 
} 

	var http = createRequestObject(); 

function validateMail(email){ 

    var url = '/osMod/nl01/v01/cms/cms_nl01_checkmail.php?mail='; 

    url += email; 
    http.open('get', url); 
    http.onreadystatechange = handleResponse; 
    http.send(null); 
} 

function handleResponse() { 

	if(http.readyState == 4){ 
        var response = http.responseText; 
        if(response.indexOf('true' == 1)) { 
			document.getElementById('user_email').className='osModNL01InputText';
			if (document.getElementById('mailexist')) {
				document.getElementById('mailexist').style.display = 'none';
			}				
        } 
		else {
			document.getElementById('user_email').className='osModNL01InputText';
			if (document.getElementById('mailexist')) {
				document.getElementById('mailexist').style.display = '';
			}		
		}
    } 
} 

function executeURL(url) {
	//var http = createRequestObject(); 
    http.open('get', url); 
    //http.onreadystatechange = handleResponse; 
    http.send(null); 
}

function catliste(){
catlist = document.user.cat_id.options[document.user.cat_id.selectedIndex].value;
zielseite ='cms_nl01.php?obj=user&action=list&cmd=cat&catid='+catlist;
//alert();
document.location=zielseite;
}

function showTextHTML(){
	if (document.OSForm.news_format.selectedIndex == 0){
	document.getElementById('p_content_html_show').style.display = 'none';
	document.getElementById('p_content_text_show').style.display = '';
	document.getElementById('p_content_website_show').style.display = 'none';		
	}
	//if (document.OSForm.news_format.options[document.OSForm.news_format.selectedIndex].value == 1){
	if (document.OSForm.news_format.selectedIndex == 1){
	document.getElementById('p_content_html_show').style.display = '';
	document.getElementById('p_content_text_show').style.display = 'none';
	document.getElementById('p_content_website_show').style.display = 'none';		
	}
//	if (document.OSForm.news_format.options[document.OSForm.news_format.selectedIndex].value == 2){	
	if (document.OSForm.news_format.selectedIndex == 2){
	document.getElementById('p_content_html_show').style.display = '';
	document.getElementById('p_content_text_show').style.display = '';	
	document.getElementById('p_content_website_show').style.display = 'none';		
	}	
	if (document.OSForm.news_format.selectedIndex == 3){
	document.getElementById('p_content_html_show').style.display = 'none';
	document.getElementById('p_content_text_show').style.display = 'none';
	document.getElementById('p_content_website_show').style.display = '';			
	}		
}

function showCat()
{
    if ($("#job_selection").val() == 'cat') {
        $("#cat_select").show();
	}
    else {
        $("#cat_select").hide();
	}

}

function nl01_show_newspage(){
	if ($('#website').val() >0 ) {
		dest = $('#website').val();
		window.open('cms_nl01.php?obj=news&action=showpage&id='+dest+'&lang=de','webcontent','width=890,height=500,left=50,top=20,scrollbars=yes');
	//alert (document.getElementById('website').options[document.getElementById('website').selectedIndex].value )
	}

}

function nl01_show_status(){
	if (document.getElementById('show_status').style.display == 'none'){
		document.getElementById('show_status').style.display = '';
		document.getElementById('switch_status').innerHTML = 'verstecken';
	}
	else {
		document.getElementById('show_status').style.display = 'none';	
		document.getElementById('switch_status').innerHTML = 'anzeigen';
	}
}
function nl01_show_cat(){
	if (document.getElementById('show_cat').style.display == 'none'){
		document.getElementById('show_cat').style.display = '';
		document.getElementById('switch_cat').innerHTML = 'verstecken';
	}
	else {
		document.getElementById('show_cat').style.display = 'none';	
		document.getElementById('switch_cat').innerHTML = 'anzeigen';
	}
}

function nl01_show_usercat() {

    if ($("#cmd").val() == 'cat') {
        $('#showcat').show();
    }
    else {
        $('#showcat').hide();
        document.location = 'cms_nl01.php?obj=user&action=list&cmd='+$("#cmd").val();
    }
}

function nl01_show_userlist() {
    document.location = 'cms_nl01.php?obj=user&action=list&cmd=' + $("#cmd").val()+'&cat_id='+$('#cat_id').val();
}
function nl01_find_user() {
    document.location = 'cms_nl01.php?obj=user&action=list&cmd=ind&usersearch=' + $("#usersearch").val();
}

function job_select() {

    $.getJSON("/osMod/nl01/v02/site/nl01_ajax.php?command=get_newsletterdetail&news_id=" + $("#news_id").val(), function (data) {
        $("#job_subject").val(data.news_subject);
        $("#job_name").val(data.news_title);
    });
}