/* CUSTOM JS BY DM */

jQuery(document).ready(function() {
	
	/* menu more button for filter-menu */
	
	jQuery(".menu-more").click(function(){
		jQuery(this).slideUp("fast");
		jQuery(this).parent().children("li.menu-child-hide").slideDown("fast");
		
		return false;
	});
	
	
	
	/* slider for newsticker */
	
	tickerboxnews = window.setTimeout("ticker_move(1, 10, '.ticker-box-news')", 3000);
	tickerboxposts = window.setTimeout("ticker_move(1, 10, '.ticker-box-posts')", 4500);
	
	
	
	/* Media Library function */
	
	jQuery("#media-single-form").find("input#save").click(function() {
		if( jQuery("#media-single-form").find(".image_alt").find("input.text").val() == ""){
			$confirm = confirm("The Alternate Text field has to be filled out. Press OK to get back or Cancel to proceed anyway.");
			if ($confirm == true){
				return false;
			}else{
				return true;
			}
		}
	});
	
	jQuery("#file-form").find("input#save").click(function() {
		if( jQuery("#file-form").find(".image_alt").find("input.text").val() == ""){
			$confirm = confirm("The Alternate Text field has to be filled out. Press OK to get back or Cancel to proceed anyway.");
			if ($confirm == true){
				return false;
			}else{
				return true;
			}
		}
	});
	
});

function cuWaiter() {
	jQuery('#publish').removeClass("button-primary-disabled");
	jQuery('#ajax-loading').hide();
}

function ticker_move(counter, last, selector){
	if( (counter) >= last){
		counter = 0;
		jQuery(selector).animate({
			left: '0px'
		  }, 1000, function() {
			window.setTimeout("ticker_move(" + (counter+1) + ", " + last + ", '" + selector + "')", 3000);
		  });
	}else{
		var toLeft = parseInt(jQuery(".post-list-post").css("width")) + parseInt(jQuery(".post-list-post").css("padding-left")) + parseInt(jQuery(".post-list-post").css("padding-right"));
		jQuery(selector).animate({
		left: '-=' + toLeft + 'px'
	  }, 1000, function() {
		window.setTimeout("ticker_move(" + (counter+1) + ", " + last + ", '" + selector + "')", 3000);
	  });
  }
}
