$(window).bind('load',function(){
	if(typeof($().fancybox)=='function'){
		$('.zoom li a, .fb-zoom').fancybox({
			padding: 0,
			zoomSpeedIn			:	400,
			zoomSpeedOut		:	400,
			zoomSpeedChange		:	300,
			centerOnScroll		:	false,
			easingIn			:	'swing',
			easingOut			:	'swing',
			easingChange		:	'swing',
			overlayShow			:	false
		});
	}
	if(typeof($().slideShow)=='function'){
		$('div.gallery-holder').slideShow({
			numElementLink:'ul.paging li a',
			slideEl:'ul.s-items li',
			autoSlideShow:true,
			onChange: function(){
				if(typeof(Cufon)=="function") Cufon.refresh('.paging a');
			},
			switchTime:8000,
			duration:500
		});
	}

	if(typeof($().accordion)=='function'){
		$('.navigation').accordion({
			active: false,
			change: function(event, ui) {
				Cufon.refresh('.navigation .font.ui-state-active');
				Cufon.refresh('.navigation .font');
			},
			collapsible: true
		})
	}
	clearInput();
})

function initTooltip(){
	var _tt = '<div class="tooltip"><div class="tooltip-t"/><div class="tooltip-c"><div class="tt-img"></div></div><div class="tooltip-b"><strong class="tt-title"></strong></div></div>'
	$('.tooltip-link').each(function(_ind){
		var _title = $(this).attr('title');
		$(this).attr('title','');
		var _img = $(this).attr('rel');
		$(this).attr('index','tooltip-msg'+_ind);
		var _tmp = $(_tt).attr('id','tooltip-msg'+_ind);
		_tmp.find('strong.tt-title').html(_title);
		_tmp.find('div.tt-img').html('<img src="'+_img+'" alt="'+_title+'" />');
		if(typeof(document.body.style.maxHeight) == 'undefined'){
			var _frame = $('<iframe src="javascript:false" />');
			_tmp.append(_frame);
			_frame.css({
				opacity: 0,
				clear: 'both',
				position: 'absolute',
				left: 0,
				top: 0,
				width: "100%",
				height: "100%",
				zIndex: 0
			});
		}
		$('body').append(_tmp);
	});

	var over = false;
	$('a.tooltip-link').mouseenter(function(){
		var _this = $(this);
		var holder = $('#'+$(this).attr('index'));
		holder.css({
			height: holder.height()+'px',
			top: _this.offset().top - holder.height()+'px',
			left: _this.offset().left + _this.width()/2 - holder.width()/2 +'px'
		}).show();
		holder.mouseenter(function(){
			over = true;
			$(this).show();
		}).mouseleave(function(){
			over = false;
			$(this).hide();
		})
	}).mouseleave(function(){
		if(!over) $('#'+$(this).attr('index')).hide();
	});
}
$(document).ready(function(){
	//$('div.galery1').galleryScroll();
	//initTooltip();
});

function clearInput(){
	var _input = $('input:text, textarea');

	_input.each(function(){
		var _this = $(this);
		_this.attr('def',_this.attr('value'));

		_this.focus(function(){
			if($(this).attr('value')==$(this).attr('def')) $(this).attr('value','');
		}).blur(function(){
			if($(this).attr('value')=='' || $(this).attr('value')==$(this).attr('def')) $(this).attr('value',$(this).attr('def'));
		});
	});
}

