
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
$(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');	
			}
		});
	});
});




