
$.ajaxSetup({
	type: "post",
	dataType: "json"
});

uri = document.URL.split('/');

$(function() {
	
	// Drop Down Menu
	$("#drop-down, #smenu").hover(function() {
		if ( navigator.userAgent.match(/MSIE 6.0/i) == null ) {
			$("#drop-down").css({
				"background-color": "#136FB0"
			});
			
			$("#smenu").show();
			
			$("#smenu").css({
				"top": getElementPosition("drop-down").top + getElementPosition("drop-down").height + "px",
				"left": getElementPosition("drop-down").left + "px"
			});
		}
	}, function() {
		if ( navigator.userAgent.match(/MSIE 6.0/i) == null ) {
			$("#drop-down").css({
				"background-color": "#116098"
			});
			
			$("#smenu").hide();
		}
	});
	
	// Prevent
	$(".prevent").click(function(e){
		e.preventDefault();
	});
	
	// Add the comment
	$("#addcomment").click(function(){
	
		var ajaxQuery = $(this).parent().serialize();
		
		$.ajax({
			data: ajaxQuery,
			url: "ajax.php",
			beforeSend: function(){
				$("#addcomment").parent().children("img").attr({ "src": "images/cm-w8.gif" });
				$("#addcomment").parent().children("img").show();
				$("#report").html('');
			},
			success: function(rs){
				
				if ( !rs['error'] ) {
					$("#addcomment").parent().children("img").attr({ "src": "images/cm-okay.jpg" });
					$("#report").html('Комментарий добавлен');
				} else {
					$("#addcomment").parent().children("img").attr({ "src": "images/cm-error.jpg" });
					$("#report").html(rs['error']);
				}
				
			}
		});
	
	});
	
	
});

