$(document).ready(function(){
<!--
	
	//============= EXPAND / CONTRACT ===========================
	var cl_animate = true;
	var cl_animate_ie = true;
	var cl_expandsrc = '/images/icons/down.png';
	var cl_contractsrc = '/images/icons/up.png';
	
	// add the expand image if required
	if (cl_expandsrc) {$(".expandicon").prepend("<img class='cl_expandicon' src='"+cl_expandsrc+"' alt='' />");}
	
	// do expand / contract
	$(".expandtrigger").toggle(
	function () { // expand
		var thisid = $(this).attr("id");
		var cl_ajax_target = $("#" + thisid + "_box > div.ajax_target").text();
		if (cl_ajax_target) {$("#" + thisid + "_box").load(cl_ajax_target);}
		//alert(cl_ajax_target);
		
		if (cl_animate == false || (cl_animate_ie == false && $.browser.msie)) {
			$("#" + thisid + "_box").show();
		} else {
			$("#" + thisid + "_box").show("slow");
		}
		$('.'+thisid+'_expandhide').hide();
		if (cl_contractsrc) {$("#" + thisid + " > img:first").attr("src",cl_contractsrc);}
		
	},
	function () { // contract
		var thisid = $(this).attr("id");
		
		if (cl_animate == false || (cl_animate_ie == false && $.browser.msie)) {
			$("#" + thisid + "_box").hide();
		} else {
			$("#" + thisid + "_box").hide("slow");
		}
		
		if (cl_expandsrc) {$("#" + thisid + " > img:first").attr("src",cl_expandsrc);}
	});
	// ============== EXPAND / CONTRACT END ====================
	
	// ============== SET CONTENT UPPERCASE ===================
	$(".ucase").change( function() {
		var to_upper_text = $(this).attr("value");
		$(this).attr({value:to_upper_text.toUpperCase()});
	});
	
	// ============== ADD CLASS ON FIELD CHANGE ===============
	$("input").change( function() {
		$(this).addClass("cl_modified");
	});
	
	// ============ ADD CLASS ON HOVER =========================
	$(".tag").hover( 
		function() {
			$(this).addClass("side_tag_hover");
		},
		function() {
			$(this).removeClass("side_tag_hover");
		}

	);
	//=============== FORM VALIDATION ===========================
	
	$('.clbSubmit').click( function() {
		if(!$('#spam-detector').attr('value')){
			var id = $(this).attr('name');
			var name = $('#name').attr('value');
			var email = $('#email').attr('value');
			var content = tinyMCE.get('body').getContent();
			var data = new Object();
			data.content = content;
			var dataString = $.toJSON(data);
			$.post('/js/json_comment.php?id='+id+'&name='+name+'&email='+email, {data:dataString}, function(json){
				if(json[0]['errors']){
					$('div.errors').html(json[0]['errors']);
				}
				if(json[0]['comment']){
					$('div.clbNewComment').html(json[0]['comment']);
				}
			}, 'json');
		}
	});
	
		
}); // end ready