/* author: AkimVital */
/* Creation date: 02.01.04 */

Array.prototype.serialize = function ()
{
	var postc = "a:"+this.length+":{";

	for (var i=0; i < this.length; i++) {
		switch (typeof(this[i])) {
			case 'number':
				postc = postc+"i:"+i+";i:"+this[i]+";";
				break;
			case 'string':
				postc = postc+"i:"+i+";s:"+this[i].length+":\""+this[i]+"\";";
				break;
			case 'object':
				try {
					postc = postc+"i:"+i+";"+this[i].serialize();
				} catch(err){}
				break;
			default:
				postc = postc+"i:"+i+";s:"+this[i].toString().length+":\""+this[i].toString()+"\";";
				break;
		}
	}

	return postc+"}";
};

window.getWidth = function ()
{
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		return window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		return document.body.clientWidth;
	}
};

window.getHeight = function ()
{
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		return window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		return document.body.clientHeight;
	}
};

document.elementWidth = function (obj)
{
	if( typeof( obj.innerWidth ) == 'number' ) {
		//Non-IE
		return obj.innerWidth;
	} else if( obj.clientWidth || obj.clientHeight ) {
		//IE 6+ in 'standards compliant mode'
		return obj.clientWidth;
	}
};

document.elementHeight = function (obj)
{
	if( typeof( obj.innerHeight ) == 'number' ) {
		//Non-IE
		return obj.innerHeight;
	} else if( obj.clientWidth || obj.clientHeight ) {
		//IE 6+ in 'standards compliant mode'
		return obj.clientHeight;
	}
};

document.getObject = function (name)
{
	obj = new Object;
	if (document.getElementById) {
		obj = document.getElementById(name);
	}
	else if (document.all) {
		obj = document.all[name];
	}
	else if (document.layers) {
		obj = getObjNN4(document,name);
		obj.style = obj;
	}
	return obj;
};

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

function bookmark()
{
    var title="Пошук житла та нерухомості GYTLO.com"
    var url="http://gytlo.com"

    if (window.sidebar) window.sidebar.addPanel(title, url,"");

    /*else if( window.opera && window.print )
    {
			var mbm = document.createElement('a');
			mbm.setAttribute('rel','sidebar');
			mbm.setAttribute('href',url);
			mbm.setAttribute('title',title);
			mbm.click();
			//window.external.AddBookmark(url, title);
    }*/

    else /*if( document.all )*/ window.external.AddFavorite(url, title);

}

function gHomePage(objSrc)
{
    var homepage = "http://gytlo.com";
    if (objSrc.style.behavior)
    {
        objSrc.setHomePage(homepage);
    }
    else if (netscape
              && netscape.security
              && netscape.security.PrivilegeManager
              && navigator.preference)
    {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
        navigator.preference("browser.startup.homepage", homepage);
    }
}