// JavaScript Document var loginTabClicked = false; var menuHeight = new Array(); jQuery(document).ready(function(){ jQuery('.bannerText li').last().css({'border-right':'0'}); jQuery('.labelify').labelify(); jQuery('.homeLink').click(function(){ window.location.href = "http://www.zefsci.com/"; }); // Contextual menu items depending on location jQuery(document).ready(function(){ // Select previous selected flag jQuery('#flagUS').addClass('selected'); // Show corresponding contents /* if (jQuery('#flagUS').add('#flagMA').hasClass('selected')){ jQuery('.canadaOnly').parent('li').parent().css({height: 'auto'}); jQuery('.canadaOnly').parent('li').hide(); } */ showSelectedRegionMenu(); jQuery('.country img').click(function(){ // Store selecion jQuery.ajax({ url: '/select-country.php', type: 'POST', dataType: 'json', data: {'select':jQuery(this).attr('id')}, success: function(data) {} }); // Set select tag if (!jQuery(this).hasClass('selected')){ jQuery('.country img.selected').removeClass('selected'); jQuery(this).addClass('selected'); } /*else { jQuery(this).removeClass('selected'); }*/ /* if (jQuery('#flagUS').add('#flagMA').hasClass('selected')){ jQuery('.canadaOnly').parent('li').parent().css({height: 'auto'}); jQuery('.canadaOnly').parent('li').hide(); } else { jQuery('.canadaOnly').parent('li').parent().css({height: 'auto'}); jQuery('.canadaOnly').parent('li').show(); } */ showSelectedRegionMenu(); }); }); // Disable the link if mainmenu item has a submenu jQuery('.mainMenuTab > ul > li').each(function(){ if(jQuery(this).find('ul li').length > 0){ var aText = jQuery(this).children('a').text(); var aClass = jQuery(this).children('a').attr('class'); jQuery(this).children('a').remove(); jQuery(this).prepend('
'+aText+'
'); } // Keep originl height of the submenu menuHeight[jQuery(this).position().left] = jQuery(this).children('ul').first().height(); }); // Main menu hover effect jQuery('.mainMenuTab > ul > li').hover( function(){ jQuery(this).children('ul').css({'height':'auto'}); var currentHeight = jQuery(this).children('ul').height(); jQuery(this).children('ul').css({'height':'0'}); jQuery(this).children('ul').css({'left':jQuery(this).position().left+'px'}); // jQuery(this).children('ul').animate({'height':menuHeight[jQuery(this).children('ul').position().left]+'px'},200); jQuery(this).children('ul').stop().animate({'height':currentHeight+'px'},200); }, function(){ jQuery(this).children('ul').stop().animate({'height':'0'},100,function(){ jQuery(this).css({'left':'-5000px'}); }); } ); jQuery(document).ready(function(){ jQuery('.mainMenuTab ul li ul li:has(ul)').find('a').addClass('arrow'); jQuery('.mainMenuTab ul li ul li:has(ul)').hover(function(){ jQuery(this).parent('ul').css({'overflow': 'visible'}); jQuery(this).children('ul').css({'height':'auto'}); jQuery(this).children('ul').css({'left': '250px'}); }, function(){ jQuery(this).children('ul').css({'height': '0'}); jQuery(this).children('ul').css({'left': '-5000px'}); }); }); //jQuery(document).ready(function(){ // var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false; // if (ie7===true){ // jQuery('.mainMenuTab ul li ul li').prepend('
');
// jQuery('.mainMenuTab ul li ul li:has(ul)').children('.arrow').show();
// }
// jQuery('.mainMenuTab ul li ul li:has(ul)').hover(function(){
// jQuery(this).parent('ul').css({'overflow': 'visible'});
// jQuery(this).children('ul').css({'height':'auto'});
// jQuery(this).children('ul').css({'left': '250px'});
// }, function(){
// jQuery(this).children('ul').css({'height': '0'});
// jQuery(this).children('ul').css({'left': '-5000px'});
// });
// });
jQuery('.sideBarMenuBG, .sideBarMailBG, .mainBG, .sideBarMailTop, .sideBarMailBottom, .mainPanelTop, .mainPanelBottom').animate({'opacity':'0.8'},0);
balanceHeight();
jQuery(document).ready(function() {
// Table styling
jQuery('.mainText table tr:even').addClass('cellBg');
jQuery('.mainText table th:first').css({borderLeft:'inherit'});
});
// Form validation
jQuery(document).ready(function() {
jQuery('#sidebar-contact').validationEngine({
promptPosition: "topRight",
ajaxSubmit: true,
ajaxSubmitFile: "../templates/form2mail.php",
success : false,
failure : function() {}
});
});
jQuery(document).ready(function() {
jQuery('#contactForm').validationEngine({
promptPosition: "topRight",
ajaxSubmit: true,
ajaxSubmitFile: "../templates/form2mail.php",
success : false,
failure : function() {}
});
});
jQuery(document).ready(function() {
jQuery('#submit').click(function(e){
if (jQuery('.captcha-block').is(':hidden')){
e.preventDefault();
}
jQuery('.sideBarMiddle').css({'height':'auto'});
jQuery('.captcha-block').slideDown(500,function(){
balanceHeight();
});
});
});
jQuery(document).ready(function(){
jQuery('#sidebar-contact #submit').click(function(){
var dataString = jQuery('#captcha_code').val();
if(dataString == '') return;
jQuery.ajax({
type: 'POST',
url: '/templates/captcha.php',
data: {'captcha_code':dataString},
dataType: 'json',
success: function(data){
if(data['success']==true){
// captcha validation succeeded
jQuery('#captcha_code').css({'color':'#444'});
jQuery('#sidebar-contact').submit();
jQuery('#captcha_code').val('');
}else{
// captcha validation failed
jQuery('#captcha_code').css({'color':'#b00'});
jQuery('#captcha_code').val('Incorrect code. Please try again.');
// Hide the message when user input
jQuery('#captcha_code').unbind('focus.cms');
jQuery('#captcha_code').bind('focus.cms', function(){
jQuery('#captcha_code').css({'color':'#444'});
jQuery('#captcha_code').val('');
jQuery('#captcha_code').unbind('focus.cms');
});
}
}
});
return false;
});
});
jQuery(document).ready(function(){
jQuery('#contactForm #submit').click(function(){
var dataString = jQuery('#captcha_code').val();
if(dataString == '') return;
jQuery.ajax({
type: 'POST',
url: '/templates/captcha.php',
data: {'captcha_code':dataString},
dataType: 'json',
success: function(data){
if(data['success']==true){
// captcha validation succeeded
jQuery('#captcha_code').css({'color':'#444'});
jQuery('#contactForm').submit();
jQuery('#captcha_code').val('');
}else{
// captcha validation failed
jQuery('#captcha_code').css({'color':'#b00'});
jQuery('#captcha_code').val('Incorrect code. Please try again.');
// Hide the message when user input
jQuery('#captcha_code').unbind('focus.cms');
jQuery('#captcha_code').bind('focus.cms', function(){
jQuery('#captcha_code').css({'color':'#444'});
jQuery('#captcha_code').val('');
jQuery('#captcha_code').unbind('focus.cms');
});
}
}
});
return false;
});
})
});
function showSelectedRegionMenu(){
var menuSelection = 'menuUS';
if (jQuery('#flagCA').hasClass('selected')){
menuSelection = 'menuCA';
}
if (jQuery('#flagMA').hasClass('selected')){
menuSelection = 'menuMA';
}
jQuery('.'+menuSelection).parent('li').show();
jQuery('.mainMenuTab a:not(.'+menuSelection+'), .sideBarMenu a:not(.'+menuSelection+')').parent('li').hide();
jQuery('.mainMenuTab p:not(.'+menuSelection+'), .sideBarMenu p:not(.'+menuSelection+')').parent('li').hide();
jQuery('.'+menuSelection).parent('li').parent().css({height: 'auto'});
jQuery('.mainMenuTab a:not(.'+menuSelection+'), .sideBarMenu a:not(.'+menuSelection+')').parent('li').parent().css({height: 'auto'});
jQuery('.mainMenuTab p:not(.'+menuSelection+'), .sideBarMenu p:not(.'+menuSelection+')').parent('li').parent().css({height: 'auto'});
}
function balanceHeight(){
var sidebarHeight = jQuery('.sideBarMiddle').height();
var mainHeight = jQuery('.mainMiddle').height();
if(sidebarHeight > mainHeight){
jQuery('.mainMiddle').height(sidebarHeight);
jQuery('.mainPanel').height(sidebarHeight-8);
}else{
jQuery('.sideBarMiddle').height(mainHeight);
}
}
function restoreHeight(object, time){
if(time==null) time = 500;
jQuery(object).stop();
jQuery(object).css({'height':'auto'});
var height=jQuery(object).height();
jQuery(object).css({'height':'0'});
jQuery(object).animate({'height':height+'px'},
time,
function(){
jQuery(object).css({'height':'auto'});
});
}
/*
* Login Tab display and hide
*/
jQuery(document).ready(function(){
jQuery('#employeeLogin').click(function(){
jQuery('.loginMiddle > div').animate({'height':0}, 500);
restoreHeight(jQuery('#employeeLoginTab'),500);
return false;
});
jQuery('#adminLogin').click(function(){
jQuery('.loginMiddle > div').animate({'height':0}, 500);
restoreHeight(jQuery('#adminLoginTab'),500);
return false;
});
// login panel
jQuery('body').unbind('click.cms');
jQuery('.loginBottom').click(function(event){
event.stopPropagation();
if(loginTabClicked == true){
jQuery('.loginMiddle').stop().animate({'height':'0px'},500);
loginTabClicked = false;
return false;
}
// perform login action when the login tab is already opened
if(loginTabClicked == true && jQuery('.inputUsername').val()!=jQuery('.inputUsername').attr('text')){
jQuery('#formLogin').submit();
return false;
}else{
jQuery('.loginMiddle > div').animate({'height':0}, 500);
restoreHeight(jQuery('#topLoginTab'), 500);
}
loginTabClicked = true;
jQuery('.loginMiddle').stop().animate({'height':'135px'},500);
jQuery('body').unbind('click.cms');
jQuery('body').bind('click.cms', function(){
if(loginTabClicked){
jQuery('.loginMiddle').stop().animate({'height':'0px'},500);
}
loginTabClicked = false;
jQuery('body').unbind('click.cms');
});
});
// Set default value
jQuery('.loginMiddle input').click(function(event){
event.stopPropagation();
});
jQuery('.loginMiddle input').each(function(){
jQuery(this).val(jQuery(this).attr('text'));
});
// Input username and password hint
jQuery('.loginMiddle input').css({'color':'#ccc'});
jQuery('.loginMiddle input').focus(function(){
// Switch to password
if(jQuery(this).attr('name')=='passwordShow'){
jQuery(this).hide();
jQuery('.passwordHidden').show();
jQuery('.passwordHidden').focus();
}
if(jQuery(this).val()==jQuery(this).attr('name')){
jQuery(this).val('');
}
jQuery(this).css({'color':'#000'});
});
jQuery('.loginMiddle input').blur(function(){
// Show the clear password
if(jQuery(this).attr('name')=='password' && jQuery(this).val()==''){
jQuery(this).hide();
jQuery('.passwordShow').val(jQuery('.passwordShow').attr('text'));
jQuery('.passwordShow').css({'color':'#ccc'});
jQuery('.passwordShow').show();
}
if(jQuery(this).val()==''){
jQuery(this).val(jQuery(this).attr('name'));
jQuery(this).css({'color':'#ccc'});
}
});
// Userinfo panel
jQuery('.userinfoBottom').click(function(event){
event.stopPropagation();
if(loginTabClicked == true){
jQuery('.loginMiddle').stop().animate({'height':'0px'},500);
loginTabClicked = false;
return false;
}
loginTabClicked = true;
jQuery('.loginMiddle').stop().animate({'height':'135px'},500);
jQuery('.loginMiddle > div').animate({'height':0}, 500);
restoreHeight(jQuery('#topLoginTab'), 500);
jQuery('body').unbind('click.cms');
jQuery('body').bind('click.cms', function(){
if(loginTabClicked){
jQuery('.loginMiddle').stop().animate({'height':'0px'},500);
}
loginTabClicked = false;
jQuery('body').unbind('click.cms');
});
});
});
/*
* Sidebar expanding function
*/
jQuery(document).ready(function(){
// Set expand icon
jQuery('.category > ul > li').each(function(){
if(jQuery('ul',jQuery(this)).length > 0){
jQuery(this).css({'padding-left':'0px'});
jQuery('ul',jQuery(this)).css({'margin-left':'15px', 'overflow':'hidden'});
jQuery(this).prepend('
');
}else{
jQuery(this).css({'padding-left':'23px'});
}
});
// Category expand button
jQuery('.category > ul > li a').click(function(){
// Shrink all other categories
// jQuery('.category > ul > li > ul > li > ul').animate({'height':'0'},300);
var productBox = jQuery('> ul',jQuery(this).parent());
// Go to the page if the link is the leaf link
if(productBox.length == 0) return true;
if(productBox.height()==0){
// Shrinked, expanded it now
jQuery(this).prev().removeClass();
jQuery(this).prev().addClass('expandIconExpanded');
productBox.css({'height':'auto'});
var originalHeight = productBox.height();
productBox.css({'height':'0'});
productBox.animate({'height':originalHeight+'px', 'margin-top':'10px'}, 500, function(){
productBox.css({'height':'auto'});
});
}else{
// Expanded, shrink it now
jQuery(this).prev().removeClass();
jQuery(this).prev().addClass('expandIcon');
var originalHeight = productBox.height();
productBox.animate({'height':'0','margin-top':'0'}, 500);
}
return false;
});
// Auto expand the current product page
jQuery('.category a').each(function(){
if((location.href.substr(location.href.length - jQuery(this).attr('href').length, jQuery(this).attr('href').length)==jQuery(this).attr('href') && 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'))){
// Only set background color in single child
if(jQuery('ul',jQuery(this).parent()).length==0){
jQuery(this).parent().css({'background-color':'#eee'});
}else{
jQuery(this).css({'font-weight':'bold'});
}
// Expand parent blocks
var parentUl = jQuery(this).parent().parent();
while(parentUl.height()==0){
jQuery('a',parentUl.parent()).first().click();
parentUl = parentUl.parent().parent();
}
// Stop searching
return false;
}
});
});
/*
* Solution for target="_blank". Use class="newWindow" to indicate open a new window for the link
*/
jQuery(document).ready(function(){
jQuery('.newWindow').click(function(){
var href = jQuery(this).attr('href');
window.open(href);
return false;
});
});