
function errorMsg(view)
		{
			$('#errorMsg')[0].style.visibility=view;
		}


function check()
		{
			var ret=false;

			var country=parseInt($('#country')[0].value);
			if ( country = 'US' ) {
				var min_age = 21;
			}
			else {
				var min_age = 18;
			}
			var year=parseInt($('#year')[0].value);
			var month=parseInt($('#month')[0].value)-1;
			var day=parseInt($('#day')[0].value);

			var redir='index.php';

			var theirDate = new Date((year + min_age), month, day);
			var today = new Date;
			if ( (today.getTime() - theirDate.getTime()) > 0) {
				ret=true
			}

			if (!ret) errorMsg('visible')
				else errorMsg('hidden');

			switch($('#country')[0].value) {
				case 'HU': redir='http://zwack.hu/index2.php'; break;
				case 'GB': redir='http://zwack.hu/index2.php?set_lang=en'; break;
				case 'US': redir='index.php'; break;
				case 'IT': redir='http://www.unicum.it/'; break;
				default: redir='http://zwack.hu/index2.php?set_lang=en'; break;
			}
            
			$('#enterForm').attr('action',redir);
			return ret;
		}

function accessibilityStatementPopoup(w,h,mypage,scroll)
	{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
		win = window.open(mypage, 'pop', winprops)
		win.window.focus();

	}

	jQuery.preloadImages = function()
		{

		  for(var i = 0; i<arguments.length; i++)
		  {
			jQuery("<img>").attr("src", arguments[i]);
		  }

		}

	closeFlashLayer	=function(){

		$('#flashcontent').remove();

	}

$(document).ready(function() {

	$('.familyBoxBgr, .storyTxt, .theDrink .textBox').css({
        opacity: 0.90
    } );

    if ($('#hungarianBullVideo').length  > 0) {
		swfobject.embedSWF("/swf/export-video-player.swf", "hungarianBullVideo", '600', '303', "9.0.0", "/swf/expressInstall.swf", {}, {wmode:"opaque", quality: 'best', bgcolor:'#000000'}, {});
	}

    if ($('body').is('.flashStart')) {

		wWidth=$(window).width();
		wHeight=$(window).height();

		$('.flashStart').html('<div id="flashBg">'
            +'<img style="float: left;" src="/img/pic_no_flash_site.jpg" width="1020" height="601" alt="ZWACK" title="" usemap="#noFlashSite" />'
            +'<map id="noFlashSite" name="noFlashSite">'
                +'<area shape="rect" coords="835,60,939,85" href="http://www.facebook.com/home.php#/ZwackUS?ref=s" alt="Facebook" />'
                +'<area shape="rect" coords="545,339,597,404" href="index.php/Zwack-Events" alt="Zwack Events" />'
                +'<area shape="rect" coords="602,339,649,404" href="index.php/Zwack-The-Secret-Recipe" alt="Zwack - The Secret Recipe" />'
                +'<area shape="rect" coords="667,339,715,404" href="index.php/Zwack-Cool-Facts" alt="Zwack - Cool facts" />'
                +'<area shape="rect" coords="722,339,771,404" href="index.php/Zwack-Bartender-of-the-Month" alt="Zwack - Bartender of the Month" />'
                +'<area shape="rect" coords="778,339,827,404" href="index.php/Zwack-Zwacktails" alt="Zwack - Zwacktails" />'
                +'<area shape="rect" coords="836,339,885,404" href="index.php/Zwack-The-1st-Shot" alt="Zwack - The 1st Shot" />'
                +'<area shape="rect" coords="236,534,367,548" href="index.php/Zwack-In-The-News" alt="Zwack - In The News" />'
                +'<area shape="rect" coords="396,534,567,548" href="index.php/Zwack-My-Zwack" alt="Zwack - Zwack My Zwack" />'
                +'<area shape="rect" coords="499,534,576,548" href="index.php/Zwack-Contact" alt="Zwack - Zwack Contact" />'
                +'<area shape="rect" coords="608,534,778,548" href="accessibility.html" onclick="accessibilityStatementPopoup(500,520,this.href) return false;" alt="Zwack - Zwack Contact" />'
            +'</map>'
        +'</div>');
        swfobject.embedSWF("/swf/intro.swf", "flashBg", "100%", "100%", "8.0.0", "/swf/expressInstall.swf", {}, {scale:"noscale", swLiveConnect:"true", AllowScriptAccess:"always"}, {});
    }

    if ($('body').is('.flashBg')) {

		wWidth=$(window).width();
		wHeight=$(window).height();

		$('#pContainer').css("left", ((wWidth-808)/2) + "px");

		$('#pContainer').before('<div id="flashBg"><h1>Alternative content</h1><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p></div>');
		swfobject.embedSWF("/swf/ice-animation.swf", "flashBg", "100%", "100%", "9.0.0", "/swf/expressInstall.swf", {}, {scale:"noscale", wmode:"opaque", bgcolor:"0x00000", align: 'TC'}, {});

		$('#pContainer').before('<div id="flashBgShadow"><img src="/img/bg_flashMovieBottom.png" class="pngFix" alt="" title="" /></div>');
		$('#flashBgShadow IMG').css("width", wWidth + "px");
	}

	$('.videoGalleryBtn').click(function(){

		var flashvars = {
			videoPATH: "/video/export-video2.flv"
		};

		$('#pWrapper').before('<div id="flashcontent"></div>');
		swfobject.embedSWF("/swf/export-video-layer.swf", "flashcontent", "100%", "100%", "8.0.0", "/swf/expressInstall.swf", flashvars, {wmode:"transparent", quality: 'high', bgcolor:'#000000'}, {});

	});

    $('.outerLink').each(function(index){
		this.target='_blank';
	} )

	$('.imgsSmall').mouseover(function (){

		var id='imgBigImg' + this.getAttribute('id').substr(5,1);

		$('#imgBigImg1').css("display", "none");
		$('#imgBigImg2').css("display", "none");
		$('#imgBigImg3').css("display", "none");

		$('#' + id).css("display", "block");

	});

	if ($('.lightBoxPage').length  > 0) {
		$(function() {
			$('.imgBig a').lightBox();
		});
	}

	var animLeft = 0;

	if ($('.storyPager').length  > 0) {
		$('.storyPager').eq(0).addClass('active');
		$('.storyPager').each(function(index){
			$(this).click(function(){
				$('.storyPager').removeClass('active');

				var actualPage=index;
				// alert(actualPage);
				$('.storyPager').eq(actualPage).addClass('active');

				$('#storyBox').animate({
					left: 10-(652*actualPage) + 'px'
				}, 1000, 'easeInOutQuart');

				return false;
			});
		});
	}

	/* story slide start */

	var step=0;
	var recipeWidth=353;

	function recipe(){
		$('#galleryBox').animate({
			left: step*recipeWidth + 'px'
		}, 1000, 'easeInOutQuart');
		return false;
	}

	var recipes=($('.picBox').length);

	$('#nextGal').each(function(index){
		$(this).click(function(){
			step--;
			//if (step<=-recipes) step=0; //korbemenne
			if (step<=-recipes) step=-(recipes-1);
			recipe();
			return false;

		});
	});

	$('#previousGal').each(function(index){
		$(this).click(function(){
			step++;
			//if (step>=1) step=-(recipes-1);  //korbemenne
			if (step>=1) step=0;
			recipe();
			return false;

		});
	});

	/* story slide end */

	/* story slide in start */

	$('.linkIzabella').addClass('linkIzabellaActive');
	$('.boxSandor').css('display', 'none');
	var activeName="Izabella";

	$('.linkSandor').click(function(){

		$('.linkSandor').addClass('linkSandorActive');
		$('.linkIzabella').removeClass('linkIzabellaActive');

		$('.boxSandor').fadeIn('slow');
		$('.boxIzabella').fadeOut('slow');

		activeName="Sandor";

	});

	$('.linkIzabella').click(function(){

		$('.linkIzabella').addClass('linkIzabellaActive');
		$('.linkSandor').removeClass('linkSandorActive');

		$('.boxSandor').fadeOut('slow');
		$('.boxIzabella').fadeIn('slow');

		activeName="Izabella";

	});

	stepSandor=0;
	stepIzabella=0;
	storyWidth=290;
	familyBoxesSandor=6;
	familyBoxesIzabella=3;

	function familyBoxesMove(mystep){
		$('.content'+activeName).animate({
			left: mystep*storyWidth + 'px'
		}, 1000, 'easeInOutQuart');
		return false;
	}

	$('.btnRightIzabella, .btnRightSandor').each(function(index){
		$(this).click(function(){

			var stepF=eval('step'+activeName);
			stepF--;

			var familyBoxes=eval('familyBoxes'+activeName);

			if (stepF<=-familyBoxes) stepF=-(familyBoxes-1);
			eval('step'+activeName+'=stepF');
			familyBoxesMove(stepF);
			return false;

		});
	});

	$('.btnLeftIzabella, .btnLeftSandor').each(function(index){
		$(this).click(function(){

			var stepF=eval('step'+activeName);
			stepF++;

			var familyBoxes=eval('familyBoxes'+activeName);

			if (stepF>=1) stepF=0;
			eval('step'+activeName+'=stepF');
			familyBoxesMove(stepF);
			return false;

		});
	});

	/* story slide in end */

	/* news slide start */

	var pagerPos=0;
	var pagerHeight=200;
	var maxHeight=$('.contentBoxNewsSlider').height();

	function newsMove(){
		$('.contentBoxNewsSlider').animate({
			top: pagerPos + 'px'
		}, 1500, 'easeInOutQuart');
		return false;
	}

	$('.nextNews').each(function(index){
		$(this).click(function(){
			pagerPos=pagerPos-pagerHeight;
			if((pagerPos-pagerHeight)<(0-maxHeight+pagerHeight)) pagerPos=0-maxHeight+pagerHeight;
			newsMove();
			return false;
		});
	});

	$('.prevNews').each(function(index){
		$(this).click(function(){
			pagerPos=pagerPos+pagerHeight;
			if(pagerPos>0) pagerPos=0;
			if(maxHeight>pagerHeight) newsMove();
			return false;
		});
	});

	/* news slide end */

	/* months slide start */

	var pagerMonthsPos=0;
	var pagerMonthsHeight=200;
	var maxMonthsHeight=$('.textBox').height();

	function newsMonthsMove(){

		$('.textBox').animate({
			top: pagerMonthsPos + 'px'
		}, 1500, 'easeInOutQuart');
		return false;
	}

	$('.pagerBtnRight').each(function(index){
		$(this).click(function(){
			pagerMonthsPos=pagerMonthsPos-pagerMonthsHeight;
			if((pagerMonthsPos-pagerMonthsHeight)<(0-maxMonthsHeight+pagerMonthsHeight)) pagerMonthsPos=0-maxMonthsHeight+pagerMonthsHeight;
			if(maxMonthsHeight>pagerMonthsHeight) newsMonthsMove();
			return false;
		});
	});

	$('.pagerBtnLeft').each(function(index){
		$(this).click(function(){
			pagerMonthsPos=pagerMonthsPos+pagerMonthsHeight;
			if(pagerMonthsPos>0) pagerMonthsPos=0;
			newsMonthsMove();
			return false;
		});
	});

	/* months slide end */
   
   if($('#termsOfUse').length){
       $('#termsOfUse').click(function(){
           accessibilityStatementPopoup(500,520,$(this).attr('href'),1);
           return false;
       });
       
       $('#privacyStatement').click(function(){
           accessibilityStatementPopoup(500,520,$(this).attr('href'),1);
           return false;
       });
       
       $('#accessibilityStatement').click(function(){
           accessibilityStatementPopoup(500,520,$(this).attr('href'),0);
           return false;
       });
   }


});