/*
jQuery.ScrollTo - Easy element scrolling using jQuery.
Copyright (c) 2007-2008 Ariel Flesler 
http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);

/*
jQuery Color Animations
Copyright 2007 John Resig
Released under the MIT and GPL licenses.
 */
(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]=function(fx){if(fx.state==0){fx.start=getColor(fx.elem,attr);fx.end=getRGB(fx.end)}fx.elem.style[attr]="rgb("+[Math.max(Math.min(parseInt((fx.pos*(fx.end[0]-fx.start[0]))+fx.start[0]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[1]-fx.start[1]))+fx.start[1]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[2]-fx.start[2]))+fx.start[2]),255),0)].join(",")+")"}});function getRGB(color){var result;if(color&&color.constructor==Array&&color.length==3)return color;if(result=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))return[parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if(result=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))return[parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if(result=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))return[parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if(result=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))return[parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()]}function getColor(elem,attr){var color;do{color=jQuery.curCSS(elem,attr);if(color!=''&&color!='transparent'||jQuery.nodeName(elem,"body"))break;attr="backgroundColor"}while(elem=elem.parentNode);return getRGB(color)}})(jQuery);

/*
Background-Position Animations
WEBSITE: http://plugins.jquery.com/project/backgroundPosition-Effect
Copyright Alexander Farkas
*/
(function($){if(!document.defaultView||!document.defaultView.getComputedStyle){var oldCurCSS=jQuery.curCSS;jQuery.curCSS=function(elem,name,force){if(name!=='backgroundPosition'||!elem.currentStyle||elem.currentStyle[name]){return oldCurCSS.apply(this,arguments)}var style=elem.style;if(!force&&style&&style[name]){return style[name]}return oldCurCSS(elem,'backgroundPositionX',force)+' '+oldCurCSS(elem,'backgroundPositionY',force)}}})(jQuery);(function($){function toArray(strg){strg=strg.replace(/left|top/g,'0px');strg=strg.replace(/right|bottom/g,'100%');strg=strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var res=strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]]}$.fx.step.backgroundPosition=function(fx){if(!fx.bgPosReady){var start=$.curCSS(fx.elem,'backgroundPosition');if(!start){start='0px 0px'}start=toArray(start);fx.start=[start[0],start[2]];var end=toArray(fx.options.curAnim.backgroundPosition);fx.end=[end[0],end[2]];fx.unit=[end[1],end[3]];fx.bgPosReady=true}var nowPosX=[];nowPosX[0]=((fx.end[0]-fx.start[0])*fx.pos)+fx.start[0]+fx.unit[0];nowPosX[1]=((fx.end[1]-fx.start[1])*fx.pos)+fx.start[1]+fx.unit[1];fx.elem.style.backgroundPosition=nowPosX[0]+' '+nowPosX[1]}})(jQuery);

/*
 * Inline Form Validation Engine, jQuery plugin
 * Copyright(c) 2009, Cedric Dugas
 * http://www.position-relative.net
 */
jQuery.fn.validationEngine = function(settings) {
allRules={"required":{"regex":"none","alertText":"Это поле обязательно нужно заполнить","alertTextCheckboxMultiple":"Пожалуйста, выберите","alertTextCheckboxe":"Этот флажок должен быть отмечен"},"length":{"regex":"none","alertText":"Должно быть от ","alertText2":" до ","alertText3":" символов."},"minCheckbox":{"regex":"none","alertText":"Поставлено слишком много флажков"},"confirm":{"regex":"none","alertText":"Поле не соответствует требованиям"},"telephone":{"regex":"/^[0-9\-\–\+\(\)\ ]+$/","alertText":"Введите корректный номер телефона"},"email":{"regex":"/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/","alertText":"Введите корректный e-mail"},"date":{"regex":"/^[0-9]{1,2}\-\[0-9]{1,2}\-\[0-9]{4}$/","alertText":"введите корректную дату (формат: DD-MM-YYYY)"},"onlyNumber":{"regex":"/^[0-9\ ]+$/","alertText":"В этом поле допустимы только цифры"},"noSpecialCaracters":{"regex":"/^[0-9a-zA-Zа-яА-Я]+$/","alertText":"В этом поле допустимы только цифры и буквы"},"onlyLetter":{"regex":"/^[a-zA-Zа-яА-Я\-\–\.\,\ \']+$/","alertText":"В этом поле допустимы только буквы"}}
settings = jQuery.extend({	allrules:allRules,success : false,failure : function() {}}, settings);$("form").bind("submit", function(caller){if(submitValidation(this) == false){if (settings.success){settings.success && settings.success(); return false;}}else{settings.failure && settings.failure(); return false;}});$(this).not("[type=checkbox]").bind("blur", function(caller){loadValidation(this)});$(this+"[type=checkbox]").bind("click", function(caller){loadValidation(this)});var buildPrompt = function(caller,promptText) {var divFormError = document.createElement('div');var formErrorContent = document.createElement('div');var arrow = document.createElement('div');$(divFormError).addClass("formError");$(divFormError).addClass($(caller).attr("name"));$(formErrorContent).addClass("formErrorContent");$(arrow).addClass("formErrorArrow");$("body").append(divFormError);$(divFormError).append(arrow);$(divFormError).append(formErrorContent);$(arrow).html('<div class="line10"></div><div class="line9"></div><div class="line8"></div><div class="line7"></div><div class="line6"></div><div class="line5"></div><div class="line4"></div><div class="line3"></div><div class="line2"></div><div class="line1"></div>');$(formErrorContent).html(promptText);callerTopPosition = $(caller).offset().top;callerleftPosition = $(caller).offset().left;callerWidth =  $(caller).width();callerHeight =  $(caller).height();inputHeight = $(divFormError).height();if (callerWidth > 250) callerleftPosition = callerleftPosition + callerWidth -214; else callerleftPosition = callerleftPosition - 20;callerTopPosition = callerTopPosition  -inputHeight -8;$(divFormError).css({top:callerTopPosition,left:callerleftPosition,opacity:0});/* добавлено убирание предупреждения */$(divFormError).fadeTo(200,1).delay(2000).fadeTo(200,0,function(){$(this).remove();})};var updatePromptText = function(caller,promptText) {updateThisPrompt =  $(caller).attr("name");$("."+updateThisPrompt).find(".formErrorContent").html(promptText);callerTopPosition  = $(caller).offset().top;inputHeight = $("."+updateThisPrompt).height();callerTopPosition = callerTopPosition  -inputHeight -10;$("."+updateThisPrompt).animate({top:callerTopPosition});};var loadValidation = function(caller) {rulesParsing = $(caller).attr('class');rulesRegExp = /\[(.*)\]/;getRules = rulesRegExp.exec(rulesParsing);str = getRules[1];pattern = /\W+/;result= str.split(pattern);	var validateCalll = validateCall(caller,result);return validateCalll;};var validateCall = function(caller,rules) {var promptText ="";var prompt = $(caller).attr("name");var caller = caller;isError = false;callerType = $(caller).attr("type");for (i=0; i<rules.length;i++){switch (rules[i]){case "optional": if(!$(caller).val()){closePrompt(caller);return isError;}break;case "required": _required(caller,rules);break;case "custom": _customRegex(caller,rules,i);break;case "length": _length(caller,rules,i);break;case "minCheckbox": _minCheckbox(caller,rules,i);break;case "confirm": _confirm(caller,rules,i);break;default :;};};if (isError == true){if($("input[name="+prompt+"]").size()> 1 && callerType == "radio") {caller = $("input[name="+prompt+"]:first")}($("."+prompt).size() ==0) ? buildPrompt(caller,promptText)	: updatePromptText(caller,promptText)}else{closePrompt(caller)}function _required(caller,rules){callerType = $(caller).attr("type");if (callerType == "text" || callerType == "password" || callerType == "textarea"){if(!$(caller).val()){isError = true;promptText += settings.allrules[rules[i]].alertText+"<br />"}	}if (callerType == "radio" || callerType == "checkbox" ){callerName = $(caller).attr("name");if($("input[name="+callerName+"]:checked").size() == 0) {isError = true;if($("input[name="+callerName+"]").size() ==1) {promptText += settings.allrules[rules[i]].alertTextCheckboxe+"<br />";}else{promptText += settings.allrules[rules[i]].alertTextCheckboxMultiple+"<br />";}}}if (callerType == "select-one") {callerName = $(caller).attr("name");if(!$("select[name="+callerName+"]").val()) {isError = true;promptText += settings.allrules[rules[i]].alertText+"<br />";}}if (callerType == "select-multiple") {callerName = $(caller).attr("id");if(!$("#"+callerName).val()) {isError = true;promptText += settings.allrules[rules[i]].alertText+"<br />";}}}function _customRegex(caller,rules,position){customRule = rules[position+1];pattern = eval(settings.allrules[customRule].regex);if(!pattern.test($(caller).attr('value'))){isError = true;promptText += settings.allrules[customRule].alertText+"<br />";}}function _confirm(caller,rules,position){confirmField = rules[position+1];if($(caller).attr('value') != $("#"+confirmField).attr('value')){isError = true;promptText += settings.allrules["confirm"].alertText+"<br />";}}function _length(caller,rules,position){startLength = eval(rules[position+1]);endLength = eval(rules[position+2]);feildLength = $(caller).attr('value').length;if(feildLength<startLength || feildLength>endLength){isError = true;promptText += settings.allrules["length"].alertText+startLength+settings.allrules["length"].alertText2+endLength+settings.allrules["length"].alertText3+"<br />";}}function _minCheckbox(caller,rules,position){nbCheck = eval(rules[position+1]);groupname = $(caller).attr("name");groupSize = $("input[name="+groupname+"]:checked").size();if(groupSize > nbCheck){isError = true;promptText += settings.allrules["minCheckbox"].alertText+"<br />";}}return(isError) ? isError : false;};var closePrompt = function(caller) {closingPrompt = $(caller).attr("name");$("."+closingPrompt).fadeTo("fast",0,function(){$("."+closingPrompt).remove();});};var submitValidation = function(caller) {var stopForm = false;$(caller).find(".formError").remove();var toValidateSize = $(caller).find("[class^=validate]").size();$(caller).find("[class^=validate]").each(function(){var validationPass = loadValidation(this);return(validationPass) ? stopForm = true : "";});if(stopForm){destination = $(".formError:first").offset().top;$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100);return true;}else{return false;}};};

/*
* Slimbox v2.02 - The ultimate lightweight Lightbox clone for jQuery
* (c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
*/
(function(w){var E=w(window),u,g,F=-1,o,x,D,v,y,L,s,n=!window.XMLHttpRequest,e=window.opera&&(document.compatMode=="CSS1Compat")&&(w.browser.version>=9.3),m=document.documentElement,l={},t=new Image(),J=new Image(),H,a,h,q,I,d,G,c,A,K;w(function(){w("body").append(w([H=w('<div id="lbOverlay" />')[0],a=w('<div id="lbCenter" />')[0],G=w('<div id="lbBottomContainer" />')[0]]).css("display","none"));h=w('<div id="lbImage" />').appendTo(a).append(q=w('<div style="position: relative;" />').append([I=w('<a id="lbPrevLink" href="#" />').click(B)[0],d=w('<a id="lbNextLink" href="#" />').click(f)[0]])[0])[0];c=w('<div id="lbBottom" />').appendTo(G).append([w('<a id="lbCloseLink" href="#" />').add(H).click(C)[0],A=w('<div id="lbCaption" />')[0],K=w('<div id="lbNumber" />')[0],w('<div style="clear: both;" />')[0]])[0]});w.slimbox=function(O,N,M){u=w.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Изображение {x} из {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},M);if(typeof O=="string"){O=[[O,N]];N=0}y=E.scrollTop()+((e?m.clientHeight:E.height())/2);L=u.initialWidth;s=u.initialHeight;w(a).css({top:Math.max(0,y-(s/2)),width:L,height:s,marginLeft:-L/2}).show();v=n||(H.currentStyle&&(H.currentStyle.position!="fixed"));if(v){H.style.position="absolute"}w(H).css("opacity",u.overlayOpacity).fadeIn(u.overlayFadeDuration);z();k(1);g=O;u.loop=u.loop&&(g.length>1);return b(N)};w.fn.slimbox=function(M,P,O){P=P||function(Q){return[Q.href,Q.title]};O=O||function(){return true};var N=this;return N.unbind("click").click(function(){var S=this,U=0,T,Q=0,R;T=w.grep(N,function(W,V){return O.call(S,W,V)});for(R=T.length;Q<R;++Q){if(T[Q]==S){U=Q}T[Q]=P(T[Q],Q)}return w.slimbox(T,U,M)})};function z(){var N=E.scrollLeft(),M=e?m.clientWidth:E.width();w([a,G]).css("left",N+(M/2));if(v){w(H).css({left:N,top:E.scrollTop(),width:M,height:E.height()})}}function k(M){w("object").add(n?"select":"embed").each(function(O,P){if(M){w.data(P,"slimbox",P.style.visibility)}P.style.visibility=M?"hidden":w.data(P,"slimbox")});var N=M?"bind":"unbind";E[N]("scroll resize",z);w(document)[N]("keydown",p)}function p(O){var N=O.keyCode,M=w.inArray;return(M(N,u.closeKeys)>=0)?C():(M(N,u.nextKeys)>=0)?f():(M(N,u.previousKeys)>=0)?B():false}function B(){return b(x)}function f(){return b(D)}function b(M){if(M>=0){F=M;o=g[F][0];x=(F||(u.loop?g.length:0))-1;D=((F+1)%g.length)||(u.loop?0:-1);r();a.className="lbLoading";l=new Image();l.onload=j;l.src=o}return false}function j(){a.className="";w(h).css({backgroundImage:"url("+o+")",visibility:"hidden",display:""});w(q).width(l.width);w([q,I,d]).height(l.height);w(A).html(g[F][1]||"");w(K).html((((g.length>1)&&u.counterText)||"").replace(/{x}/,F+1).replace(/{y}/,g.length));if(x>=0){t.src=g[x][0]}if(D>=0){J.src=g[D][0]}L=h.offsetWidth;s=h.offsetHeight;var M=Math.max(0,y-(s/2));if(a.offsetHeight!=s){w(a).animate({height:s,top:M},u.resizeDuration,u.resizeEasing)}if(a.offsetWidth!=L){w(a).animate({width:L,marginLeft:-L/2},u.resizeDuration,u.resizeEasing)}w(a).queue(function(){w(G).css({width:L,top:M+s,marginLeft:-L/2,visibility:"hidden",display:""});w(h).css({display:"none",visibility:"",opacity:""}).fadeIn(u.imageFadeDuration,i)})}function i(){if(x>=0){w(I).show()}if(D>=0){w(d).show()}w(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},u.captionAnimationDuration);G.style.visibility=""}function r(){l.onload=null;l.src=t.src=J.src=o;w([a,h,c]).stop(true);w([I,d,h,G]).hide()}function C(){if(F>=0){r();F=x=D=-1;w(a).hide();w(H).stop().fadeOut(u.overlayFadeDuration,k)}return false}})(jQuery);

/*
Nikolay Gromov
Author URI: http://nicothin.ru
*/
$(document).ready(function() {

// валидатор форм
$("[class^=validate]").validationEngine({
	success :  false,
	failure : function() {}
})

// работа инпута формы для поиска
$("#s").bind("focus",function(){
	if ($(this).val() == "Поиск...") $(this).val("");
}).bind("blur",function(){
	if($(this).val() == "") $(this).val("Поиск...");
});

// вся плавная прокрутка 
$("div.pane").scrollTo( 0 );
//$.scrollTo( 0 );
$(function( $ ){
	$('#footer .on-top, .post-comment-add a, a.reply, .comment-body a[href*="#comment-"], a.local-link, .ogl a').click(function(){
		$.scrollTo( this.hash, 700);
		return false;
	});
});

 // бумажка для RSS-подписки
$("#aside p.trinfo-rss-subscribe").addClass("js-rss").children().filter("a").wrapInner('<span class="hide"></span>').append('<span class="rss-hover"></span>');

//  добавление иконок в «цветные» параграфы
$("p.red1, p.green1, p.blue1, p.yellow1").addClass("js-padding").prepend('<span class="addicon"></span>');

// визитка в футере
var cardBlock = $("#footer .fastcontact");
$(cardBlock).addClass("js-cart");
$("big a" , cardBlock).addClass("vizitko").wrapInner('<span class="hide"></span>');
$("big a span.hide" , cardBlock).after('<span class="f-all-cont"></span><span class="f-shadow"></span>');
$("big a" , cardBlock).bind("mouseover",function(){
	$("big a span.f-all-cont" , cardBlock).hide();
	$(this).stop().animate({ backgroundPosition: '(0 -113px)' },400);
}).bind("mouseout",function(){
	$(this).stop().animate({ backgroundPosition: '(0 -153px)' },800,function(){$("big a span.f-all-cont" , cardBlock).show();});
});


// анимация цветов
// картинка, которая является ссылкой и кнопки демок и скачиваний — синька
$("#supwrap a img").css({backgroundColor: "#fff"}).bind("mouseover",function(){
	$(this).stop(); $(this).animate({ backgroundColor: "#009ec6" }, 100);
}).bind("mouseout",function(){
	$(this).stop(); $(this).animate({ backgroundColor: "#fff" }, 300);
});
// элементы форм — постепенное отбеливание
$("textarea, input[type='text'], input[type='password'], select").not("#s").css({backgroundColor: "#f7f7f7"}).bind("focus",function(){
	$(this).stop(); $(this).animate({ backgroundColor: "#fff" }, 200);
}).bind("blur",function(){
	$(this).stop(); $(this).animate({ backgroundColor: "#f7f7f7" }, 300);
});

// интерактивность формы комментариев
$("#comments_reg_2").parent().children("p.subinput-descr").hide().parent().next().hide().next().hide();
$("#comments_reg_2").bind("focus",function(){
	$(this).parent().children("p.subinput-descr").slideDown("fast").parent().next().slideDown("fast").next().slideDown("fast").prev().prev().prev().slideUp("fast").prev().children("p.subinput-descr").slideUp("fast");
});
$("#comments_reg_1").bind("focus",function(){
	$("#comments_reg_2").parent().children("p.subinput-descr").slideUp("fast").parent().next().slideUp("fast").next().slideUp("fast").prev().prev().prev().slideDown("fast").prev().children("p.subinput-descr").slideDown("fast");
});

// ответить на коммент
$("a.reply").click(function(){
	var auth = $(this).parents("li.comment").find("big");
	var commid = $(this).parents("li.comment").attr("id");
	$("textarea[name=comments_content]").append("&lt;a href=&quot;#" + commid + "&quot;&gt;@ " + $(auth).text() + ":&lt;/a&gt; \n").focus();
});


// интерактивность форм Технического задания
$("#site-lang, #adress-site, #hosting-site, #site-home-str, #site-gallery-str, #site-catalog-str, #site-portfolio-str").parent().hide();
$("#site-langsel").change( function() {
	if (($(this).val()) == "Другие") { $("#site-lang").parent().fadeIn(400).children("textarea").focus(); } 
	else { $("#site-lang").parent().slideUp("fast"); }
});
$("#site-home, #site-gallery, #site-catalog, #site-portfolio").parent().bind("change click" , function() {
	if($(this).children('input:checkbox').is(':checked')) {
		$(this).next().fadeIn(400).children("textarea").focus();
	} else {
		$(this).next().slideUp("fast");
	}
});
$("#adress-q-1").bind("focus click",function(){$("#adress-site").parent().fadeIn(400).children("input").focus();});
$("#adress-q-2").bind("focus click",function(){$("#adress-site").parent().slideUp("fast");});
$("#hosting-q-1").bind("focus click",function(){$("#hosting-site").parent().fadeIn(400).children("input").focus();});
$("#hosting-q-2").bind("focus click",function(){$("#hosting-site").parent().slideUp("fast");});
if ( !($('#crossbr-ie8').is(':checked')) || !($('#crossbr-ie7').is(':checked')) || !($('#crossbr-ie6').is(':checked')) || !($('#crossbr-ff').is(':checked')) || !($('#crossbr-op').is(':checked')) || !($('#crossbr-sfr').is(':checked')) || !($('#crossbr-chr').is(':checked')) ) {
	$('#crossbr-ie8').parent().children(":checkbox").attr("checked","checked");
	$('#crossbr-ie6').removeAttr("checked");
}


// навигация в портфолио 
// сначала добавляем саму навигацию
var portsize = $("#portfolio div.my-work").size();
var pagination = '<ul id="portfolio-pagination">\n<li id="tuda">&larr;</li>\n';
for (var i = 1; i <= portsize; i++) { var pagination = pagination + '<li id="site-' + i + '">' + i + '</li>\n'; }
var pagination = pagination + '<li id="suda">&rarr;</li>\n</ul>';
if ( $(document).width() > 1110 ) { var pagination = pagination + '\n<span id="ex-tuda">&larr;</span><span id="ex-suda">&rarr;</span>';}
$("#portfolio").parent().addClass("js");
$("#supwrap.js").prepend(pagination);
$("#portfolio").after('<span class="local-link show-more">показать подробности</span>');
// потом формируем механизъм Иго роботы
$.scrollTo.defaults.axis = "x, y";
var $paneTarget = $("#portfolio");
var alllinks = $("#portfolio-pagination li, span#ex-tuda, span#ex-suda");
// ф-я передвижения портфолио и записи куки
function slideUp() 
{
	var tmp = $(alllinks).filter(".display").attr("id");
	var movelink = "#" + tmp + "t";
	$paneTarget.stop().scrollTo( movelink , 700 );
}
$(alllinks).filter(":eq(1)").addClass("display");
// клики на навигации портфолио
$(alllinks).click(function(){
	var ithemID = $(this).attr("id");
	if (ithemID == "tuda") {
		if ( $("#tuda").next().is(".display") ) {
			$(alllinks).filter(".display").removeClass();
			$(alllinks).filter("li").filter(":last").prev().addClass("display");
			slideUp();
		}
		else {
			$(alllinks).filter(".display").removeClass().prev().addClass("display"); 
			slideUp();
		}
	}
	else if (ithemID == "ex-tuda") {
		if ( $("#tuda").next().is(".display") ) {
			$(alllinks).filter(".display").removeClass();
			$(alllinks).filter("li").filter(":last").prev().addClass("display"); 
			slideUp();
		}
		else {
			$(alllinks).filter(".display").removeClass().prev().addClass("display");
			slideUp();
		}
	}
	else if (ithemID == "suda") {
		if ( $("#suda").prev().is(".display") ) {
			$(alllinks).filter(".display").removeClass();
			$(alllinks).filter("li").filter(":first").next().addClass("display"); 
			slideUp();
		}
		else { 
			$(alllinks).filter(".display").removeClass().next().addClass("display"); 
			slideUp();
		}
	}
	else if (ithemID == "ex-suda") {
		if ( $("#suda").prev().is(".display") ) {
			$(alllinks).filter(".display").removeClass();
			$(alllinks).filter("li").filter(":first").next().addClass("display"); 
			slideUp();
		}
		else {
			$(alllinks).filter(".display").removeClass().next().addClass("display"); 
			slideUp();
		}
	}
	else {
		$(alllinks).filter(".display").removeClass();
		$(this).addClass("display");
		slideUp();
	}
});

// показать подробности
$("#supwrap.js > span.show-more").toggle(
	function () {
		//$('#portfolio, .my-work p.hide, #portfolio-pagination, .show-more, .my-work a.hide:has(img)').stop();
		$("#portfolio-pagination, .show-more").hide();
		$("#portfolio").animate({ height: "42.6em" }, 400, 
			function () {
				$("#portfolio-pagination").css({ top: "43.7em" });
				$(".show-more").text("скрыть подробности").css({ top: "40.6em" });
				$(".my-work p.hide, #portfolio-pagination, .show-more, .my-work a.hide:has(img)").fadeIn(200);
			}
		);
		if ( $(window).height() < 760 ) { $.scrollTo( "#service" , 400 ); }
	},
	function () {
		//$('#portfolio, .my-work p.hide, #portfolio-pagination, .show-more, .my-work a.hide:has(img)').stop();
		$(".my-work p.hide, #portfolio-pagination, .show-more, .my-work a.hide:has(img)").hide(); 
		$("#portfolio").animate({ height: "30em" }, 400, 
			function () {
				$("#portfolio-pagination").css({ top: "31em" });
				$(".show-more").text("показать подробности").css({ top: "28em" });
				$("#portfolio-pagination, .show-more").fadeIn(200);
			} 
		);
		//if ( $(window).height() < 760 ) { $.scrollTo( "#wrap" , 400 ); }
		//$('#portfolio').stop();
	}
);


// исправление пролемы IE6 и IE7. безрукие мутанты писали эти браузеры
if (($.browser.msie) && ($.browser.version <= 7)) {
	$("#content pre").each(function () {
		if (this.scrollWidth > this.offsetWidth) {
			$(this).css({"paddingBottom" : "30px", "overflow-y" : "hidden"});
		}
	}); 
	$("input[type='submit'], #aside p a span.rss-hover").css({"cursor" : "pointer"});
	$('select').parent().children('label').css({ padding : '0 2% 0 0' });
};

// фотогалерея
//$('.gallery a:has(img)').attr("rel","lightbox-gal").removeAttr("title").wrap('<div class="gal-img"></div>');
//$('.gallery a img').attr("alt","Дон Хонг-Оай (Don Hong-Oai)").removeAttr("style");
$("a[rel^='lightbox']").slimbox({}, null, function(el) {
	return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
}); 

// слайды
var slideli=$('div.nicothin-slide > div');$(slideli).not(':eq(0)').hide();var ssize=$(slideli).size();var slidelist='<hr /><p class="slide-pagination float-parent"><span id="prev-slide">&larr;</span> ';for(var i=1;i<=ssize;i++){var slidelist=slidelist+'<span id="s'+i+'">'+i+'</span> '}var slidelist=slidelist+'<span id="next-slide">&rarr;</span></p>';$(slideli).parent().append(slidelist);function showslide(){var tmp=$(slide).filter(".display").attr("id");tmp.split();var tmp=tmp[1]-1;$(slideli).filter(':visible').hide();$(slideli).eq(tmp).show()}var slide=$('p.slide-pagination span');$(slide).filter(":eq(1)").addClass("display");$(slide).click(function(){var ithemID=$(this).attr("id");if(ithemID=="prev-slide"){if($("#prev-slide").next().is(".display")){$(slide).filter(".display").removeClass();$(slide).filter(":last").prev().addClass("display");showslide()}else{$(slide).filter(".display").removeClass().prev().addClass("display");showslide()}}else if(ithemID=="next-slide"){if($("#next-slide").prev().is(".display")){$(slide).filter(".display").removeClass();$(slide).filter(":first").next().addClass("display");showslide()}else{$(slide).filter(".display").removeClass().next().addClass("display");showslide()}}else{$(slide).filter(".display").removeClass();$(this).addClass("display");showslide()}});

// приколы и хохмы :)
// для раздела контактов
$("div.contact-with-the-brain").click(function(){
	alert("Дорогой пользователь!\nРазработка прямого контакта МОСК-в-МОСК пока не завершена…");
});
// для 404 ошибки
$("#page-404 div").click(function(){
	if ( $('#page-404 div.tell span').text() == 'Ошибочка вышла…' )
	{
		$('#page-404 div.head').animate({top: "-=20px"}, 500, 
			function(){
				$('#page-404 div.head').animate({top: "+=20px"}, 300, 
					function(){
						$('#page-404 div.tell span').remove();
						$('#page-404 div.tell').append('<span>Мне, правда, жаль</span>');
					} 
				);
			} 
		);
	}
	else if ( $('#page-404 div.tell span').text() == 'Мне, правда, жаль' )
	{
		$('#page-404 div.tell span').remove();
		$('#page-404 div.tell').append('<span>Прекрати</span>');
		$('#page-404 div.head').animate({top: "-=50px"}, 500 );
		$('#page-404 div.tell').animate({left: "+=30px", top: "-=20px"}, 500 );
	}
	else if ( $('#page-404 div.tell span').text() == 'Прекрати' )
	{
		$('#page-404 div.tell span').remove();
		$('#page-404 div.tell').append('<span>Не доставай!</span>');
	}
	else if ( $('#page-404 div.tell span').text() == 'Не доставай!' )
	{
		$('#page-404 div.tell span').remove();
		$('#page-404 div.tell').append('<span>Все, оставь меня</span>');
		$('#page-404 div.head').animate({top: "+=50px"}, 500 );
		$('#page-404 div.tell').animate({left: "-=30px", top: "+=20px"}, 500, function(){location.href='http://nicothin.ru'; return false;} );
	}
}); 

});
