File: //home/awaldron/www/archive/pbo/js/main.js
$(document).ready(function() {
$('.menublock').each(function() {
$(this).children('.menusub:first').show();
});
$('.resize').each(function() {
var thisId = $(this).attr('id');
var bodyH = $('#'+thisId+'-body').height();
var bgH = bodyH - 650;
if (bgH < 0) bgH = 100;
bgH = bgH + 100;
var thisH = bgH + 215 + 650;
$('#'+thisId+'-bg').height(bgH);
$('#'+thisId).height(thisH);
});
$('.tnav, .pnav').click(function() {
var thisId = $(this).attr('href').substr(1);
var offset = $('#'+thisId).offset();
var scroll = offset.top;
if (thisId != 'home' && thisId != 'contact') {
scroll = scroll + 175;
}
$('html,body').animate({ scrollTop: scroll }, 650, 'easeOutBack');
return false;
});
$('li > a.snav').click(function() {
var thisId = $(this).attr('id').substr(3);
$('#menu-'+thisId).siblings().fadeOut(function() {
$('#menu-'+thisId).fadeIn();
});
$(this).addClass("on").animate({paddingRight: '18%'},50,'swing').animate({paddingRight: '0px'},600,'easeOutBounce').parent().siblings().children("a").removeClass("on");
return false;
});
// SLIDER
$( "#human" ).slider({
value:0,
min: 0,
max: 100,
step: 50,
tooltip: 'hide',
handle: 'square',
formater: function( humanVal ) {
if (humanVal == 0) $( "#humantxt" ).html( 'Robot' );
if (humanVal == 50) $( "#humantxt" ).html( 'Cyborg' );
if (humanVal == 100) {
$( "#humantxt" ).html( 'Human!' );
$('#msg-submit').removeAttr('disabled').addClass('btn-warning');
} else {
$('#msg-submit').attr('disabled','disabled').removeClass('btn-warning');
}
}
});
$("#messageForm").submit(function() {
var theName = $('#name').val();
var theEmail = $('#email').val();
var theMesg = $('#message').val();
$('#mesgResult').load('message.php',{ name: theName, email: theEmail, message: theMesg },
function(data) {
var status = data.substr(0,14);
if (status == '<!--SUCCESS-->') {
$('#messageForm').slideUp();
}
}
);
return false;
});
});
var navOpen = false;
$(window).scroll(function(){
var y = $(window).scrollTop();
if (y >= 415 && !navOpen) {
$('#p-nav').animate({ top: '0px' }, 250 );
navOpen = true;
} else if (y < 415 && navOpen) {
$('#p-nav').animate({ top: '-90px' }, 250 );
navOpen = false;
}
});
$(window).resize(function() {
$('.resize').each(function() {
var thisId = $(this).attr('id');
var bodyH = $('#'+thisId+'-body').height();
var bgH = bodyH - 650;
if (bgH < 0) bgH = 100;
bgH = bgH + 100;
var thisH = bgH + 215 + 650;
$('#'+thisId+'-bg').height(bgH);
$('#'+thisId).height(thisH);
});
});
var preload = new function () {
var me = this;
var $loader,
currentImage = 0;
me.init = function () {
var ww = $(window).width();
if (ww >= 768) {
var s=["img/bg-slate-repeat.png", "img/logo.png", "img/bg-black55.png", "img/bg-brick.jpg", "img/bg-drink.jpg", "img/bg-food.jpg", "img/bg-footer.jpg", "img/bg-leather.jpg", "img/bg-slate-fade3.png", "img/black25.png", "img/flame.png", "img/line-vert.gif", "img/line-y.png", "img/line.png", "img/logo-sm.png", "img/photo-drink.jpg", "img/photo-food.jpg", "img/shade.png", "img/shadow.png", "img/splash-photos.jpg", "img/title-about.png", "img/title-drinks.png", "img/title-food.png", "img/title-press.png"];
$loader = $('#loader');
$loader.max = s.length;
imageCache.pushArray(s, loadImageEvent, loadAllEvent);
} else loadAllEvent();
}
function loadImageEvent() {
val = parseInt($loader.attr('value'));
val++;
var pct = Math.ceil(val * 100 / 24);
$('#pct').html(pct);
$loader.attr('value', val);
}
function loadAllEvent() {
$('#progressContainer').fadeOut(function() {
$('#content').fadeIn(function() {
$('.resize').each(function() {
var thisId = $(this).attr('id');
var bodyH = $('#'+thisId+'-body').height();
var bgH = bodyH - 650;
if (bgH < 0) bgH = 100;
bgH = bgH + 100;
var thisH = bgH + 215 + 650;
$('#'+thisId+'-bg').height(bgH);
$('#'+thisId).height(thisH);
$('.slider').width(210);
});
});
});
$('#gmap').html('<iframe width="100%" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps/ms?msid=207828861775637641740.0004e1f11d2358f8d8c89&msa=0&ie=UTF8&t=m&source=embed&ll=40.448384,-80.007892&spn=0.009797,0.01605&z=15&output=embed"></iframe><br /><a href="https://maps.google.com/maps/ms?msid=207828861775637641740.0004e1f11d2358f8d8c89&msa=0&ie=UTF8&t=m&ll=40.44391,-79.999952&spn=0.009798,0.018239&z=15&source=embed" style="text-align:left">View in a larger map</a>');
}
}
/*
* Use $(window).load() instead of $(document).ready() because we wan't to start caching images
* as soon as the progress bar images are loaded.
*/
$(window).load(preload.init);