/* " */
function chkFormular (x) {
    var msg = "下面的值是必需的的：\n\n";
    var stateField = 0;
    if (x.first_name) {
        if (x.first_name.value == "" || x.first_name.value == x.first_name.title) {
           msg += x.first_name.title + "\n";
        }
    }
    if (x.last_name) {
        if (x.last_name.value == "" || x.last_name.value == x.last_name.title) {
           msg += x.last_name.title + "\n";
        }
    }
    if (x.email) {
        var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        emailstr = x.email.value;
        if(emailstr.match(emailRegEx)){
        }
        else {
               msg += x.email.title + "\n";
        }
    }
    if (x.company) {
        if (x.company.value == "" || x.company.value == x.company.title) {
            msg += x.company.title + "\n";
        }
    }
    if ($("#state").length){
    if ($("#state").css("display") != "none") {
         stateField = 1;
         if ($("#state").val() == "" || $("#state").val() == $("#state").attr("title")){
            msg += $("#state").attr("title") + "\n";
        }
    }
    }
    if ($("#state_list").length){
    if ($("#state_list").css("display") != "none"){
        stateField = 2;
        if ($("#state_list").val() == "" || $("#state_list").val() == $("#state_list").attr("title")){
            msg += $("#state_list").attr("title") + "\n";
        }
    }
    }
    if (x.city) {
        if (x.city.value == "" || x.city.value == x.city.title) {
            msg += x.city.title + "\n";
        }
    }
    if (x.zip) {    
        if (x.zip.value == "" || x.zip.value == x.zip.title) {
            msg += x.zip.title + " (If not applicable, enter 'xxxxx')" + "\n";
        }
    }
    if (x.Literature_Country__c) {
        if (x.Literature_Country__c.selectedIndex == 0) {
           msg += x.Literature_Country__c.title + "\n";
        }
    }       
    if (x.industry.tagName.toLowerCase() == "select") { 
           if (x.industry.selectedIndex == 0) {
            msg += x.industry.title + "\n";
        }   
    }
   if (x.Primary_Product_Interest__c.tagName.toLowerCase()  == "select") {    
          if (x.Primary_Product_Interest__c.selectedIndex == 0) {
           msg += x.Primary_Product_Interest__c.title + "\n";
        }
    }
    if( msg!="下面的值是必需的的：\n\n" ){
        alert(msg);
        return false;
    }
    else {
        if (stateField == 1){
            $("#state_list").remove();
        } 
        else if (stateField == 2){
            $("#state").remove();
        }
    }    
}
function popup_locator(){
    var useh = 600
    var usew = 815
    useh = useh+78
    usew = usew
    javascript:window.open( 'http://apps.danahermotion.com/locator/','popupwindow','height='+useh+', width='+usew+', toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizeable=yes,copyhistory=no,menubar=no');
}

/********
     function popup_faq(){
    var useh = 
    var usew = 
    useh = useh+78
    usew = usew
    javascript:window.open( '','popupwindow','height='+useh+', width='+usew+', toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizeable=no,copyhistory=no,menubar=no');
}
************/

/* function for grabbing query string values */
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) 
        {
        var r2 = unescape(r[2]);
        var r2 = r2.replace(/\+/g, " ");
        return r2;
        }
    return null;
}

//Inline-Popup
$(document).ready(function(){
    $.ajax({
        url: "/website/com/eng/js/jquery-ui.js",
        type: 'get',
        cache: false,
        dataType: 'script',
        success: function() { 
            $("input[name=search-term]").autocomplete({
                source: "/website/ccsuggest",
                minLength: 2,
                select: function(event, ui) {
                    $("input[name=search-term]").val('"' + ui.item.value + '"');
                    $("#head_search").submit();
                    return false;
                }
            });                
        }
    });

});
 

//Tabs-Rollover
    $("#content_tabs li").mouseover(function(){
        $(this).addClass("on");
    });
    $("#content_tabs li").mouseout(function(){
        $(this).removeClass("on");
    });
//});

(function($){
    /* hoverIntent by Brian Cherne */
    $.fn.hoverIntent = function(f,g) {
        // default configuration options
        var cfg = {
            sensitivity: 7,
            interval: 100,
            timeout: 0
        };
        // override configuration options with user supplied object
        cfg = $.extend(cfg, g ? { over: f, out: g } : f );
        // instantiate variables
        // cX, cY = current X and Y position of mouse, updated by mousemove event
        // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
        var cX, cY, pX, pY;
        // A private function for getting mouse position
        var track = function(ev) {
            cX = ev.pageX;
            cY = ev.pageY;
        };
        // A private function for comparing current and previous mouse position
        var compare = function(ev,ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            // compare mouse positions to see if they've crossed the threshold
            if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
                $(ob).unbind("mousemove",track);
                // set hoverIntent state to true (so mouseOut can be called)
                ob.hoverIntent_s = 1;
                return cfg.over.apply(ob,[ev]);
            } else {
                // set previous coordinates for next time
                pX = cX; pY = cY;
                // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
                ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
            }
        };
        // A private function for delaying the mouseOut function
        var delay = function(ev,ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            ob.hoverIntent_s = 0;
            return cfg.out.apply(ob,[ev]);
        };
        // A private function for handling mouse 'hovering'
        var handleHover = function(e) {
            // next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
            var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
            while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
            if ( p == this ) { return false; }
            // copy objects to be passed into t (required for event object to be passed in IE)
            var ev = jQuery.extend({},e);
            var ob = this;
            // cancel hoverIntent timer if it exists
            if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
            // else e.type == "onmouseover"
            if (e.type == "mouseover") {
                // set "previous" X and Y position based on initial entry point
                pX = ev.pageX; pY = ev.pageY;
                // update "current" X and Y position based on mousemove
                $(ob).bind("mousemove",track);
                // start polling interval (self-calling timeout) to compare mouse coordinates over time
                if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
            // else e.type == "onmouseout"
            } else {
                // unbind expensive mousemove event
                $(ob).unbind("mousemove",track);
                // if hoverIntent state is true, then call the mouseOut function after the specified delay
                if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
            }
        };
        // bind the function to the two event listeners
        return this.mouseover(handleHover).mouseout(handleHover);
    };
    
})(jQuery);
 


/*
 * Superfish v1.4.1 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 *     http://www.opensource.org/licenses/mit-license.php
 *     http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */
(function($){
    $.superfish = {};
    $.superfish.o = [];
    $.superfish.op = {};
    $.superfish.defaults = {
        hoverClass    : 'sfHover',
        pathClass    : 'overideThisToUse',
        delay        : 800,
        animation    : {opacity:'show'},
        speed        : 'fast',
        oldJquery    : false, /* set to true if using jQuery version below 1.2 */
        disableHI    : false, /* set to true to disable hoverIntent usage */
        // callback functions:
        onInit        : function(){},
        onBeforeShow: function(){},
        onShow        : function(){}, /* note this name changed ('onshow' to 'onShow') from version 1.4 onward */
        onHide        : function(){}
    };
    $.fn.superfish = function(op){
        var bcClass = 'sfbreadcrumb',
            over = function(){
                var $$ = $(this), menu = getMenu($$);
                getOpts(menu,true);
                clearTimeout(menu.sfTimer);
                $$.showSuperfishUl().siblings().hideSuperfishUl();
            },
            out = function(){
                var $$ = $(this), menu = getMenu($$);
                var o = getOpts(menu,true);
                clearTimeout(menu.sfTimer);
                if ( !$$.is('.'+bcClass) ) {
                    menu.sfTimer=setTimeout(function(){
                        $$.hideSuperfishUl();
                        if (o.$path.length){over.call(o.$path);}
                    },o.delay);
                }        
            },
            getMenu = function($el){ return $el.parents('ul.superfish:first')[0]; },
            getOpts = function(el,menuFound){ el = menuFound ? el : getMenu(el); return $.superfish.op = $.superfish.o[el.serial]; },
            hasUl = function(){ return $.superfish.op.oldJquery ? 'li[ul]' : 'li:has(ul)'; };
        return this.each(function() {
            var s = this.serial = $.superfish.o.length;
            var o = $.extend({},$.superfish.defaults,op);
            o.$path = $('li.'+o.pathClass,this).each(function(){
                $(this).addClass(o.hoverClass+' '+bcClass)
                    .filter(hasUl()).removeClass(o.pathClass);
            });
            $.superfish.o[s] = $.superfish.op = o;
            
            $(hasUl(),this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out)
            .not('.'+bcClass)
                .hideSuperfishUl();
            
            var $a = $('a',this);
            $a.each(function(i){
                var $li = $a.eq(i).parents('li');
                $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
            });
            
            o.onInit.call(this);
            
        }).addClass('superfish');
    };
    
    $.fn.extend({
        hideSuperfishUl : function(){
            var o = $.superfish.op,
                $ul = $('li.'+o.hoverClass,this).add(this).removeClass(o.hoverClass)
                    .find('>ul').hide().css('visibility','hidden');
            o.onHide.call($ul);
            return this;
        },
        showSuperfishUl : function(){
            var o = $.superfish.op,
                $ul = this.addClass(o.hoverClass)
                    .find('>ul:hidden').css('visibility','visible');
            o.onBeforeShow.call($ul);
            $ul.animate(o.animation,o.speed,function(){ o.onShow.call(this); });
            return this;
        }
    });
    
    $(window).unload(function(){
        $('ul.superfish').each(function(){
            $('li',this).unbind('mouseover','mouseout','mouseenter','mouseleave');
        });
    });
})(jQuery);
 
/*!
 * jQuery Cycle Lite Plugin
 * http://malsup.com/jquery/cycle/lite/
 * Copyright (c) 2008 M. Alsup
 * Version: 1.0 (06/08/2008)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.3 or later
 */
(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery)

