﻿/*
Name:      Plugins Pack for Restorange.Ru
Use with:  jQuery
Included:  shogo, menu
*/
(function($){$.menu=function(elems,options){if(!elems){return }var opts=$.extend(true,{},$.menu.defaults,options),popups=[];var $hide=function(){for(var i=0,l=popups.length;i<l;i++){var el=$(popups[i]);if(el.data("animating")){$(el).stop(true,true);$(el).hide()}}};$(elems).each(function(){var bid=$(this).attr("id");if(!bid){return true}var targel="#"+bid+opts.mask;if(opts.manipulation){$("body").append($(targel))}popups.push(targel);$(this).hover(function(){$hide();opts.show_prepare($(this));if(opts.effect){$(targel).data("animating","true")}$.showpos(this,$(targel),opts.posTop,opts.posLeft,!opts.manipulation,opts.effect,function(){if(opts.effect){$(targel).removeData("animating")}opts.show_ready($("#"+bid))})},function(e){var check=($(e.relatedTarget).attr("id")&&"#"+$(e.relatedTarget).attr("id")==targel)||$(e.relatedTarget).parents(targel).length!=0;if(check){return }$(targel).hide();$hide();opts.hide_callback($(this))});$(targel).mouseleave(function(e){if($(e.relatedTarget).parents("#"+bid).length!=0){return }$(this).hide();opts.hide_callback($("#"+bid))})})};$.showpos=function(src,targ,posTop,posLeft,relative,effect,callback){if(!src||!targ){return false}var src=typeof src=="string"?$("#"+src):$(src),targ=typeof targ=="string"?$("#"+targ):$(targ),coords=relative?src.position():src.offset(),tw=targ.outerWidth(),th=targ.outerHeight(),sw=src.outerWidth(),sh=src.outerHeight();var countValue=function(str,sideTop){var aliasTop={above:coords.top-th,top:coords.top,center:coords.top+sh/2,bottom:coords.top+sh-th,under:coords.top+sh},aliasLeft={before:coords.left-tw,left:coords.left,center:coords.left+sw/2,right:coords.left+sw-tw,after:coords.left+sw},templates={"%%SOURCEWIDTH%%":sw,"%%SOURCEHEIGHT%%":sh,"%%THISWIDTH%%":tw,"%%THISHEIGHT%%":th,"%%WINDOWWIDTH%%":$(window).width(),"%%WINDOWHEIGHT%%":$(window).height(),"%%DOCUMENTWIDTH%%":$(document).width(),"%%DOCUMENTHEIGHT%%":$(document).height()},keys=[];for(var i in sideTop?aliasTop:aliasLeft){keys.push(i)}var re=new RegExp("^.*("+keys.join("|")+")(.*)$","i");var parsed=re.exec(str);return eval("("+(sideTop?aliasTop:aliasLeft)[parsed[1]]+parsed[2].replace(/(%%[A-Z]+%%)/g,function($0){return templates[$0]})+")")};var tt=countValue(posTop.value,true),tl=countValue(posLeft.value);targ.css({top:posTop.auto?((tt+th)>($(window).height()+$(document).scrollTop())?countValue(posTop.auto,true):tt):tt,left:posLeft.auto?((tl+tw)>($(window).width()+$(document).scrollLeft())?countValue(posLeft.auto):tl):tl}).show(effect,callback);if(!effect&&callback){callback()}return true};$.menu.defaults={mask:"_content",posTop:{value:"under",auto:"above"},posLeft:{value:"left",auto:"right"},effect:"fast",manipulation:true,show_prepare:$.noop,show_ready:$.noop,hide_callback:$.noop}})(jQuery);var msie6=!!(jQuery.browser.msie&&(jQuery.browser.version&&jQuery.browser.version<7||/MSIE 6.0/.test(navigator.userAgent)));var bgFixer=function(C,B){var A=C.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);if(A&&msie6){A=A[1];if(!A.match(/http:\/\//)&&jQuery("head base").length){A="/"+A}if(C.currentStyle.width=="auto"){jQuery(C).css("width",jQuery(C).width()+"px")}if(C.currentStyle.height=="auto"){jQuery(C).css("height",jQuery(C).height()+"px")}C.runtimeStyle.backgroundImage="none";C.runtimeStyle.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+A+'",sizingMethod="'+B+'")';jQuery(C).find("a").css("position","relative")}};function fixBgPNG_c(A){bgFixer(A,"crop")}function fixBgPNG_s(A){bgFixer(A,"scale")}jQuery(function(){var A=function(C){var B=jQuery(C).attr("src");if(!jQuery(C).attr("width")){jQuery(C).attr("width",jQuery(C).width())}if(!jQuery(C).attr("height")){jQuery(C).attr("height",jQuery(C).height())}if(!B.match(/http:\/\//)&&jQuery("head base").length){B="/"+B}jQuery(C).attr("src","i/sp.gif");C.runtimeStyle.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+B+'",sizingMethod="crop")'};if(jQuery.browser.msie){jQuery("img.pngfix_all[src$=.png]").each(function(){A(this)})}if(msie6){jQuery("img.pngfix[src$=.png], input.pngfix[src$=.png]").each(function(){A(this)})}});var this_url=document.location.href.replace(/#.*$/,"")+(document.location.href.match(/\?/)==null?"?":"&")+"$js="+(new Date()).valueOf();jQuery(function(){if("hs" in window&&hs.expand){jQuery("a.highslide").click(function(A){A.preventDefault();hs.expand(this)})}});var gbi=function(A){return !!document.getElementById(A)};function $HAR(resp){var result=false;var defmsg="Произошла неизвестная ошибка!";if(resp&&resp.status){switch(resp.status){case"ok":result=true;break;case"error":alert(resp.message||defmsg);break;default:alert(defmsg)}if(resp.evaluate){eval(resp.evaluate)}}return result}function check_required(C){for(var B=0,A=C.length;B<A;B++){if(!jQuery("#"+C[B]["id"]).val().replace(/^\s+/,"").replace(/\s+$/,"").length){alert(C[B]["name"]+" не может быть пустым!");jQuery("#"+C[B]["id"]).focus();return false}if(C[B]["email"]&&!jQuery("#"+C[B]["id"]).val().match(/\S+@\S+\.\S+/)){alert(C[B]["name"]+" содержит некорректное значение!");jQuery("#"+C[B]["id"]).focus();return false}if(C[B]["numeric"]&&!jQuery("#"+C[B]["id"]).val().match(/[\d]+/)){alert(C[B]["name"]+" содержит некорректное значение!");jQuery("#"+C[B]["id"]).focus();return false}if(C[B]["group_1_2_3"]&&!jQuery("#"+C[B]["id"]).val().match(/(1|2|3)(,(1|2|3))*/)){alert(C[B]["name"]+" содержит некорректное значение!");jQuery("#"+C[B]["id"]).focus();return false}}return true}jQuery(function(){jQuery(".fbhandler-activate").each(function(){var B=jQuery(this).attr("id");if(!B){return }var E="#"+B,A=":not(.fbhandler-exclude)",C=jQuery(":text"+A+", :password"+A+", textarea"+A,E);C.each(function(){var F=jQuery(this).attr("title")||"";if(jQuery(this).is(":password")){var H=function(J){var L=null;if(jQuery(J).is(":hidden")){L=jQuery(J).css("display")=="none"?jQuery(J):jQuery(J).parents(":hidden",document.body).map(function(){return jQuery(this).css("display")=="none"?this:null})}if(L){L.show()}var K=jQuery(J).position();if(L){L.hide()}return K};var I=H(this);jQuery(this).after(jQuery(this).clone().css({position:"absolute",zIndex:"9999",top:I.top,left:I.left}).wrap("<div />").parent()[0].innerHTML.replace(/type=(")?password(")?/i,'type="text"')).next().attr("value",F).focus(function(){jQuery(this).hide().prev().trigger("focus")});var G=this;jQuery(window).resize(function(){var J=H(G);jQuery(G).next().css({top:J.top,left:J.left})})}if(!jQuery(this).val()||jQuery(this).val()==F){jQuery(this).val(F).data("is_empty",true)}jQuery(this).focus(function(){if(!jQuery(this).data("is_changed")&&(jQuery(this).data("is_empty")||(!jQuery(this).data("is_empty")&&jQuery(this).val()==F))){jQuery(this).val("")}}).blur(function(){if(!jQuery(this).data("is_changed")&&(jQuery(this).data("is_empty")||(!jQuery(this).data("is_empty")&&!jQuery(this).val()))){jQuery(this).val(F);if(jQuery(this).is(":password")){jQuery(this).next().show()}}}).change(function(){jQuery(this).data("is_changed",jQuery(this).val())})});jQuery("form",E).submit(function(){var F=false;C.each(function(){if((!jQuery(this).data("is_changed")&&(jQuery(this).data("is_empty")||(!jQuery(this).data("is_empty")&&jQuery(this).val()==jQuery(this).attr("title"))))||!jQuery(this).val()){F=true}});return !F});var D=jQuery("form a:has(img)",E);if(D.length){D.click(function(F){F.preventDefault();jQuery("form",E).trigger("submit")})}})});jQuery.preventDefaultEvent=function(C,B){B=B||{shift:1,ctrl:1,alt:1,meta:1};var A=C.currentTarget.getAttribute("href");if(((B.shift&&C.shiftKey)||(B.alt&&C.altKey)||(B.ctrl&&C.ctrlKey)||(B.meta&&C.metaKey))&&A&&A.indexOf("#")!=0&&A.indexOf("javascript:")!=0){return true}C.preventDefault();return false};String.prototype.find=function(A){return(this.indexOf(A)!==-1?true:false)};function scroll_to(B,C){var A=jQuery(B).offset().top;jQuery("html").animate({scrollTop:A},C?C:0)};
