var windownum = 1;

function popupWin(src, w, h, x, y) {

	++windownum; 

	var x,y,w,h;

	var winSize = getWindowSize();

	if(!w) {
		w = winSize[0] * .9;
		h = winSize[1] * .9;
	}
	
	if(!x) {
		if (document.all) {
			x = window.screenLeft + (winSize[0] - w) / 2;
			y = window.screenTop + (winSize[1] - h) / 2 - 50;
		}
		else if (window.innerWidth) {
			x = window.screenX + (winSize[0] - w) / 2;
			y = window.screenY + (winSize[1] - h) / 2;
		}
	}

	if(hndle = window.open(src, windownum, 'scrollbars=yes,resizable=yes,status=yes,width=' + w + ',height=' + h + ',left=' + x + ',top=' + y))
		return hndle;
	else
		return false;
}

function popupWinName(winName, src, w, h, x, y) {

	var x,y,w,h;

	var winSize = getWindowSize();

	if(!w) {
		w = winSize[0] * .9;
		h = winSize[1] * .9;
	}
	
	if(!x) {
		if (document.all) {
			x = window.screenLeft + (winSize[0] - w) / 2;
			y = window.screenTop + (winSize[1] - h) / 2 - 50;
		}
		else if (window.innerWidth) {
			x = window.screenX + (winSize[0] - w) / 2;
			y = window.screenY + (winSize[1] - h) / 2;
		}
	}

	if(hndle = window.open(src, winName, 'scrollbars=yes,resizable=yes,status=yes,width=' + w + ',height=' + h + ',left=' + x + ',top=' + y)) {
		hndle.focus();
		return hndle;
	}
	else
		return false;
		
	
}

function popupBlank(src,w,h) {

	++windownum; 

	var x,y,w,h;

	var winSize = getWindowSize();

	if(!w) {
		w = winSize[0] * .9;
		h = winSize[1] * .9;
	}
	
	if (document.all) {
		x = window.screenLeft + (winSize[0] - w) / 2;
		y = window.screenTop + (winSize[1] - h) / 2 - 50;
	}
	else if (window.innerWidth) {
		x = window.screenX + (winSize[0] - w) / 2;
		y = window.screenY + (winSize[1] - h) / 2;
	}

	if(hndle = window.open(src, windownum, 'titlebar=yes,menubar=yes,toolbar=yes,location=yes,directories=yes,scrollbars=yes,resizable=yes,status=yes,width=' + w + ',height=' + h + ',left=' + x + ',top=' + y))
		return hndle;
	else
		return false;
}

function getWindowSize() {
  
  var myWidth = 0, myHeight = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
   myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  var winSize = new Array();  
  winSize[0] = myWidth;
  winSize[1] = myHeight;
  
  return winSize;
}