//-------------------------------------------//
//	cookie class
//-------------------------------------------//
var cookieEnabled=(navigator.cookieEnabled)? true : false

//if not IE4+ nor NS6+
if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
	document.cookie="testcookie"
	cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false
}

function Cookie(document, name, hours, path, domain, secure)
{
    this.$document = document;
    this.$name = name;
//    if (hours)
        this.$expiration = new Date((new Date()).getTime(  ) + hours*3600000);
}

Cookie.prototype.store = function (  ) {
    var cookieval = "";
    for(var prop in this) {
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + escape(this[prop]);
    }

    var cookie = this.$name + '=' + cookieval;
    if (this.$expiration)
        cookie += '; expires=' + this.$expiration.toGMTString(  );

    this.$document.cookie = cookie;
}

Cookie.prototype.load = function(  ) { 
    var allcookies = this.$document.cookie;
    if (allcookies == "") return false;

    var start = allcookies.indexOf(this.$name + '=');
    if (start == -1) return false;   // Cookie not defined for this page
    start += this.$name.length + 1;  // Skip name and equals sign
    var end = allcookies.indexOf(';', start);
    if (end == -1) end = allcookies.length;
    var cookieval = allcookies.substring(start, end);


    var a = cookieval.split('&');    // Break it into an array of name/value pairs
    for(var i=0; i < a.length; i++)  // Break each pair into an array
        a[i] = a[i].split(':');

    for(var i = 0; i < a.length; i++) {
        this[a[i][0]] = unescape(a[i][1]);
    }

    return true;
}

Cookie.prototype.remove = function(  ) {
    var cookie;
    cookie = this.$name + '=';
    cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';

    this.$document.cookie = cookie;
}

//-------------------------------------------//
//	functions
//-------------------------------------------//
function loadAd(sec, div_sec)
{
	var ax = new ajax ("/get.php?d=" + sec, {postBody: '', update: $(''), onComplete: function(req){
			if (req.responseText == "") return;
			
			var odiv = document.getElementById(div_sec);
			if (odiv) odiv.innerHTML = req.responseText;
		}
	});
}

function homeLoadDone()
{
	var ax = new ajax ("/f/bangla_css_msg.php", {postBody: '', update: $(''), onComplete: function(req){
			if (req.responseText == "") return;
			
			var odiv = document.getElementById("div_sys_msg");
			if (odiv) odiv.innerHTML = req.responseText;
		}
	});
}

//-------------------------------------------//
//	hits
//-------------------------------------------//
function hitsDone(request)
{
	if (request.responseText == "okay")
	{
		hits.visits = 0;
		hits.store();
	}
}

if (cookieEnabled)
{
	var hits = new Cookie(document, "amaderorthoneeti_hits", 480);
	hits.load();

	if (hits.visits == null)
		hits.visits = 0;

	hits.visits++;
	hits.store();

	if (hits.visits >= 10)
	{
		var ax = new ajax ("http://amaderorthoneeti.com/online/hit.php?c=" + hits.visits, {postBody: '', update: $(''), onComplete: hitsDone});
	}
}
