//Узнаем ширину и высоту страницы
function bodySize() {
if(document.width && document.height) {
	w=document.width;
	h=document.height;
}
if(document.body.scrollWidth && document.body.scrollHeight) {
	w=document.body.scrollWidth;
	h=document.body.scrollHeight;
}
if(document.body.style.pixelWidth && document.body.style.pixelHeight) {
	w=document.body.style.pixelWidth;
	h=document.body.style.pixelHeight;
}
  return {"w":w, "h":h};
}

function makezIndex() {
document.getElementById('box').style.zIndex='15';
document.getElementById('window_request').style.zIndex='16';
document.getElementById('placing').style.display='inline';
//document.getElementById('page_paper').style.zIndex='16';
}

function deletzIndex() {
document.getElementById('box').style.zIndex='-1';
document.getElementById('window_request').style.zIndex='-1';
//document.getElementById('page_paper').style.zIndex='-1';
}

//Проверка данных формы
function checkForm() {
var err = 0;
var arrpole = new Array("company", "fio", "post", "phone", "email", "text_report");

for(i=0; i<arrpole.length; i++) {
if (document.getElementById(arrpole[i]).value == '') {
    document.getElementById("texterr").innerHTML = "Вы заполнили не все поля";
    err = 1;
}
}
if (err == 0) document.getElementById("maledate").submit();
}

function clear_texterr() {
document.getElementById("texterr").innerHTML = '';
}

function clear_form() {
var arrpole = new Array("company", "fio", "post", "phone", "email", "text_report");

for(i=0; i<arrpole.length; i++) document.getElementById(arrpole[i]).value = '';
}

//Положение курсора мыши
function mouseXY(cursor)
{
  if (!cursor) cursor = window.event;

  var x = 0;
  var y = 0;
  if (cursor.pageX || cursor.pageY) {
    x = cursor.pageX;
    y = cursor.pageY;
  }
  else if (cursor.clientX || cursor.clientY) {
    x = cursor.clientX + document.body.scrollLeft;
    y = cursor.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }
  return {"x":x, "y":y};
}

//показываем фото
var fotoLargeCurrent = null;
var fotoLargeNew = null;
var fotoSmallCurrent = null;

function showFoto(id, event) {
var mouseCoord = mouseXY(event);
x=mouseCoord.x - 240;
y=mouseCoord.y-270;

fotoLargeNew = document.getElementById(id);
if(fotoLargeNew != fotoLargeCurrent) {
if(fotoLargeCurrent) {
fotoLargeCurrent.style.display = 'none';
}
if(fotoLargeNew) {
fotoLargeNew.style.left = x+"px";
fotoLargeNew.style.top = y+"px";
fotoLargeNew.style.display = 'block';
fotoLargeCurrent = fotoLargeNew;
}
}
}

function closeFoto(id) {
fotoLargeCurrent = document.getElementById(id);
fotoLargeCurrent.style.display = 'none';
fotoLargeNew.style.left = '0';
fotoLargeNew.style.top = '0';
fotoLargeCurrent = null;
}

function positionForm(id, dx, dy, event){
var mouseCoord = mouseXY(event);
x=mouseCoord.x;
y=mouseCoord.y;

obj = document.getElementById(id);
obj.style.left = "15px";
obj.style.top = y-dy+"px";
}

function positionFormClose(id) {
obj = document.getElementById(id);
obj.style.left = "0px";
obj.style.top = "0px";
}

function paper_list(id) {
document.getElementById(id).style.display="block";
}

function close_paper(id) {
document.getElementById(id).style.display="none";
}

function change_style(id, coll_menu) {
  for(i=0; i<coll_menu; i++) {
	document.getElementById('menu'+i).style.background="none";
  }
  document.getElementById('menu'+id).style.background="#0091DC";
}


/*min-width для ie*/
var d = document;
var winIE = (navigator.userAgent.indexOf('Opera')==-1 && (d.getElementById && d.documentElement.behaviorUrns)) ? true : false;

function bodySizeIE(){
    if(winIE && d.documentElement.clientWidth) {
    sObj = d.getElementsByTagName('body')[0].style;
    sObj.width = (d.documentElement.clientWidth<1003) ? '1003px' : '100%';
    }
}

function init(){
    if(winIE) { bodySizeIE(); }
}
onload = init;
if(winIE) { onresize = bodySizeIE;}



