$(function() {

	$('input:submit').addClass('submit_type');
	$('input:text').addClass('text_type');
	$('input:button').addClass('button_type');
	if(($.browser.msie) && ($.browser.version <= 6)) {
		$('#home .home_box')
			.mouseover(function() { $(this).addClass('hover')})
			.mouseout(function() { $(this).removeClass('hover')});
		//$('#menu li:has(ul)').children('a').addClass('no');	
	};	
	$('#menu li.active ul').parent().children('a').addClass('no');

	/*PRELOAD*/
		$('#thumbs li a').each(function() { 
		var reference=$(this).attr('href');
		img=new Image;
		img.src=""+reference+"";
	});
	
	/*GALLERY CLICK ON THUMBNAIL*/
	$('#gallery #thumbs li:first').addClass('on');
	$('#thumbs li a').click(function() { 
			$('#thumbs li').removeClass('on');
			$(this).parent().addClass('on');
			var source=$(this).attr('href'); 
			$('#bigimg img').hide();
			$('#bigimg img').removeAttr('width');
			$('#bigimg img').attr('src', source).fadeIn(400); 
			//title();
			return false;	
	});
	
	$('#gallery').show()
	
	$('a.gallery').click(function(){
		$('body').prepend('<div id="overlay"></div>')
		var H = window.outerHeight
		$('#overlay').height(H)
		$('#gallery').css('left','30%')
		$('#gallery').fadeIn()
	})
	
	$('#thumbs').jcarousel({ 
		initCallback: thumbs_initCallback
	});
	
	if (($.browser.msie) && ($.browser.version <= 6)) {
	
		var x=$('#thumbs').width()
		$('#thumbs').width(x+75)
	}
	
	$('#gallery').find('.close').click(function(){
		$(this).parent().fadeOut()
		$('body').find('#overlay').remove()
	})
});

function PrintLink() {
	var url = document.location.href;  
	var newurl = url;
	if ( url.indexOf("?") > -1 ) newurl = newurl+'&typeP=1';
	else  newurl = newurl+'?typeP=1';
	
	window.open(newurl,'PrintPage','menubar=1,scrollbars=1,width=540,height=680');
}

function thumbs_initCallback(carousel) {
	$('.jcarousel-next').bind('click', function() {
        carousel.options.scroll = 1;
		carousel.next();
        return false;
    });

    $('.jcarousel-prev').bind('click', function() {
        carousel.options.scroll = 1;
    	carousel.prev();
        return false;
    });

	$('.next-fast').bind('click', function() {
	        carousel.options.scroll = 10;
	        carousel.next();
	        return false;
    });

    $('.prev-fast').bind('click', function() {
        carousel.options.scroll = 10;
    	carousel.prev();
        return false;
    });
};