﻿$(document).ready(function() {
	$('.helps-block .hd').click(function() {
		var tsel = $(this).next()
		opensel(tsel)
		return false
	});
	$('.show-list').click(function() {
		var elemtotal = $('.helps-block .hd').size()
		if(anim != true) {
			anim = true
			if($('.helps-block .h-sel').size() == elemtotal) {
				$('.helps-block .hd').removeClass('h-sel')
				$('.helps-block .hd').next().slideUp('400', function() {
					anim = false
					openall()
				});
			}
			else{
				$('.helps-block .hd').addClass('h-sel')
				$('.helps-block .hd').next().slideDown('400', function() {
					anim = false
					openall()
				});
			}
		}
		return false
	});
	$(".feedback .i-p").toggleVal({populateFrom: "title"});
	
	$(".lawer-all-i a").click(function(){
		var nid = $(this).parent().attr("class");
		$(".lawer-card:visible").fadeOut(500, function(){
			$("#"+nid).fadeIn(500);
			$(".lawer-all-i a.lctv").removeClass('lctv');
			$("."+nid).children('a').addClass('lctv');
		});
		return false;
	});
	
});

window.anim = false;

function opensel(tsel) {
	$t = tsel
	var elemtotal = $('.helps-block .hd').size()
	if(window.anim != true) {
		anim = true
		$t.prev().toggleClass('h-sel')
		$t.slideToggle('400', function() {
			anim = false
			openall()
		});
	}
}
function openall() {
	var elemtotal = $('.helps-block .hd').size()
	if($('.helps-block .h-sel').size() == elemtotal) {
		$('.show-list').addClass('all-list');
		$('.show-list span').html('Свернуть')
	}
	else{
		$('.show-list').removeClass('all-list');
		$('.show-list span').html('Развернуть')
	}
}
/* -------------------------------------------------- *
 * ToggleVal 2.1
 * Updated: 1/16/09
 * -------------------------------------------------- *
 * Author: Aaron Kuzemchak
 * URL: http://aaronkuzemchak.com/
 * Copyright: 2008-2009 Aaron Kuzemchak
 * License: MIT License
** -------------------------------------------------- */

;(function($){$.fn.toggleVal=function(theOptions){if(!theOptions||typeof(theOptions)=="object"){theOptions=$.extend({focusClass:"tv-focused",changedClass:"tv-changed",populateFrom:"default",text:null,removeLabels:false},theOptions);}
else if(typeof(theOptions)=="string"&&theOptions.toLowerCase()=="destroy"){var destroy=true;}
return this.each(function(){if(destroy){$(this).unbind("focus.toggleval").unbind("blur.toggleval").removeData("defText");return false;}
var defText="";switch(theOptions.populateFrom){case"title":defText=$(this).attr("title");$(this).val(defText);break;case"label":defText=$("label[for='"+$(this).attr("id")+"']").text();$(this).val(defText);break;case"custom":defText=theOptions.text;$(this).val(defText);break;default:defText=$(this).val();}
$(this).addClass("toggleval").data("defText",defText);if(theOptions.removeLabels==true){$("label[for='"+$(this).attr("id")+"']").remove();}
$(this).bind("focus.toggleval",function(){if($(this).val()==$(this).data("defText")){$(this).val("");}
$(this).addClass(theOptions.focusClass).removeClass(theOptions.changedClass);}).bind("blur.toggleval",function(){if($(this).val()==""){$(this).val($(this).data("defText"));}
$(this).removeClass(theOptions.focusClass);if($(this).val()!=$(this).data("defText")){$(this).addClass(theOptions.changedClass);}
else{$(this).removeClass(theOptions.changedClass);}});});};})(jQuery);

function startcount(){$('.frame-view .item').empty().html('<ul></ul>');for(i=0;i<=9;i++){$('.frame-view .item ul').append("<li class='n-"+i+"'><i></i></li>")};$('.item ul').not('.lst-count ul').cycle({timeout:0,cleartype:1,sync:true,speed:300,before:function(a,b,c){if(c.currSlide==c.slideCount-1){$(this).parent().parent().prev().find('ul').cycle('resume',true)}}});$(".item ul").not('.lst-count ul').each(function(k){var a=Math.round(Math.random()*(4)+4);$(this).cycle(a)});$('.frameview .lst-count ul').cycle({speed:200,cleartype:1,timeout:1000,startingSlide:Math.round(Math.random()*(4)+4),sync:true,before:function(a,b,c){if(c.currSlide==c.slideCount-1){$('.lst-count').prev().find('ul').cycle('resume',true)}}})};
