function hideshow(el,act)
{
	if(act) $('#'+el).css('visibility','visible');
	else $('#'+el).css('visibility','hidden');
}

function error(act,txt)
{
	hideshow('error',act);
	if(txt) $('#error').html(txt);
}
$(document).ready(function(){
						  
	$('#backCal').click(function() {
								  
		if(parseInt($('#month').val())==parseInt($('#nowMonth').val()) && parseInt($('#year').val())==parseInt($('#nowYear').val())){
			jQuery.noticeAdd() 
			return false;
		} 
		if(parseInt($('#month').val())==1 && parseInt($('#year').val())>parseInt($('#nowYear').val())){
			
			var backYear=parseInt($('#year').val())-1;
			$('#year').val(backYear);
			$('#month').val(13);
		} else if(parseInt($('#month').val())!=1 && parseInt($('#year').val())>parseInt($('#nowYear').val())){
			
		}
		
		jQuery.ajax({
			url: $('#valLink').val()+'&move=back&&month='+$('#month').val()+'&year='+$('#year').val(), 
			cache: false,
			success: function(message) {
			
			var valMonth = parseInt($('#month').val())-3;
			$('#month').val(valMonth);
			
			if($('#month').val()== -1){
						var nextYear = parseInt($('#year').val())-1;
						$('#month').val(11);	
						$('#year').val(nextYear);	
					}
					
			document.getElementById("calHolder").innerHTML='<div style="font-weight:bold;z-index:99999;padding:60px;text-align:center;color:#000000;">Loading...</div>';
				setTimeout('loadData("'+message+'")',1000);	
			}
		});
	});
});
$(document).ready(function(){
						    
	$('#nextCal').click(function() {
				jQuery.ajax({
					url: $('#valLink').val()+'&move=next&&month='+$('#month').val()+'&year='+$('#year').val(), 
					cache: false,
					success: function(message) {
					
					var valMonth = parseInt($('#month').val())+3;
					$('#month').val(valMonth);
					if($('#month').val()==14){
						var nextYear = parseInt($('#year').val())+1;
						$('#month').val(2);	
						$('#year').val(nextYear);	
					}
					if($('#month').val()==15){
						var nextYear = parseInt($('#year').val())+1;
						$('#month').val(3);	
						$('#year').val(nextYear);	
					}
				
					document.getElementById("calHolder").innerHTML='<div style="font-weight:bold;z-index:99999;padding:60px;text-align:center;color:#000000;">Loading...</div>';
						setTimeout('loadData("'+message+'")',1000);	
					}
				});
	})
	
});
function loadData(msg){
	
	
	document.getElementById("calHolder").innerHTML=msg;	
}
(function(jQuery)
{
	jQuery.extend({			
		noticeAdd: function(options)
		{	
			var defaults = {
				inEffect: 			{opacity: 'show'},	// in effect
				inEffectDuration: 	600,				// in effect duration in miliseconds
				stayTime: 			3000,				// time in miliseconds before the item has to disappear
				text: 				'Yuo can not go back',					// content of the item
				stay: 				false,				// should the notice item stay or not?
				type: 				'notice' 			// could also be error, succes
			}
			
			// declare varaibles
			var options, noticeWrapAll, noticeItemOuter, noticeItemInner, noticeItemClose;
								
			options 		= jQuery.extend({}, defaults, options);
			noticeWrapAll	= (!jQuery('.notice-wrap').length) ? jQuery('<div></div>').addClass('notice-wrap').appendTo('body') : jQuery('.notice-wrap');
			noticeItemOuter	= jQuery('<div></div>').addClass('notice-item-wrapper');
			noticeItemInner	= jQuery('<div></div>').hide().addClass('notice-item ' + options.type).appendTo(noticeWrapAll).html('<p style="margin-top:20px;margin-left:40px;">'+options.text+'</p>').animate(options.inEffect, options.inEffectDuration).wrap(noticeItemOuter);
			noticeItemClose	= jQuery('<div></div>').addClass('notice-item-close').prependTo(noticeItemInner).html('x').click(function() { jQuery.noticeRemove(noticeItemInner) });
			
			// hmmmz, zucht
			if(navigator.userAgent.match(/MSIE 6/i)) 
			{
		    	noticeWrapAll.css({top: document.documentElement.scrollTop});
		    }
			
			if(!options.stay)
			{
				setTimeout(function()
				{
					jQuery.noticeRemove(noticeItemInner);
				},
				options.stayTime);
			}
		},
		
		noticeRemove: function(obj)
		{
			obj.animate({opacity: '0'}, 600, function()
			{
				obj.parent().animate({height: '0px'}, 300, function()
				{
					obj.parent().remove();
				});
			});
		}
	});
})(jQuery);

// JavaScript Document
