$(function(){
	
	createSiteMenu();	
	createZoomMenu();
	
});



function createSiteMenu() {
	$(".menu").each(function() {
		//$(this)
		//.appendTo('body');
		$("li.sel",this).each(function() {
			$(this)
			.bind('mouseover',function() {
				$(this).attr("class","sel show");
			})
			.bind('mouseout',function() {
				$(this).attr("class","sel noshow");
			});
			//$(".menu2",this).width($(this).width()-2);
		});
	});
}

function createZoomMenu() {
	$('.line-gallery img').each(function() {
		$(this)
		.unbind('mouseover')
		.bind('mouseover',function() {createBigPhoto(this,2)});		
	});
}


function createBigPhoto(myObj,mySize) {
	var myPath = $(myObj.parentNode).attr("rel");
	var myNum = $(myObj.parentNode.parentNode).attr("rel");
	
	$('.zoomPhoto').each(function() {
		if(this && this.parentNode) this.parentNode.removeChild(this);
	});
	
	mySize = (!mySize)? 1.5 : parseFloat(mySize);
	var myNewPic = myObj.cloneNode(false);
	
	if (!myNewPic) return;
	
	document.body.appendChild(myNewPic);
	

	
	$(myNewPic).each(function() {
		$(this)
			$(this)
			.unbind('mouseover')
			.css({
				'position' : 'absolute'	,
				'top' : $(myObj).offset().top,
				'left' : $(myObj).offset().left,
				'cursor' : 'pointer',
				'zIndex': 1000000
			})
			.attr('class','zoomPhoto')
			.width($(myObj).width())
			.height($(myObj).height())
			.animate({
				width: parseFloat($(myObj).width()*mySize),
				height: parseFloat($(myObj).height()*mySize),
				left :  parseFloat($(myNewPic).offset().left - (($(myObj).width()*mySize - $(myObj).width()) /2)),
				top :  parseFloat($(myNewPic).offset().top - (($(myObj).height()*mySize - $(myObj).height()) /2))
			},		
			300)
			.bind('click',function() {showGallery(myPath,myNum)})
			.bind('mouseout',function() {
				$(this)
				.animate({
					width: 	$(myObj).width(),
					height: $(myObj).height(),
					left :  $(myObj).offset().left,
					top :  $(myObj).offset().top
				},		
				300,
				function() {
					$(this).remove();
					createZoomMenu();
				}
				);
			});
		
	});
}


	
	
