// JUST TESTING (MOVABLE) POPUP
// SHOWING WORKS EVERYWHERE
// MOVING WORKS IN IE7+ ONLY AT THIS MOMENT

  var ie = document.all;
  var nn6 = document.getElementById &&! document.all;

  var isdrag = false;
  var x, y;
  var dobj;
	
  function showPOP(nameOfPop,W,H) {
		// show transparent overlay
	  document.getElementById('overlay2').style.display='block';
		
	  // count position (left and top)
		// show popup
    center(nameOfPop,W,H);
  }

	// get count position for popup when you scrolling
	function center(nameOfPop,W,H){

		var windowSize = getPageDimensions();
		var window_width  = windowSize[0];
		var window_height = windowSize[1];
	
		var scrollY = 0;
	
		if ( document.documentElement && document.documentElement.scrollTop ){
			scrollY = document.documentElement.scrollTop;
		} else if ( document.body && document.body.scrollTop ){
			scrollY = document.body.scrollTop;
		}else if ( window.pageYOffset ){
			scrollY = window.pageYOffset;
		}else if ( window.scrollY ){
			scrollY = window.scrollY;
		}
	
		var setX = ( window_width  - W  ) / 2;
		var setY = ( window_height - H ) / 2 + scrollY;
	
		setX = ( setX < 0 ) ? 0 : setX;
		setY = ( setY < 0 ) ? 0 : setY;
		
		// +70px more down because of f* flash
		document.getElementById(nameOfPop).style.top=setY+70+'px';
	  document.getElementById(nameOfPop).style.left=setX+'px';
		document.getElementById(nameOfPop).style.display='block';
	}
	
  function getPageDimensions(){
		var xScroll, yScroll;
	
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
				
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		arrayPageSize = new Array(windowWidth,windowHeight,pageWidth,pageHeight) 
		return arrayPageSize;
	}

  // function for moving popup
	// at this moment out of use
  function movemouse( e ) {
    if( isdrag ) {
      dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
      dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
      return false;
    }
  }


  function selectmouse( e ) {

    var fobj       = nn6 ? e.target : event.srcElement;
    var topelement = nn6 ?  'HTML'  :  'BODY' ;
    while (fobj.tagName != topelement && fobj.className != 'dragme') {
      fobj = nn6 ? fobj.parentNode : fobj.parentElement;
    }

    if (fobj.className=='dragme') {

      isdrag = true;
      dobj = document.getElementById(nameOfPop);
      tx = parseInt(dobj.style.left+0);
      ty = parseInt(dobj.style.top+0);
      x = nn6 ? e.clientX : event.clientX;
      y = nn6 ? e.clientY : event.clientY;
      document.onmousemove=movemouse;
      return false;
    }
  }


  function styledPopupClose(nameOfPop) {
	  document.getElementById('overlay2').style.display='none';
    document.getElementById(nameOfPop).style.display='none';
  }


  //document.onmousedown=selectmouse();
  document.onmouseup=new Function('isdrag=false');