var counter = {
    ss: '',
    c: 0,
    str: '',
    currentUrl: '',
    exp: '',
    did: 0,
    host: '',
    
    
    init: function() {
        ss = counter.ss + Math.random();
        ss = ss.substr(2);
        document.cookie="sscic" + ss;
        str = document.cookie;
        
        if(str.indexOf(ss) != -1) {
            c=1;
        }
        
        //document.write('<img src="http://klimapro.lv/statistic/st.php?d=28019&l=1&n=0&c='+c+'&r='+escape(document.referrer)+'&rn='+ss+'" width="1" height="1" border="0">');
        
        counter.getID();
        counter.getHost();
        
        var newStr = '<img src="http://' + host + '/statistic/st.php?d=' + did + '&l=1&n=0&c='+c+'&r='+escape(document.referrer)+'&rn='+ss+'" width="1" height="1" border="0">';
        
        el = document.getElementById('myCnt');
        el.innerHTML = el.innerHTML + newStr;
        
       //alert(did);
        
    },
    
    getID: function () {
        currentUrl = window.top.location;
        
        var string1= '' +currentUrl+'';
        if(match=string1.match(/\d+/g)) {
            did = match[0];
            return true;
        } else {
            return false;
        }
    },
    
    getHost: function () {
        currentUrl = window.top.location;
        
        var string1= '' +currentUrl+'';
        if(match=string1.match(/\w+/gi)) {
            
            host = match[1] + '.' + match[2];
            
            return host;
        } else {
            alert('host failed');
            return false;
        }
    }
}

window.onload = function() {
    counter.init();
}
