// JavaScript Document jQuery(document).ready(function(){ setTimeout('updateHeight();',200); setTimeout('showSubmenu();',400); jQuery('.menu > ul > li > ul > li').last().css({'border-bottom':'0'}); jQuery(window).resize(function(){ updateContactUs(); }); // Product expand button jQuery('.products').mouseover(function(){ var productBox = jQuery('ul',jQuery(this).parent()); if(productBox.is(':not(:animated)')){ // Prevents queueing of submenu animation if the submenu is already being animated. if(productBox.height()==0){ // Shrinked, expanded it now productBox.css({'height':'auto'}); var originalHeight = productBox.height(); productBox.css({'height':'0'}); jQuery('.contactFloat').animate({'top':(jQuery('.contactUs').offset().top + originalHeight) + 'px'}, 500); jQuery('.contactUs').animate({'height':(jQuery('.contactUs').height() - originalHeight) + 'px'}, 500); productBox.animate({'height':originalHeight+'px'}, 500); }else{ // Expanded, shrink it now var originalHeight = productBox.height(); jQuery('.contactFloat').animate({'top':(jQuery('.contactUs').offset().top - originalHeight) + 'px'}, 500); jQuery('.contactUs').animate({'height':(jQuery('.contactUs').height() + originalHeight) + 'px'}, 500); productBox.animate({'height':'0'}, 500); } } return false; }); jQuery('.menu a').each(function(){ if((location.href.indexOf(jQuery(this).attr('href'))!=-1 && jQuery(this).attr('href')!='/') || (jQuery(this).attr('href')=='/' && (location.href.substr(location.href.length-5, 5)=='.com/' || location.href.substr(location.href.length-4, 4)=='.com' || location.href.substr(location.href.length-14, 14)=='.com/index.htm'))){ jQuery(this).parent().css({'background-color':'#fbfbf6'}); } }); // More button jQuery('.showMore').click(function(){ if(jQuery(this).text().indexOf('More') != -1){ // To expand jQuery(this).parent().next().css({'height':'auto'}); var originalHeight = jQuery(this).parent().next().height(); jQuery(this).parent().next().css({'height':'0'}); // Resize the background jQuery('.background').animate({'height':(jQuery('.background').height() + originalHeight) + 'px'}, 500); jQuery('.contactUs').animate({'height':(jQuery('.contactUs').height() + originalHeight) + 'px'}, 500); // Resize the content jQuery(this).parent().next().animate({'height':originalHeight+'px'},500,function(){ jQuery(this).css({'height':'auto'}); updateHeight(); }); }else{ var originalHeight = jQuery(this).parent().next().height(); // Resize the background jQuery('.background').animate({'height':(jQuery('.background').height() - originalHeight) + 'px'}, 500); jQuery('.contactUs').animate({'height':(jQuery('.contactUs').height() - originalHeight) + 'px'}, 500); // To shrink the content jQuery(this).parent().next().animate({'height':0},500,function(){ jQuery('.contactUs').css({'height':'auto'}); jQuery('.content').css({'height':'auto'}); jQuery('.background').css({'height':'1253px'}); updateHeight(); }); } var oldText = jQuery(this).text(); var newText = jQuery(this).attr('replace'); jQuery(this).text(newText); jQuery(this).attr({'replace':oldText}); return false; }); // Gallery function jQuery('a[rel^="prettyPhoto"]').prettyPhoto(); // Generate excerpt for the Articles page. jQuery('.articles .excerpt').each(function(idx){ var arr = jQuery('.articles .excerpt'); var eLink = jQuery(this).prev('li').find('a').attr('href'); jQuery(this).load(eLink+' p:first', function(){ var excerpt = $(this).text(); var excerpt = excerpt.substr(0,100); jQuery(this).text(excerpt).append(' [...]'); }); if (idx == (arr.length - 1)) { updateHeight(); } }); // Sidebar contact form. $('.labelify').val(''); $('.labelify').labelify(); $('#contact').validate({ ignoreTitle: true, errorElement: 'div', errorPlacement: function(error, element) { error.insertBefore(element); $('.labelify').labelify(); }, submitHandler: function(form) { $(form).ajaxSubmit({ success: function(){ $(form).slideUp(function(){ $('.notification.success').slideDown(); }); } }); } }); }); function showSubmenu(){ // Show submenu when the page is in the submenu jQuery('ul a', jQuery('.products').parent()).each(function(){ if(location.href.indexOf(jQuery(this).attr('href'))!=-1 && jQuery(this).attr('href')!='/'){ jQuery('.products').click(); } }); } function updateHeight(){ // Change background height updateContactUs(); //jQuery('.background').css({'height':jQuery(document).height()+'px'}); // Change sidebar and content height var sidebarHeight = jQuery('.sideBar').height(); var contentHeight = jQuery('.content').height()+404; if(sidebarHeight > contentHeight){ jQuery('.content').height(sidebarHeight - 404); }else if(sidebarHeight < contentHeight){ var diff = contentHeight - sidebarHeight; jQuery('.contactUs').height(jQuery('.contactUs').height() + diff + 51); } } function updateContactUs(){ jQuery('.contactFloat').css({'left':jQuery('.contactUs').offset().left + 'px'}); jQuery('.contactFloat').css({'top':jQuery('.contactUs').offset().top + 'px'}); }