function fixPNG(element,act){if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){var src;if (element.tagName=='IMG'){if (/\.png$/.test(element.src)){src = element.src;element.src = "/i/blank.gif";}}else{src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);if (src){src = src[1];element.runtimeStyle.backgroundImage="none";}}if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "'"+(act?",sizingMethod='scale'":'')+")";}}
function toggle(id){obj=document.getElementById(id).style;obj.display=(obj.display=='block')?'none':'block';}
function show(id){obj=document.getElementById(id);obj.style.display='block';document.cookie='menuc='+obj.style.display+'; path=/;'}
function hide(id){obj=document.getElementById(id);obj.style.display='none';document.cookie='menuc='+obj.style.display+'; path=/;'}
function ret(id){
	obj=document.getElementById(id);
	obj.style.top = '40px';
	obj.style.left = parseInt(screen.width*0.75);
	document.cookie='menu='+obj.style.top+'|'+obj.style.left+'; path=/;'
}
function showPic(src,name,w,h){width = screen.width;w+=40;height = screen.height;h+=40;if(name) h+=40;win=window.open('/?pic='+src+'&name='+name, 'cpic', 'width='+w+', height='+h+',left='+Math.round((width-w)/2)+',top='+Math.round((height-h)/2)+',resizable=no,scrollbars=no,status=no');win.focus();return false;}
function showContent(url){width = screen.width;height = screen.height;w=800;h=600;win=window.open(url+'?lite', 'ccont', 'width='+w+', height='+h+',left='+Math.round((width-w)/2)+',top='+Math.round((height-h)/2)+',resizable=yes,scrollbars=yes,status=no');win.focus();return false;}
function caclFormValidate(){
	var fields = new Array('credit_sum','period_num','interest_rate');
	var titles = new Array('Сумма кредита','Срок кредита','Годовая ставка');
	for(i=0;i<fields.length;i++)
		if(!parseFloat(CreditCalcForm.elements[fields[i]].value)){
			alert('Заполните поле "'+titles[i]+'" корректно!');
			return false;
		}
	document.CreditCalcForm.submit();
}
function showcomment(e,text){
	var posx=0,posy=0,dx=20,dy=20;
	if(e.pageX || e.pageY){posx=e.pageX; posy=e.pageY;}
	else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
	    posx=e.clientX+document.documentElement.scrollLeft;
	    posy=e.clientY+document.documentElement.scrollTop;
    }
    else{
      posx=e.clientX+document.body.scrollLeft;
      posy=e.clientY+document.body.scrollTop;
    }
  }
    
	document.getElementById('comm').style.left=posx+dx+"px";
	document.getElementById('comm').style.top=posy+dy+"px";
	if(!text) text = 'Добавить/удалить<br />сравнение квартир';
	document.getElementById('comm').innerHTML = text;
	document.getElementById('comm').style.display='block';
}
function outcomment(){document.getElementById('comm').style.display='none'; }

/********************************************************************/
function cmpFlat(obj) {
  JsHttpRequest.query(
    '/cmp.php',{
        'id':obj.value,
        'set':obj.checked/*,
        'sid':parseInt(Math.random()*10000)*/
    },
    function(result, errors) {
    	document.getElementById('pr'+obj.value).style.backgroundColor = (obj.checked?'#ffe8c5':'transparent');
    	document.getElementById('fcmp').innerHTML = result;
    },
    true
  );
}
function cmpReload(){JsHttpRequest.query('/cmp.php?reload',{},function(result, errors) {document.location.reload();},false);}
function add2fav(){
	JsHttpRequest.query(
    '/links/?ajax',{
        'url':escape(document.location),
        'title':escape(document.title)/*,
        'sid':parseInt(Math.random()*10000)*/
    },
    function(result, errors){if(result) document.getElementById('add2fav').src='/i/'+result+'.gif';},
    true
  );
}
function scrlTo(){if(document.location.toString().indexOf('#') == -1) window.scrollTo(0,430);}

function getUrlParam(key,url){
	var get = new String(url?url:window.location);
	x = get.indexOf('?');
	if(x == -1) return false;
	get = get.substr(x + 1, get.length - x);
	x = get.split('&');
	for(i in x){
		get = x[i].split('=');
		if(get[0] == key) return get[1];
	}
	return false;
}