function scrollTo(e){
if(jQuery("#"+e))	
jQuery('html, body').animate({scrollTop: jQuery("#"+e).offset().top}, 500)
}
var item_width = 381;
var item_height = 246;
var item_count;
var obj_id = "#moveable-area";
var current_img_pos = 1;
var normal_speed = 400; // millisecondes
var wait_delay = 13000;
var interval_id;

jQuery(document).ready(function(){
	item_count = jQuery(obj_id+" a").length;
	jQuery(obj_id).css("width",item_count*item_width+"px");
	jQuery(obj_id).css("height",item_height+"px");	
	interval_id = setInterval("slide('right', 1)",normal_speed+wait_delay);
});
function slide(direction, step) {	
	if ( step >= item_count ) {
		return false;
	}
	var speed = normal_speed/step;
	if ( direction=="right" && step==1 && current_img_pos==item_count ) {
		direction = "left";
		step = item_count -1;
	}
	var current_left = getNumericValue(jQuery(obj_id).css("left"));
	var move_length = step * item_width;
	if ( direction=="right" ) {		
		jQuery(obj_id).animate({
			'marginLeft' : "-="+ move_length+"px"
		},speed);		
		current_img_pos = current_img_pos + step;
	} else {		
		jQuery(obj_id).animate({
				'marginLeft' : "+="+ move_length+"px"
		},speed);	
		current_img_pos = current_img_pos - step;
	}
	jQuery("#page-area span.page_number").removeClass("selected");
	jQuery("#page-area span#page_number_"+current_img_pos).addClass("selected");
}
function selectPage(page_number) {
	clearInterval(interval_id);
	if ( page_number == current_img_pos ) {
		return false;
	}
	if ( current_img_pos < page_number ) {
		slide("right",page_number-current_img_pos);	
	}
	if ( current_img_pos > page_number ) {
		slide("left",current_img_pos-page_number);	
	}
	interval_id = setInterval("slide('right', 1)",normal_speed+wait_delay);
}
function getNumericValue(str) {
	return parseInt(str.replace("px",""));
}
jQuery().ready(function() {
	// validate the comment form when it is submitted
	//jQuery("#contactform").validate();

	jQuery("ul.main_menu").superfish({
				pathClass : 'current'
			});

	jQuery("ul.sidemenu li a.active").parents("ul").prev('a')
			.addClass("active");
	jQuery("ul.sidemenu li a.active").parent("li").parent("ul").parent("li")
			.prev("li").children("a.solidblue").addClass("active");
	jQuery("ul.sidemenu").show();

	jQuery("a.imgbutton img").fadeTo("fast", 0.7);

	jQuery("a.imgbutton img").hover(function() {
		jQuery(this).stop().fadeTo("fast", 1);
		jQuery(this).parent().parent().find('a.sp_green2')
				.addClass('sp_green2_hover');
	}, function() {
		jQuery(this).stop().fadeTo("fast", 0.7);
		jQuery(this).parent().parent().find('a.sp_green2')
				.removeClass('sp_green2_hover');
	});

	jQuery("a.sp_green2").hover(function() {
		jQuery(this).parent().parent().find('a.imgbutton img').stop().fadeTo(
				"fast", 1);
	}, function() {
		jQuery(this).parent().parent().find('a.imgbutton img').stop().fadeTo(
				"fast", 0.7);
	});

	jQuery(".sfHover .submenu").attr('style',
			'display:block; visibility: visible;');
	jQuery(".about").mouseover(function() {
				jQuery("#about_menu").attr('style', 'visibility: visible;');
			});
	jQuery("#about_menu").mouseover(function() {
				jQuery("#about_menu").attr('style', 'visibility: visible;');
			}).mouseout(function() {
				jQuery(this).attr('style', 'visibility: hidden;');
			});

});

/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */

(function($){
	$.fn.superfish = function(op){

		var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
			over = function(){
				//alert("Navodim");
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function(){
				//alert("Uvodim");
				var $$ = $(this), menu = getMenu($$), o = sf.op;
				clearTimeout(menu.sfTimer);
				//alert(o.$path.length);
				menu.sfTimer=setTimeout(function(){					
					o.retainPath=($.inArray($$[0],o.$path)>-1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
				},o.delay);	
			},
			getMenu = function($menu){
				//alert("Formiruem menu");
				var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
			
		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({},sf.defaults,op);
			o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
				$(this).addClass([o.hoverClass,c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;
			
			$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
				if (o.autoArrows) addArrow( $('>a:first-child',this) );
			})
			.not('.'+c.bcClass)
				.hideSuperfishUl();
			
			var $a = $('a',this);
			$a.each(function(i){
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
			});
			o.onInit.call(this);
			
		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function(){
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
			this.toggleClass(sf.c.shadowClass+'-off');
		};
	sf.c = {
		bcClass     : 'sf-breadcrumb',
		menuClass   : 'sf-js-enabled',
		anchorClass : 'sf-with-ul',
		arrowClass  : 'sf-sub-indicator',
		shadowClass : 'sf-shadow'
	};
	sf.defaults = {
		hoverClass	: 'sfHover',
		pathClass	: 'overideThisToUse',
		pathLevels	: 1,
		delay		: 850,
		animation	: {opacity:'show',height:'show'},
		speed		: 'slow',
		autoArrows	: true,
		dropShadows : true,
		disableHI	: false,		// true disables hoverIntent detection
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){}
	};
	$.fn.extend({
		hideSuperfishUl : function(){
			var o = sf.op,
				not = (o.retainPath===true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility','hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl : function(){
			var o = sf.op,
				sh = sf.c.shadowClass+'-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility','visible');
			sf.IE7fix.call($ul);
			o.onBeforeShow.call($ul);
			
			//$ul.show("fast");
			$ul.fadeIn(800);
			//$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);

