function img1(name) {
	 img=new Image();
     img.src = '/i/'+name+'.gif';
	 document.images[name].src=img.src;
}

function img2(name) {
	 img=new Image();
     img.src = '/i/'+name+'b.gif';
	 document.images[name].src=img.src;
}

function dbl(t) {
	if(t.dlg_clicked)
		return false;
	t.dlg_clicked=true;
	return true;
}

function bookmark_add() {
    url = document.location;
    title = document.title;
    if(window.sidebar) 
        window.sidebar.addPanel(title, url, ""); 
    else if(window.external) 
        window.external.AddFavorite(url, title)
}

function contact_switch(obj) {
}

/* AJAXOWE SELECTY */

function dlg_url(u)
{
	if(typeof(u)=='object') {
		var s=u[0];
		if(typeof(u[1])=='object') {
			var k;
			var sp='?';
			for (k in u[1]) {
				s+=sp+encodeURIComponent(k)+'='+encodeURIComponent(u[1][k]);
				sp='&';
			}
		}
		if(typeof(u[2])!='undefined')
			s+='#'+u[2];
		return s;
	}
	return u;
}

function dlg_get(u,cb,cbp)
{
	return dlg_xmlhttprequest(u,'GET','','',cb,cbp);
}


function dlg_xmlhttprequest(u,m,d,c,cb,cbp)
{
	u=dlg_url(u);
	var r=false;
    if(window.XMLHttpRequest) {
    	try {
			r=new XMLHttpRequest();
        }
		catch(e) {
			r=false;
        }
    }
	else if(window.ActiveXObject) {
       	try {
        	r=new ActiveXObject("Msxml2.XMLHTTP");
      	}
		catch(e) {
        	try {
          		r=new ActiveXObject("Microsoft.XMLHTTP");
        	}
			catch(e) {
          		r=false;
        	}
		}
    }

	if(r) {
		r.onreadystatechange=function() {
			if(r.readyState==4) {
				if(r.status==200)
					cb(r.responseText,cbp);
			}
		};
		r.open(m,u);
		if(c!='')
			r.setRequestHeader('Content-Type',c);
		r.send(d);
		return true;
	}
	return false;
}

function reset() {
	dlg_get('/ajaxselect.php?reset=1',function(d){document.getElementById('ajaxselect').innerHTML=d;});
}


function opacity(id, opacStart, opacEnd, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpacity(" + i + ",'" + id +"')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpacity(" + i + ",'" + id +"')",(timer * speed));
			timer++;
		}
	}
}
function changeOpacity(opacity, id) {
	document.getElementById(id).className = 'opacity'+opacity;
}
function animCommentHeight(id,end) {
	var height = parseInt(document.getElementById(id).offsetHeight);
	if(height>end) {
		changeHeight(id,end,20,700,1);
		if(id == 'commentForm') {
		}
	}
	else {
		changeHeight(id,parseInt(document.getElementById(id+"Inner").offsetHeight),20,700,0.5);
		if(id == 'commentForm') {
			document.getElementById(id+"Icon").className="closer";
			document.getElementById(id+"IconText").innerHTML="-";
		}
	}
}
function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) { 
    var delta = maxValue - minValue; 
    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
    return Math.ceil(stepp)
} 
function changeHeight(id,endHeight,steps,millisec,powr) { 
	var obj = document.getElementById(id);
	obj.currentHeight = parseInt(obj.offsetHeight);
	var startHeight = obj.currentHeight;
	var speed = Math.round(millisec / 100);
    if (obj.heightChange)
		window.clearInterval(obj.heightChange);
    var actStep = 0;
    obj.heightChange = window.setInterval(
	function() { 
	  obj.currentHeight = easeInOut(startHeight,endHeight,steps,actStep,powr);
	  obj.style.height = obj.currentHeight + "px"; 
	  actStep++;
	  if (actStep > steps) {
		  if(obj.id == 'commentForm' && obj.currentHeight <= 0) {
			document.getElementById(obj.id+"Icon").className="opener";
			document.getElementById(obj.id+"IconText").innerHTML="+";
		  }
		  window.clearInterval(obj.heightChange);
	  };
	}, speed);
}

