function getUrl(v)
{
	var url = location.href.split('#')[1];
	return (url == undefined) ? false : url.split('/')[v];
}

$(function()
{
	jQuery.easing.def = 'easeOutQuart';
	var mainLeft = (-1060 - 200) + ($(window).width() / 2);
	var aboutLeft = (-2060 - 500) + ($(window).width() / 2);
	var contactLeft = (-3460 - 250) + ($(window).width() / 2);
	var onLoadLeft = (getUrl(0) != false) ? eval(getUrl(0) + 'Left') : mainLeft;
	var onLoadHeightC = (getUrl(0) != false) ? getUrl(0) : 'main';

	$(window).bind('load', function()
	{
		$('#loading').hide();
		$('#site').show();
		$('#line').css('height', $('.' + onLoadHeightC + '-page').height() + 300);
		$('#line > .line-img').animate({'left': onLoadLeft}, 3000, function()
		{
			switch(onLoadHeightC)
			{
				case 'main' : { $('.about-page, .contact-page').hide(); break; }
				case 'about' : { $('.main-page, .contact-page').hide(); break; }
				case 'contact' : { $('.about-page, .main-page').hide(); break; }
			}
		});
	});

	$('.yur-1, .yur-2, .yur-3, .yur-4').bind('keyup', function()
	{
		if(
			$('.yur-1').val() != '' &&
			$('.yur-2').val() != '' &&
			$('.yur-3').val() != '' &&
			$('.yur-4').val() != ''
		) { $('.yur-submit').show('slow'); }
		else { $('.yur-submit').hide('slow'); }
	});

	$('.fiz-1, .fiz-2, .fiz-3, .fiz-4').bind('keyup', function()
	{
		if(
			$('.fiz-1').val() != '' &&
			$('.fiz-2').val() != '' &&
			$('.fiz-3').val() != '' &&
			$('.fiz-4').val() != ''
		) { $('.fiz-submit').show('slow'); }
		else { $('.fiz-submit').hide('slow'); }
	});

	$('.dofiz').click(function()
	{
		$(this).toggleClass('licoSel');
		$('.doyur').removeClass('licoSel');
		$('.yurlico').hide();
		$('.fizlico').show();
		return false;
	});

	$('.doyur').click(function()
	{
		$(this).toggleClass('licoSel');
		$('.dofiz').removeClass('licoSel');
		$('.fizlico').hide();
		$('.yurlico').show();
		return false;
	});

	$('.img-border').click(function()
	{
		window.location.href = $(this).attr('hrefto');
	});

	$('.pr-subhead-1, .pr-subhead-2, .pr-subhead-3').click(function()
	{
		$('.product-nav').each(function(j)
		{
			$(this).hide();
		});
	});

	$('.pr-subhead-1').click(function()
	{
		$('#prnav-1-' + $(this).attr('sub')).show();
		return false;
	});

	$('.pr-subhead-2').click(function()
	{
		$('#prnav-2-' + $(this).attr('sub')).show();
		return false;
	});

	$('.pr-subhead-3').click(function()
	{
		$('#prnav-3-' + $(this).attr('sub')).show();
		return false;
	});

	$('.nav-slub').click(function()
	{
		//$('#prnavslub-' + $(this).attr('sub')).toggle();
		//return false;
	});

	$('.img-item').bind('mouseover', function()
	{
		$(this).children('.img-border').show();
	}).bind('mouseout', function()
	{
		$(this).children('.img-border').hide();
	});

	$('.product-imgs-list').click(function()
	{
		$('.img-border-product').hide();
		$(this).children('.img-border-product').show();
		$('.mainimg').attr('src', $(this).find('a').attr('href'));
		$('.mainimg').attr('hrefto', $(this).find('a').attr('hrefto'));
		$('.mainimg').attr('w', $(this).find('a').attr('w'));
		$('.mainimg').attr('h', $(this).find('a').attr('h'));

		return false;
	});

	$('.mainimg').click(function()
	{
		var toTop = ($(window).height() / 2) - ($(this).attr('h') / 2) + $(window).scrollTop();
		var toLeft = ($(window).width() / 2) - ($(this).attr('w') / 2);
		if(toTop < 10) { toTop = 30; }
		$('.black').css('width', $(document).width()).css('height', $(document).height()).show();
		$('.zoomPrImg').css('top', toTop).css('left', toLeft).show();
		$('.zoomPrImg > img').attr('src', $(this).attr('hrefto'));
		return false;
	});

	$('.black, .zoomPrImg').click(function()
	{
		$('.black, .zoomPrImg').hide();
	});

	$('.main-link, .about-link, .contact-link').click(function()
	{
		$('#line').css('height', $('.' + $(this).attr('load') + '-page').height() + 300);
		$('#line > .line-img').stop();
		$('.main-page, .about-page, .contact-page').show();
		window.location.href = '#' + $(this).attr('load');

		switch($(this).attr('class'))
		{
			case 'main-link' :
			{
				$('#line > .line-img').animate({'left': mainLeft}, 1000, function()
				{
					$('.about-page, .contact-page').hide();
				});
				break;
			}
			case 'about-link' :
			{
				$('#line > .line-img').animate({'left': aboutLeft}, 1000, function()
				{
					$('.main-page, .contact-page').hide();
				});
				break;
			}
			case 'contact-link' :
			{
				$('#line > .line-img').animate({'left': contactLeft}, 1000, function()
				{
					$('.about-page, .main-page').hide();
				});
				break;
			}
		}
		return false;
	});

	$(window).bind('resize', function()
	{
		var mainLeft = (-1060 - 200) + ($(window).width() / 2);
		var aboutLeft = (-2060 - 500) + ($(window).width() / 2);
		var contactLeft = (-3460 - 250) + ($(window).width() / 2);

		switch(getUrl(0))
		{
			case 'false' : { $('#line > .line-img').css('left', mainLeft); break; }
			case 'main' : { $('#line > .line-img').css('left', mainLeft); break; }
			case 'about' : { $('#line > .line-img').css('left', aboutLeft); break; }
			case 'contact' : { $('#line > .line-img').css('left', contactLeft); break; }
		}
		return false;
	});

});
