if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	window.onload = fnLoadPngs;
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt!=null && Number(rslt[1])>=5.0);
	var img = document.images;
	for (var i = img.length - 1; i>=0; i--) {
		if (itsAllGood && img[i].src.match(/\.png$/i)) {
			var src = img[i].src;
			img[i].style.width = img[i].width + "px";
			img[i].style.height = img[i].height + "px";
			img[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
			img[i].src = "images/1pix.gif";
		}
	}
}

function findXCoord(evt) {
	if (evt.pageX) 	return evt.pageX+30;
	return evt.x+30; 
}

function findYCoord(evt) {
	if (evt.pageY) return evt.pageY;
	return evt.y; 
}
 

function findScrollY() {
	if (window.scrollY) return window.scrollY;
	if (document.documentElement.scrollTop) return document.documentElement.scrollTop;
	return document.body.scrollTop;
}

function findWindowY() {
	if (window.innerHeight) return window.innerHeight;
    	if (document.documentElement.clientHeight) return document.documentElement.clientHeight;
	return document.body.offsetHeight;
}

function getBodyScrollTop()
 {
  yScroll = 0;

  if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX)
   {
    yScroll = window.innerHeight + window.scrollMaxY;
    xScroll = window.innerWidth + window.scrollMaxX;

    var deff = document.documentElement;
    var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
    var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;

    xScroll -= (window.innerWidth - wff);
    yScroll -= (window.innerHeight - hff);
   } 
  else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth)
   { // all but Explorer Mac
    yScroll = document.body.scrollHeight;
    xScroll = document.body.scrollWidth;
   } 
  else 
   { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    yScroll = document.body.offsetHeight;
    xScroll = document.body.offsetWidth;
   }

  return yScroll;
 }

function getDocumentHeight()
{
  var deff = document.documentElement;     
  var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
  return hff;
}

function hide_tovar_big_image(evt, artikul, visible, target) {
	document.getElementById(artikul).style.display='none';
}

function show_tovar_big_image(evt, artikul, visible, target){
	
	if(!evt) evt = window.event

	document.getElementById(artikul).style.display=visible;  
	var artikul = document.getElementById(artikul);
	artikul.style.left=findXCoord(evt)+'px'; 
	

	var minY = findScrollY();
	var maxY = minY + findWindowY();
    var currentY = findYCoord(evt);
	if( typeof window.scrollY == 'undefined') {
		  currentY +=minY;
	}
	var hPic = artikul.clientHeight;
    var maxPicY = currentY + hPic;

    if ( maxPicY > maxY )  {
		topPic = maxY - hPic;
		if (  topPic < minY )  {
			artikul.style.top=minY+'px';
		}else{
			artikul.style.top=topPic+'px';
		}
    }else{
      artikul.style.top=currentY+'px';
    }    
}

function change_news_gorod(id,mode,categ){
	
	if(mode==1){//start
		if(id=='-')
			window.location='index.php?gorod_id=-1'
		else
			window.location='index.php?gorod_id='+id
	}
	else{
		if(id=='-')
			window.location='index.php?p=newsarchive&categ='+categ+'&gorod_id=-1'
		else
			window.location='index.php?p=newsarchive&categ='+categ+'&gorod_id='+id
	}
}

function redirect_to_news(id){

		if(id=='-')
			window.location='index.php?p=newsarchive&categ=9&gorod_id=-1'
		else
			window.location='index.php?p=newsarchive&categ=9&gorod_id='+id
}


/*zakaz_form.php*/

function check_cform(){
	var ElId = 1234567890;

	if(apform.aname.value=="") {
		alert('Необходимо запольнить поле - "Фамилия, имя, отчество"');
		apform.aname.focus();
		return false;
		}
		if(apform.ada.value=="") {
		alert('Необходимо запольнить поле число дня рождения');
		apform.ada.focus();
		return false;
		}
		if(apform.apos.value=="") {
		alert('Необходимо запольнить поле "должность"');
		apform.apos.focus();
		return false;
		}
		if(apform.aaddress.value=="") {
		alert('Необходимо запольнить поле "Адрес проживания"');
		apform.aaddress.focus();
		return false;
		}
		if(apform.atel.value=="") {
		alert('Необходимо запольнить поле "Телефон"');
		apform.atel.focus();
		return false;
		}
		if(apform.aedu.value=="") {
		alert('Необходимо запольнить поле "Образование и специальность"');
		apform.aedu.focus();
		return false;
		}
		if(apform.anation.value=="") {
		alert('Необходимо запольнить поле "Гражданство"');
		apform.anation.focus();
		return false;
		}
		if(apform.asalary.value=="") {
		alert('Необходимо запольнить поле "Ожидаемый уровень заработной платы"');
		apform.asalary.focus();
		return false;
		}
 form1.submit();
}

/*magazinin - vibor goroda*/
function show_hide(id){
		if(document.getElementById)
			el = document.getElementById(id)
		else
			el = document.all[id]
			
		if(el.style.display=='none')
			el.style.display = 'block'
		else
			el.style.display = 'none'
}

function set_city(id,name){
	
	if(document.getElementById)
			e1 = document.getElementById('city')
		else
			e1 = document.all['city']
	
	if(document.getElementById)
			e2 = document.getElementById('city_span')
		else
			e2 = document.all['city_span']
	
	if(document.getElementById)
			e3 = document.getElementById('city_div')
		else
			e3 = document.all['city_div']
			
	e1.value=id
	e2.innerHTML = name 
	e3.style.display = 'none'
	
}