
function toggle_visibility(id) {
   var e = document.getElementById(id);
      if(e.style.display == 'none')
         e.style.display = 'block';
      else
         e.style.display = 'none';
}

function hideContent(id) {
      document.getElementById(id).style.display = "none";
}

function showContent(id) {
   document.getElementById(id).style.display = "block";
}

function popWin(imgUrl) {
   var imgWindow=null;
   var w='200';
   var h='100';
   LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/3:100;
   settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=yes,status=no,menubar=no,toolbar=no,resizable=yes';
   imgWindow=window.open("http://toderash.net/wp-content/themes/strategic/imgpop.php?img="+imgUrl,'popup',settings);
   imgWindow.focus();
   return false;
}

// Word Count for Text Areas
/* Usage: add class="count=[n]" to the (e.g., comment or form) textarea tag to have wordcount applied, where n is the word count at which the class should change from 'wordCount' to 'error' and style with CSS - this ONLY changes the style, it doesn't trim the comment or input length */
$(document).ready(function() {
	$("[class^='count[']").each(function() {
		var elClass = $(this).attr('class');
		var minWords = 0;
		var maxWords = 0;
		var countControl = elClass.substring((elClass.indexOf('['))+1, elClass.lastIndexOf(']')).split(',');
		
		if(countControl.length > 1) {
			minWords = countControl[0];
			maxWords = countControl[1];
		} else {
			maxWords = countControl[0];
		}	
		
		$(this).after('<div class="wordCount"><strong>0</strong> Words</div>');
		if(minWords > 0) {
			$(this).siblings('.wordCount').addClass('error');
		}	
		
		$(this).bind('keyup click blur focus change paste', function() {
			var numWords = jQuery.trim($(this).val()).split(' ').length;
			if($(this).val() === '') {
				numWords = 0;
			}	
			$(this).siblings('.wordCount').children('strong').text(numWords);
			
			if(numWords < minWords || (numWords > maxWords && maxWords != 0)) {
				$(this).siblings('.wordCount').addClass('error');
			} else {
				$(this).siblings('.wordCount').removeClass('error');	
			}
		});
	});
});


jQuery(function() {

	jQuery("#archive-wrapper").height(jQuery("#archive-pot").height());

	jQuery("#archive-browser select").change(function() {
	
		jQuery("#archive-pot")
			.empty()
			.html("<div style='text-align: center; padding: 30px;'><img src='/wp-content/themes/DiggingIntoWordPress-2/images/ajax-loader.gif' /></div>");
	
		var dateArray = jQuery("#month-choice").val().split("/");
		var y = dateArray[3];
		var m = dateArray[4];
		var c = jQuery("#cat").val();
		
		jQuery.ajax({
		
			url: "/archives-getter/",
			dataType: "html",
			type: "POST",
			data: ({
// $table_prefix  = 'sw_dev1_';
//				"digwp_y": y,
//				"digwp_m" : m,
//				"digwp_c" : c
				"sw_dev1_y": y,
				"sw_dev1_m" : m,
				"sw_dev1_c" : c
			}),
			success: function(data) {
				jQuery("#archive-pot").html(data);
				
				jQuery("#archive-wrapper").animate({
					height: jQuery("#archives-table tr").length * 50
				});
			
			}
			
		});
			
	});

});


