﻿var MYBO = (function ()
{
    var public = {
    }
    return public;
})();

MYBO.Browser = (function ()
{
    // Returns 0 if the browser is anything but IE
    function getIEVers()
    {
        if (Object.prototype.toString.call(window.opera) == '[object Opera]')
            return 0;

        var ua = window.navigator.userAgent, ie = ua.indexOf('MSIE ');
            return ((ie > 0) ? parseInt(ua.substring(ie+5, ua.indexOf('.', ie))) : 0);
    }
    var ieVers = getIEVers(), isIE = ieVers > 0;
    if (ieVers == 6)
        try {
            document.execCommand("BackgroundImageCache", false, true);
        } catch(ex) { }
    var public = {
        IEVers: ieVers,
        IsIE: isIE
    }
    return public;    
})();

function trimStr(str)
{
	return str.replace( /^\s+|\s+$/g, '' );
}
function my$(id)
{
	return document.getElementById(id);
}
function getKeyCode(e)
{
    var code;
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    return code;
}
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	} else {
		window.onload =
			function()
			{
				if (oldonload) {
					oldonload();
				}
				func();
			}
	}
}
// Register an empty onunload function to get onload work when back button used to navigate back to the page.
(function ()
{
	var oldonunload = window.onunload;
	window.onunload =
		function()
		{
			if (oldonunload) {
				oldonunload();
			}
		}
})();
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 = '';
	document.cookie = name+'='+value+expires+'; path=/';
}
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 queryString( key )
{
    var re = new RegExp( '[?&]' + key + '=([^&$]*)', 'i' );
    var offset = location.search.search( re );
    if ( offset == -1 ) return null;
    return RegExp.$1;
}
function updateLang(ln)
{
    if (ln == null)
        ln = 'tr';
    createCookie('ln', ln, 30);
}
if (typeof console == 'undefined' || typeof console.log == 'undefined')  { console = { log: function() {} };  }
