/*
	Author:	Ogilvy Interactive Johannesburg
		oi.co.za
*/


var isLive = true,
root = isLive ? 'http://millersa.co.za' : '/miller';



function browserCheck(){capable=true;if($.browser.msie&&parseInt($.browser.version)<8)capable=false;if($.browser.mozilla&&parseInt($.browser.version)<6)capable=false;if(!capable)e(root+"/js/mylibs/ie6/")}function checkProfileAge(){d=$("#dob_d").val();m=$("#dob_m").val();y=$("#dob_y").val();date=d+"-"+m+"-"+y;try{var a=new Date;a.setFullYear(y,m,d)}catch(b){alert(b);$("#dob_d").val("").focus();return false}var c=new Date,e=new Date,f=new Date;e.setFullYear(c.getFullYear()-100);f.setFullYear(c.getFullYear()-18);if(a.getTime()>f.getTime()){$(".dob input").addClass("error");setTimeout("$('.dob input').removeClass('error')",5e3);alert("You need to be at least 18 years old to register on this site.");$("#dob_d").val("").focus();$("#dob_m,#dob_y").val("");return false}$(".dob input").removeClass("error");return true}function checkProfileYear(){val=$("#dob_y").val().length;if(val==4){if($("#dob_d").val().length>=1&&$("#dob_m").val().length>=1)checkProfileAge()}}function checkProfileMonth(){val=$("#dob_m").val().length;if(val==2)$("#dob_y").val("").focus()}function checkProfileDay(){val=$("#dob_d").val().length;if(val==2)$("#dob_m").val("").focus()}function buildAge(){d=$("#ageVerify .dobD").val();m=$("#ageVerify .dobM").val();y=$("#ageVerify .dobY").val();if(d<1||d==""||m<1||m==""||y<1||y=="")return false;date=d+"-"+m+"-"+y;try{var a=new Date;a.setFullYear(y,m-1,d)}catch(b){alert(b);$("#ageVerify .dobD").val("").focus();return false}var c=new Date,e=new Date,f=new Date;e.setFullYear(c.getFullYear()-100);f.setFullYear(c.getFullYear()-18);age=c.getFullYear()-a.getFullYear();if(a.getTime()<e.getTime()){alert("Please enter a valid age.");return false}if(a.getTime()>f.getTime()){_gaq.push(["_trackEvent","Miller SA","Age Verification","Under 18",age]);alert("The content on this site is only viewable if you are over 18.");return false}if(age<24){_gaq.push(["_trackEvent","Miller SA","Age Verification","Under 24",age])}else{_gaq.push(["_trackEvent","Miller SA","Age Verification","Over 24",age])}$.ajax({data:date,type:"POST",url:root+"/session/0sF98sjKFa345snkl12dhJIiiL",success:function(){window.location.reload()},error:function(a){return false}})}function checkYear(){val=$("#ageVerify .dobY").val().length;if(val==4){if($("#ageVerify .dobD").val().length>=1&&$("#ageVerify .dobM").val().length>=1)buildAge()}}function checkMonth(){val=$("#ageVerify .dobM").val().length;if(val==2)$("#ageVerify .dobY").val("").focus()}function checkDay(){val=$("#ageVerify .dobD").val().length;if(val==2)$("#ageVerify .dobM").val("").focus()}function checkNumber(a){var b=[48,49,50,51,52,53,54,55,56,57,8,46],c=a.keyCode?a.keyCode:a.which;isNumeric=$.inArray(c,b)>-1?false:true;return isNumeric}function hideModals(){$("#userBar .login").removeClass("open");$("#userBar .formWrap").hide();$(".shareWrap").hide()}function goLogin(){password=$.md5($("#login_pass").val());data="email="+$("#login_email").val().toLowerCase()+"&password="+password;$.ajax({data:data,type:"POST",url:root+"/login",success:function(a,b){if(a=="Error"){$(".formWrap .errors").html("Please double check your email & password.").slideDown();return false}else if(a=="Unauthorized"){$(".formWrap .errors").html('Your account is not active yet.<br>Check your email for the activation link, or we could resend you the email.<br><br><div class="button resendAuthMail">Resend it</div>').slideDown();return false}else if(a=="Success"){$("#frmLogin").submit()}},error:function(a){return false}})}function fx02(){$("#fx02").keyframe({1e3:{opacity:0,right:"-100px"},2e3:{opacity:.7,right:"-90px"},3e3:{opacity:0,right:"-80px"},9e3:{opacity:.1,right:"-80px"},9010:{opacity:.5,right:"-70px"},12e3:{opacity:.3,right:"-40px"},15e3:{opacity:0,right:"-10px"}},"easeInQuad");var a=Math.floor(Math.random()*3e3);b=15e3+a;setTimeout("fx02()",b)}function fx01(){$("#fx01").keyframe({100:{opacity:0,left:"-100px"},1200:{opacity:.3,left:"-90px"},1210:{opacity:.2,left:"-90px"},1600:{opacity:0,left:"-95px"},5600:{opacity:.1,left:"-100px"},5650:{opacity:.4,left:"-100px"},7e3:{opacity:0,left:"-90px"},9100:{opacity:.2},10600:{opacity:.1},15600:{opacity:0},2e4:{opacity:.1},20010:{opacity:.6,left:"-70px"},21010:{opacity:0,left:"-60px"}},"easeInQuad");var a=Math.floor(Math.random()*3e3);b=22e3+a;setTimeout("fx01()",b)}window.onload=function(){browserCheck()};$(document).ready(function(){$("a[rel|=external]").click(function(){window.open(this.href);return false});$("input:text[placeholder]").placeholderLabel();$("#userBar").click(function(a){a.stopPropagation()});$("#userBar .login").click(function(a){$("#userBar .formWrap").toggle();$(this).toggleClass("open")});$("#frmLogin .doLogin").click(function(){setTimeout("$('#frmLogin input').removeClass('error')",5e3);if(!$("#frmLogin").valid())return false;$(".formWrap .errors").html('<img src="../img/wait.gif" height="16" width="16" alt="Please wait..." />').show();goLogin()});$("#frmLogin input").bind("keypress",function(a){code=a.keyCode?a.keyCode:a.which;if(code==13)goLogin();$(".formWrap .errors").slideUp()});$("#frmForgotPassword .forgot").click(function(){$("#frmForgotPassword").slideUp(function(){$("#frmLogin").slideDown()});return false});$("#frmLogin .forgot").click(function(){$("#frmLogin").slideUp(function(){$("#frmForgotPassword").slideDown()});return false});$("#frmForgotPassword .button").click(function(){$("#frmForgotPassword").submit()});$("#frmForgotPassword").submit(function(){if(!$(this).valid())return false;data="email="+$("#forgot_email").val().toLowerCase();$.ajax({data:data,type:"POST",url:root+"/password/reset",success:function(a){$("#frmForgotPassword h1").html('Check your inbox!<span class="grad">Check your inbox!</span>').width("210px");$("#frmForgotPassword input,#frmForgotPassword .button").hide();setTimeout("$('#frmForgotPassword .forgot').trigger('click')",5e3);return false},error:function(a){return false}});return false});$("#ageVerify .button").click(function(){$("#ageVerify form").submit();return false});$("#ageVerify form").submit(function(){buildAge();return false});$("#ageVerify .dobD").bind("keypress",function(a){if(checkNumber(a))return false;setTimeout("checkDay()",1)});$("#ageVerify .dobM").bind("keypress",function(a){if(checkNumber(a))return false;setTimeout("checkMonth()",1)});$("#ageVerify .dobY").bind("keypress",function(a){if(checkNumber(a))return false;setTimeout("checkYear()",1)});$("#dob_d").bind("keypress",function(a){if(checkNumber(a))return false;setTimeout("checkProfileDay()",1)});$("#dob_m").bind("keypress",function(a){if(checkNumber(a))return false;setTimeout("checkProfileMonth()",1)});$("#dob_y").bind("keypress",function(a){if(checkNumber(a))return false;setTimeout("checkProfileYear()",1)});$("#contactUs .button").click(function(){$("#contactUs").submit()});$("#contactUs").submit(function(){if(!$(this).valid())return false;data=$(this).serialize();$.ajax({data:data,type:"POST",url:"sendContact",success:function(){$("#contact #main h1").html('Your message has been sent!<span class="grad">Your message has been sent!</span>');$("#contactUs").hide()},error:function(a){}});return false});$("#frmRegistration input").bind("keypress",function(a){code=a.keyCode?a.keyCode:a.which;if(code==13)$("#frmRegistration").submit()});$("#frmRegistration .submit").click(function(){$("#frmRegistration").submit()});$("#frmRegistration").submit(function(){setTimeout("$('#frmRegistration input').removeClass('error')",5e3);setTimeout("$('.terms label').removeClass('red')",5e3);if(!$(".terms input").is(":checked")){$(".terms label").addClass("red");return false}if(!checkProfileAge())return false;if(!$(this).valid())return false;password=$.md5($("#password").val());var a="name="+$("#name").val()+"&surname="+$("#surname").val()+"&email="+$("#email").val().toLowerCase()+"&mobile="+$("#mobile").val()+"&dob_d="+$("#dob_d").val()+"&dob_m="+$("#dob_m").val()+"&dob_y="+$("#dob_y").val()+"&gender="+$('input[name="gender"]:checked').val()+"&password="+password;$.ajax({data:a,type:"POST",url:"profile/register",success:function(a){if(a=="email exists"){$("#email").addClass("error").val("").focus();alert("That email address has already been registered.");setTimeout("$('#email').removeClass('error')",5e3);return false}else if(a!="Success"){alert("Something went wrong. Please try again.");return false}a="email="+$("#email").val().toLowerCase();$.ajax({data:a,type:"POST",url:"profile/sendAuthMail",success:function(a){window.location="authenticate"},error:function(a){}})},error:function(a){alert("Something went wrong. Please try again.")}});return false});$(".fbConnect").click(function(){setTimeout("$('.terms label').removeClass('red')",5e3);if(!$(".terms input").is(":checked")){$(".terms label").addClass("red");return false}$(".blackout").fadeIn(function(){$(".fbRegistration").fadeIn()});return false});$(".modal .close").click(function(){$(".modal").fadeOut(function(){$(".blackout").fadeOut()});return false});$("#updateUser input").bind("keypress",function(a){code=a.keyCode?a.keyCode:a.which;if(code==13)$("#updateUser").submit()});$("#updateUser .button").click(function(){$("#updateUser").submit()});$("#updateUser").submit(function(){if(!$(this).valid())return false;data=$(this).serialize();$.ajax({data:data,type:"POST",url:root+"/profile/update",success:function(a){window.location.reload()},error:function(a){}});return false});$(".shareOptions").click(function(a){a.stopPropagation();$(this).children(".shareWrap").toggle()});$("#changePassword input").bind("keypress",function(a){code=a.keyCode?a.keyCode:a.which;if(code==13)$("#changePassword").submit()});$("#changePassword .button").click(function(){$("#changePassword").submit()});$("#changePassword").submit(function(){if(!$(this).valid())return false;data="uid="+$("#uid").val()+"&password="+$.md5($("#password").val());$.ajax({data:data,type:"POST",url:root+"/resetPassword",success:function(a){if(a!="Success")return false;$(".resetPassword h1").html('Your password has been reset...<span class="grad">Your password has been reset...</span>');$("#changePassword").hide();setTimeout("window.location.reload()",3e3);return false},error:function(a){return false}});return false});$(".errors").delegate(".resendAuthMail","click",function(){data="email="+$("#login_email").val().toLowerCase();$.ajax({data:data,type:"POST",url:"profile/sendAuthMail",success:function(a){window.location="authenticate"},error:function(a){}})});$("#downloads .download").hoverIntent(function(){$(this).find(".colour").fadeIn();$(this).find("footer").fadeIn()},function(){$(this).find(".colour").fadeOut();$(this).find("footer").fadeOut()});$(".hotSpot").click(function(){$hotspotNr=$(this).attr("id");setTimeout(function(){$("#ourBeer").addClass("active")},800);$(".top, #mainMenu, .footer, .hotSpot").fadeOut(450);$(".bottleLrg.default").fadeOut(400);$(".zoom").delay(200).fadeIn(900);$(".topHeader").fadeOut(450);setTimeout(function(){$(".hotSpot#"+$hotspotNr).addClass("prvSelected")},400);$(".bottleLrg.zoom").addClass($hotspotNr);$(".popup."+$hotspotNr).delay(1e3).fadeIn(1e3)});$(".popup .close").click(function(){$(".top, #mainMenu, .footer, .topHeader, .hotSpot").delay(800).fadeIn();$(".popup").fadeOut();$(".bottleLrg.default").delay(900).fadeIn(1e3);$(".bottleLrg.zoom").removeClass($hotspotNr);$(".bottleLrg.zoom").fadeOut(500);setTimeout(function(){$("#ourBeer").removeClass("active")},800)});$(".event").hoverIntent(function(){$(this).addClass("hover");$(this).find("p").slideDown()},function(){$(this).delay(500).removeClass("hover");$(this).find("p").delay(500).slideUp()});var a=Math.floor(Math.random()*1e3),b=Math.floor(Math.random()*1e3);setTimeout("fx01()",a);setTimeout("fx02()",b)});$("body").click(function(){hideModals()});$(document).keyup(function(a){code=a.keyCode?a.keyCode:a.which;if(code==27){hideModals()}});$("#frmLogin").validate({rules:{login_pass:"required",login_email:{required:true,email:true}}});$("#frmRegistration").validate({rules:{name:"required",surname:"required",gender:"required",accept:"required",password:"required",confirm_password:{required:true,equalTo:"#password"},email:{email:true,required:true},mobile:{number:true,required:true,minlength:9},dob_d:{number:true,required:true},dob_m:{number:true,required:true},dob_y:{number:true,required:true,minlength:4}}});$("#updateUser").validate({rules:{name:"required",surname:"required",gender:"required",email:{email:true,required:true},mobile:{number:true,required:true,minlength:9},dob_d:{number:true,required:true},dob_m:{number:true,required:true},dob_y:{number:true,required:true,minlength:4}}});$("#frmForgotPassword").validate({rules:{forgot_email:{required:true,email:true}}});$("#contactUs").validate({rules:{name:"required",email:{required:true,email:true},message:"required"}});$("#changePassword").validate({rules:{password:"required",confirm_password:{required:true,equalTo:"#password"}}});$("#_close").live("click",function(){$("#_d").fadeOut(function(){$("#_l").fadeOut()})})
