function open_tab(id){
	var container = document.getElementById(id);
	if(container.style.display=="none"){
		container.style.display="block";
	}else{
		container.style.display="none";
	}
}

function taber(id,el){
    var element = document.getElementById(id);
    if(element.style.display=='none'){
       element.style.display='block';
       el.className = 'minus'; 
    }else{
       element.style.display='none'; 
       el.className = 'plus';    
    }
    return false;
}

function showTab(el){
	active_class = 'active_tab';
	$('#'+el).addClass(active_class);
	
	if(el == 'month'){
		$('#week').removeClass(active_class);
		$('.week_data').hide();
		$('.month_data').show();
		$('#month_data').show();
		$('#week_data').hide();
	}else{
		$('#month').removeClass(active_class);
		$('.week_data').show();
		$('.month_data').hide();
		$('#month_data').hide();
		$('#week_data').show();
	}
	
	return false;
}

function checkPollForm(){
	it = new Array;
	$('#pollForm').find('input').each(function(i){
		if(this.checked==true){
			it[it.length] = $(this).attr('rel');
		};
	});

	if(it.length > 0){
		var windowSize = getPageSize();
		if (windowSize){
			var scrW = windowSize[0];
			var scrH = windowSize[1];
		} else {
			var scrW = 0;
			var scrH = 0;
		}
	
		$('#pollButton').val('Подождите').attr('disabled',true);
		$.post(
			'/ajax/poll.vote.php',
			{
				answer: it, 
				other: encodeURIComponent($('#a_other').val()), 
				vk: $('#isvk').val(), 
				type: $('#polltype').val(),
				screenwidth: scrW,
				screenheight: scrH
			},
			function(data){
				$('#pollForm').html(data);
			}
		);
	}
	
	return false;
}



function  getPageSize(){

	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		   windowWidth = self.innerWidth;
		   windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		   windowWidth = document.documentElement.clientWidth;
		   windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		   windowWidth = document.body.clientWidth;
		   windowHeight = document.body.clientHeight;
	}

	return [windowWidth, windowHeight];
}

$(document).ready(function(){
	$('input.other').focus(function(){
		$('#a0').attr('checked', true);
	});

	$('input.other_big').focus(function(){
		$('#answer0').attr('checked', true);
	});
	
	$("input[rel='0']").click(function() {
		if($(this).attr('checked') == true){
			$('#a_other').focus();
		}
	});
});
