$(function() {
	$('a').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var target = $(this).attr("href");
            target = $(target);
			target = target.length && target;
			if (target.length) {
				var sclpos = 30;
				var scldurat = 1200;
				var targetOffset = target.offset().top - sclpos;
				$('html,body')
					.animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
				return false;
			}
		}
	});
});

$.auto = {
	init: function() {
		for (module in $.auto) {
			if ($.auto[module].init)
				$.auto[module].init();
		}
	}
};

$(document).ready($.auto.init);

$.auto.hide = {
	init: function() {
		$('.Hide').hide();
	}
};

$.auto.hover = {

	init: function() {
		$('.Hover')
			.bind('mouseover', this.enter)
			.bind('mouseout', this.exit)
			.each(this.preload);
	},

	preload: function() {
		this.preloaded = new Image;
		this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
	},

	enter: function() {
		this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
	},

	exit: function() {
		this.src = this.src.replace(/^(.+)_over(\.[a-z]+)$/, "$1$2");
	}
};

$.auto.submit = {
	init: function() {
		$('SELECT.Submit').bind('change', this.on_change);
	},

	on_change: function() {
		if (this.value) this.form.submit();
	}
};

$.auto.select = {
	init: function() {
		$('LABEL.Select').each(this.label_action);
		$('INPUT.Select').bind('click', function(){ this.select(); });
	},

	label_action: function() {
		var field = $('#'+this.htmlFor).get(0);
		if (field && field.focus && field.select) {
			$(this).bind('click', function(){ field.focus(); field.select(); });
		}
	}
};

$.auto.tabs = {

	init: function() {

		$('.Tabs').each(function(){
			var f = $.auto.tabs.click;
			var group = this;
			$('.Tab', group).each(function(){
				this.group = group;
				$(this).click(f);
				$('#'+this.id+'_body').hide();
			}).filter(':first').trigger('click');
		});

	},

	click: function() {
		var tab = $('#'+this.id+'_body').get(0);
		$('.Tab', this.group).each(function(){
			$(this).removeClass('Active');
			$('#'+this.id+'_body').hide();
		});

		$(this).addClass('Active');
		$(tab).show();
		this.blur();

		return false;
	}

};

$(function() {
	$('#faqlist a').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var target = $(this).attr("href");
            $('.pointup').html('');
            $(target).append('<span class="pointup"><img src="images/faq/answer.gif" alt="answer" width="50" height="17" class="vm" /></span>');
            
		}
	});
});

$(function() {
	$('.up').click(function() {
        $('.pointup').html('');
	});
});

$(function() {
    if($("#im").size()!=0){
        var photo = $('#im li');
        photo.css('display','none');
        setTimeout(sliders,100);
        
    }
});

function sliders(){
        $("#im").easySlider({
            auto: true,
            continuous: true,
            numeric : true,
            speed : 800,
            pause: 8000
        });
        return false;
}

function imagefade(item,nexitem)
{
    item.fadeOut(500,function(){
        nexitem.fadeIn(500);
        $('#pr li').everyTime(5000,'imgtimer',imgtimer);
    });
    
}

$(function() {
    $('#pr li').everyTime(5000,'imgtimer',imgtimer);
});
function imgtimer(){
    var photo = $('#pr li');
    var item = photo.filter(':visible');
    var nextitem = $(item).next('li');
    if(nextitem.size() < 1){
        nextitem = photo.filter(':first');
    }
    imagefade(item,nextitem);
}

$(function() {
    var photo = $('#pr li');
	
    
    
    $('#prprev').click(function(ev) {
        $('#pr li').stopTime('imgtimer');
        var item = photo.filter(':visible');
        var previtem = $(item).prev('li');
        if(previtem.size() < 1){
            previtem = photo.filter(':last');
        }
        imagefade(item,previtem);
	});
    
    $('#prnext').click(function(ev) {
        $('#pr li').stopTime('imgtimer');
        var item = photo.filter(':visible');
        var nextitem = $(item).next('li');
        if(nextitem.size() < 1){
            nextitem = photo.filter(':first');
        }
        imagefade(item,nextitem);
	});
    photo.eq(0).nextAll().hide();
});
