function toggle(element) {
	if (document.getElementById(element).style.display == "none") {
		document.getElementById(element).style.display = "";
	} else {
		document.getElementById(element).style.display = "none";
	}
}
$(document).ready(function(){	
		
	$('[class^=savebox]').hide();
	$('[class^=blockbox]').hide();
	$('[class^=emailbox]').hide();
	$('[class^=morebox]').hide();
	//save
	$("a.save").click(function() {
		var targetId = $(this).attr("id").replace("save-", "save");
		$("." + targetId).toggle(400);
		$('[class^=blockbox]').hide();
		$('[class^=emailbox]').hide();
		$('[class^=morebox]').hide();
	});
	//block
	$("a.block").click(function() {
		var targetId = $(this).attr("id").replace("block-", "block");
		$("." + targetId).toggle(400);
		$('[class^=savebox]').hide();
		$('[class^=emailbox]').hide();
		$('[class^=morebox]').hide();
	});
	//email
	$("a.email").click(function() {
		var targetId = $(this).attr("id").replace("email-", "email");
		$("." + targetId).toggle(400);
		$('[class^=savebox]').hide();
		$('[class^=blockbox]').hide();
		$('[class^=morebox]').hide();
	});
	//more
	$("a.more").click(function() {
		var targetId = $(this).attr("id").replace("more-", "more");
		$("." + targetId).toggle(400);
		$('[class^=savebox]').hide();
		$('[class^=blockbox]').hide();
		$('[class^=emailbox]').hide();
	});
	
	var i = 1;
	$('.notesForm').each(function () {
		var object = $(this);
		object.ajaxForm({
			target: '#htmlNotesTarget' + i, 
			success: function() { 
				$('#htmlNotesTarget' + i).fadeIn('slow');
				object.hide();
		   }
		});
		i++;
	});
	
	var i = 1;
	$('.htmlForm').each(function () {
		var object = $(this);
		object.ajaxForm({
			target: '#htmlExampleTarget' + i, 
			success: function() { 
				$('#htmlExampleTarget' + i).fadeIn('slow');
				object.hide();
		   }
		});
		i++;
	});
	
	var i = 1;
	$('.block').click(function () {
		var object = $(this);
		object.ajaxForm({
			target: '#cekblock' + i,
			success: function() { 
				$('#cekblock' + i).fadeIn('slow');
				object.hide();
			}
		});
		i++;
	});
	
});

function validate_form ( )
{
	valid = true;

    if ( document.searchform.q.value == "" )
    {
        //alert ( "Please fill in the 'Your Name' box." );
        $('#keyword').addClass("error");
		$("input#keyword").focus();		         
		valid = false;
    }

    return valid;
}

function showRemove(e, jid) {
	$(e).html("<span class='saved'>saved to</span> <a href='/jb'>basket</a> - ");
	$(e).css('text-decoration', 'none');
	var rj = $("<span class='sl'>remove</span>").bind('click', function() {
		$.cookie('SJ', $.cookie('SJ').replace('|' + jid, ''), {expires: 30, path: '/'});					
		$(this).remove();
		e.saved = false;
		$(e).html("save job");
		$(e).css('text-decoration', 'underline');
	});
	$(e).after(rj);
	e.saved = true;
}
