function yg_cmp_insurance_programms_over(id)
{
	
	
	for (var i = 1; i <=6; i++ ){
		
		if (i == id){
			var menu_link = document.getElementById('insurance_programms_list_' + id);
			if (!menu_link.className.match(/\yg_cmp_insurance_programms_list_select\b/)){
				menu_link.className += " yg_cmp_insurance_programms_list_select";
			}
			
		}else{
			var menu_link = document.getElementById('insurance_programms_list_' + i);
			regExpStr = 'yg_cmp_insurance_programms_list_select';
			menu_link.className = menu_link.className.replace(new RegExp(regExpStr), '');
		}
	}
}

function yg_cmp_insurance_programms_out(id)
{
	var menu_link = document.getElementById('insurance_programms_list_' + id);

	regExpStr = 'yg_cmp_insurance_programms_list_select';
	menu_link.className = menu_link.className.replace(new RegExp(regExpStr), '');

}


function region_show_block(id)
{
	var region_box = document.getElementById(id);
	
	if(region_box.style.display == 'none'){
		region_box.style.display = 'block';
	}else{
		region_box.style.display = 'none';		
	}
}

//4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 2.0.50727)
function detectie6(){
  var browser = navigator.appName;
  if (browser == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") ==-1){
    var b_version = navigator.appVersion;
    var re = /\MSIE\s+(\d\.\d\b)/;
    var res = b_version.match(re);
    if (res[1] <= 6){
      return true;
    }
  }
  return false;
}
function pop_ifrm (id_frame,id_pop) {
	if (detectie6()) {
	document.getElementById(id_frame).style.height = document.getElementById(id_pop).clientHeight+'px';
	}
}
function getClientHeight() { // получаем высоту браузера
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
function getClientWidth() { // получаем высоту браузера
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
var last_block_id = '';
function pop(id,act) {
	try {
	document.getElementById(id).style.textAlign = 'left'; // глюкофикс
	} catch(err){}
	// фикс по центру
	var width;
	width = 0 - document.getElementById(id).offsetWidth * 0.5;
	var math;
	math = getClientHeight() - document.getElementById(id).offsetHeight;
	var math_w;
	math_w = getClientWidth() - document.getElementById(id).offsetWidth;
	var height;
	var left;
	var top;
	if (math > 0 && math_w > 0 && detectie6()) { // для ие6-
		height = (getClientHeight() - document.getElementById(id).offsetHeight) / 2;
		left = (getClientWidth() - document.getElementById(id).offsetWidth ) / 2;
		document.getElementById(id).style.left = left;
		width = 0;
	}
	else {
		if (math > 0 && math_w > 0) { // для всех
			height =  0 - document.getElementById(id).offsetHeight * 0.5;
			document.getElementById(id).setAttribute("class", "ug_tmpl_def_popup");
			document.getElementById(id).style.top = '';
			document.getElementById(id).style.position = '';
			document.getElementById(id).style.left = '';
			document.getElementById(id).style.margin = '';
		}
		else {
			if (math_w > 0) { // если высота дива больше окна
				document.getElementById(id).setAttribute("class", "ug_tmpl_def_popup_over");
				document.getElementById(id).style.top = '10px';
				document.getElementById(id).style.position = 'absolute';
				document.getElementById(id).style.zIndex='900';
				left = (getClientWidth() - document.getElementById(id).offsetWidth ) / 2;
				left = Math.ceil(left);
				document.getElementById(id).style.left = left+"px";
				width = 0;
				height = 0;
			}
			else {
					document.getElementById(id).setAttribute("class", "ug_tmpl_def_popup_over");
					document.getElementById(id).style.top = '10px';
					document.getElementById(id).style.left = '10px';
					document.getElementById(id).style.position = 'absolute';
					document.getElementById(id).style.zIndex='900';
					height = 0;
					width = 0;
			}
		}
	}
	document.getElementById(id).style.margin = +height+'px 0 0 '+width+'px';

		// если еще раз вызвали функцию с этим id
		if (last_block_id == id && document.getElementById(id).style.visibility == 'visible') {
			document.getElementById(id).style.visibility='hidden';
		}
		else { // видимость вкл.
			document.getElementById(id).style.visibility='visible';
			//document.getElementById('yg_tmpl_main').style.position='relative';
			//document.getElementById('yg_tmpl_main').style.zIndex='1';
			document.getElementById('yg_tmpl_main_banner_left_col').setAttribute("class", "f_ie8");
			//document.getElementById('yg_tmpl_main').style.display='none';
			//document.getElementById('id_letter_div').style.display='none';
			
			//document.getElementById('yg_tmpl_main_banner_left_col').style.position='relative';
			//document.getElementById('yg_tmpl_main_banner_left_col').style.zIndex='1';
		}
		// видимость прошлого выкл.

	if (last_block_id != '' && last_block_id != id) {
		block_id = document.getElementById(last_block_id);
		if (block_id){
			block_id.style.visibility='hidden';
		}
	}
	last_block_id = id;
}
function pop_c(id) {
	document.getElementById(id).style.visibility='hidden';
}
function form_validate (form,fields,ques,popup) {
	var error_code = '<p>Неверно введены символы с картинки<br />Не заполнены следующие обязательные поля:</p><ul>';
	for (var i=0;i<fields.length;i++) {
		if (document.getElementsByName(fields[i])[0].value == '') {
			error_code += '<li>'+ques[i]+'</li>';
			var have_errors = true;
		}
	}
	if (have_errors) {
		error_code += '</ul>';
		document.getElementById('errors_'+form).innerHTML = error_code;
		pop(popup);pop(popup);
	} else {
		eval("document."+form+".submit();");
	}
}

