/**
 * @copyright Dvir.net.ua (c) 2004
 * @author Oleksiy Tymoshenko
 * @since 11.06.2005
 */

/**
 * to add this page to bookmarks
 */
function Add2Bookmarks()
{
	var url = self.location.href;
	var title = 'Мегет и партнеры: '+document.title;

	if (window.sidebar)
	{
		title = 'Мегет и партнеры - Продажа недвижимости';		//
		window.sidebar.addPanel(title, url, title);
	}
	else
	{
		window.external.AddFavorite( url, title);
	}
}


function setHome(ob) {
	 if(document.all)
	 {
		ob.style.behavior='url(#default#homepage)';
		ob.setHomePage(document.location);
	 }
}
function dspl(s)
{
	obj = document.getElementById(s);
	if(obj.style.display=='none')
		obj.style.display = 'block'
	else
		obj.style.display='none'
}
function axpst(url_, obj_, obj_res_n) 
{
    JsHttpRequest.query( url_, {'q': obj_},
      function(result, errors) {
		if(errors.length>0) {alert(errors);return false;}
		else document.getElementById(obj_res_n).innerHTML = result["out"];
      }, true
    );
}

function _reload_img(){
	var obj = document.getElementById('im');
	obj.src='/im.php?i='+Math.random();
}

// Helen NikitinA
function second_win(img_path,img_alt){
var str, StrBody;
	str = 'resizable=yes,width=189,height=176,screenX=200,screenY=100,left=100,top=100';
	if (document.all){
		StrBody = '<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="White" onblur="self.window.close();">';
	} else {
		StrBody = '<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="White" onblur="self.window.close();" >';
	}
	var win_op = window.open('','show', str);
	win_op.document.open();
	win_op.document.writeln('<html>');
	win_op.document.writeln('<head>');
	win_op.document.writeln('<title>' + img_alt + '</title>');
	win_op.document.writeln('<script>');
	win_op.document.writeln('function resize_img() {');
	win_op.document.writeln('var width = document.image.width;');
	win_op.document.writeln('var height = document.image.height;');
	win_op.document.writeln('if (!(document.all)){ self.resizeTo(width,height); } else { self.resizeTo((width+22),(height + 91));');
	win_op.document.writeln('self.resizeTo(width,height);');
	win_op.document.writeln(' }');
	win_op.document.writeln('}');
	win_op.document.writeln("</"+"script>");
	win_op.document.writeln("</"+"head>");
	win_op.document.writeln(StrBody);
	win_op.document.writeln('<img name="image" src='+ img_path + ' border=0 alt="'+img_alt+'" onload="resize_img();">');
	win_op.document.writeln("</"+"body>");
	win_op.document.writeln("</"+"html>");
	win_op.document.close();
}

function textCounter(field,counter,maxlimit,linecounter) 
{
    var fieldWidth = parseInt(field.offsetWidth);
    var charcnt = field.value.length;
    if (charcnt > maxlimit) 
    {
        field.value = field.value.substring(0, maxlimit);
    }
    else {
        var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
        document.getElementById(counter).style.width = parseInt((fieldWidth*percentage)/100)+"px";
        document.getElementById(counter).innerHTML=" "+percentage+"%"
        setcolor(document.getElementById(counter),percentage,"backgroundColor");
    }
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

function Browser()
{
   this.ver=navigator.appVersion;
   this.agent=navigator.userAgent;
   this.dom=document.getElementById?1:0;
   this.opera=window.opera?1:0;
   this.opera7=((this.agent.toLowerCase().indexOf('opera 7')>-1) ||(this.agent.toLowerCase().indexOf('opera/7')>-1))?1:0;
   this.firefox=(this.agent.toLowerCase().indexOf('firefox')>-1)?1:0;
   this.operaOld=this.opera&&!this.opera7;
   this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.operaOld)?1:0;
   this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.operaOld)?1:0;
   this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.operaOld)?1:0;
   this.ie4=(document.all && !this.dom &&!this.operaOld)?1:0;
   this.ie=this.ie4||this.ie5||this.ie6||this.ie7;
   this.mac=this.agent.indexOf("Mac")>-1;
   this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
   this.ns4=(document.layers && !this.dom)?1:0;
   this.bw=(this.ie7||this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.operaOld);
   return this;
}
bw=new Browser();

function shBrdr(obj, tp, cl)
{
	obj.style.border='1px ' + tp + ' ' + cl;	
	return;
}