var my_div = null;
var newDiv = null;
var currentwindow=null;
var nrwindows=0;

function addElement()
{
  newDiv = document.createElement("div");
  newDiv.innerHTML = "<h1>Hi there and greetings!</h1>";
  my_div = document.getElementById("org_div1");
  document.body.insertBefore(newDiv, my_div);
}

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}

function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-150;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}

function popup(windowname) {
	blanket_size(windowname);
	toggle('blanket');
}

//pentru fereastra

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){

}

function dd(e){
   return false;  
}

function ddN4(whatDog){

}

function hideMe(){
  if (isIE||isNN) theLayer.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";

}

function showMe(){

  if (isIE||isNN) {
	 theLayer.style.visibility="visible";
	}
  else if (isN4) document.theLayer.visibility="show";
timeoutAscundere();	
}

function aratadiv(el) {
	if (typeof(el)=='string') el=$(el);
	el.style.display='';
}

function ascundediv(el) {
	if (typeof(el)=='string') el=$(el);
	el.style.display='none';
}

function timeout(element, delay) {
	var el = element;
	if (delay==null) delay=2000;
	setTimeout(function() {ascundediv(el);}, delay);
}




function ascundedivmeniu(idDiv) {
	el=document.getElementById(idDiv);
if ((mouseX<el.style.left-5) || (mouseX>el.style.left+5) || (mouseY<el.style.top-5) || (mousey>el.style.top+10)) {
		el.style.display="none";
}
}

function ascundeElement(el){
  if (isIE||isNN) el.style.visibility="hidden";
  else if (isN4) el.visibility="hidden";
}

function arataElement(el){
  if (isIE||isNN) el.style.visibility="visible";
  else if (isN4) el.visibility="visible";
}

function timeoutAfisare(delay) {
	if (delay==null) delay=3000;
	setTimeout(function() {showMe();}, delay);
}

function timeoutAscundere(delay) {
	if (delay==null) delay=15000;
	setTimeout(function() {hideMe();}, delay);
}
