<!--//

function OpenWin(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
	if ((obj=MM_findObj(args[i]))!=null)
	{
		v=args[i+2];
		if (obj.style)
		{
			obj=obj.style;
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
		}
		obj.visibility=v;
	}
}

function MM_selectedLayers() { //v3.0
  var i,p,v,obj,args=MM_selectedLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
	if ((obj=MM_findObj(args[i]))!=null)
	{
		v=args[i+2];
		if (obj.style)
		{
			obj=obj.style;
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
		}
		obj.visibility=v;
	}

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0 
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getObj(obj) { 
     compLayr = eval("document.all." + obj + ".style") 
     return compLayr 
}

function showHide(name){ 
   obj = getObj(name) ;
	   
   if (obj.visibility=="hidden"){ 
		obj.visibility = "visible" ;
   } else {
	   obj.visibility = "hidden" ;
   } 
}

function rankInfo() {
         window.open('http://www.buyking.com/ranking/rankinfo','new','scrollbars=yes,width=640,height=500');
}

function productOpen() {
         window.open('http://www.buyking.com/productOpen','new','scrollbars=yes,width=600,height=500');
}

function tagHelp() {
         window.open('http://www.buyking.com/tag_help','new','resizable=yes,width=520,height=320');
}

function helpPoint() {
         window.open('http://www.buyking.com/level_help','new','resizable=yes,width=530,height=370');
}

function openWindow(url,name,width,height,top,left) {
	popupWin=window.open(url, name, "scrollbars=yes,resizable=no,width="+width+",height="+height+",top="+top+",left="+left);
}

function userProfile(user){
          openWindow('http://www.buyking.com/myBuyking/myPop?user='+user,'',450,400,100,200);
}

function addBookmark(url){ 
    window.external.AddFavorite(url, '»óÇ°Á¤º¸ ¹Ìµð¾î, ¹ÙÀÌÅ· ´º½º - »óÇ°À» ÅëÇØ ¼¼»óÀ» º»´Ù¢â') 
}

function safeNavigate(url){
    document.location.href = url;
}

function addImageLink(url, cmf, name){
    if(!name) name = 'channel'
    page = 'http://www.buyking.com/' + name + '_wizard'
    if(url && cmf) page += '?remote_url=' + escape(url) + '&cmf='+cmf;

    openWindow(page,'cwizard',500,700,0,800);
}

function createAjaxObj(){
    var httprequest=false
    if (window.XMLHttpRequest){ // if Mozilla, Safari etc
        httprequest=new XMLHttpRequest()
        if (httprequest.overrideMimeType)
            httprequest.overrideMimeType('text/xml')
    }
    else if (window.ActiveXObject){ // if IE
        try {
            httprequest=new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e){
            try{
                httprequest=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e){}
        }
    }
    return httprequest
}

function goPrint(curl, tp){
    var sWinName = "printarticle";
    var sWinopts = 'left=0,top=0,width=750,scrollbars=1,resizable=1';
    target = curl + '/printNews';
    window.open(target,sWinName,sWinopts);
}
function sendEmail(curl, tp){
    var sWinName = "emel";
    var sWinopts = 'scrollbars=no,resizable=no,width=540,height=490';
    target = curl + '/sendFriends';
    window.open(target,sWinName,sWinopts);	
}

function loginform_clearbg(type) {
    if (type == "id") {
        document.frmLogin.__ac_name.style.backgroundImage = '';
    } else if (type == "pw") {
        document.frmLogin.__ac_password.style.backgroundImage = '';
    }
}

function pwd_lost() {
    window.open("http://www.buyking.com/lost_idpwd_form", "win", "width=500,height=350");
}

var menuLoader;

function showContextMenu(url){
  if(menuLoader){
    displayContextMenu();
  }else{
      menuLoader=createAjaxObj();
      var url=url+'/context_menu_data';
      menuLoader.onreadystatechange=function(){renderContextMenu()}
      menuLoader.open('GET', url, true)
      menuLoader.send(null)
  }
}

function renderContextMenu(){
    if (menuLoader.readyState == 4) {
        if (menuLoader.status == 200) {
            document.getElementById('pContextMenu').innerHTML = menuLoader.responseText;
            displayContextMenu();
       } else {
          alert('¿äÃ»À» Ã³¸®ÇÏ´Âµ¥ ¹®Á¦°¡ ÀÖ½À´Ï´Ù.');
       }
    }
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function popUpProperties(inobj) {
	op = window.open();
	op.document.open('text/plain');
	for (objprop in inobj) {
	op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
	}
	op.document.close();
}


function displayContextMenu(){
  var headbox = document.getElementById('headbox');
  var obj = document.getElementById('pContextMenu').style;
  obj.top = '3px';
  obj.width = '200px';
  if (document.all){
    obj.left = headbox.offsetLeft + headbox.offsetWidth + 'px';
  }else{
    obj.left = parseInt((headbox.offsetWidth - headbox.width) / 2) + parseInt(headbox.width) + 10;
  }
  obj.visibility='visible';
}

function hideContextMenu(){
  document.getElementById('pContextMenu').style.visibility='hidden';
}

function getObject(objectId) { 
	// checkW3C DOM, then MSIE 4, then NN 4. 
	if(document.getElementById && document.getElementById(objectId)) { 
		return document.getElementById(objectId); 
	} else if (document.all && document.all(objectId)) { 
		return document.all(objectId); 
	} else if (document.layers && document.layers[objectId]) { 
		return document.layers[objectId]; 
	} else { 
		return false; 
	} 
}

function popup_init(dbg) {
	var g_fIsSP2 = false;
	g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
	heightPadding = 70;
	//if (g_fIsSP2) heightPadding = 61;  // XP ºê¶ó¿ìÀú

	try {
		var el = getObject("popup");
		if( el ){
			self.resizeTo(el.offsetWidth+10, el.offsetHeight+heightPadding);
			if(typeof(dbg)!="undefined" && dbg)
				alert((el.offsetWidth+10)+","+(height));
		} else {
			el = document.getElementsByTagName("TABLE")[0];
			self.resizeTo(el.offsetWidth+10, el.offsetHeight+heightPadding);
		}
	} catch(e) {
		alert(e.message);
	}
}
//-->


