function window_open(url, name, width, height) {
	var left = parseInt((screen.width - width) / 2);
	var top = parseInt((screen.height - height) / 2);

	var features = "left=" + left + ", top=" + top + ", width=" + width + ", height=" + height;
	features += ", scrollbars=no, resizable=no";

	window.open(url, name, features);
}

function window_open_scroll(url, name, width, height) {
	var left = parseInt((screen.width - width) / 2);
	var top = parseInt((screen.height - height) / 2);

	var features = "left=" + left + ", top=" + top + ", width=" + width + ", height=" + height;
	features += ", scrollbars=yes, resizable=yes";
	window.open(url, name, features);
}

function win_open_scroll(url, winW, winH) {

    var mTop = (screen.height / 2) - (winH / 2);
    var mLeft = (screen.width / 2) - (winW / 2);

    str = "'fullscreen=no, scrollbars=yes, resizable=no, width=" + winW + ", height=" + winH + ", top=" + mTop + ", left=" + mLeft + "'";

    window.open(url,"winname", str);
}


function pop_zipcode(TYPE) {
    var width = 350;
	var height = 237;
	var url = "/popzipcode/pop_code.php?TYPE=" + TYPE;
	var name = "pop_code";

	// window_open(url, name, width, height);
	window_open_scroll(url, name, width, height);
}

function go_search(f)
{
	
  if (!f.KEYWORD.value)
  {
    alert('검색어를 입력하세요');
    f.KEYWORD.focus();
    return false;
  }
  f.action =  "search_" + f.SEARCHTYPE.value + ".php";

//  return true;
}

function new_go_search(f)
{
	
  if (!f.KEYWORD.value)
  {
    alert('검색어를 입력하세요');
    f.KEYWORD.focus();
    return false;
  }
  f.action =  "search_total.php";

//  return true;
}


// XMLHttpRequest 관련 시작
var req;

function loadXMLDoc(url) {
	req = false;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        }
        catch(e) {
			req = false;
        }
    }
    // branch for IE/Windows ActiveX version
    else if (window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	}
      	catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	}
        	catch(e) {
          		req = false;
        	}
		}
    }
	if (req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
		req.send("");
	}
}
function loadXMLDoc_for_calendar(url) {
	req = false;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        }
        catch(e) {
			req = false;
        }
    }
    // branch for IE/Windows ActiveX version
    else if (window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	}
      	catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	}
        	catch(e) {
          		req = false;
        	}
		}
    }
	if (req) {
		req.onreadystatechange = processReqChange_for_calendar;
		req.open("GET", url, true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
		req.send("");
	}
}
function loadXMLDocPost(url, queryString) {
	req = false;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        }
        catch(e) {
			req = false;
        }
    }
    // branch for IE/Windows ActiveX version
    else if (window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	}
      	catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	}
        	catch(e) {
          		req = false;
        	}
		}
    }
	if (req) {
		req.open("POST", url, true);
		req.onreadystatechange = processReqChange;
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; Charset=utf-8");
        //req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(queryString);
	}
}

var debug_mode = false;

function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (debug_mode)
        {
           document.write(req.responseText);
        }

        eval (req.responseText);

    }
}
function processReqChange_for_calendar() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (debug_mode)
        {
           document.write(req.responseText);
        }

        eval (req.responseText);

    }
}
function mov(src,w,h,vol,scon){
	html = '';

	//showcontrols
	if(scon == "") {
		scon = "true";
	}	else {
		scon = "false";
	}

	//width
	if(w == "") {
		w = '';
	}	else {
		w = '" width="'+w+'"';
	}

	//height
	if(h == "") {
		h = '';
	}	else {
		h = '" height="'+h+'"';
	}

	//volume
	if(vol == "") {
		vol = '';
	}	else {
		vol = '" volume="'+vol+'"';
	}

	html = '<embed src="'+src+'" showcontrols="'+scon+'" autostart="true" enablecontextmenu="false" '+w+' '+h+' '+vol+'></embed>';
	document.write(html);
}
function setEmbed()
{
  var obj = new String;
  var parameter = new String;
  var embed = new String;
  var html = new String;
  var allParameter = new String;
  var clsid = new String;
  var codebase = new String;
  var pluginspace = new String;
  var embedType = new String;
  var src = new String;
  var width = new String;
  var height = new String;


  this.init = function( getType , s ,w , h ) {

      if ( getType == "flash")
      {

        clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
        pluginspage = "http://www.macromedia.com/go/getflashplayer";
        embedType = "application/x-shockwave-flash";
      }
      else if ("moviethumnail")
      {
        clsid = "EBE61D01-76D5-479A-8318-9492887EECFA";
        codebase = "/js/editor/PlayEditor.cab#version=1,0,0,4";
		pluginspage = "";
        embedType = "";
      }

      parameter += "<param name='movie' value='"+ s + "'>\n";
      parameter += "<param name='quality' value='high'>\n";

      src = s;
      width = w;
      height = h;
  }

  this.parameter = function( parm , value ) {
      parameter += "<param name='"+parm +"' value='"+ value + "'>\n";
      allParameter += " "+parm + "='"+ value+"'";
  }

  this.show = function() {
      if ( clsid )
      {
        obj = "<object classid=\"clsid:"+ clsid +"\" codebase=\""+ codebase +"\" width='"+ width +"' height='"+ height +"'>\n";
      }

      embed = "<embed src='" + src + "' pluginspage='"+ pluginspage + "' type='"+ embedType + "' width='"+ width + "' height='"+ height +"'"+ allParameter +" ></embed>\n";

      if ( obj )
      {
        embed += "</object>\n";
      }

      html = obj + parameter + embed;

      document.write( html );
  }

}

function setEmbed2()
{
  var obj = new String;
  var parameter = new String;
  var embed = new String;
  var html = new String;
  var allParameter = new String;
  var clsid = new String;
  var codebase = new String;
  var pluginspace = new String;
  var embedType = new String;
  var src = new String;
  var width = new String;
  var height = new String;


  this.init = function( getType , s ,w , h ) {

      if ( getType == "flash")
      {

        clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
        pluginspage = "http://www.macromedia.com/go/getflashplayer";
        embedType = "application/x-shockwave-flash";
      }
      else if ("moviethumnail")
      {
        clsid = "EBE61D01-76D5-479A-8318-9492887EECFA";
        codebase = "/js/editor/PlayEditor.cab#version=1,0,0,4";
		pluginspage = "";
        embedType = "";
      }

      //parameter += "<param name='movie' value='"+ s + "'>\n";
      //parameter += "<param name='quality' value='high'>\n";

      src = s;
      width = w;
      Height = h;
  }

  this.parameter = function( parm , value ) {
      parameter += "<param name='"+parm +"' value='"+ value + "'>\n";
      allParameter += " "+parm + "='"+ value+"'";
  }

  this.show = function() {
      if ( clsid )
      {
        obj = "<object id=\"" + src + "\" classid=\"clsid:"+ clsid +"\" codebase=\""+ codebase +"\" width='"+ width +"' height='"+ height +"'>\n";
      }

      embed = "<embed src='" + src + "' pluginspage='"+ pluginspage + "' type='"+ embedType + "' width='"+ width + "' height='"+ height +"'"+ allParameter +" ></embed>\n";

      if ( obj )
      {
        embed += "</object>\n";
      }

      html = obj + parameter + embed;

      document.write( html );
  }

}



function setEmbed_ImageEditor()
{

  var obj = new String;
  var parameter = new String;
  var embed = new String;
  var html = new String;
  var allParameter = new String;
  var clsid = new String;
  var codebase = new String;
  var pluginspace = new String;
  var embedType = new String;
  var src = new String;
  var width = new String;
  var height = new String;


  this.init = function( getType , s ,w , h ) {

      if ( getType == "flash")
      {

        clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
        pluginspage = "http://www.macromedia.com/go/getflashplayer";
        embedType = "application/x-shockwave-flash";
      }
      else if ("ImageEditor")
      {
        clsid = "A55DFE67-3E78-4611-8FB9-383B3A9F13B8";
        codebase = "/js/ImageEditorControl.cab#version=1,0,2,11";
		pluginspage = "";
        embedType = "";
      }

      //parameter += "<param name='movie' value='"+ s + "'>\n";
      //parameter += "<param name='quality' value='high'>\n";

      src = s;
      width = w;
      height = h;
  }

  this.parameter = function( parm , value ) {
      parameter += "<param name='"+parm +"' value='"+ value + "'>\n";
      allParameter += " "+parm + "='"+ value+"'";
  }

  this.show = function() {
      if ( clsid )
      {
        obj = "<object name=\"" + src + "\" id=\"" + src + "\" classid=\"clsid:"+ clsid +"\" codebase=\""+ codebase +"\" width='"+ width +"' height='"+ height +"'>\n";
      }

      embed = "<embed src='" + src + "' pluginspage='"+ pluginspage + "' type='"+ embedType + "' width='"+ width + "' height='"+ height +"'"+ allParameter +" ></embed>\n";

      if ( obj )
      {
        embed += "</object>\n";
      }

      html = obj + parameter + embed;

      document.write( html );
  }

}

function getCookieNR(name)
{
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length ) {
							var y = (x+nameOfCookie.length);
 					if ( document.cookie.substring( x, y ) == nameOfCookie ) {
					 if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) {
						endOfCookie = document.cookie.length;
					 }
					 return unescape( document.cookie.substring( y, endOfCookie ) );
				}
				x = document.cookie.indexOf( " ", x ) + 1;
				if ( x == 0 ) {
					 break;
				}
		}
		return "";

}
function clear_background(f)
{
  f.style.background = "";
}

function login_process(form) {
    if (form.id.value == "") {
        alert("아이디를 입력하세요.");
        form.id.focus();
        return false;
    }
    if (form.pass.value == "") {
        alert("비밀번호를 입력하세요.");
        form.pass.focus();
        return false;
    }
}

function pop_id() {
	var width = 350;
	var height = 255;

	var url = "/user/pop_idsearch.php";
	var name = "pop_idsearch";

	window_open(url, name, width, height);
}

function pop_pw() {
	var width = 350;
	var height = 312;

	var url = "/user/pop_pwsearch.php";
	var name = "pop_pwsearch";

	window_open(url, name, width, height);
}

function friend_group(layernum) {
	//form = document.friendgroup_form;

	//document.getElementById("group_layer" + (parseInt(count) + 1)).style.display = "";
	if(document.getElementById("group_layer" + parseInt(layernum)).style.display == "none")
		document.getElementById("group_layer" + parseInt(layernum)).style.display = "";
	else
		document.getElementById("group_layer" + parseInt(layernum)).style.display = "none";

}

function go_search(f)
{
  if (!f.KEYWORD.value)
  {
    alert('검색어를 입력하세요');
    f.KEYWORD.focus();
    return false;
  }
  f.action =  "search_" + f.SEARCHTYPE.value + ".php";

//  return true;
}
function pop_event()
{
	window.open('/event/event_pop.php', 'eventpopup', 'width=400 height=220 scrollbars=no');
}
