/*******************************************************
* Author    : Sebastian Grinke                         *
* Homepage  : http://sebastiangrinke.info              *
* E-Mail    : webmaster@sebastiangrinke.info           *
* Copyright : Copyright © 2008 - 2009 Sebastian Grinke *
*																								       *
* Dieses Dokument darf verändert werden aber das       *
* Copyright muss erhalten bleiben.                     *
*******************************************************/
function microtime(get_as_float){
   var now = new Date().getTime() / 1000;
   var s = parseInt(now);
   return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s;
}
function substr(f_string,f_start,f_length){
   f_string += '';
   if(f_start < 0){f_start += f_string.length;}
   if(f_length == undefined){f_length = f_string.length;}
   else if(f_length < 0){f_length += f_string.length;}
   else {f_length += f_start;}
   if(f_length < f_start){f_length = f_start;}
   return f_string.substring(f_start, f_length);
}
function open_browser_dl(){
   window.open('/templates/k1ll3r8e_color/data/layout/includes/browser_dl.php', 'Browser Download', 'width=230,height=230,left=200,top=250,toolbar=no,resizable=no,status=no,menubar=no,location=no,dependent=yes');
}
function animate(elementID, newLeft, newTop, newWidth, newHeight, time, callback){
	 var el = document.getElementById(elementID);
   if(el == null)
      return;
		  var cLeft = parseInt(el.style.left);
		  var cTop = parseInt(el.style.top);
		  var cWidth = parseInt(el.style.width);
		  var cHeight = parseInt(el.style.height);
		  var totalFrames = 1;
		  if(time> 0)
		     totalFrames = time/40;
		  var fLeft = newLeft - cLeft;
		  if(fLeft != 0)
		     fLeft /= totalFrames;
		  var fTop = newTop - cTop;
		  if(fTop != 0)
		     fTop /= totalFrames;
		  var fWidth = newWidth - cWidth;
		  if(fWidth != 0)
		     fWidth /= totalFrames;
		  var fHeight = newHeight - cHeight;
		  if(fHeight != 0)
		     fHeight /= totalFrames;
		  doFrame(elementID, cLeft, newLeft, fLeft, cTop, newTop, fTop, cWidth, newWidth, fWidth, cHeight, newHeight, fHeight, callback);
}
function doFrame(eID, cLeft, nLeft, fLeft, cTop, nTop, fTop, cWidth, nWidth, fWidth, cHeight, nHeight, fHeight, callback){
	 var el = document.getElementById(eID);
   if(el == null)
      return;
   		cLeft = moveSingleVal(cLeft, nLeft, fLeft);
   		cTop = moveSingleVal(cTop, nTop, fTop);
   		cWidth = moveSingleVal(cWidth, nWidth, fWidth);
   		cHeight = moveSingleVal(cHeight, nHeight, fHeight);
		  el.style.left = Math.round(cLeft) + 'px';
		  el.style.top = Math.round(cTop) + 'px';
		  el.style.width = Math.round(cWidth) + 'px';
		  el.style.height = Math.round(cHeight) + 'px';
		  if(cLeft == nLeft && cTop == nTop && cHeight == nHeight && cWidth == nWidth){
		     if(callback != null)
		     	  callback();
		   		  return;
		  }
		  setTimeout( 'doFrame("'+eID+'",'+cLeft+','+nLeft+','+fLeft+','
		  +cTop+','+nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+','
		  +cHeight+','+nHeight+','+fHeight+','+callback+')', 40);
}
function moveSingleVal(currentVal, finalVal, frameAmt){
	 if(frameAmt == 0 || currentVal == finalVal)
      return finalVal;
  	  currentVal += frameAmt;
  	  if((frameAmt> 0 && currentVal>= finalVal) || (frameAmt <0 && currentVal <= finalVal)){
    		 return finalVal;
  	  }
  	  return currentVal;
}
