// JavaScript Document

$(function() {
	
	$('.single_submenu_item')
		.bind('mouseover',function() {
			$(this).addClass('roll');
		})
		.bind('mouseout',function() {
			$(this).removeClass('roll');
		})
	
	$('.menu_item')
		.bind('mouseover',function() {
			$(this).find('img').css('background-position','0px 40px');
		})
		.bind('mouseout',function() {
			$(this).find('img').css('background-position','0px 0px');
		})
		
	$('#services, #effects, #about_us')
		.bind('mouseover',function() {
			pos = $(this).position();
			obj = $('.submenu:has(.submenu_' + $(this).attr('id') + ')');
			obj.css('left',pos.left-obj.width()/2+$(this).width()/2+'px')
				.css('top',$(this).position().top+$(this).height()+'px')
				.css('display','block');
			clearTimeout(obj.attr('rel'));
		})
		.unbind('mouseout')
		.bind('mouseout',function() {
			var obj = $('.submenu:has(.submenu_' + $(this).attr('id') + ')');
			var _this = $(this);
			obj.attr('rel', setTimeout( function() {
				obj.css('display','none');
				_this.find('img').css('background-position','0px 0px');
			}, 100 ));
		})
	$('.submenu')
		.bind('mouseover',function() {
			clearTimeout($(this).attr('rel'));
			name = $(this).children().first().attr('class').split('_');
			$('#'+name[1]).find('img').css('background-position','0px 40px');
		})
		.bind('mouseout',function() {
			var name = $(this).children().first().attr('class').split('_');
			var obj = $(this);
			obj.attr('rel', setTimeout( function() {
				$('#'+name[1]).find('img').css('background-position','0px 0px');
				obj.css('display','none');
			}, 100 ));
		});
		
	$('.single_tout_image')
		.bind('mouseover',function() {
			$(this).children('.single_tout_overlay').css('display','none');
		})
		.bind('mouseout',function() {	
			$(this).children('.single_tout_overlay').css('display','block');
		});
		
	$('.inner_submenu_item')
		.bind('mouseover',function() {$(this).addClass('roll');})
		.bind('mouseout',function() {$(this).removeClass('roll');});
		
	if ($("a[rel^='prettyPhoto']").length) $("a[rel^='prettyPhoto']").prettyPhoto();
	
	$('.content_gallery_image_big').each( function() {
		var big_image = $(this);
		$(this).parent('.content_gallery_pack').find('.content_gallery_image').click( function() {
			big_image.find('a').attr('href', '/admin1/upload/image/' + $(this).find('a').attr('rel') );
			big_image.find('img').attr('src', '/admin1/upload/thumb/' + $(this).find('a').attr('rel') );
			return false;
		});
	})
});

