// Resize Menus
function size_menu() {
	// top menu numbers
	top_num = $$("div.hor_menu li").size();
	top_w = Math.floor(582/top_num)-1;
	top_last = 1 + top_w + 582%top_num;

	// botom menu numbers
	bottom_num = $$("div.bottom li").size();
	bottom_w = Math.floor(560/bottom_num)-1;
	bottom_last = bottom_w + 560%bottom_num;

	// top menu
	$$("div.hor_menu li").each(function(n) {
		n.setStyle({
		  width: top_w+'px',
		  textAlign: 'center'
		});

	});

	// bottom menu
	$$("div.bottom li").each(function(n) {
		n.setStyle({
		  width: bottom_w+'px',
		  textAlign: 'center'
		});

	});

	$$("div.hor_menu li a, div.bottom li a").each(function(n) {
		n.setStyle({
		  width: '100%'
		});

	});

	// top
	$$("div.hor_menu li").last().setStyle({	  width: top_last+'px', border: 'none'	});
	// bottom
	$$("div.bottom li").last().setStyle({	  width: bottom_last+'px', border: 'none'	});

}

function load_slider() {

	if($('slider')) {

		$('slider').innerHTML='';
	}
}


Event.observe(window, 'load', function() {
	//size_menu();
	// slider
	if($('slider')) {
		//load_slider();
		my_glider = new Glider('slider', {duration:0.5, autoGlide:true, frequency: 6});
	}

	// tab boxes
	if($('tnav')) {
		boxes = $$('div.main div.tab');
		boxes.invoke('hide');
		boxes.first().show();
		$$('#tnav a').first().toggleClassName('active');

		$$('#tnav a').each(function(n, index) {

			Event.observe(n, 'click', function(event) {
				//n.blur();
				Event.stop(event);

				// change active 
				$$('#tnav a').invoke('removeClassName', 'active');
				n.toggleClassName('active');

				//show corresponding box
				boxes.invoke('hide');
				boxes[index].show();
			});
		});
	}

	// office thumbs 
	if($('thumbs')) {
		$$('#thumbs img').each(function(n) {
			n.observe('click', function(event) {
				Event.stop(event);
				// new Effect.Opacity('img', { from: 1, to: 0 , duration: 1 });
				var mm=$('img').src.replace(/.jpg/gi, "_small.jpg");
				$('img').src=n.src.replace(/_small/gi, "");
				n.src=mm;
				// new Effect.Opacity('img', { from: 0, to: 1 , duration: 1 });
			});
		});
	}

});