$(document).ready(function(){
	$("a.grouped_images").fancybox({
		'padding':5,
		'titleShow':true,
		'titlePosition':'over'
	});
	
	$(".cornered").corner("5px");
	
	$(".rightCol").height($(".content").height());
	
	$("#orderFormTrigger").fancybox();
	
	$("#fizTrigger").click(function(){
		$(".ofUr").fadeOut("fast",function(){
			$(".ofFiz").fadeIn();
		});
	});
	
	$("#urTrigger").click(function(){
		$(".ofFiz").fadeOut("fast",function(){
			$(".ofUr").fadeIn();
		});
	});
	
	$("#orderForm").bind("reset",function(){
		$(".ofUr").fadeOut("fast",function(){
			$(".ofFiz").fadeIn();
		});
	});
	
	$("#orderForm").bind("submit",function(){
		$("#orderForm .form_btns").attr({"disabled":true});
		$("#orderForm #ofMesBox").removeClass();
		$("#orderForm #ofMesBox").hide();
		$.ajax({
			type: "POST",
			cache: false,
			url: "../source/ajax/json_common.php",
			data: $(this).serializeArray(),
			dataType: "json",
			success: function(data) {
				$("#orderForm .form_btns").removeAttr("disabled");
				if(data.flag){
					$("#orderForm").html("<div class='success'>"+data.str+"</div>");
				}
				else{
					$("#orderForm #ofMesBox").addClass("error");
					$("#orderForm #ofMesBox").html(data.str);
					$("#orderForm #ofMesBox").show();
				}
			}
		});
		return false;
	});
});

function calDate(date){
	$("#calendarHeader").html("<img src='./style/main/images/loading_hor.gif' border='0'>");
	$.ajax(
    {
		type: "POST",
		url: "../source/ajax/json_common.php",
		data: {"action":"calendarOtherPeriod", "period":date},
		dataType: "html",
		success: function( data )
		{
			$("#newsCalendar").html(data);
        }
    });
}

function chldMenu(did){
	var status = $("#chb_"+did).css("display");
	if(status == 'none'){
		$.fancybox.showActivity();
		$.ajax(
	    {
			type: "POST",
			url: "../source/ajax/json_common.php",
			data: {"action":"getChildren", "did":did},
			dataType: "html",
			success: function( data )
			{
				$.fancybox.hideActivity();
				$("#chb_"+did).html(data);
				$("#chb_"+did).slideDown();
	        }
	    });
	}
	else{
		$("#chb_"+did).slideUp();
	}
}

function reloadCaptcha(){
	var now = new Date();
	$("#ofCaptcha").attr({"src":'./addons/kcaptcha/?'+ now.getTime()});
}
