
var oLastOpendBlock = null;

function open_close(block_id){
	var oAdvantageBlock = document.getElementById(block_id);
	if ( oAdvantageBlock ) {
		cmnSwitch_class(oAdvantageBlock, 'opened', ' ');
		cmnSwitch_class(oAdvantageBlock, block_id, ' ');
		if( cmnMatch_class(oAdvantageBlock,block_id) ){
			oAdvantageBlock.style.marginBottom = oAdvantageBlock.getAttribute('influx');
		} else {
			oAdvantageBlock.style.marginBottom = '0px';
		}
		if ( window.oLastOpendBlock && window.oLastOpendBlock.getAttribute('id') != oAdvantageBlock.getAttribute('id')) {
			cmnRemove_class(window.oLastOpendBlock, 'opened')
			cmnRemove_class(window.oLastOpendBlock, oLastOpendBlock.getAttribute('id'))
			window.oLastOpendBlock.style.marginBottom = '0px';
		}
		window.oLastOpendBlock = oAdvantageBlock;
	}
}


var oAnchors = {
	quality:		'advantage_1',
	fastinternet:	'advantage_3',
	ecological:		'advantage_10',
	safety:			'advantage_11'
}

cmnAdd_event(window, 'load', function(){
	var sUrl = window.location.href;
	var anchor = sUrl.match(/#(.*)$/)
	if(anchor) open_close(oAnchors[anchor[1]]);
});

