


function checkfield (type, form, field) {
	jQuery("#loading").ajaxStart(function(){
  		jQuery(this).show();
 	});
	jQuery("#loading").ajaxStop(function(){
	   jQuery(this).hide();
	 });

	jQuery.ajax({
			url: "/checkfield.php",
			data: 'type='+type+'&name=' + field.value,
			type:'GET',
			 success: function(aws){
				if (aws == 'OK') {
					jQuery.jGrowl('<p></p>"'+field.value+'" : ' +aws, {
					theme: 	'success',
					header: '&Uuml;berpr&uuml;fen',
					life:	4000,
					sticky: false
					});
					jQuery('#'+field.name+'checkitvalue').html('<span style="color:green">"' + field.value + 
							'": ' + aws + '</span>');
				} else {
					jQuery.jGrowl('<p></p>"'+field.value+'" : ' +aws, {
					theme: 	'warning',
					header: '&Uuml;berpr&uuml;fen',
					life:	4000,
					sticky: false
					});
					jQuery('#'+field.name+'checkitvalue').html('<span style="color:red">"' + field.value + '": ' +
					aws + '</span>');
					
				}
			
			 },
			 error: function (aws){
				 alert(aws);
			 }
		});
}

function unvote (user, id, htmlid, md5, value){
	var link_data = "unvote=true&id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
	var user_data = user;
	exp_vote(link_data,user,id);
}

function vote (user, id, htmlid, md5, value){
	var link_data = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		if (value == '-10'){
		jQuery.ajax({
			url: "/vote.php",
			data: link_data,
			type:'POST',
			 success: function(aws){
				 
				split = new RegExp ("~--~");
				if (aws.match (split)) {
				b = aws.split (split);
				jQuery.jGrowl('<p></p>Vielen Dank für Ihren Hinweis.', {
				theme: 	'error',
				header: 'Gemeldet',
				life:	4000,
				sticky: false
			});
				jQuery("#id_story-"+id).find('#xvotes').html(b[0]);
				jQuery("#id_story-"+id).find('.vote_img').html("<span class='vote_text_small'>Stimmen</span>").parents('.stories').find('#linksummaryBury').hide();
				}}})}else{
				
				exp_vote(link_data,user,id);
				};

};

function exp_vote(link_data,user,id){
	anonymous_vote = true ;
        if (anonymous_vote == false && user == '0') {
			jQuery.scrollTo('#top_body', 800 );
			/*
			jQuery.jGrowl('<p></p>Zum Bewerten bitte einloggen', {
				theme: 	'warning',
				header: 'Login',
				life:	4000,
				sticky: false
			});
			*/
            jQuery("div#box_conteiner").slideDown("normal");
			jQuery("#a_login").addClass('current');
        } else {
 	jQuery.ajax({
			url: "/vote.php",
			data: link_data,
			type:'POST',
			 success: function(aws){
				 
				split = new RegExp ("~--~");
				if (aws.match (split)) {
				b = aws.split (split);
				jQuery.jGrowl('<p></p>Vielen Dank, dass Sie abgestimmt haben.', {
				theme: 	'success',
				header: 'Erfolgreich!',
				life:	4000,
				sticky: false
			});
				jQuery("#id_story-"+id).find('#xvotes').html(b[0]);
				jQuery("#id_story-"+id).find('.vote_img').html("<span class='vote_text_small'>Stimmen</span>").parents('.stories').find('#linksummaryBury').hide();
				} else {
				errormatch = new RegExp ("^ERROR:");
				aws = aws.substring (6, aws.length);
				jQuery.jGrowl('<p></p>'+aws, {
				theme: 	'warning',
				header: 'Warnung !',
				life:	4000,
				sticky: false
			});
				jQuery("#id_story-"+id).find(".information_box").show().html(aws).fadeOut(3000);
				}
				 
			
			 },
			 error: function (aws){
			 }
		});
		}
}

function link_add_remove(href_link ,title_link,link_this) {
		jQuery.ajax({
			url: href_link,
			type:'POST',
			 complete: function(){
				jQuery(link_this).parents(".stories").find(".information_box").show().html(title_link).fadeOut(3000);
		
			 }
		});
		
	}

$(document).ready(function() {
	
	jQuery('.groupstorystatus_bg a').click(function(){
			
		var this_link = jQuery(this).parents(".title");
		var href_link = jQuery(this).attr('href');
		jQuery.ajax({
				url: href_link,
				type:'POST',
			success: function(aws){
		jQuery(this_link).find(".story_status_success").show('slow').end().find(".groupstorystatus_box").toggle('slow');
			}
		});
		return false;
	});	
	
	jQuery("#footer_copy_top a").click(function(){
		jQuery.scrollTo('#top_body', 800 );
	});
	
	jQuery('.groupstorystatus_link').click(function(){
		jQuery(this).parents(".title").find(".groupstorystatus_box").toggle('slow').end().find(".story_status_success").hide();
		return false;
	});	
	
	jQuery("input[name=exp_rssfeeds]")
		.click(function() {
			jQuery(this).select();
		});
								
	jQuery("#a_login").click(function(){
		if (jQuery("div#box_conteiner").is(":hidden")) {
        jQuery("div#box_conteiner").slideDown("normal");
		jQuery(this).addClass('current');
      } else {
        jQuery("div#box_conteiner").slideUp("normal");
		jQuery(this).removeClass('current');
      }
	
	});
	
	jQuery("#comment_login").click(function(){
		jQuery.scrollTo('#top_body', 800 );
		jQuery("div#box_conteiner").slideDown("normal");
		jQuery("#a_login").addClass('current');
	});
	
	jQuery('#submit_login').click(function(){
		jQuery(this).parents('form').find('input.login_return').val(window.location.href);
	});
	
	jQuery("input, textarea").addClass("idle");
            jQuery("input, textarea").focus(function(){
                jQuery(this).addClass("activeField").removeClass("idle");
	    }).blur(function(){
                jQuery(this).removeClass("activeField").addClass("idle");
	    });
	
	 jQuery('.save_add , .remove_add').click(function(event) {
		var href_link = jQuery(this).attr('href');
		var title_link = jQuery(this).attr('title');
		var link_this = this;
		link_add_remove(href_link ,title_link,link_this);
		return false;
  });
	
	jQuery("select#exp_sort").change(function(){
		window.location=jQuery(this).val();												   
		});
	
	jQuery('#story_sort select[name="exp_sort"]').removeAttr("disabled");
			
	jQuery(".stories_opacity").css('opacity',0.3);

	jQuery('.shared,.close_box').click(function(){
		jQuery('div.share_box' , jQuery(this).parents().parents('div:first')).toggle('slow');
		return false;
	});	
	
	jQuery('.tags_link').click(function(){
		jQuery(this).parents(".stories").find(".tags_share_box").toggle('slow');
		return false;
	});	
	
	jQuery('.group_link').click(function(){
		jQuery(this).parents(".stories").find(".group_share_box").toggle('slow');
		return false;
	});	
	
	jQuery('.admin_link').click(function(){
		jQuery(this).parents(".title").find(".ls_adminlinks_exp").toggle('slow').end().find(".story_status_success").hide('slow');
		return false;
	});
	
	function makeTabs(contId) {
    	var tabContainers = jQuery('#'+contId+' div.tabs > div');
    	tabContainers.hide().filter(':first').show();
    
    	jQuery('#'+contId+' div.tabs ul.tabNavigation a').click(function () {
        	tabContainers.hide();
        	tabContainers.filter(this.hash).show();
        	jQuery('#'+contId+' div.tabs ul.tabNavigation a').removeClass('selected');
        	jQuery(this).addClass('selected');
        	return false;
    	}).filter(':first').click();
    }
	makeTabs('tabs-1');



	
});
function cvote (user, id, htmlid, md5, value){
			anonymous_vote = true ;
        if (anonymous_vote == false && user == '0') {
			jQuery.scrollTo('#top_body', 800 );
            jQuery("div#box_conteiner").slideDown("normal");
			jQuery("#a_login").addClass('current');
        } else {
			jQuery.ajax({
			url: "/cvote.php",
			data: "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value,
			type:'POST',
			 success: function(aws){
				 
				split = new RegExp ("~--~");
				if (aws.match (split)) {
				b = aws.split (split);
				jQuery.jGrowl('<p></p>Vielen Dank, dass Sie diesen Kommentar bewertet haben.', {
				theme: 	'success',
				header: 'Kommentar Bewerten',
				life:	4000,
				sticky: false
				});
				
				jQuery("#cvote-"+id).text(b[0]);
				jQuery("#rate_text_exp-"+id).fadeOut(3000);
				
				} else {
				errormatch = new RegExp ("^ERROR:");
				aws = aws.substring (6, aws.length);
				jQuery.jGrowl('<p></p>'+aws, {
				theme: 	'warning',
				header: 'Kommentar Bewerten',
				life:	4000,
				sticky: false
				});
				/*
				jQuery("#ratebuttons").parents('#comment-wrap').show().append(aws).fadeOut(3000);
				*/
				
				}
				 
			
			 },
			 error: function (aws){
			 }
			});
		}
}

