$(function(){
	$('.search_check_tabs > li > a').css("cursor","pointer");
	$('h1').addClass('general_inform_header');
	$('.search_check_tabs > li > a').click(function(){
		//alert($('.check_input').attr('value'));
		$('.search_check_tabs > li > a').each(function(){
			current_class = $(this).attr("class")
			current		  = current_class.search("current");
			if(current != -1){
				$(this).removeClass(current_class);
				$(this).addClass(current_class.substring(0,(current-1)));
			}
		})
		
		var index = $(".search_check_tabs > li > a").index(this);
		attr = $(this).attr("class");
		is = attr.search("current");
		if(is == -1){
			$(this).removeClass(attr);
			$(this).addClass(attr+'_current');
				$('.content').children().hide();
				$('.content_second_level').eq(index).show();
		}
		$('.panel_control').show();
		$('.panel_control_collapsed').hide();
		$('.content_collapsed').hide();
		$('.content').show();
		$('.check').css("top","61px");
		$('.information').css("margin-top","10px");
//		$('.content_collapsed').hide();
//		$('.content').show();
//		if(open != "61px")
//			$('.information').css("margin-top","75px");
//		$('.check').css("top","61px");
		if(index == 6){
			$('.check_input').hide();
		}else{
			$('.check_input').show();
		}

	});
	
	$('.check').click(function(){
		$('.panel_control').show();
		$('.panel_control_collapsed').hide();
		$('.content_collapsed').hide();
		$('.content').show();
		$('.check').css("top","61px");
		$('.information').css("margin-top","10px");
//		$('.content_collapsed').hide();
//		$('.content').show();
//		open = $('.check').css("top");
//		if(open != "61px")
//		 $('.information').css("margin-top","75px");
//		$('.check').css("top","61px");
	});
	

	
	$('.panel_control_header1').click(function(){
		$('.panel_control').show();
		$('.panel_control_collapsed').hide();
		$('.content_collapsed').hide();
		$('.content').show();
		$('.check').css("top","61px");
		$('.information').css("margin-top","10px");
	})
	
	$('.panel_control_header2').click(function(){
		$('.panel_control_collapsed').show();
		$('.panel_control').hide();
		$('.content').hide();
		$('.content_collapsed').show();
		$('.check').css("top","41px");
		$('.information').css("margin-top","10px");

	})
	
	$('.content').children().hide();
	$('.content_second_level').eq(0).show();
//	$('.panel_control').hide();
//	$('.check').css("top","41px");
//	$('.content').hide();
	
	$('.search_check_tabs > li:last-child').click(function(){
		search_str = $('.check_input').val();
		var textarea_text = '';
		if($('.content :checkbox').filter(':checked"').size( )> 0)
		{
//			$('.check_input').val(search_str+".com");
			$('.content :checkbox').filter(':checked"').each(function(){
				textarea_text += search_str + '.' + $(this).val()+'\r\n';
			});
			//alert(textarea_text);
			$('#domain_text').val(textarea_text);
		}
	});
	
	$('.mySelect1').ready(function(){
		$.get('/external/cur.ru.xml', {  }, 
			function(data) { 
				var select = $('#mySelect1');
				var defval = select.val();
				$(data).find('menuitem').each(function(){
					var title = $(this).find('title').text();
					var value = $(this).find('value').text();
					if (value == defval) { select.append("<option value='" + value + "' selected>" + title + "</option>"); }
					else { select.append("<option value='" + value + "'>" + title + "</option>"); } 
				});
			});
	});   

	$('.mySelect2').ready(function(){
		$.get('/external/cur.ru.xml', {  }, 
			function(data) { 
				var select = $('#mySelect2');
				var defval = select.val();
				$(data).find('menuitem').each(function(){
					var title = $(this).find('title').text();
					var value = $(this).find('value').text();
					if (value == defval) { select.append("<option value='" + value + "' selected>" + title + "</option>"); }
					else { select.append("<option value='" + value + "'>" + title + "</option>"); } 
				});
			});
	});   

})

$(function() {
	$('span[title]').hovertip();
});
