var spin='<img src="http://www.makeyourownyogurt.com/images/elements/progress-spinner.gif" width="16" height="16" alt="Loading&#8230;" id="spinner" />';$(document).ready(function(){if(jQuery.browser.msie){if(parseInt(jQuery.browser.version)=='6'){$('body').css({width:'90%'});window.onresize=function(){document.documentElement.offsetWidth<801?$('body').css({width:'800px'}):$('body').css({width:'90%'});}}}
makepopups();modal();validate();});function makepopups(){$('a.popup-link').click(function(event){var w=$(window).width();var h=$(window).height();var defs='resizable,toolbar=yes,location=yes,scrollbars=yes';var r=$(this).attr('rel');if(!r){f='width='+w+',height='+h+','+defs;popup($(this).attr('href'),'yogurt',f);return false;}else{r=$(this).attr('rel').split(' ');if(jQuery.browser.msie){w=parseInt(r[1])+40;h=parseInt(r[2])+40;}else{w=r[1];h=r[2]}
popup($(this).attr('href'),r[0],'width='+w+', height='+h+','+defs);return false;}});}
function show_hide(v,id,tog,open,shut){if(v==0){$('#'+id).hide();}else{$('#'+id).fadeIn('slow');}
$('#'+tog).html(v?'<a href="" onclick="show_hide(0,\''+id+'\',\''+tog+'\',\''+open+'\',\''+shut+'\'); return false" accesskey="l">'+shut+'</a>':'<a href="" onclick="show_hide(1,\''+id+'\',\''+tog+'\',\''+open+'\',\''+shut+'\'); return false" accesskey="c">'+open+'</a>');}
function popup(u,n,f){var newwin=window.open(u,n,f);newwin.focus();}
function validate(){$('form.must-be-valid').submit(function(){var id=$(this).attr('id');$('#'+id+' .error').remove();$('.success-box').remove();var hasError=false;var emailReg=/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;var crack=/(\r|\n)(to:|from:|cc:|bcc:)/;$('#'+id+' span.req ~ :input').each(function(){var t=$(this).prevAll('label').text().split(':');if($(this).val()==''){$(this).after('<span class="error"><br />'+t[0]+' is Required</span>');hasError=true;}});$('#'+id+' input[name$="email"]').each(function(){if(!emailReg.test($(this).val())){$(this).after('<span class="error"><br />Please enter a valid email address</span>');hasError=true;}});$('#'+id+' textarea').each(function(){if(crack.test($(this).val())){$(this).after('<span class="error"><br />There appear to be email headers in your message</span>');hasError=true;}});if(hasError==false){var u=$(this).attr('action');var d=$(this).serialize();var s=$('button[type="submit"]').attr('name');d+='&'+s+'='+s+'&hijax=true';hijax(id,u,d);}
return false;});}
function hijax(id,u,d){$.ajax({cache:false,data:d,dataType:'json',error:function(XMLHttpRequest,textStatus,errorThrown){},success:function(data){var mess=data.message;if($('#'+data.id).find('input[name="referer"]').length>0){var redirect=$('input[name="referer"]').val();mess=mess+' You will be redirected in 5 seconds...';}
if(data.status=='success'){$('#'+data.id).slideUp("normal",function(){$('#'+data.id).before('<div class="'+data.status+'-box">'+mess+'</div>');$('#toggle-'+data.id).hide();});if(undefined!=redirect){window.setTimeout('window.location="'+redirect+'"',5000);}}else{$("#submit").before('<p class="error">'+data.message+'</p>');}},type:'POST',url:u});return false;}
var showModal=function(hash){$('#modal-content').ajaxStart(function(){if($(this).html()==''){$(this).html(spin);}else{if($('#spinner').length<1){$(this).prepend(spin);}}});var $t=$(hash.t);var $u=$t.attr('href');var $r=$t.attr('rel');if($r){$r=$t.attr('rel').split(' ');if($r[0]=='video'){$v=$u.split('=');$u='/video.php?video='+$v[1];}
$l=$u+' #'+$r[0];$f=$r[1];}else{$l=$u;}
$(hash.w).css('opacity',100).show();$('#modal-content').load($l).ajaxStop(function(){if($f){$(window).trigger($f);}});}
function modal(){if(($('a.modal-link').length>0)&&$($('#dialog').length<1)){$('#content').after('<div class="jqmWindow" id="dialog"><h4 id="modal-head"><a href="" class="modal-close" title="Close this Window">Close</a></h4><div id="modal-content"></div><a href="#" id="modal-foot" class="modal-close">Close</a></div>');$('#dialog').jqm({overlayClass:'modal-dimmer',closeClass:'modal-close',trigger:'a.modal-link',toTop:true,onShow:showModal,onHide:function(h){$(h.w).hide().children('#modal-content').html('');$(h.o).remove();}});}};(function($){$.fn.jqm=function(o){var p={overlay:50,overlayClass:'jqmOverlay',closeClass:'jqmClose',trigger:'.jqModal',ajax:F,ajaxText:'',target:F,modal:F,toTop:F,onShow:F,onHide:F,onLoad:F};return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};if(p.trigger)$(this).jqmAddTrigger(p.trigger);});};$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};$.fn.jqmShow=function(t){return this.each(function(){$.jqm.open(this._jqm,t);});};$.fn.jqmHide=function(t){return this.each(function(){$.jqm.close(this._jqm,t)});};$.jqm={hash:{},open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index'))),z=(z>0)?z:3000,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);if(c.modal){if(!A[0])L('bind');A.push(s);}
else if(c.overlay>0)h.w.jqmAddClose(o);else o=F;h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in{Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}
if(c.ajax){var r=c.target||h.w,u=c.ajax,r=(typeof r=='string')?$(r,h.w):$(r),u=(u.substr(0,1)=='@')?$(t).attr(u.substring(1)):u;r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
else if(cc)h.w.jqmAddClose($(cc,h.w));if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);(c.onShow)?c.onShow(h):h.w.show();e(h);return F;},close:function(s){var h=H[s];if(!h.a)return F;h.a=F;if(A[0]){A.pop();if(!A[0])L('unbind');}
if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();}return F;},params:{}};var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version=="6.0"),F=false,i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i);f(h);},f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return!r;},hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function(){if(!this[c]){this[c]=[];$(this).click(function(){for(var i in{jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};})(jQuery);
