var JSON=JSON||{};(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var host = location.host;
	var n1 = host.lastIndexOf(".");
	var n2 = host.substr(0,n1).lastIndexOf(".");
	if(n2 !== -1){
		host = host.substr(n2+1);
	}
	document.cookie = name+"="+value+expires+" ; path=/; domain=."+host;
}

function addClassName(o,cn,addifexists){
	if(o.className === undefined)
		return false;
	if(addifexists)
		o.className += " "+cn;
	else{
		var classes = o.className.replace(/\s{2,}/,'').split(" ");
		if(classes.inArray(cn) === false){
			classes.push(cn);
			o.className = classes.join(" ");
		}
	}
	return true;
};

function removeClassName(o,cn){
	if(o.className === undefined)
		return false;
	var nc = [];
	var classes = o.className.replace(/\s{2,}/,'').split(" ");
	for(var i=0;i<classes.length;i++){
		if(classes[i] != cn){
			nc.push(classes[i]);
		}
	}
	o.className = nc.join(" ");
	return true;
};

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


if (typeof document.all !== "undefined" && !window.opera)
    browser = 'IE'
else
    browser = 'MO'


function $(v) { return(document.getElementById(v)); };

function define(name,value){
    eval("self."+name+" = "+value+";");
}
Array.prototype.inArray = function(value){
    for(var i=0;i<this.length;i++){
		if(this[i] == value){
		    return i;
		}
    }
    return false;
}

function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}

window.onloadList = [];
window.onloadListLast = [];
window.onclickList = [];

window.addOnload = function(callback,last){
	if(last){
		window.onloadListLast.push(callback);
	}else{
		window.onloadList.push(callback);
	}
}
window.addOnclick = function(callback){
	window.onclickList.push(callback);
}
document.onclick = function(e){
	for(var i=0;i<window.onclickList.length;i++){
		window.onclickList[i](e);
	}
}

function add_option(select,option){
	try{
  		select.add(option,null); // standards compliant
  	}catch(ex){
  		select.add(option); // IE only
  	}
}



function set_select_list(xml_doc,obj,selected,havenull,dis){
    var main = xml_doc.getElementsByTagName("main")[0];
    if(main){
		var list = main.getElementsByTagName("field");
	}
    else{
    	main = xml_doc;
		var list = xml_doc.getElementsByTagName("field");
	}
	
    while(obj.options.length){
        obj.remove(0);
    }

    if(havenull){
		var option = document.createElement("OPTION");
		add_option(obj,option);
    }

	var sel = "";
    var selI = 0;
    var fsel = main.getAttribute("selected");
    if(fsel)
    	fsel = "E"+fsel;
    else
    	fsel = null;
    
    for(var i=0;i<list.length;i++){
        var option = document.createElement("option");
        option.text = list[i].getAttribute("name");
		//option.innerText = list[i].getAttribute("name");
        option.value = list[i].getAttribute("value");
		var id;
		if(id = list[i].getAttribute("id")){
			option.id = id;
		}
        add_option(obj,option);

		if(selected == option.value || fsel == option.value){
		    //option.selected = true;
		    selI = i;
		    sel = option.id;
		}
    }
    
    if(havenull)
    	selI++;
    var t;
    obj.selectedIndex = selI;
    
    if(!sel){
		if(list[0]){
		    sel = list[0].getAttribute("id");
		}
    }
    
    //obj.selected = sel;
    if(!dis)
		obj.disabled = false;
    return sel;
}

function AddToSelect(obj,text,value){
    var option = document.createElement("OPTION");
    option.text = text;
    option.value = value;
    obj.appendChild(option);
}

function DeleteFromSelect(obj,id){
    for(var i=0;i<obj.options.length;i++){
	if(obj.options[i].value == id){
	    obj.remove(i);
	}
    }
}

function SetSelected(obj,value){
    if(obj.options){
	for(var i=0;i<obj.options.length;i++){
	    if(obj.options[i].value == value){
		break;
	    }
	}
	if(i<obj.options.length){
	    obj.selectedIndex = i;
	    return true;
	}
    }
    return false;
}

function SetObjInfo(id,params,values){
    var obj = document.getElementById(id);
    if(!obj){
	alert(id);
	return;
    }
    for(var i=0;i<params.length;i++){
	if(values[i])
	    values[i] = values[i].replace(/'/g,"\\'"); // "
	eval("obj."+params[i]+" = '"+values[i]+"'");

    }
    if(obj.style.zIndex > zIndex){
	zIndex = obj.style.zIndex;
    }    
    obj._onmousedown = function(event){dragOBJ(this,event)};
    obj.altID = id;
}

function whichElement(e){
    var targ;
    if (!e){
	var e=window.event;
    }
    if (e.target){
	targ=e.target;
    }else if (e.srcElement){
	targ=e.srcElement;
    }
    if (targ.nodeType==3){
	targ = targ.parentNode;
    }
    if(targ._parent){
	targ = document.getElementById(targ._parent);
    }
    if(targ._onmousedown){
	targ._onmousedown(e);
    }
    if(targ.id == "AREA" && FreeClick){
	FreeClick();
    }
    if(targ.altType == 1){
	targ.blur();
	return false;
    }
    return targ;
}

function trim(text){
    if(browser == 'MO')
	text = text.replace(/\n/g,'');
    else
	text = text.replace(/\r\n/g,'');
    text = text.replace(/[ ]+/,' ');
    return text;
}

function GetPosition(obj){
    var o = obj;
    var res = [obj.offsetLeft,obj.offsetTop];
    while(o = o.offsetParent){
	res[0] += o.offsetLeft;
	res[1] += o.offsetTop;
    }
    return res;
}

function AddNewFile(n,SID,FID){
    var a = $('FileA'+SID+':'+FID+':'+n);
    a.style.display = "none";
    if(n == FILE_COUNT[SID+':'+FID]-2){
		var b = $('FileA'+SID+':'+FID+':'+(n+1));
		if(b){
		    //b.parentNode.removeChild(b);
		    b.style.display = 'none';
		}
    }
    $('FileTr'+SID+':'+FID+':'+(n+1)).style.display = "";
}

window.onresize = function(){
	var c;
	if(c = $('COVER')){
		c.style.height = Screen.getDocumentHeight();
		c.style.width = Screen.getDocumentWidth();
	}
	if(c = $('COVERDIV')){
		c.style.height = Screen.getDocumentHeight();
		c.style.width = Screen.getDocumentWidth();
	}
}

function SetValue(obj,value){
/*    if(browser == 'MO')
	obj.textContent = value;
    else
	obj.text = value;
    alert(1);*/
    obj.innerHTML = value;
}

function preloadMyAlert(){
	var list = [
		'/myrealtyam-img/bgimages/ok_btt.png',
		'http://img.myrealty.am/myrealtyam-img/'+LANG_NAME+'/yes_btt.png',
		'http://img.myrealty.am/myrealtyam-img/'+LANG_NAME+'/no_btt.png',
		'/myrealtyam-img/bgimages/not_l.png',
		'/myrealtyam-img/bgimages/not_r.png',
		'/myrealtyam-img/bgimages/add.gif',
		'/myrealtyam-img/bgimages/delete.gif',
		'/myrealtyam-img/bgimages/inform.gif',
		'/myrealtyam-img/bgimages/warning.gif',
		'/myrealtyam-img/bgimages/ok.gif'
	];
	for(var i=0;i<list.length;i++){
		var img = new Image();
		img.src = list[i];
	}
}



function myAlert(type,msg,callback1,callback2,img_name){
	this.timeout = null;
	var div;
	if(!(div=$('COVERDIV'))){
		div = document.createElement("div");
		div.id = "COVERDIV";
		div.style.zIndex = "100000";
		div.style.position="absolute";
		div.style.top = "0px";
		div.style.left = "0px";
		div.style.opacity = "0";
		div.style.filter = "alpha(opacity=0)";
		div.style.backgroundColor = "#000000";
		div.style.display = "none";
		var tbl = $('myAlertTable');
		if(tbl){
			document.body.removeChild(tbl);
		}
		document.body.appendChild(div);
	}else{
		//div.style.display = "";
	}
	if(browser == 'IE'){
		var selects = document.getElementsByTagName("select");
		for(var i=0;i<selects.length;i++){
			var sel = selects[i];
			sel.dis = sel.style.display.length?false:true;
			sel.style.display = "none";
		}
	}
	var innerHTML = "";
	innerHTML  = '<table border="0" cellspacing="0" cellpadding="0"><tr>';
    innerHTML += '<td width="18" height="100" rowspan="2" class="not_l">&nbsp;</td>';
    innerHTML += '<td width="53" height="100" rowspan="2" style="background-color:white;" class="not_img" ><img  class="not_img" src="/myrealtyam-img/bgimages/'+img_name+'.gif" /></td>';
    innerHTML += '<td width="258" height="70" valign="middle" class="not_rt" style="padding-right: 20px;"></td>';
    innerHTML += '</tr><tr>';
    innerHTML += '<td height="30" align="center" valign="middle" class="not_rb">';
    innerHTML += '<div></div>';
    innerHTML += '</td></tr></table>';
    div.innerHTML = innerHTML;
	var tbl = div.childNodes[0];
	tbl.id = "myAlertTable";
	tbl.style.position="absolute";
	tbl.style.width = "349px";
	tbl.style.height = "100px";
	
	var viewportheight = 0;
	
	if (typeof window.innerHeight != 'undefined'){
		viewportheight = window.innerHeight;
	}else if(
		typeof document.documentElement != 'undefined' && 
		typeof document.documentElement.clientHeight != 'undefined' && 
		document.documentElement.clientHeight != 0){
		
		viewportheight = document.documentElement.clientHeight;
		
	}else{
		viewportheight = document.body.clientHeight;
	}
	
	tbl.style.top = ((window.pageYOffset || document.documentElement.scrollTop)+viewportheight/2-intval(tbl.style.height)/2)+"px";
	tbl.style.left = (Screen.getDocumentWidth()/2-intval(tbl.style.width)/2)+"px";
	//tbl.style.backgroundColor = "white";
	
	var span = div.firstChild.firstChild.firstChild.childNodes[2];
    var img = div.firstChild.firstChild.firstChild.childNodes[1].firstChild;
    var buttdiv = div.firstChild.firstChild.childNodes[1].firstChild.firstChild;
	
	switch(type){
		case 1:
			var okButton = document.createElement("img");
			okButton.src = 'http://img.myrealty.am/myrealtyam-img/'+LANG_NAME+'/yes_btt.png',
			okButton.style.cursor = "pointer";
			if(callback1)
				okButton.onclick = function(){closeCover();callback1()};
			else
				okButton.onclick = closeCover;
			
			var closeButton = document.createElement("img");
			closeButton.src = 'http://img.myrealty.am/myrealtyam-img/'+LANG_NAME+'/no_btt.png',
			closeButton.style.cursor = "pointer";
			if(callback2)
				closeButton.onclick = function(){closeCover();callback2();};
			else
				closeButton.onclick = closeCover;
			
			buttdiv.appendChild(okButton);
			buttdiv.appendChild(closeButton);
						
			span.innerHTML = msg;
		break;
		default:
			var okButton = document.createElement("img");
			okButton.src = "/myrealtyam-img/bgimages/ok_btt.png";
			okButton.style.cursor = "pointer";
			if(callback1)
				okButton.onclick = function(){closeCover();callback1()};
			else
				okButton.onclick = closeCover;

			buttdiv.appendChild(okButton);
			span.innerHTML = msg;
		break;
	}
	
	//if(window.onscroll && window.scroll !== myScroll){
//		window.myOldScroll = window.onscroll;
	//}
	//window.onscroll = myScroll;
	//document.body.style.overflow = "hidden";
	div.style.height = Screen.getDocumentHeight()+"px";
	div.style.width = Screen.getDocumentWidth()+"px";
	document.body.appendChild(tbl);
	tbl.style.zIndex = div.style.zIndex+1;
	div.style.display = "";
	if(myAlert.timeout){
		clearTimeout(myAlert.timeout);
	}
	displayCover(1);
}

function displayCover(d){
	var div = $('COVERDIV');
	if(browser == 'MO'){
		var o = parseFloat(div.style.opacity);
		if((d == 1 && o < 0.5) || (d == -1 && o > 0)){
			o += d*0.05;
			o = Math.round(o*100)/100;
			o = o>0?o:0;
			
			div.style.opacity = o;
			myAlert.timeout = setTimeout("displayCover("+d+")",20);
		}else{
			if(d == -1){
				div.style.display = "none";
				var tbl = $('myAlertTable');
				//document.body.style.overflow = "auto";
				if(tbl){
					document.body.removeChild(tbl);
				}
			}
		}
	}else{
		var result = div.style.filter.match(/alpha\s*\([^\(]*opacity\s*\=(\d+)/);
		var o = intval(result[1]);
		if((d == 1 && o < 50) || (d == -1 && o > 0)){
			o+=d*10;
			div.style.filter = "alpha(opacity="+o+")";
			myAlert.timeout = setTimeout("displayCover("+d+")",20);
		} else{
			if(d == -1){
				div.style.display = "none";
				var selects = document.getElementsByTagName("select");
				for(var i=0;i<selects.length;i++){
					var sel = selects[i];
					if(sel.dis)
						sel.style.display = "";
				}
				var tbl = $('myAlertTable');
				//document.body.style.overflow = "auto";
				if(tbl){
					document.body.removeChild(tbl);
				}
			}
		}
	}
}

function closeCover(){
	var tbl = $('myAlertTable');
	if(tbl){
		document.body.removeChild(tbl);
	}
	if(window.myOldScroll){
		window.onscroll = document.body.myOldScroll;
	}else{
	//	alert(1);
		window.onscroll = null;
	}
	if(myAlert.timeout){
		clearTimeout(myAlert.timeout);
	}
	displayCover(-1);
}

function myScroll(e){
	if(window.myOldScroll){
		window.myOldScroll(e);
	}
	var tbl = $("myAlertTable");
	if(tbl){
		var top =  intval(tbl.style.top);
		var diff = document.body.scrollOldTop-document.body.scrollTop;
		document.body.scrollOldTop = document.body.scrollTop;
		top -= diff;
		tbl.style.top = top+"px";
	}
}

function intval(val){
	var res = parseInt(val);
	if(isNaN(res))
		return 0;
	return res;
}

function MoreInfo(RID,width,height){
    window.open("/info.php?RID="+RID,intval(Math.random()*10000000),"menubar=1,resizable=1,width="+(width+20)+",height="+(height+20));
}

function defined(o) {
	return (typeof(o)!="undefined");
};



var Screen = (function() {
	var screen = {};

	// Get a reference to the body
	// --------------------------------------------------------------------
	screen.getBody = function() {
		if (document.body) {
			return document.body;
		}
		if (document.getElementsByTagName) {
			var bodies = document.getElementsByTagName("BODY");
			if (bodies!=null && bodies.length>0) {
				return bodies[0];
			}
		}
		return null;
	};

	// Get the amount that the main document has scrolled from top
	// --------------------------------------------------------------------
	screen.getScrollTop = function() {
		if (document.documentElement && defined(document.documentElement.scrollTop) && document.documentElement.scrollTop>0) {
			return document.documentElement.scrollTop;
		}
		if (document.body && defined(document.body.scrollTop)) {
			return document.body.scrollTop;
		}
		return null;
	};
	
	// Get the amount that the main document has scrolled from left
	// --------------------------------------------------------------------
	screen.getScrollLeft = function() {
		if (document.documentElement && defined(document.documentElement.scrollLeft) && document.documentElement.scrollLeft>0) {
			return document.documentElement.scrollLeft;
		}
		if (document.body && defined(document.body.scrollLeft)) {
			return document.body.scrollLeft;
		}
		return null;
	};
	
	// Util function to default a bad number to 0
	// --------------------------------------------------------------------
	screen.zero = function(n) {
		return (!defined(n) || isNaN(n))?0:n;
	};

	// Get the width of the entire document
	// --------------------------------------------------------------------
	screen.getDocumentWidth = function() {
		var width = 0;
		var body = screen.getBody();
		if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
		    var rightMargin = parseInt(body.style.marginRight,10) || 0;
		    var leftMargin = parseInt(body.style.marginLeft, 10) || 0;
			width = Math.max(body.offsetWidth + leftMargin + rightMargin, document.documentElement.clientWidth);
		}
		else {
			width =  Math.max(body.clientWidth, body.scrollWidth);
		}
		if (isNaN(width) || width==0) {
			width = screen.zero(self.innerWidth);
		}
		return width;
	};
	
	// Get the height of the entire document
	// --------------------------------------------------------------------
	screen.getDocumentHeight = function() {
		var body = screen.getBody();
		var innerHeight = (defined(self.innerHeight)&&!isNaN(self.innerHeight))?self.innerHeight:0;
		if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
		    var topMargin = parseInt(body.style.marginTop,10) || 0;
		    var bottomMargin = parseInt(body.style.marginBottom, 10) || 0;
			return Math.max(body.offsetHeight + topMargin + bottomMargin, document.documentElement.clientHeight, document.documentElement.scrollHeight, screen.zero(self.innerHeight));
		}
		return Math.max(body.scrollHeight, body.clientHeight, screen.zero(self.innerHeight));
	};
	
	// Get the width of the viewport (viewable area) in the browser window
	// --------------------------------------------------------------------
	screen.getViewportWidth = function() {
		if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
			return document.documentElement.clientWidth;
		}
		else if (document.compatMode && document.body) {
			return document.body.clientWidth;
		}
		return screen.zero(self.innerWidth);
	};
	
	// Get the height of the viewport (viewable area) in the browser window
	// --------------------------------------------------------------------
	screen.getViewportHeight = function() {
		if (!window.opera && document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
			return document.documentElement.clientHeight;
		}
		else if (document.compatMode && !window.opera && document.body) {
			return document.body.clientHeight;
		}
		return screen.zero(self.innerHeight);
	};

	return screen;
})();var Sort = (function(){
	var sort = {};
	sort.AlphaNumeric = function(a,b) {
		if (a==b) { return 0; }
		if (a<b) { return -1; }
		return 1;
	};

	sort.Default = sort.AlphaNumeric;
	
	sort.NumericConversion = function(val) {
		if (typeof(val)!="number") {
			if (typeof(val)=="string") {
				val = parseFloat(val.replace(/,/g,''));
				if (isNaN(val) || val==null) { val=0; }
			}
			else {
				val = 0;
			}
		}
		return val;
	};
	
	sort.Numeric = function(a,b) {
		return sort.NumericConversion(a)-sort.NumericConversion(b);
	};

	sort.IgnoreCaseConversion = function(val) {
		if (val==null) { val=""; }
		return (""+val).toLowerCase();
	};

	sort.IgnoreCase = function(a,b) {
		return sort.AlphaNumeric(sort.IgnoreCaseConversion(a),sort.IgnoreCaseConversion(b));
	};

	sort.CurrencyConversion = function(val) {
		if (typeof(val)=="string") {
			val = val.replace(/^[^\d\.]/,'');
		}
		return sort.NumericConversion(val);
	};
	
	sort.Currency = function(a,b) {
		return sort.Numeric(sort.CurrencyConversion(a),sort.CurrencyConversion(b));
	};
	
	sort.DateConversion = function(val) {
		// inner util function to parse date formats
		function getdate(str) {
			// inner util function to convert 2-digit years to 4
			function fixYear(yr) {
				yr = +yr;
				if (yr<50) { yr += 2000; }
				else if (yr<100) { yr += 1900; }
				return yr;
			};
			var ret;
			// YYYY-MM-DD
			if (ret=str.match(/(\d{2,4})-(\d{1,2})-(\d{1,2})/)) {
				return (fixYear(ret[1])*10000) + (ret[2]*100) + (+ret[3]);
			}
			// MM/DD/YY[YY] or MM-DD-YY[YY]
			if (ret=str.match(/(\d{1,2})[\/-](\d{1,2})[\/-](\d{2,4})/)) {
				return (fixYear(ret[3])*10000) + (ret[1]*100) + (+ret[2]);
			}
			return 99999999; // So non-parsed dates will be last, not first
		};
		return getdate(val);
	};

	sort.Date = function(a,b) {
		return sort.Numeric(sort.DateConversion(a),sort.DateConversion(b));
	};

	return sort;
})();

if(!window.Root){
	window.addOnload(preloadMyAlert);
	
	window.focused = false;
	window.addOnload(
		function(event){
			document.onkeypress = function(e){
				var keynum;
				if(window.event){
	  				keynum = window.event.keyCode;
	  			}else if(e.which){
	  				keynum = e.which;
	  			}
	  			if(keynum == 13){
	  				if(window.focused && window.focused.form && window.focused.tagName == "INPUT"){
	  					var f = window.focused.form;
	  					for(var i=0;i<f.elements.length;i++){
	  						if(f.elements[i].tagName == "INPUT" && f.elements[i].type == "submit"){
	  							return;
	  						}
	  					}
	  					f.submit();
	  				}
	  			}
			}
			window.addOnclick(function(e){
					window.focused = whichElement(e);
				}
			)
		}
	);
}
 

var pageName = "MyRealy, Centrilized Online Real estate market"; 
var urlAddress = "http://www.myrealty.am/";
function addToFavorites_myrealty() { 
	if (window.sidebar) {window.sidebar.addPanel(pageName, urlAddress,"");} 
	else if (window.external) {window.external.AddFavorite(urlAddress,pageName) } 
	else 
	{myAlert(0,"Sorry! Your browser doesn't support this function.",null,null,'warning');} 
} 
 

function ShowLoader(type,status,cover,obj){
	var pos;
	var size;
	if(!Loader)
		return;
	switch(type){
		case 0:
			var obj = COVER;
			pos = [document.body.scrollLeft,document.body.scrollTop];
			size = [Screen.getDocumentWidth(),document.body.offsetHeight];
		case 1:
			if(!pos){
				pos = GetPosition(obj);
				size = [obj.offsetWidth,obj.offsetHeight];
			}
			if(status === 1){
				///alert(pos);
				//alert(size);
				Loader.style.left = pos[0];
				Loader.style.top = pos[1];
				Loader.style.height = size[1];
				Loader.style.width = size[0];
				Loader.style.zIndex = intval(obj.style.zIndex)+10000;
				Loader.style.display = '';
				$('LoaderChild').style.height = Loader.offsetHeight;
				$('LoaderChild').style.width = Loader.offsetWidth;
			}else{
				Loader.style.display = 'none';
			}
		break;
		case 2:
			if(!obj.style.display){
				pos = GetPosition(obj);
				Loader.style.left = obj.style.left;
				Loader.style.top = obj.style.top;
				Loader.style.height = obj.style.height;
				Loader.style.width = obj.style.width;
				Loader.style.zIndex = intval(obj.style.zIndex)+100000;
				$('LoaderChild').style.height = obj.style.height;
				$('LoaderChild').style.width = obj.style.width;
				Loader.style.display = '';
			}
		break;
		case 3:
			if(!obj.style.display){
				pos = GetPosition(obj);
				Loader.style.left = pos[0];
				Loader.style.top = pos[1];
				Loader.style.height = obj.style.height;
				Loader.style.width = obj.style.width;
				Loader.style.zIndex = intval(obj.style.zIndex)+10000;
				$('LoaderChild').style.height = obj.style.height;
				$('LoaderChild').style.width = obj.style.width;
				Loader.style.display = '';
			}
		break;
	}
}
function HideLoader(){
	if(Loader)
		Loader.style.display = 'none';
}
 

if(!document.getElementsByClassName){
	document.getElementsByClassName = function(searchClass,node,tag) {
	  var classElements = new Array();
	  if ( node == null )
	    node = document;
	  if ( tag == null )
	    tag = '*';
	  var els = node.getElementsByTagName(tag);
	  var elsLen = els.length;
	  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	  for (i = 0, j = 0; i < elsLen; i++) {
	    if ( pattern.test(els[i].className) ) {
	      classElements[j] = els[i];
	      j++;
	    }
	  }
	  return classElements;
	}
}
