






function loginAndReload(){
    
    var username = $('blogUsername').getValue();
    var password = $('blogPassword').getValue();
    
    
    new Ajax.Request('ajaxServer.php?action=siteLogin&username='+username+'&password='+password, {
        onSuccess: function(transport) {
            location.reload();
        }
    });
    
    
}

function loginForm(){
    
    myLightWindow.activateWindow({
	href: 'http://duisburgnonstop-relaunch.contentboxx.info/site_de/loginForm.html'
    });
    
}

function sendCommentPro(){

    
    var name = $('commentName').getValue();
    var mail = $('commentMail').getValue();
    var text = $('commentText').getValue();
    var id =   $('commentArticleID').getValue();
    
    
        var error = false;
    
    if(name == ""){
        $('commentNameError').show('slow');
        error = true;
    }else{
        $('commentNameError').hide('slow');
    }
    
    if(mail == ""){
        $('commentMailError').show('slow');
        error = true;
    }else{
        $('commentMailError').hide('slow');
    }
    
    if(text == ""){
        $('commentTextError').show('slow');
        error = true;
    }else{
        $('commentTextError').hide('slow');
    }
    
    
    
    
    var comment = new Object();
    
    comment.id = id;
    comment.name = name;
    comment.mail = mail;
    comment.text = text;
    
    
    var html = '<div class="commentImgTop"></div>';
    html += '<div class="comment">';
    html +=    '<div class="comment_head"></div>';
    html +=    '<div class="comment_content">';
    //html +=        '<div class="comment_name">'+comment.name+'</div>';
    html +=        '<div class="comment_text">'+comment.text+'</div>';
    html +=    '</div>';
    html +=    '<div class="comment_footer">Name: '+comment.name+'</div>';
    html +=     '</div>';
    html += '<div class="commentImgBottom"></div>';
    
    
    var form = $('blogNewComment');
    var wait = $('newBlogCommentMessage');
    var thx = $('newBlogCommentDanke');
    
    if(!error){
        form.hide();
        wait.show();
        
	jQuery.ajax({
	    type: 'POST',
	    url: 'ajaxServer.php?action=articleComment',
	    data: comment,
	    success: function(){
		
            insertCommentText(html);
	    wait.hide();
            thx.show();
            window.setTimeout("showCommentFormPro()", 3000);
		
	    }	
	});	
	
	
	
        //new Ajax.Request('ajaxServer.php?action=articleComment',{
        //    method: 'POST',
        //    parameters: 'name='+name+'&mail='+mail+'&text='+text+'&id='+id,
        //    onSuccess: function(transport) {
        //        
        //        insertCommentText(html);
        //    }
        //});
    }
    
    
    
}


function insertCommentText(html){
    
    $('articleComments').insert(html, { position: 'top' })
    
}


function showCommentFormPro(){
    var thx = $('newBlogCommentDanke');
    var form = $('blogNewComment');
    
    thx.hide();
    form.show();
    
}

Event.observe(window, 'load', function() { 

        Hotkeys.bind('ctrl+l', loginForm);

});
