/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/


var Base64 = {

    // private property
    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode : function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);

        while (i < input.length) {

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }

        return output;
    },

    // public method for decoding
    decode : function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

        while (i < input.length) {

            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }

        }

        output = Base64._utf8_decode(output);

        return output;

    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}



function removehtml(obj){
	if($(obj)) 
	{
		  if(typeof(obj)=='string'){
		    obj = document.getElementById(obj);
		  }
		  while(obj.firstChild!=null){
		    obj.removeChild(obj.firstChild);
		  }
		  return false;
	}
}

function addhtml(nkontener,id,tag){
	if(id) 
	{
		var znacznik = document.createElement(tag);
		znacznik.setAttribute('id', id);
		znacznik.setAttribute('class', 'object_'+id);
		var kontener = $(nkontener);
		if(!kontener) { alert('Element o podanym ID jeszcze nie istnieje: '+nkontener); }
		kontener.appendChild(znacznik);
		//mint.fx.Fade(id, 0, 1, 1);
		//mint.fx.Fade(id, 100, 20, 100);
	}
}

// LADOWANIE STRONY

var req = mint.Request();
   req.evalScripts = true;
   req.evalResponse = true;
   req.retryNum = 0;
   req.timeout = 120;
	
 //  mint.fx.Fade('fullscreen', 0, 1, 1);
   
   req.OnSuccess = function() {
   
				
		if(this.responseText.substr(0,7)=='<script')
		{
			mint.fx.Stop('fullscreen');
			//mint.fx.Fade('fullscreen', 100, 5, 100);
			$("connect").innerHTML = this.responseText;
			
		}	
   }
   
    req.OnAbort =  function() {
        alert("Conection Error. Server not response.");
		//mint.fx.Fade('fullscreen', 100, 1, 1);
    }
	
req.Send("req.php?ajax=on");





function SendForm(t1,ids,evant,co,czy) {
    var req = mint.Request();
    

    req.evalScripts = true;
    req.evalResponse = true;
	req.retryNum = 0;
	req.timeout = 120;
	
	
			
	
		if($(ids))
		{
			req.ids = ids;

			
			//$(req.ids).style.cursor = 'wait';
		}
	
   req.OnSuccess = function() {
   

		
		if(this.responseText.substr(0,7)='<script')
		{
		
			$("connect").innerHTML = Base64.decode(this.responseText);
		}	
		
		if($(req.ids))
		{
			//$(req.ids).style.cursor = 'pointer';
		}
		
    req.OnAbort =  function() {
        alert("Conection Error. Server not response.");
    }
	
   }
   


    req.SendForm(ids,'req.php?ajax=on&evantid='+ids+'&evant='+evant+'&exec='+co,'post');
}

function SendEvant(t1,ids,evant,co,ob)
{
   var req = mint.Request();
   req.evalScripts = true;
   req.evalResponse = true;
    req.AddParam("ajax", 'on');
	req.AddParam("evantid", ids);
	req.AddParam("evant", evant);
	req.AddParam("exec", co);
	req.retryNum = 0;
	req.timeout = 120;
	
	
	//$(ob).innerHTML = 'Loading...';
	
	req.ob = ob;
	mint.fx.Fade(req.ob, 20, 2, 100);
	
		if($(ids))
		{
			req.ids = ids;
			//$(req.ids).style.cursor = 'wait';
			

		}
	
   req.OnSuccess = function() {
		
		mint.fx.Fade(req.ob, 100, 2, 100);
		
		if(this.responseText.substr(0,7)='<script')
		{
			$("connect").innerHTML = Base64.decode(this.responseText);
		}	
		
		if($(req.ids))
		{
			//$(req.ids).style.cursor = 'pointer';
		}
   }
   
    req.OnAbort =  function() {
        alert("Conection Error. Server not response.");
    }
	
	req.Send("req.php");
}

function aEL(o,t,f){var a=[] 
for(i=3;i<arguments.length;)a[i-3]=arguments[i++] 
o[t+f]=function(e){return !1===f.apply(o,[e||window.event].concat(a))?e.preventDefault?e.preventDefault():!1:1} 
return(o.x=o.addEventListener)?o.x(t,o[t+f],!1):(o.x=o.attachEvent)?o.x('on'+t,o[t+f]):!1 
} 

function rEL(o,t,f){f=o[t+f] 
return(o.x=o.removeEventListener)?o.x(t,f,!1):(o.x=o.detachEvent)?o.x('on'+t,f):!1 
}

var sends = 0;

function TimerClick()
{
	if (!sends)
	{	
		sends = 1;
		SendEvant(null,'timer','desktop','onTime');
	}
	setTimeout('TimerClick();',10000);
}

//setTimeout('TimerClick();',5000);


