/************************************************
 * createElement - Jquery						*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function loadJquery()
{
	var strJsFile= "/script/jquery.js";
	loadJS(strJsFile);
}
/************************************************
 * createElement - javascript					*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function loadJS(url) { 
	var script = document.createElement('script'); 
	script.type = 'text/javascript'; 
	script.src = url; 
	document.getElementsByTagName('head')[0].appendChild(script); 
}
/************************************************
 * createElement - CSS							*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function loadCSS(url) { 
	var CSS = document.createElement('link'); 
	CSS.type = 'text/css'; 
	CSS.rel = 'stylesheet';
	CSS.href = url; 
	document.getElementsByTagName('head')[0].appendChild(CSS); 
}
/************************************************
 * flash										*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function mFlashWrite(url,w,h,id,bg,win,vars)
{
	var mflashStr=
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
	"<param name='allowFullScreen' value='true' />"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='FlashVars' value='"+vars+"' />"+
	//"<param name='wmode' value='"+win+"' />"+
	"<param name='wmode' value='transparent' />"+
	"<param name='menu' value='false' />"+
	"<param name='quality' value='high' />"+
	"<param name='base' value='.' />"+
	"<param name='bgcolor' value='"+bg+"' />"+
	"<embed src='"+url+"' FlashVars='"+vars+"' base='.' wmode='transparent' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' allowScriptAccess='always'  allowFullScreen='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";
	document.write(mflashStr);
}
/************************************************
 * IE : Flicker Bug								*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function flickerBug()
{
	try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}
}

/************************************************
 * Ajax (page loading)							*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
var showContents = function(url,DIVid) {
  var respond = $(DIVid);
  new Ajax.Request(url, {
	method: 'get', onSuccess: function(req) {
	  respond.innerHTML = req.responseText;
	  historyHandler.add(url);
	  var urlNum = changenum(url);
	}, onFailure: function() {
	  respond.innerHTML = 'respond error';
	}
  });
};
/************************************************
 * Tab											*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function mTab(p,tabNum,loadPagesName,createDIV,changeTab)
{
	showContents(loadPagesName+p+'.html',createDIV);
	//window.scrollTo(0,0);
	for(var i = 1; i <= tabNum ; i++) {
	  eval("$('"+changeTab+i+"')").removeClassName('on');
	}
	$(changeTab+p).addClassName('on');
}
/************************************************
 * getStyle										*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function getStyle(elementID, propertyName)
{
	var element = document.getElementById(elementID);if (element.currentStyle){var propertyValue = element.currentStyle[propertyName];}else if (window.getComputedStyle){var computedStyle = document.defaultView.getComputedStyle(element,null);var propertyValue = computedStyle.getPropertyValue(propertyName);}return propertyValue;
}
/************************************************
 * String										*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
String.prototype.cut = function(len) 
{
 var str = this;
 var l = 0;
 for (var i=0; i<str.length; i++) {
  l += (str.charCodeAt(i) > 128) ? 2 : 1;
  if (l > len) return str.substring(0,i);
 }
 return str;
}
String.prototype.bytes = function() 
{
 var str = this;
 var l = 0;
 for (var i=0; i<str.length; i++) l += (str.charCodeAt(i) > 128) ? 2 : 1;
 return l;
}
/************************************************
 * gnb toggleSearch								*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function toggleSearch() 
{
	var eID = document.getElementById('cat_list');
	var eIDcov = document.getElementById('cat_list_cov');
	if(getStyle('cat_list',"display")=='none'){eID.style.display = eIDcov.style.display = 'block';}
	else{eID.style.display = eIDcov.style.display = 'none';}
}
/************************************************
 * gnb search cat change						*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
function gnbSearch_catchanger(tit, value)
{
	var change = document.getElementById('cat_list');
	var cat_select = document.getElementById('cat');
	var cat_title = document.getElementById('cat_title');
	change.style.display='none';
	cat_select.value = value;
	cat_title.innerHTML= tit+"<img src=\"http://contents.auction.co.kr/images/skin/red/sch_sel_bt.gif\" id=\"sch_sel_bt\" />";
	cat_title.style.backgroundPosition='70px -308px';
}
/************************************************
 * showNicknameMenu								*
 * mgoon										*
 * Date: 										*
 * memo: '유저닉네임 클릭시 뜨는 레이어'				*
 * Rev: 										*
 ************************************************/
 function makeNicknameMenuHTML(member)
{
	strHTML = "<div id='div_test'>"
		 + "레이어띄울곳"
		 + "</div>";
	return strHTML;
}
function showNicknameMenu(e, member)
{
   	objDiv = document.getElementById("bMenu");
	xcoord = mouseX(e) - 10;
	ycoord = mouseY(e) - 10;
	objDiv.style.left = xcoord + "px";
	objDiv.style.top = ycoord + "px";

	objDiv.innerHTML = makeNicknameMenuHTML(member);
	objDiv.style.display = "inline";
}
function mouseX(e) {
   var posx = 0;
   if (!e) var e = window.event;

   if (e.pageX)
   {
      posx = e.pageX;
   }
   else if (e.clientX)
   {
      posx = e.clientX + document.documentElement.scrollLeft;
   }

   return posx;
}
function mouseY(e) {
   var posy = 0;
   if (!e) var e = window.event;
   if (e.pageY) { //FF
      posy = e.pageY;
   }
   else if (e.clientY)   { //IE
      posy = e.clientY + document.documentElement.scrollTop;
   }
   return posy;
}
function show()
{
	objDiv = document.getElementById("bMenu");
	objDiv.style.display = "inline";
}

function hideNicknameMenu()
{
	objDiv = document.getElementById("bMenu");
	objDiv.style.display = "none";
}

/************************************************
 * onload										*
 * gilhyun										*
 * Date: 2009/09								*
 * Rev: 										*
 ************************************************/
window.onload = function ()
{
	//all
	flickerBug();
}