if (!this.JSON)
{
    JSON = function ()
    {
        function f(n)
        {
            return n < 10 ? '0' + n : n;
        }
        
        Date.prototype.toJSON = function (key)
        {
            return this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z';
        };
        
        var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
            escapeable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
            meta = {    
                '\b': '\\b',
                '\t': '\\t',
                '\n': '\\n',
                '\f': '\\f',
                '\r': '\\r',
                '"' : '\\"',
                '\\': '\\\\'
            };
            
        function quote(string)
        {
			escapeable.lastIndex = 0;
            return escapeable.test(string) ?
                '"' + string.replace(escapeable, function (a){
                    var c = meta[a];
                    if (typeof c === 'string') {
                        return c;
                    }
                    return '\\u' + ('0000' +
                            (+(a.charCodeAt(0))).toString(16)).slice(-4);
                }) + '"' :
                '"' + string + '"';
        }

        function str(key, holder)
        {
			var i,          
                k,          
                v,          
                length,
                partial,
                value = holder[key];

			if (value && typeof value === 'object' && typeof value.toJSON === 'function')
			{
				value = value.toJSON.parse(key);
			}
			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';
					}
					partial = [];
					if (typeof value.length === 'number' && !(value.propertyIsEnumerable('length')))
					{
						length = value.length;
						for (i = 0; i < length; i += 1)
						{
							partial[i] = str(i, value) || 'null';
						}
						v = partial.length === 0 ? '[]' : '[' + partial.join(',') + ']';
						return v;
					}

					for (k in value)
					{
						if (Object.hasOwnProperty.call(value, k))
						{
							v = str(k, value);
							if (v)
							{
								partial.push(quote(k) + ':' + v);
							}
						}
					}

					v = partial.length === 0 ? '{}' : '{' + partial.join(',') + '}';
					return v;
			}
        }
		
		return	{
			stringify: function (value)
			{
				return str('', {'': value});
			},

			parse: function (text, nonSafe)
			{
				if(text==null)
					return null;
				var j;
				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(/\\["\\\/bfnrtu]/g, '@').
					replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
					replace(/(?:^|:|,)(?:\s*\[)+/g, '')))
				{
					return eval('(' + text + ')');
				}
				throw new SyntaxError('JSON.parse');
			}
		};
    }();
}

var handler=document.URL.substring(0, document.URL.lastIndexOf("/"))+"/Act.aspx";
function AjaxCall(params, callback, args)
{
	return XHR(handler, params, callback, args);
}

function AjaxReq()
{
	var req = null;
	if (window.XMLHttpRequest)
    {
	    req = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
    {
        req=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
	    alert("Tarayıcı AJAX desteklemiyor.");
	}
	return req;
}
	
function XHR(url, params, callback, args)
{
	var req = AjaxReq();
	req.open("POST", url, (callback)?true:false);
	if (typeof(params)!="string")
	{
		params=JSON.stringify(params);
		req.setRequestHeader("Content-type", "text/plain; charset=ISO-8859-9");
	}
	else
		req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.setRequestHeader("Content-length", params.length);
	req.setRequestHeader("Connection", "close");
	if (callback)
	{
		req.onreadystatechange = function()
		{
			if (req.readyState==4)
			{
				if (req.status==200)
				{
					callback(req.responseText, args);	
				}
				else
				    alert("Bir sorun oluştu. Olası nedenler:\r\n- Zaman aşımına uğradınız\r\n- Güncelleme yapılıyor\r\n- Sunucu bakıma girdi\r\n- ISP kaynaklı geçici bir erişim hatası\r\n\r\nSayfayı yenileyerek tekrar deneyebilirsiniz.");
			}
		}
	}
	req.send(params);
	return req;
}
Array.prototype.find=function(str)
{
    for (var k=0; k<this.length; ++k)
        if (this[k]==str)
            return true;
    return false;
}
var lC = [new Array(), new Array()];
function Load(src, type, callback)
{
	if (type==null)
		type=0;
	if (lC[type].find(src)==true)
	{
	    if (callback)
	        callback();
	    return;
	}
	var req = XHR("Loader.aspx", "src="+src+"&type="+type, (callback)?self.Proc.Bind(self):null, [type, callback]);
	lC[type].push(src);
	if (!callback)
	{
		Proc(req.responseText, [type, null]);
	}
}
function LJSA(arr)
{
    var src='';
    for (var k=0; k<arr.length; ++k)
    {
        if (lC[0].find(arr[k])==false)
        {
            if (src!='')
                src+=',';
            src += arr[k];         
        }
    }
    if (src=='')
        return;
    var req = XHR("Loader.aspx", "src="+src+"&type=0");
    lC[0].concat(arr);
    Proc(req.responseText, [0, null]);
}
var jsSize=0;
function Proc(txt, args)
{
	if (args[0]==0)
	{
	    jsSize += txt.length;
		eval(txt);
		if (args[1] && args[1]!="")
			args[1]();
	}
	else
	{
		if (document.styleSheets.length==0)
		{
			var sheet = document.createElement('style');
			sheet.type = "text/css";
			document.getElementsByTagName('head')[0].appendChild(sheet);
		}
		if (isIE==true)
			document.styleSheets[0].cssText += txt;
		else
		{
			var s = txt.split('}');
			for (var k=0; k<s.length; ++k)
				if (s[k].length>0)
					document.styleSheets[0].insertRule(s[k]+'}', document.styleSheets[0].cssRules.length);
		}
	}	
}
var isIE=false, fixPNG=false;
function initDHTMLAPI() 
{
    if (document.images) 
    {
        if (navigator.appName.indexOf("Explorer")!=-1)
        {
            fixPNG = (navigator.appVersion.indexOf("MSIE 6.0")>=0);
			isIE = true;
		}
    }
}

function getObjL(elem)  
{
    var result = 0;
    if (document.defaultView) 
    {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("left");
    } 
    else if (elem.currentStyle) 
    {
        result = elem.currentStyle.left;
    } 
    else if (elem.style) 
    {
        result = elem.style.left;
    } 
    return parseInt(result);
}

function getObjT(elem)  
{
    var result = 0;
    if (document.defaultView) 
    {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("top");
    } 
    else if (elem.currentStyle) 
    {
        result = elem.currentStyle.top;
    } 
    else if (elem.style) 
    {
        result = elem.style.top;
    } 
    return parseInt(result);
}

function getObjW(elem)  
{
    var result = 0;
    if (elem.offsetWidth) 
    {
        result = elem.offsetWidth;
    }
    else if (elem.clip && elem.clip.width) 
    {
        result = elem.clip.width;
    } 
    else if (elem.style && elem.style.pixelWidth) 
    {
        result = elem.style.pixelWidth;
    }
    return parseInt(result);
}

function getObjH(elem) 
{
    var result = 0;
    if (elem.offsetHeight) 
    {
        result = elem.offsetHeight;
    } 
    else if (elem.clip && elem.clip.height) 
    {
        result = elem.clip.height;
    } 
    else if (elem.style && elem.style.pixelHeight) 
    {
        result = elem.style.pixelHeight;
    }
    return parseInt(result);
}

function getBW() 
{
    if (window.innerWidth) 
    {
        return window.innerWidth;
    } 
    else if (document.body && document.body.clientWidth) 
    {
        return document.body.clientWidth;
    }
    return 0;
}

function getBH() 
{
    if (window.innerHeight) 
    {
        return window.innerHeight;
    } 
    else if (document.body && document.body.clientHeight) 
    {
        return document.body.clientHeight;
    }
    return 0;
}
Object.prototype.clone = function() 
{
    var newObj = (this instanceof Array) ? [] : {};
    for (i in this)
    {
        if (i == 'clone') 
            continue;
        if (this[i] && typeof this[i] == "object") 
        {
            newObj[i] = this[i].clone();
        } 
        else 
            newObj[i] = this[i];
    } 
    return newObj;
};
initDHTMLAPI();
Load("APIEx");
Load("CustomStyles", 1);
self.gIC=new ImageCache();
gIC.AddImage('backArrow', 'images/meta/arrb.png');
gIC.AddImage('closePanel', 'images/meta/closePanel.png');
gIC.AddImage('forwardArrow', 'images/meta/arrf.png');
gIC.AddImage("spot", "images/map/objects/object.png");
gIC.AddImage("closeDiv", "sets/"+g_iconSet+"/icon/close.png");
gIC.AddImage("pngFix", "images/x.gif");
self.g_mapDlg=null;
self.g_appName="Avea";
LJSA(["Dialog","Interface","Utility"]);
