/**
 * @type   : function
 * @access : public
 * @desc   : Open Window Popup
 *
 * @sig    : url, winName, winProps
 * @param  : url      - target url
 * @param  : winName  - window name
 * @param  : winProps - window Properties
 * @return : window
 * @author : Seo Sung-il
 * @Date   : 2006-11-08
 */
function openPop(URL, winName, feautres) {
	var farWindow
	
	farWindow = cfOpenWindowPost(URL, winName, feautres);
	
	return farWindow;
}


/**
 * @type   : function
 * @access : public
 * @desc   : Open Window Popup
 *
 * @sig    : url, winName, winProps, sizeX, sizeY, feautres
 * @param  : url      - target url
 * @param  : winName  - window name
 * @param  : sizeX    - position X
 * @param  : sizeY    - position Y
 * @param  : winProps - window Properties
 * @return : window
 */
function openPopup(URL, winName, sizeX, sizeY, feautres){

  var urlstring = URL;
  var target    = winName;
  var xpos=sizeX;
  var ypos=sizeY;
  var screenX = top.window.screen.width;
  var screenY = top.window.screen.height;
  var center = true;

  var sFeatures = feautres;   //directories, channelmode, fullscreen, location, toolbar, menubar, resizable, scrollbars, status

  sFeatures += sFeatures.length ==0 ? "" : ", ";
  sFeatures += "width=" + xpos ;
  sFeatures += ", height=" + ypos ;
  
  //farwindow=window.open(urlstring, target, sFeatures);
  
  farwindow = cfOpenWindowPost(urlstring, target, sFeatures);

  if (center) farwindow.top.moveTo((screenX-xpos)/2,(screenY-ypos)/2);
 
  if (farwindow != null) {
     if (farwindow.opener == null) {
         farwindow.opener = self;
     }
  }
 
  if (farwindow) farwindow.focus();
  
}

/**
 * @type   : function
 * @access : public
 * @desc   : Open Window Popup : get -> Post
 *
 * @sig    : url, winName, winProps
 * @param  : url      - target url
 * @param  : winName  - window name
 * @param  : winProps - window Properties
 * @return : window
 * @author : Seo Sung-il
 * @Date   : 2006-11-08
 */
function cfOpenWindowPost(url, winName, winProps) {

	var urlString = url;
	var urlPage   =""
	var urlQuery  ="";
	var tmp       =""
	var tmp2      ="";
	var farWindow, oInput;

	if (urlString.indexOf("?") > -1) {  // QueryString exist
		
		farWindow = window.open('about:blank', winName, winProps);    
		farWindow.document.write("<form name='frmfarWindowForm' method='post'>");
		farWindow.document.write("</form>");
	
		urlPage = urlString.substring(0, urlString.indexOf("?"));
		urlQuery= urlString.substring(urlString.indexOf("?")+1);
		
		tmp = urlQuery;
		
		if(tmp != null) {
			tmp = tmp.split("&");
			
			for(var i = 0; i<tmp.length; i++) {
				tmp2 = tmp[i].split("=");
				
				oInput = farWindow.document.createElement("<INPUT TYPE='hidden'>");
				oInput.name  = tmp2[0];
				oInput.value = tmp2[1];
				farWindow.document.frmfarWindowForm.appendChild(oInput);				
			}
		}
		
		farWindow.document.frmfarWindowForm.action = urlPage;
		farWindow.document.frmfarWindowForm.submit();

	} else {  // QueryString not exist
	
		farWindow = window.open(url, winName, winProps);
	    
	}
	
	return farWindow;
}
