var funk={};funk.is={};funk.is.iPhone=(navigator.userAgent.match(/iPhone/i)=='iPhone') ? true:false;funk.open=false;funk.social={'linkedin':'http://www.linkedin.com/in/jeffjohns', 'twitter':'http://twitter.com/phpfunk', 'viddler':'http://www.viddler.com/phpfunk/', 'vimeo':'http://vimeo.com/phpfunk', 'github':'http://github.com/phpfunk', 'qik':'http://qik.com/phpfunk', 'flickr':'http://www.flickr.com/phpfunk', 'tumblr':'http://t.phpfunk.me', 'lastfm':'http://www.last.fm/user/phpfunk', 'facebook':'http://www.facebook.com/jeffjohns'};funk.special_chars={"\\+":"&#43;"};funk.tab=null;funk.timer=0;funk.current_box='';funk.buttons=function(){$('.icon').hover( function (){$(this).fadeTo(100, '.35');}, function (){$(this).fadeTo(100, 1);});$('.icon').click(function(){$(this).fadeTo(100, 1);var eyed=$(this).attr('id');if (eyed=='email' || eyed=='alfred'){if (funk.current_box==''){funk.current_box=eyed;funk.slide(eyed)}else{$('#' + funk.current_box + "-box").slideUp(1000, function(){funk.scrollTo();if (eyed !=funk.current_box){funk.current_box=eyed;if (eyed=='email'){$('#form-contact-message').val('');}funk.slide(eyed)}else{funk.current_box='';window.location.hash='';}});}}else{funk.tab=open(funk.social[eyed], eyed);}});};funk.changeBorder=function(){if ($.browser.opera || $.browser.ie){$('div.box').css('borderColor', '#433d35');}};funk.empty=function(str){return (str===null || str===undefined || str=="" || !str || str.length < 1) ? true:false;};funk.iPhone=function(){if (funk.is.iPhone===true){$('p.right').html('<a href="tel:+1-484-619-3865" title="Call Me">484-619-FUNK</a>');}};funk.replaceSpecial=function(str, dir){if (funk.empty(str)){return str;}var re=new RegExp();for (var i in funk.special_chars){re=new RegExp((dir===true) ? funk.special_chars[i]:i, 'gi');str=str.replace(re, (dir===true) ? i.replace(/\\/,''):funk.special_chars[i]);}return str;};funk.scrollTo=function(y, ms){y=y || 0;ms=ms || 1000;$('body, html').animate({scrollTop:y}, ms);};funk.slide=function(eyed){if (eyed.indexOf('#') >=0){eyed=eyed.substring(1);funk.current_box=eyed;}$('#' + eyed + '-box').slideDown(1000, function(){window.location.hash='#' + eyed;funk.scrollTo($('#' + eyed + '-box').offset().top);});};funk.close=function(){$('a[id^="close-"]').click(function(){var eyed=$(this).attr('id').split('-')[1];$('#' + eyed + "-box").slideUp(1000, function(){funk.scrollTo();funk.current_box='';window.location.hash='';});});};funk.showError=function(main_eyed, msg_eyed, msg){$('#' + main_eyed).fadeOut('fast', function(){$('#' + msg_eyed).html(msg).fadeIn('fast', function(){clearTimeout(funk.timer);funk.timer=setTimeout(function(){$('#' + msg_eyed).fadeOut('fast', function(){$('#' + main_eyed).fadeIn('fast');});}, 3500);});});};funk.submitForm=function(){$('a[id^="form-submit-"]').click(function(){var container=$(this).parent().parent().attr('id');var html=$(this).html();var eyed=$(this).attr('id').replace(/form-submit-/, '');var req=false;var val=null;var data='';var input_eyed=null;var error=false;$('input[id^="form-' + eyed + '-"],textarea[id^="form-' + eyed + '-"]').each(function(){input_eyed=eyed + '-' + $(this).attr('id').split('-')[2];req=$(this).attr('required');val=funk.trim($(this).val());if ((req===true || req=='true' || req==1) && funk.empty(val)){$('#label-' + input_eyed).css('color', '#ff0000').css('fontWeight','bold');error=true;}else{val=funk.urlEncode(val);$('#label-' + input_eyed).css('color', '#fff').css('fontWeight','normal');data +=(funk.empty(data)) ? input_eyed + '=' + val:'&' + input_eyed + '=' + val;}});if (error){funk.showError('form-submit-' + eyed, container + ' p.message', 'Please correct the areas in red above.');}else{$.ajax({url:'/process/' + eyed + '.php', cache:false, data:data, dataType:'html', type:'post', success:function(msg){if (msg=='ok'){$('#' + container + ' div.show').slideUp(750, function(){$('#' + container + ' div.hide').slideDown(1000, function(){clearTimeout(funk.timer);funk.timer=setTimeout(function(){$('#' + container).slideUp(1000, function(){$('#' + container + ' div.hide').hide();$('#' + container + ' div.show').show();funk.open=false;});}, 5000);});});}else{funk.showError('form-submit-' + eyed, container + ' p.message', 'There was an error sending your message. Please try again.');}}, error:function(){funk.showError('form-submit-' + eyed, container + ' p.message', 'There was an error sending your message. Please try again.');}});}return false;});};funk.trim=function(str){return (funk.empty(str)) ? str:str.replace(/^(\s*|\n*|\r*|\t*)|(\s*|\n*|\r*|\t*)$/g,'');};funk.urlDecode=function(str){if (funk.empty(str)){return str;}return funk.replaceSpecial(decodeURIComponent(str), true);};funk.urlEncode=function(str){if (funk.empty(str)){return str;}return encodeURIComponent(funk.replaceSpecial(str));};$(document).ready(function(){funk.iPhone();funk.changeBorder();funk.buttons();funk.submitForm();funk.slide(window.location.hash);funk.close();});
