isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;
var path = "http://"+document.domain+"/";
//document.write = ""
function c()
{
	var dc;
	var d;
	var a;
	var i;
	var f;
	var tim;
	var id_obj;
	this.incs();
}


c.prototype.incs = function()
{
	var self = this;
	self.id_obj = Math.random();
	self.tim = 0;
	self.dc = function(ele){ return document.createElement(ele);};
	self.d=self.dc("div");
	self.a=self.dc("a");
	self.i=self.dc("img");
	self.f=self.dc("iframe");
	self.a.href = "http://www.e-customer-satisfaction.com/"+ecs_cert+"/certificate.php";
	self.a.target = "_blank";
	self.i.src = ecs_path;
	self.i.border = 0;
	self.i.onmouseover = function(){self.onoff = 1; self.i_mouver(this); };
	self.i.onmouseout = function(){self.onoff = 0; self.i_mout(this); };
	
	self.d.style.width = "320px";
	self.d.style.height = "215px";
	self.d.style.border = "1px solid #CCCCCA";
	self.d.style.display = "none";
	self.d.style.position = "absolute";
	self.d.style.backgroundColor = "#FFFFFF";
	self.d.style.zIndex = "1000000";
	self.d.onmouseover = function(){ self.onoff = 1; };
	self.d.onmouseout = function(){ self.onoff = 0; self.i_mout(this); };
	
	self.f.style.width = "320px";
	self.f.style.height = "215px";
	self.f.style.border = "0px";
	self.f.src = "http://www.e-customer-satisfaction.com/ecs_cert.php?xc="+ecs_cert;
	self.f.name = "esc_if";
	self.f.frameBorder = "no";
	self.f.onmouseover = function(){ self.onoff = 1; };
	self.f.onmouseout = function(){ self.onoff = 0; self.i_mout(this); };
	
	self.d.innerHTML = "<div style=\"position:absolute; width:315px; top:5px;\" align=\"right\"><a href=\"\" onclick=\"cx.exit(); return false;\"><img border=\"0\" src=\"http://www.e-customer-satisfaction.com/images/bt_x.jpg\"></a></div>";
	self.a.appendChild(self.i);
	self.d.appendChild(self.f);
	document.write("<div id=\"ecs_con\"></div>");
	var ecs_con_d = getelement('ecs_con');
	var nrx = posx(0,ecs_con_d);
	var nry = posy(0,ecs_con_d);
	getelement('ecs_con').id = "ecs_con"+nrx+""+nry;
	getelement('ecs_con'+nrx+""+nry).appendChild(self.a);

	bb = document.body;
	bb.insertBefore(self.d,bb.firstChild)
}

c.prototype.i_mouver = function(el)
{
	var self = this;
	var coors = captureMousePosition();
	var px = posx(0,el)+88;
	var py = posy(0,el)-70;
	
	if(px < coors[0]) px = coors[0]+10;
	if((px+320) > coors[1]) px = coors[1]-330;
	if(py < coors[2]) py = coors[2]+10;
	if((py+215) > coors[3]) py = coors[3]-225;
	
	self.d.style.left = (px)+"px";
	self.d.style.top = (py)+"px";
	self.d.style.display = "";
}

c.prototype.i_mout = function(el)
{
	var self = this;
	self.tim = setTimeout(function(){self.i_moutEx();},1000,this);
	//self.tim = setTimeout(function(self){var self = this; alert(this);},1000,this);
	//self.tim = setTimeout(cx.i_moutEx,1000,this);
}

c.prototype.i_moutEx = function()
{
	var self = this;
	if(self.onoff == 0)
	{
		self.exit();
		self.onoff = 2;
	}
}

c.prototype.exit = function()
{
	var self = this;
	if(self.d.style.display == "")
	{
		self.d.style.display = "none";
		//self.f.src = "http://www.e-customer-satisfaction.com/ecs_cert.php?xc="+ecs_cert;
	}
}

c.prototype.exit2 = function(el)
{
	var self = this;
}

var cx = new c();

function getelement(id)
{
	if (isNS4){
		elm = document.layers[id];
        if (!elm) elm = false;
	}
	else 
		if (isIE4){
			elm = document.all[id];
			if (!elm) elm = false;
		}
		else 
			if (isIE5){
				elm = document.getElementById(id);
				if (!elm) elm = false;
			}
			else 
				if (isNS6){
					elm = document.getElementById(id);
					if (!elm) elm = false;
				}
	return elm;
}

function posx (x, img) {
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) { x += img.x; alert(x);}
	return x;
}

function posy (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.y >= 0) y += img.y;
	return y;
}

function SAddEvent(obj,event_t,event_f)
{
	if(typeof window.addEventListener != "undefined")
	{
		if(obj)
			obj.addEventListener(event_t, event_f, false );
		else
			window.addEventListener(event_t, event_f, false );
		return 1;
	}

	if(typeof window.attachEvent != "undefined" )
	{
		if(obj)
			obj.attachEvent("on"+event_t, event_f);
		else
			if(document.attachEvent("on"+event_t, event_f))
				window.attachEvent("on"+event_t, event_f)
		return 1;
	}
	return 0;
}

function captureMousePosition() {
	xMx = 0; // Width of the page
	yMx = 0; // Height of the page
	xMn = 0; // Width of the page
	yMn = 0; // Height of the page
	xMp = 0; // Horizontal position of the mouse on the screen
	yMp = 0; // Vertical position of the mouse on the screen
	var s = "";

    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        
        //xMp = e.pageX;
        //yMp = e.pageY;
        
        xMn = window.pageXOffset;
        yMn = window.pageYOffset;
        
        xMx = window.innerWidth+window.pageXOffset;
        yMx = window.innerHeight+window.pageYOffset;
        s = "NC";
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position
        // reflects the position from the top/left of the screen the
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no
        // matter if the user has scrolled or not.
        //xMousePos = window.event.x;//+document.body.scrollLeft;
        //yMousePos = window.event.y+document.body.scrollTop;
        
        
        if (document.documentElement && document.documentElement.scrollTop)
        {
        	//xMp = window.event.x+document.documentElement.scrollLeft;
        	//yMp = window.event.y+document.documentElement.scrollTop;

        	xMn = document.documentElement.scrollLeft;
        	yMn = document.documentElement.scrollTop;

        	xMx = document.documentElement.clientWidth+document.documentElement.scrollLeft;
        	yMx = document.documentElement.clientHeight+document.documentElement.scrollTop;
        	
        	if(xMn == xMx && yMn == yMx)
        		xMn = yMn = 0;
        	
        	s = "IEA";
        	
        }
        else
        {
        	//xMp = window.event.x+document.body.scrollLeft;
        	//yMp = window.event.y+document.body.scrollTop;
        	
        	xMn = document.body.clientWidth;
       		yMn = document.body.clientHeight;
       		
        	xMx = document.body.clientWidth+document.body.scrollLeft;
       		yMx = document.body.clientHeight+document.body.scrollTop;
       		
       		if(xMn == xMx && yMn == yMx)
        		xMn = yMn = 0;
        		
       		s = "IEB"; //napewno 6
        }
            
     //   xMousePos = window.event.x+document.body.scrollLeft;
     //   yMousePos = window.event.y+document.body.scrollTop;
        
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard
        //xMp = e.pageX;
       // yMp = e.pageY;
        
        xMn = window.pageXOffset;
        yMn = window.pageYOffset;
        
        xMx = window.innerWidth+window.pageXOffset;
        yMx = window.innerHeight+window.pageYOffset;

        s = "FF";
    }

    return [xMn,xMx,yMn,yMx,xMp,yMp,s];
}

