function loadExternalScripts() {
	var headID = document.getElementsByTagName("head")[0];         
	var newScript = document.createElement('script');
	newScript.type = 'text/javascript';
	newScript.src = baseURL + '/javascript/codepress/codepress.js';
	headID.appendChild(newScript);

}


var blog = {

	start : function() {
		blog.setup();
	},
	
	behaviour : function() {
	
	},
	
	setup : function() {
	}
}

document.observe('dom:loaded', blog.start);



function showComment() {
	if ($('com_form').style.display == "none") {
		$('lower').setStyle({
			'height' : 'auto'
		})
		document.getElementById('captcha_img').src='blog/captcha/'+new Date().getTime();
		Effect.BlindDown('com_form');
		
	} 
	return false;
}

function doComment()
{
	$('com_msg').innerHTML = "";
	new Ajax.Request(baseURL + 'blog/ajax/comment',
	{
			method: 'post',
			postBody: Form.serialize($('com_form')),
			onComplete: function(tl) {
				result = tl.responseText.evalJSON();
				
				if (result.error == 1) {
					$('com_msg').innerHTML = result.msg;
				} else if (result.error == 0) {

					if ($$(".comment").length <= 0) {
						$('comments').innerHTML = "";
					}

					Effect.BlindUp('com_form');
					
					if (result.publish == 1) 
					{
						var html = '<div class="comment">';
						html += '<h4>';
						html += '<span>' + ($$('#comments div.comment').length + 1).toString() + '.</span> ';
						html += (($F('url') == "") ? $F('name') : '<a href="'+$F('url')+'">'+$F('name')+'</a>')+'</h4>';
						html += '<p class="commentDate">' + result.time + '</p>';
						html += '<p>' + $F('comment')+'</p></div>';
						Element.insert($('comments'),{'bottom': html });

					} else {
						alert("Your comment has been lodged successfully and it's waiting for approval.\n\n Thank you!")
					}
					$('com_form').reset();
				}
			}
		}
	);
	
	return false;
				
}



function jumpTo(date)
{
	new Ajax.Request(baseURL + 'blog/calendar/'+date,
	{
			method: 'post',
			postBody: '1=1',
			onComplete: function(tl) {
				$('calendar').innerHTML = tl.responseText;
			}
		}
	);
	
	return false;
				
}
