function mygetXPosition(xwidth){
	if(document.all){ 
		return (document.body.clientWidth - width) / 2;  
	}

    return (screen.width - xwidth) / 2;
}


function setposition(object,mytop){
     width  = document.getElementById(object).style.width;      width = width.substring(0,width.length-2); 
     height = document.getElementById(object).style.height;     height = height.substring(0,height.length-2); 	
     xleft = mygetXPosition(width);
     xtop  = mytop;
	 document.getElementById(object).style.position =  "absolute";
     document.getElementById(object).style.left =  xleft;
	 document.getElementById(object).style.top  =  xtop;
}


function setposition1(object){
     width  = document.getElementById(object).style.width;      width = width.substring(0,width.length-2); 
     height = document.getElementById(object).style.height;     height = height.substring(0,height.length-2); 	
     xleft = mygetXPosition(width);
     xtop = document.body.scrollTop+20;
	 document.getElementById(object).style.position =  "absolute";
     document.getElementById(object).style.left =  xleft;
	 document.getElementById(object).style.top  =  xtop;
}

function setposition2(object, x, y){
     width  = document.getElementById(object).style.width;      width = width.substring(0,width.length-2); 
     height = document.getElementById(object).style.height;     height = height.substring(0,height.length-2); 	
     xleft = mygetXPosition(width)+x;
     xtop =  y;

	 document.getElementById(object).style.position =  "absolute";
     document.getElementById(object).style.left =  xleft;
	 document.getElementById(object).style.top  =  xtop;
}





function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}


function setOpacity(id, value) {
	//--value 0-10;
	obj = document.getElementById(id);
	if(document.all){		
	   obj.style.filter = 'alpha(opacity=' + value*10 + ')';
	}
	else{
		obj.style.opacity = value/10;
	}	
}



//---viewport functions
function vpWidth() {
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
}
function vpHeight() {
return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
}



function dynamiccontent(elementid,content){
  /*
   * minunata functie pentru schimbarea dinamica a continutului unei div, td, span sau orice alt dhtml object 
   */
  if(document.all){
     document.getElementById(elementid).innerHTML=content
  }
  else{
             if (document.getElementById && !document.all){
                rng = document.createRange();
                el = document.getElementById(elementid);
                rng.setStartBefore(el);
                htmlFrag = rng.createContextualFragment(content);
                while (el.hasChildNodes()) el.removeChild(el.lastChild);
                el.appendChild(htmlFrag);
            }
  }
}