
var buildings = new Array();
buildings['building-production'] = [268, 199, 138, 102];
buildings['building-services'] = [226, 316, 117, 162];
buildings['building-distribution'] = [308, 258, 225, 188];
buildings['building-retail'] = [228, 174, 118, 90];
buildings['building-banks'] = [291, 183, 149, 94];

buildings['building-company'] = [192, 234, 101, 123];
buildings['building-hr'] = [177, 234, 93, 123];
buildings['building-standards'] = [338, 215, 172, 110];
buildings['building-hr-techlogies'] = [376, 256, 192, 132];
buildings['building-hr-audit'] = [192, 168, 99, 87];

buildings['building-top-management'] = [259, 165, 137, 87];
buildings['building-hr-programs'] = [259, 157, 137, 83];
buildings['building-library'] = [106, 208, 56, 110];
buildings['building-consulting'] = [274, 249, 140, 127];
buildings['building-contest'] = [326, 218, 167, 112];

buildings['textlogo'] = [208, 123];


var menulinks = new Array();
menulinks['production'] = "для производственных компаний";
menulinks['services'] = "для компаний в сфере оказания услуг";
menulinks['distribution'] = "для дистрибьюторских компаний";
menulinks['retail'] = "для компаний розничной торговли";
menulinks['banks'] = "для банковского сектора";

menulinks['company'] = "диагностика системы управления компанией";
menulinks['hr'] = "диагностика системы управления персоналом";
menulinks['standards'] = "стандартизация компаний";
menulinks['hr-techlogies'] = "технологии управления персоналом";
menulinks['hr-audit'] = "кадровый аудит";

menulinks['top-management'] = "стратегические сессии для топ-менеджмента";
menulinks['hr-programs'] = "программы по управлению персоналом";
menulinks['library'] = "материалы, статьи, словарь терминов";
menulinks['consulting'] = "консультационная поддержка и коучинг";
menulinks['contest'] = "наши клиенты и проекты";


var width = window.screen.width;
var height = window.screen.height;
var currentDimention = 800;
if(width >= 1024) currentDimention = 1024;

document.write( '<LINK REL="stylesheet" TITLE="'+currentDimention+'" TYPE="text/css" href="css/'+css+'_'+currentDimention+'.css"/>' );

function openMap() {
	window.open("bigmap.html", "bigmap", "width="+(width-20)+", height="+(height-75)+", toolbar=0, status=0, menubar=0, top=0, left=0, scrollbars=1");
}

function imgMap() {
	document.write( '<img src="img/1px.gif" class="map" usemap="#mainmap'+currentDimention+'" />' );
}

function isLinkCurrent(str) {
	currentUrl = location.href;
	if(str == "") return;
		
	currentUrl = currentUrl.replace(/.*\//g, "");
	str = str.replace(/.*\//g, "");
	
	if(currentUrl == str) {
		return true;
	} else return false;
}

function menuLink(str) {
	if(isLinkCurrent(str + ".html")) document.write( menulinks[str] );
	else document.write( '<a href="'+str+'.html" title="' + menulinks[str] + '">' + menulinks[str] + '</a>' );
}

function getBuildingImg(img) {
	imgWidth = buildings[img][0];
	imgHeight = buildings[img][1];
	
	if(currentDimention == 800) {
		imgWidth = buildings[img][2];
		imgHeight = buildings[img][3];
		img += "-small";
	}
	document.write( '<img src="img/'+img+'.gif" width="'+imgWidth+'" height="'+imgHeight+'" />' );
}

function getTextImg(img) {
	imgWidth = buildings[img][0];
	imgHeight = buildings[img][1];
	
	document.write( '<img src="img/'+img+'.jpg" width="'+imgWidth+'" height="'+imgHeight+'" />' );
}

var currentObj = "";
function showTitle(obj) {
	currentObj = obj;
	
	var divObj = document.getElementById("maptitle");
	divObj.style.left = event.offsetX;
	divObj.style.top = event.offsetY;
	divObj.style.visibility = 'visible';
	increaseDivSize(divObj);
	//divObj.innerHTML = obj.getAttribute("htitle");
}

function hideTitle() {
	var divObj = document.getElementById("maptitle");
	divObj.style.posWidth = 0;
	divObj.style.posHeight = 0;
	divObj.style.visibility = 'hidden';
}

function increaseDivSize() {
	var obj = document.getElementById("maptitle");
	alert(obj.style.posWidth);
	if(obj.style.posWidth <= 300) obj.style.posWidth += 10;
	if(obj.style.posHeight <= 45) obj.style.posHeight += 3;
	
	if(obj.style.posWidth == 300 && obj.style.posHeight == 45) {
		obj.innerHTML = currentObj.getAttribute("htitle");
		return;
	} else setTimeout("increaseDivSize();", 100);
}

$(document).ready(function() {
	
	$('form.request_form input[default]').focus(function() {
		if($(this).val() == $(this).attr('default')) 
			$(this).val('');
	});
	
	$('form.request_form input[default]').blur(function() {
		if(!$(this).val()) 
			$(this).val($(this).attr('default'));
	});
	
	$('form.request_form .answer_ok a').click(function() {
		obj = $(this).parents('table').eq(0);
		$('input, textarea', obj).each(function() {
			if($(this).attr('default') == undefined)
				$(this).val('');
			else
				$(this).val($(this).attr('default'));
		});
		$('td *', obj).show();
		$('.answer_ok', obj).hide();
	});

	$('form.request_form #submit').click(function() {
		submitRequest($(this));
	});
});

function submitRequest(currObj) {
	obj = currObj.parents('table').eq(0);
	
	$('form.request_form #submit').click(function() { return false; });
	
	$.post('php/post.php', { fio:$('.request_form #fio').val(), mail:$('.request_form #mail').val(), phone:$('.request_form #phone').val(), place:$('.request_form #place').val(), date:$('.request_form #date').val(), budget:$('.request_form #budget').val(), kolvo:$('.request_form #kolvo').val(), comment:$('.request_form #comment').val() }, function() {
		$('td *', obj).hide();
		$('.answer_ok, .answer_ok *', obj).show();
		
		$('form.request_form #submit').click(function() { submitRequest($(this)); });
	});
}
