function showPicDetails(type,img){
	window.open('show_pic.php?type=' + type + '&img=' + img,'','width=600,height=400,top=50,left=50,scrollbars=yes,resizable=yes');
}//end func

function showPic1(type,img,width,height){

	width = width + 18;
	height = height + 70;

	//if (width>800)	width=800;
	//if (height>600) height=600;

	window.open('show_pic1.php?type=' + type + '&img=' + img,'','width='+ width +',height=' + height + ',top=50,left=50,scrollbars=yes,resizable=yes');
}//end func


function onOverTable(id){
	document.getElementById(id).bgColor = '#e3ebc2';
}

function onOutTable(id){
	document.getElementById(id).bgColor = '#f7f9ec';
}


var Tooltip = function(){
	var holder	= new Element('div', {'class' : 'tooltip'});
	var wrapper	= new Element('div', {'class' : 'wrapper'});
	var title	= new Element('h1');
	var content	= new Element('p');
	var move	= function(eve){
		holder.style.left	= Event.pointerX(eve) + 20;
		holder.style.top	= Event.pointerY(eve) + 20;
	};

	holder.appendChild(wrapper)
	wrapper.appendChild(title);
	wrapper.appendChild(content);

	Event.observe(window, 'load', function(){document.body.appendChild(holder);});

	this.show = function(eve, title_text, content_text){
		move(eve);
		Event.observe(document.body, 'mousemove', move);
		title.update(title_text);
		content.update(content_text);
		holder.style.display = 'block';
	}

	this.hide = function(){
		holder.style.display = 'none';
		Event.stopObserving(document.body, 'mousemove', move);
	}
}

function activateCalendar(){
	var calendar_holder = $('events_calendar');
	var tooltip			= new Tooltip();

	if(calendar_holder){
		var childs = calendar_holder.childElements();

		if(childs.length <= 1){	// First is <script>
			return;
		}
	}else{
		return;
	}

	Event.observe(window, 'load', function(){
		calendar_holder.style.height = childs[1].offsetHeight + 'px';
	});

	var scrollYear = function(eve){
		var ele			= Event.element(eve);
		var scroll_to	= $$('#events_calendar .calendar.year_' + ele.title)[0];

		if(scroll_to){
			calendar_holder.scrollTop = scroll_to.positionedOffset()[1];
		}
	}


	$$('#events_calendar .calendar .day.selected').each(function(ele){
		ele.observe('mouseover', function(eve){
			var id = ele.id.substr(ele.id.lastIndexOf('_') + 1);
			tooltip.show(eve, events_data[id].title, events_data[id].content);
		});
		ele.observe('mouseout', function(){
			tooltip.hide();
		});
	});

	var left_months		= $$('#events_calendar .calendar .month .left_arrow');
	var right_months	= $$('#events_calendar .calendar .month .right_arrow')
	var left_years		= $$('#events_calendar .calendar .year .left_arrow');
	var right_years		= $$('#events_calendar .calendar .year .right_arrow')

	left_months.each(function(ele, key){
		if(key === left_months.length - 1){
			ele.style.visibility = 'hidden';
		}else{
			ele.observe('click', function(){calendar_holder.scrollTop += ele.parentNode.parentNode.offsetHeight;});
		}
	});

	right_months.each(function(ele, key){
		if(key === 0){
			ele.style.visibility = 'hidden';
		}else{
			ele.observe('click', function(){calendar_holder.scrollTop -= ele.parentNode.parentNode.offsetHeight;});
		}
	});

	left_years.each(function(ele, key){
		if(key === left_years.length - 1){
			ele.style.visibility = 'hidden';
		}else{
			ele.observe('click', scrollYear);
		}
	});

	right_years.each(function(ele, key){
		if(key === 0){
			ele.style.visibility = 'hidden';
		}else{
			ele.observe('click', scrollYear);
		}
	});
}
