function switchForm( BlockName ){
	if( "sfProducts" == BlockName ){
		document.getElementById( "sfProducts" ).className = "visibility_on";
		document.getElementById( "sfInfo" ).className = "visibility_off";
		document.getElementById( "sfBG" ).className = "search_product_bg";
	}
	if( "sfInfo" == BlockName ){
		document.getElementById( "sfProducts" ).className = "visibility_off";
		document.getElementById( "sfInfo" ).className = "visibility_on";
		document.getElementById( "sfBG" ).className = "search_info_bg";
	}
	if( "sfMain" == BlockName ){
		document.getElementById( "sfMain" ).className = "visibility_on";
		document.getElementById( "sfInternet" ).className = "visibility_off";
	}
	if( "sfInternet" == BlockName ){
		document.getElementById( "sfInternet" ).className = "visibility_on";
		document.getElementById( "sfMain" ).className = "visibility_off";
	}
	if( "sfInternet_index" == BlockName ){
		document.getElementById( "sfInternet_index" ).className = "visibility_on";
		document.getElementById( "sfInternet_index_switcher" ).className = "switcher_on";
		document.getElementById( "sfUkraine_index" ).className = "visibility_off";
		document.getElementById( "sfUkraine_index_switcher" ).className = "switcher_off";
		document.getElementById( "sfMain_index" ).className = "visibility_off";
		document.getElementById( "sfSite_index_switcher" ).className = "switcher_off";
	}
	if( "sfUkraine_index" == BlockName ){
		document.getElementById( "sfInternet_index" ).className = "visibility_off";
		document.getElementById( "sfInternet_index_switcher" ).className = "switcher_off";
		document.getElementById( "sfUkraine_index" ).className = "visibility_on";
		document.getElementById( "sfUkraine_index_switcher" ).className = "switcher_on";
		document.getElementById( "sfMain_index" ).className = "visibility_off";
		document.getElementById( "sfSite_index_switcher" ).className = "switcher_off";
	}
	if( "sfMain_index" == BlockName ){
		document.getElementById( "sfInternet_index" ).className = "visibility_off";
		document.getElementById( "sfInternet_index_switcher" ).className = "switcher_off";
		document.getElementById( "sfUkraine_index" ).className = "visibility_off";
		document.getElementById( "sfUkraine_index_switcher" ).className = "switcher_off";
		document.getElementById( "sfMain_index" ).className = "visibility_on";
		document.getElementById( "sfSite_index_switcher" ).className = "switcher_on";
	}
}

function ChangeSearchInput( FieldName, Act ){
	if( "q" == FieldName ){
		if( "on" == Act ){
			document.getElementById( "sfInternet_index_input" ).value = "";
			document.getElementById( "sfInternet_index_input" ).className = "sfInternet_index_on";
		}
		if( "off" == Act ){
			if( "" == document.getElementById( "sfInternet_index_input" ).value ){
				document.getElementById( "sfInternet_index_input" ).value = "Введите запрос";
				document.getElementById( "sfInternet_index_input" ).className = "sfInternet_index_off";
			}
		}
	}
	if( "s_str" == FieldName ){
		if( "on" == Act ){
			document.getElementById( "sfMain_index_input" ).value = "";
			document.getElementById( "sfMain_index_input" ).className = "sfMain_index_on";
		}
		if( "off" == Act ){
			if( "" == document.getElementById( "sfMain_index_input" ).value ){
				document.getElementById( "sfMain_index_input" ).value = "Введите запрос";
				document.getElementById( "sfMain_index_input" ).className = "sfMain_index_off";
			}
		}
	}
}

function checkEmailFormat( objForm, fieldEmail ){
	var email = objForm.elements[fieldEmail].value;
	if( "" != email ){
//		emailTest = "^[_\\.0-9A-z-]+@([0-9A-z][0-9A-z_-]+\\.)+[A-z]{2,4}$";
		emailTest = "^[_\\.0-9A-z-]+@([0-9A-z_-]+\\.)+[A-z]{2,4}$";
		var regex = new RegExp( emailTest );
		if( !regex.test( email ) || !( email.length > 0 ) ){
			alert( "Поле \"Ваш e-mail\" заполнено некорректно!" );
			return false;
		}else{
			return true;
		}
	}else{
		alert( "Поле \"Ваш e-mail\" не заполнено!" );
		return false;
	}
}

function ShowMainFormComment(){
	document.getElementById( "divCommentForm" ).className = "visibility_on";
}
function ShowFormComment( id ){
	document.getElementById( "comment" + id ).className = "visibility_on";
}
function HideFormComment( id ){
	document.getElementById( "comment" + id ).className = "visibility_off";
}

function LoadMainImg( img, alt ){
	document.getElementById( "mainimg" ).innerHTML = '<img src="/images/i/loading400x300.gif" alt="' + alt + '" title="' + alt + '" width="400" height="300" border="0" style="border: 1px solid #cccccc">';
	document.getElementById( "mainimg" ).innerHTML = '<img src="/image/y/400/300/' + img + '" alt="' + alt + '" title="' + alt + '" width="400" height="300" border="0" style="border: 1px solid #cccccc">';
}

function ClearGeoState(){
	document.getElementById('div_geo_state').innerHTML = "<select name=\"state\"><option value=\"0\">загрузка...</select>";
}
function ClearGeoCity(){
	document.getElementById('div_geo_city').innerHTML = "<select name=\"city\"><option value=\"0\">загрузка...</select>";
}

function switchVisible( on, off ){
	document.getElementById( off ).className = "visibility_off";
	document.getElementById( on ).className = "visibility_on";
}

function viewMessageContent( obj ){
	var elements = document.getElementsByTagName( 'div' );
	for( var i = 0; i < elements.length; i++ ){
		if( 'message-note' == elements[i].className ){
			elements[i].style.display = 'none';
		}
	}
	document.getElementById( obj ).style.display = 'block';
}

function switchHeaderBlock( typeblock ){

	if( "articles" == typeblock ){
		document.getElementById('subArticles').innerHTML = '<a href="articles/" class="b" style="color: #ffffff">Статьи</a>';
		document.getElementById('subNews').innerHTML = '<span style="cursor: pointer" onClick="switchHeaderBlock(\'news\'); switchVisible( \'subNewsList\', \'subArticlesList\' )">Новости</span>';
	}else{
		document.getElementById('subArticles').innerHTML = '<span style="cursor: pointer" onClick="switchHeaderBlock(\'articles\'); switchVisible( \'subArticlesList\', \'subNewsList\' )">Статьи</span>';
		document.getElementById('subNews').innerHTML = '<a href="news/" class="b" style="color: #ffffff">Новости</a>';
	}

}

function ViewProductInfo( block ){

	if( 'info' == block ){

		document.getElementById('productinfo-switcher').innerHTML = 'Описание';
		document.getElementById('productparams-switcher').innerHTML = '<a href="javascript:ViewProductInfo(\'params\');" style="font-weight: normal">Характеристики</a>';
		document.getElementById('productinfo').style.display = 'block';
		document.getElementById('productparams').style.display = 'none';

	}
	
	if( 'params' == block ){
		
		document.getElementById('productinfo-switcher').innerHTML = '<a href="javascript:ViewProductInfo(\'info\');" style="font-weight: normal">Описание</a>';
		document.getElementById('productparams-switcher').innerHTML = 'Характеристики';
		document.getElementById('productinfo').style.display = 'none';
		document.getElementById('productparams').style.display = 'block';

	}

}


function jwfTabs( obj ){
	var elements = document.getElementsByTagName( 'div' );
	for( var i = 0; i < elements.length; i++ ){
		if( 'tab-on' == elements[i].className ){
			elements[i].className = 'tab-off';
		}
		if( 'tabcontent-on' == elements[i].className ){
			elements[i].className = 'tabcontent-off';
		}
	}
	document.getElementById( obj ).className = 'tab-on';
	document.getElementById( obj + 'content' ).className = 'tabcontent-on';
}

function ShowBlock( obj ){
	document.getElementById( obj + 'b' ).className = 'topmmenu-item-a';
	document.getElementById( obj ).style.display = 'block';
}
function ShowBlock2( obj ){
	document.getElementById( obj + 'b' ).className = 'topmmenu-item-a2';
	document.getElementById( obj ).style.display = 'block';
}
function ShowBlockOther( obj ){
	document.getElementById( obj + 'b' ).className = 'topmmenu-item';
}
function HideBlock( obj ){
	document.getElementById( obj ).style.display = 'none';
}
function HideAllBlocks(){
	var elements = document.getElementsByTagName( 'div' );
	for( var i = 0; i < elements.length; i++ ){
		if( 'submenu' == elements[i].className ){
			elements[i].style.display = 'none';
		}
		if( 'topmmenu-item-a' == elements[i].className || 'topmmenu-item-a2' == elements[i].className ){
			elements[i].style.className = 'topmmenu-item';
		}
	}
}

function ProductSizeOver( obj ){
	if( 'product-size-select-s' != obj.className ){
		obj.className = 'product-size-select-a';
	}
}
function ProductSizeOut( obj ){
	if( 'product-size-select-s' != obj.className ){
		obj.className = 'product-size-select';
	}
}
function ProductSizeClick( obj, id, size ){
	var elements = document.getElementsByTagName( 'div' );
	for( var i = 0; i < elements.length; i++ ){
		if( 'product-size-select-a' == elements[i].className || 'product-size-select-s' == elements[i].className ){
			elements[i].className = 'product-size-select';
		}
	}
	obj.className = 'product-size-select-s';
	document.getElementById( 'productbuybox' ).href = 'eshop/buybox.php?id=' + id + '&size=' + size;
}

function TopMenuPubSwitcher( block ){

	if( 'news' == block ){

		document.getElementById( 'topmenuarticles' ).style.display = 'none';
		document.getElementById( 'topmenunews' ).style.display = 'block';
	
	}

	if( 'articles' == block ){

		document.getElementById( 'topmenunews' ).style.display = 'none';
		document.getElementById( 'topmenuarticles' ).style.display = 'block';
	
	}

	return false;

}

function jwfDialog( obj, act ){
	if( "show" == act ){
		window.onscroll = function(){ document.getElementById( obj ).style.top = document.body.scrollTop; };
		document.getElementById( obj ).style.display = "block";
		document.getElementById( obj ).style.top = document.body.scrollTop;
	}
	if( "hide" == act ){
		document.getElementById( obj ).style.display = "none";
	}
}
