/**
 * @author gacek
 */
 
 var wejscie = {
 	setWindowDemo: function(){
		$('<div id="all_intro"></div>').css({
			position: 'absolute',
			top: 0,
			left: 0,
			width: $(document).width() + 'px',
			height: $(document).height() + 'px',
			backgroundColor: '#9a9b9d',
			overflow: 'hidden',
			zIndex: 300
		})
		.appendTo('body');
		
		$('<img id="img4_1" src="./images/logo_4_left.png" alt="4" />')
		.css({
			position: 'absolute',
			top: '-124px',
			left: ($(document).width()/2) + 100 + 'px'
		})
		.appendTo('#all_intro').hide();
		
		$('<img id="img4_2" src="./images/logo_4_right.png" alt="4" />').hide()
		.css({
			position: 'absolute',
			top: $(document).height() + 'px',
			left: '76px'
		})
		.appendTo('#all_intro');
		
		$('<img id="img_dermapol" src="./images/logo_4_dermapol.jpg" alt="4" />')
		.css({
			position: 'absolute',
			top: ($(document).height()/2 - 107) + 'px',
			left: ($(document).width()/2 - 252) + 'px'
		})
		.appendTo('#all_intro').hide();
		
		$('<img id="img_skip" src="./images/logo_4_skip.jpg" alt="4" />')
		.hide()
		.css({
			position: 'absolute',
			top: '5px',
			left:'5px'
		})
		.fadeIn(700, function(){
			$(this).attr('src', './images/logo_4_skip.png').ifixpng();
		})
		.click(function(){
			$('#all_intro').fadeOut(500, function(){
				$('#all_intro').remove();
			});
		})
		.appendTo('#all_intro');
		
		$('#all_intro img').ifixpng();
	},
	animateIntroImg: function(){
		$('#img4_1').show().animate(
			{top: '+' + (($(document).height())/2 - 150) + 'px', left: '+' + (($(document).width())/2 - 370) + 'px'},
			{queue: false, duration: 1000}
		);
		$('#img4_2').show().animate(
			{top: '+' + (($(document).height())/2 - 100) + 'px', left: '+' + (($(document).width())/2 - 340) + 'px'},
			1000
		);
		
	},
	animateIntroImgDermapol: function()
	{
		setTimeout("$('#img_dermapol:hidden').fadeIn(2000, function(){$('#img_dermapol').attr('src','./images/logo_4_dermapol.png').ifixpng()})", 1500);
		setTimeout("$('#all_intro').animate( { backgroundColor: '#fff' }, 2500)", 3300);
		setTimeout("$('#all_intro').fadeOut(400, function(){$('#allintro').remove()})", 5800);
	},
	setProductDivs: function()
	{
		var divs = {
			enableDivs: function(divId1, imgId1, loadHtml)
			{
				$('<div id="' + divId1 + '" />').appendTo('body').load('lib/html/' + loadHtml);
				
				var divId2 = '#' + divId1;
				
				$(imgId1).mouseover(function(){
					$(divId2).show();
				})
				.mouseout(function(){
					$(divId2).hide();
				})
				.mousemove(function(){
					$(divId2).css({
						left: wejscie.xPosition,
						top: wejscie.yPosition
					});
				});
			}
		}
		
		divs.enableDivs('start_best4body', '#start_body', 'best4body.html');
		divs.enableDivs('start_best4feet', '#start_feet', 'best4feet.html');
		divs.enableDivs('start_best4hand', '#start_hand', 'best4hand.html');
	},
	xPosition: 0,
	yPosition: 0
 }

 $(document).ready(function(){
 	 if ((window.location.href).indexOf('www') != -1)
 	{
 		window.location = 'http://dermapol.pl'
 	}
 	commonObject.setDropMenu();
 	if ($('iframe#hiddenFrame') !== null)
	{
		wejscie.setWindowDemo();
		wejscie.animateIntroImg();
		wejscie.animateIntroImgDermapol();
		wejscie.setProductDivs();
	}
	commonObject.setLoginAjax();
	commonObject.setMenuLinksAjax();
	commonObject.setClickAjax('#login_more_a', 'kropka_blue_1.gif');
	commonObject.execAll();
	
 });
 $(document).mousemove(function(ev){
 	wejscie.xPosition = (ev ? ev.clientX : event.x) + 10;
	wejscie.yPosition = (ev ? ev.clientY : event.y) - 150;
 });

