/*********************************************** *** BUTTON ROLLOVER & PRELOAD **************** ************************************************/ $(function(){ // button rollover if ($('.imgBtn') != null) { $('.imgBtn').hover(function(){ if(!$(this).is('.disabled')) $(this).attr("src", $(this).attr("src").replace(/^(.*?)(?:-hover)?(\..*?)$/i,'$1-hover$2')); }, function(){ if(!$(this).is('.disabled')) $(this).attr("src", $(this).attr("src").replace(/^(.*)-hover(\..*?)$/i, '$1$2')); }); } // preload image rollovers if ($("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']") != null) { $("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){ $("").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2')); }); } }); /*********************************************** *** EXTERNAL LINKS *************************** ************************************************/ $(document).ready(function() { $("a[rel=external]").each(function() { $(this).addClass('external'); $(this).attr({ title: "Open this page in a new window", target: "_blank" }); }) }); /*********************************************** *** Hide error box ********** ************************************************/ $(document).ready(function(){ $('#quickContact input[type="text"], #quickContact textarea').focus(function() { $(this).closest('li').find('.valdationError').hide(); // $(this).closest('span').css("display","none"); }); function addChild(num) { var addval ; var countNumber = 0; countNumber += num; addval = parseInt($('#action_add').val()); if (addval == 0) { addval = countNumber; } if(num == 7 ) { alert('Time to think....'); return false; } if(addval == 1) { $('#clear').hide(); } else { $('#clear').show(); } $('.addition').each(function(i) { if(i < addval) { $(this).show().find('input').removeAttr('disabled'); $(this).find('select').removeAttr('disabled'); } else { $(this).find('select').attr('disabled','disabled'); $(this).hide().find('input').attr('disabled', 'disabled'); } }); return false; } $('#addChild').click(function() { var addval = parseInt($('#action_add').val()); if(addval == 0 ) { addval = addval +2; } else { addval = addval +1; } if(addval < 7 ) { $('#action_add').val(addval); } var next = parseInt($('#action_add').val()); addChild(addval); return false; }); var addval = parseInt($('#action_add').val()); if (addval == 0 ) { addChild(1); } else { addChild(addval); } $('#clear').click(clearLast); function clearLast() { var total = parseInt($('#action_add').val()); total = total -1; var nextVal = total; if (nextVal == 1) { $('#clear').hide(); } $('.addition').each(function(i) { var j = parseInt(i); if(j == total) { $(this).hide().find('input').attr('disabled', 'disabled'); $(this).find('select').attr('disabled','disabled'); $('#action_add').val(nextVal); return false; } }); return false; } }); /*********************************************** *** COMPACT FORM (LABEL OVER INPUT) ********** ************************************************/ $(function(){ $('form.compact input, form.compact select, form.compact textarea').focus(function(){ $('label[for=' + $(this).attr('id') + ']').hide(); }); $('form.compact input, form.compact select, form.compact textarea').each(function(ele){ if($(this).val().length > 0) $('label[for=' + $(this).attr('id') + ']').css({ display: "none" }); }); $('form.compact input, form.compact select, form.compact textarea').blur(function(){ if($(this).val().length == 0) $('label[for=' + $(this).attr('id') + ']').show(); }); $('form.compact').removeClass('compact'); }); /*********************************************** *** ANIMATED SCROLLING ********************** ************************************************/ $(document).ready(function(){ $('a[href^="#"]').click(function(){ var id = $(this).attr('href'); if(id.length === 1) return; var ele = $(id); if(ele.length) { var destination = ele.offset().top; $('html:not(:animated), body:not(:animated)').animate({ scrollTop: destination -20 },500, 'easeOutQuint'); } }); /* var target = $('#contact_form_anchor'); if(target) { var destination = target.offset().top; $('html:not(:animated), body:not(:animated)').animate({ scrollTop: destination -20 },500, 'easeOutQuint'); } */ }); /*********************************************** *** ANIMATED BUTTON ********************** ************************************************/ $(document).ready(function(){ $('.fadeInFast a').hover(function(){ $(this).stop().animate({'opacity' : '0'}, 300); }, function(){$(this).stop().animate({'opacity' : '1'}, 300);}); }); $(document).ready(function(){ $('.fadeInSlow a').hover(function(){ $(this).stop().animate({'opacity' : '0'}, 500); }, function(){$(this).stop().animate({'opacity' : '1'}, 500);}); });