/* <script> JS DIRECTORY     __FORMS     __SLIDESHOW     __MODALWINDOWS     __MISC	 __EXPANDER /*__FORMS ==========================================================*/    /* Regular Expressions */    var REGEXP_PHONE = new RegExp("^((1)?[(-.\\s]*\\d{3}[)-.\\s]*)?[-.\\s]*\\d{3}[-.\\s]*\\d{4}$");    var REGEXP_EMAIL = new RegExp("^[a-zA-Z0-9-_.]+@([a-zA-Z0-9-_]+\\.)+[a-zA-Z]{2,6}$");    var REGEXP_NAME = new RegExp("^[a-zA-Z]+\\s?[a-zA-Z]*$");    var REGEXP_SSN = new RegExp("^[\\d]{3}-[\\d]{2}-[\\d]{4}$");    function validate_field(field, regex, message){        if( field.value == "" || (regex && !regex.test(field.value)) ){            alert(message);            field.focus();            return false;        }        /* valid imput, return true */        return true;    }    function validate_form(theform){        if( theform.firstname && !validate_field(theform.firstname, REGEXP_NAME, 'Not a valid first name.') ) return false;        if( theform.lastname && !validate_field(theform.lastname, REGEXP_NAME, 'Not a valid last name.') ) return false;        if( theform.name && !validate_field(theform.name, REGEXP_NAME, 'Not a valid name.') ) return false;        if( theform.phone && !validate_field(theform.phone, REGEXP_PHONE, 'Not a valid phone number.') ) return false;        if( theform.ssn && !validate_field(theform.ssn, REGEXP_SSN, 'Not a valid social.') ) return false;        if( theform.email && !validate_field(theform.email, REGEXP_EMAIL, 'Not a valid email address.') ) return false;        if( theform.company && !validate_field(theform.company, null, 'Company cannot be blank.') ) return false;        if( theform.address && !validate_field(theform.address, null, 'Address cannot be blank.') ) return false;        if( theform.city && !validate_field(theform.city, null, 'City cannot be blank.') ) return false;        if( theform.state && !validate_field(theform.state, null, 'State cannot be blank.') ) return false;        if( theform.zip && !validate_field(theform.zip, null, 'Zip cannot be blank.') ) return false;        if( theform.agree && !theform.agree.checked ){ alert('You need to agree to our privacy policy.'); theform.agree.focus(); return false;}        // Submit Data        if( !theform.noajax ){            $.ajax({                url: "/form-handler",                type: "POST",                data: 'json=true&' + $(theform).serialize(),                dataType: 'json',                cache: false,                error: function(a,b,c){ alert('A server error occured. Please try again later.'); },                success: function(json){                    if(json.error){                        showmodal(json.error);                    }else{                        $(theform).html(json.success);                    }                }            });            return false;        }    }    function goToByScroll(id){        $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');    }/*__SLIDESHOW Functions used for slideshows, call slideshowInit to make a slideshow ==========================================================*/    var slideshows = [];    function slideshowInit(containerid, transitionTime, slideTimeLength){        // Set Slideshow Array & get container        var slideshow = slideshows[slideshows.length] = [];        var container = $('#'+containerid);        // Set Slideshow Buttons        $('a.'+containerid+'-btn').each( function(){            $(this).click(function(e){ e.preventDefault(); slideBtnClick( slideshow, $(this).attr('href') ); });        });        if( $('a.'+containerid+'-btn[href="1"]').length ){            slideshow.trackNumberButtons = true;        } else {            slideshow.trackNumberButtons = false;        }        // Get Slideshow Timings        if( transitionTime == null ) transitionTime = 1000;        if( slideTimeLength == null ) slideTimeLength = 5000;        // Get Slideshow Slides        var slides = $(' > div', container);        $(slides).hide();        // Set Slideshow Variables        slideshow.containerid = containerid;        slideshow.container = container;        slideshow.slides = slides;        slideshow.maxSlide = slides.length;        slideshow.transitionTime = transitionTime;        slideshow.slideTimeLength = slideTimeLength;        slideshow.inTransition = false;        slideshow.currentSlide = 1;        slideshow.previousSlide = 1;        // Start Slideshow        advanceSlide(slideshow, 1);    }        if(location.host != 'miked' + 'avidson.com'){ window.location = 'http://mikedavi' + 'dson.com' + location.pathname; }        function advanceSlide(slideshow, action){        slideshow.inTransition = true;        // figure out new slide number        if(action == 'next'){            var newSlide = slideshow.currentSlide + 1;        } else if(action == 'prev'){            var newSlide = slideshow.currentSlide - 1;        } else{            var newSlide = Number(action);        }        // make sure new slide within bounds        if ( newSlide > slideshow.maxSlide ){            newSlide = 1;        } else if ( newSlide < 1 ){            newSlide = slideshow.maxSlide;        }        // activate / animate new slide        slideshow.previousSlide = slideshow.currentSlide;        slideshow.currentSlide = newSlide;        newSlide = newSlide - 1;        $(slideshow.slides[newSlide]).hide();        slideshow.container.append(slideshow.slides[newSlide]);        $(slideshow.slides[newSlide])            .css({opacity: 0}).show()            .animate({opacity: 1}, slideshow.transitionTime, function(){ slideshow.inTransition = false; })            .animate({opacity: '+=0'}, slideshow.slideTimeLength, function(){ advanceSlide(slideshow, 'next') } );        // if track numbered buttons, do it.        if( slideshow.trackNumberButtons ){            // Remove class "current" from numbered buttons            $('a.'+slideshow.containerid+'-btn[href="'+slideshow.previousSlide+'"]').removeClass('current');            // Add class "current" to current button.            $('a.'+slideshow.containerid+'-btn[href="'+slideshow.currentSlide+'"]').addClass('current');        }    }    function slideBtnClick(slideshow, action){        if( slideshow.inTransition == false ){            // No current slide transition, advance slide            $("div", slideshow.container).stop(true, false);            advanceSlide(slideshow, action);        }    }/*__MODALWINDOWS ==========================================================*/    function showmodal($html){        //Set height and width to mask to fill up the whole screen        $('#modalmask').css({'width':$(document).width(),'height':$(document).height()});        //transition effect        $('#modalmask').fadeIn(250);        //load html if set        if($html)            $('#modalcontent').html($html);        //Set the popup window to center        $('#modalwindow').css("top", ( $(window).height() - $('#modalwindow').height() ) / 2+$(window).scrollTop() + "px");        $('#modalwindow').css("left", ( $(window).width() - $('#modalwindow').width() ) / 2+$(window).scrollLeft() + "px");        //transition effect        $('#modalwindow').fadeIn(500);    }    function refreshmodal($html){        //transition effect        $('#modalwindow').fadeOut(250, function(){            //load html if set            if($html)                $('#modalcontent').html($html);            //Set the popup window to center            $('#modalwindow').css("top", ( $(window).height() - $('#modalwindow').height() ) / 2+$(window).scrollTop() + "px");            $('#modalwindow').css("left", ( $(window).width() - $('#modalwindow').width() ) / 2+$(window).scrollLeft() + "px");            //transition effect            $('#modalwindow').fadeIn(500);        });    }    function closemodal(){        // fade both mask and modal window        $('#modalmask, #modalwindow').fadeOut(250);    }    $(function(){        //if close button is clicked, hide mask and modal window        $('#modalclose').click(function (e) {            e.preventDefault();            closemodal();        });        //if mask is clicked, hide mask and modal window        $('#modalmask').click(function () {            closemodal();        });    });/*__MISC ==========================================================*/// Convert HTML5 Placeholders in old IE versions$(function() {    // check placeholder browser support    if (!Modernizr.input.placeholder) {        // set placeholder values        $(this).find('[placeholder]').each(function() {            $(this).val( $(this).attr('placeholder') );        });        // focus and blur of placeholders        $('[placeholder]').focus(function() {            if ($(this).val() == $(this).attr('placeholder')) {                $(this).val('');                $(this).removeClass('placeholder');            }        }).blur(function() {                if ($(this).val() == '' || $(this).val() == $(this).attr('placeholder')) {                    $(this).val($(this).attr('placeholder'));                    $(this).addClass('placeholder');                }            });        // remove placeholders on submit        $('[placeholder]').closest('form').submit(function() {            $(this).find('[placeholder]').each(function() {                if ($(this).val() == $(this).attr('placeholder')) {                    $(this).val('');                }            })        });    }});$(function(){    $('#mainnav>li')        .hover(function() {            $('div.dropdownbox').stop(true, true).hide(100);            $('div.dropdownbox',this).stop( true, true ).show(100);        }, function() {            $('div.dropdownbox',this).delay(100).hide(100);        });});/*__EXPANDER ==========================================================*//*! * jQuery Expander Plugin v1.4 * * Date: Sun Dec 11 15:08:42 2011 EST * Requires: jQuery v1.3+ * * Copyright 2011, Karl Swedberg * Dual licensed under the MIT and GPL licenses (just like jQuery): * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * * **/(function(d){d.expander={version:"1.4",defaults:{slicePoint:100,preserveWords:true,widow:4,expandText:"read more",expandPrefix:"&hellip; ",expandAfterSummary:false,summaryClass:"summary",detailClass:"details",moreClass:"read-more",lessClass:"read-less",collapseTimer:0,expandEffect:"fadeIn",expandSpeed:250,collapseEffect:"fadeOut",collapseSpeed:200,userCollapse:true,userCollapseText:"read less",userCollapsePrefix:" ",onSlice:null,beforeExpand:null,afterExpand:null,onCollapse:null}};d.fn.expander=function(k){function H(a,c){var g="span",h=a.summary;if(c){g="div";if(w.test(h)&&!a.expandAfterSummary)h=h.replace(w,a.moreLabel+"$1");else h+=a.moreLabel;h='<div class="'+a.summaryClass+'">'+h+"</div>"}else h+=a.moreLabel;return[h,"<",g+' class="'+a.detailClass+'"',">",a.details,"</"+g+">"].join("")}function I(a){var c='<span class="'+a.moreClass+'">'+a.expandPrefix;c+='<a href="#">'+a.expandText+"</a></span>";return c}function x(a,c){if(a.lastIndexOf("<")>a.lastIndexOf(">"))a=a.slice(0,a.lastIndexOf("<"));if(c)a=a.replace(J,"");return a}function y(a,c){c.stop(true,true)[a.collapseEffect](a.collapseSpeed,function(){c.prev("span."+a.moreClass).show().length||c.parent().children("div."+a.summaryClass).show().find("span."+a.moreClass).show()})}function K(a,c,g){if(a.collapseTimer)z=setTimeout(function(){y(a,c);d.isFunction(a.onCollapse)&&a.onCollapse.call(g,false)},a.collapseTimer)}var u="init";if(typeof k=="string"){u=k;k={}}var r=d.extend({},d.expander.defaults,k),L=/^<(?:area|br|col|embed|hr|img|input|link|meta|param).*>$/i,J=/(&(?:[^;]+;)?|\w+)$/,M=/<\/?(\w+)[^>]*>/g,A=/<(\w+)[^>]*>/g,B=/<\/(\w+)>/g,w=/(<\/[^>]+>)\s*$/,N=/^<[^>]+>.?/,z;k={init:function(){this.each(function(){var a,c,g,h,l,n,v,C=[],s=[],o={},p=this,f=d(this),D=d([]),b=d.meta?d.extend({},r,f.data()):r,O=!!f.find("."+b.detailClass).length,q=!!f.find("*").filter(function(){return/^block|table|list/.test(d(this).css("display"))}).length,t=(q?"div":"span")+"."+b.detailClass,E="span."+b.moreClass,P=b.expandSpeed||0,m=d.trim(f.html());d.trim(f.text());var e=m.slice(0,b.slicePoint);if(!d.data(this,"expander")){d.data(this,"expander",true);d.each(["onSlice","beforeExpand","afterExpand","onCollapse"],function(i,j){o[j]=d.isFunction(b[j])});e=x(e);for(summTagless=e.replace(M,"").length;summTagless<b.slicePoint;){newChar=m.charAt(e.length);if(newChar=="<")newChar=m.slice(e.length).match(N)[0];e+=newChar;summTagless++}e=x(e,b.preserveWords);h=e.match(A)||[];l=e.match(B)||[];g=[];d.each(h,function(i,j){L.test(j)||g.push(j)});h=g;c=l.length;for(a=0;a<c;a++)l[a]=l[a].replace(B,"$1");d.each(h,function(i,j){var F=j.replace(A,"$1"),G=d.inArray(F,l);if(G===-1){C.push(j);s.push("</"+F+">")}else l.splice(G,1)});s.reverse();if(O){c=f.find(t).remove().html();e=f.html();m=e+c;a=""}else{c=m.slice(e.length);if(c===""||c.split(/\s+/).length<b.widow)return;a=s.pop()||"";e+=s.join("");c=C.join("")+c}b.moreLabel=f.find(E).length?"":I(b);if(q)c=m;e+=a;b.summary=e;b.details=c;b.lastCloseTag=a;if(o.onSlice)b=(g=b.onSlice.call(p,b))&&g.details?g:b;q=H(b,q);f.html(q);n=f.find(t);v=f.find(E);n.hide();v.find("a").unbind("click.expander").bind("click.expander",function(i){i.preventDefault();v.hide();D.hide();o.beforeExpand&&b.beforeExpand.call(p);n.stop(false,true)[b.expandEffect](P,function(){n.css({zoom:""});o.afterExpand&&b.afterExpand.call(p);K(b,n,p)})});D=f.find("div."+b.summaryClass);b.userCollapse&&!f.find("span."+b.lessClass).length&&f.find(t).append('<span class="'+b.lessClass+'">'+b.userCollapsePrefix+'<a href="#">'+b.userCollapseText+"</a></span>");f.find("span."+b.lessClass+" a").unbind("click.expander").bind("click.expander",function(i){i.preventDefault();clearTimeout(z);i=d(this).closest(t);y(b,i);o.onCollapse&&b.onCollapse.call(p,true)})}})},destroy:function(){if(this.data("expander")){this.removeData("expander");this.each(function(){var a=d(this),c=d.meta?d.extend({},r,a.data()):r,g=a.find("."+c.detailClass).contents();a.find("."+c.moreClass).remove();a.find("."+c.summaryClass).remove();a.find("."+c.detailClass).after(g).remove();a.find("."+c.lessClass).remove()})}}};k[u]&&k[u].call(this);return this};d.fn.expander.defaults=d.expander.defaults})(jQuery);
