$(function() {
	$('table.entry').mouseover(function() {
		$(this).addClass('ui-state-hover');
		$(this).addClass('cursorpointer');
	}).mouseout(function() {
		$(this).removeClass('ui-state-hover');
		$(this).removeClass('cursorpointer');
	}).click(function() {
		var className = this.className;
		if (className.match("view")){
			top.location='view/'+$(this).closest('li').attr('id').replace(/entry_/,'')+'/';
		}
		else {
			top.location='edit/'+$(this).closest('li').attr('id').replace(/entry_/,'')+'/';
		}
	}).mousedown(function() {
		$(this).addClass('ui-state-active');
	});

})


$(function() {
	$('a.toggleButton').click(function() {
		toggleId = '#'+$(this).closest('a').attr('id');
		hiddenId = toggleId.replace(/toggle_/,'hidden_');
		buttonId = toggleId.replace(/toggle_/,'button_');
		 
		$(hiddenId).toggle('fast');

		if($(buttonId).text()!='Close Form'){
			buttonText = $(buttonId).text();
			$(buttonId).text("Close Form");
		}
		else if ($(buttonId).text()=='Close Form')
		$(buttonId).text(buttonText);
		
		return false;
		});
});

 
function checkAll(id){
  checkedStatus = $('#checkAllButton_'+id).attr('checked');

 	labelText = $('#checkAllLabel_'+id).text();
	
	if(labelText=='Uncheck All'){
			$('#checkAllLabel_'+id).text("Check All");
		}
	else if(labelText=='Check All'){
			$('#checkAllLabel_'+id).text("Uncheck All");
		}	
		
	 $('input.checkAll_'+id).each(function(){this.checked = checkedStatus; });
}


$(function() {
	$('input.toggleRadio').click(function() {
		toggleId = '#'+$(this).attr('id');
		hiddenId = toggleId.replace(/productid-/,'hidden-productid-');
		$('.showThis').hide();
		$(hiddenId).show();
		$(hiddenId).addClass('showThis');
		});
});

