//##############################################################################
// ÀÌ¹ÌÁö + ·¹ÀÌ¾î °ü·Ã Function (¼öÁ¤±ÝÁö)
//##############################################################################

// ·¹ÀÌ¾î ¿©´ÝÀ½ ½ºÅ©¸³Æ®
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_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_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_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 na_preload_img(){
	var img_list = na_preload_img.arguments;
	if (document.preloadlist == null)
		document.preloadlist = new Array();
	var top = document.preloadlist.length;
	for (var i=0; i < img_list.length; i++) {
		document.preloadlist[top+i]     = new Image;
		document.preloadlist[top+i].src = img_list[i+1];
	}
}

// ÀÌ¹ÌÁö ¿ø·¡´ë·Î µ¹·Á³õ±â (³Ý½ºÄÉÀÌÇÁ)
function na_restore_img_src(name, nsdoc){
	var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	if (name == '')
		return;
	if (img && img.altsrc) {
		img.src    = img.altsrc;
		img.altsrc = null;
	}
}

// ÀÌ¹ÌÁö ¹Ù²Ù±â (³Ý½ºÄÉÀÌÇÁ)
function na_change_img_src(name, nsdoc, rpath, preload){
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
  	return;
  if (img) {
  	img.altsrc = img.src;
  	img.src    = rpath;
  }
}

//##############################################################################
// Active X °ü·Ã IE ¼³°èº¯°æ (¼öÁ¤±ÝÁö)
//##############################################################################

// ÅÂ±×¸¦ ÀÔ·Â ¹Þ¾Æ¼­ Á÷Á¢ Ãâ·Â
function docwrite(str) {
	document.write(str);
}

// ÇÃ·¡½Ã Ãâ·Â ÇÔ¼ö : ¾ÆÀÌµð,URL,Æø,³ôÀÌ¸¸ ÀÔ·Â¹Þ¾Æ¼­ Ãâ·Â
// »ç¿ë¹ý : <script language="javascript">FlashCommon("idF1","main_flash.swf","370","236");</script>
function FlashCommon( id, ObjUri, vWidth, vHeight ) {
	var str = "";
	str  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	str += '<param name="movie" value="' + ObjUri + '">';
	str += '<param name="quality" value="high">';
	str += '<param name="AllowScriptAccess" value="always">';
	str += '<param name="wmode" value="transparent">';
	str += '<embed src="' + ObjUri + '" quality="high" wmode="transparent" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent"></embed>';
	str += '</object>';
	document.writeln(str);
}

// flash 
function FlashCommon_navi( id, ObjUri, vWidth, vHeight ) {
	var str = "";
	// È¸¿ø°¡ÀÔÀÇ °æ¿ì httpsÀÌ¹Ç·Î codebaseºÎºÐÀÌ Ãß°¡µÇ¸é º¸¾È°æ°íÃ¢ÀÌ ¶ß¹Ç·Î »«´Ù
	//str  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + vWidth + '" height="' + vHeight + ' id="' + id + '" align="middle">';
	str  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	str += '<param name="movie" value="' + ObjUri + '">';
	str += '<param name="quality" value="high">';
	str += '<param name="AllowScriptAccess" value="always">';
	str += '<param name="wmode" value="transparent">';
	str += '<embed src="' + ObjUri + '" quality="high" wmode="transparent" bgcolor="#ffffff" showliveconnect="true" width="' + vWidth + '" height="100%" id="' + id + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	str += '</object>';
	//document.writeln(str);
	return str;
}

// flash ie6
function FlashCommon_ie6( id, ObjUri, vWidth, vHeight ) {
	var str = "";
	str  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	str += '<param name="movie" value="' + ObjUri + '">';
	str += '<param name="quality" value="high">';
	str += '<param name="AllowScriptAccess" value="always">';
	str += '<param name="wmode" value="transparent">';
	str += '<embed src="' + ObjUri + '" quality="high" wmode="transparent" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent"></embed>';
	str += '</object>';
	//document.writeln(str);
	return str;
}


// ¹Ìµð¾î Ãâ·Â ÇÔ¼ö : ¾ÆÀÌµð,URL,Æø,³ôÀÌ¸¸ ÀÔ·Â¹Þ¾Æ¼­ Ãâ·Â
// »ç¿ë¹ý : <script language="javascript">MediaCommon("idM1","movie.wmv","320","240");</script>
function MediaCommon( id, ObjUri, vWidth, vHeight ) {
	var str = "";
	str  = '<EMBED id="' + id + '" src="' + ObjUri + '" width="' + vWidth + '" height="' + vHeight + '">';
	document.writeln(str);
}

//##############################################################################
// ¸µÅ© °ü·Ã °øÅë Function
//##############################################################################

// ¸µÅ© Á¡¼± °¨Ãß±â
function bluring(){
  if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG")
  document.body.focus();
}
document.onfocusin=bluring;

// ½ºÅ©·Ñ¾÷ : ±âº»
function GoTop() {
  window.scrollTo(0,0);
}
// ½ºÅ©·Ñ¾÷ : ´õºíÅ¬¸¯
function GoTop_Call() {
  document.body.ondblclick = Top;
}

//##############################################################################
// À©µµ¿ì ¿­±â ¹× ÆË¾÷Ã¢ °ü·Ã Function
//##############################################################################

// ÄíÅ°°ª ÃßÃâÇÏ±â (¼öÁ¤±ÝÁö)
function getCookie(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 setCookie(name, value, expiredays) {
  var todayDate = new Date();
  todayDate.setDate(todayDate.getDate() + expiredays);
  document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
  //document.cookie = name + "=" + escape(value) + "; domain=tt.co.kr; path=/; expires=" + todayDate.toGMTString() + ";"
}

// ÆË¾÷Ã¢ ¿­±â : ÆË¾÷Ã¢ È®ÀÎ ÄíÅ°°¡ ¼³Á¤µÈ °æ¿ì´Â ¶ç¿ìÁö ¾Ê´Â´Ù.
function openPopupWindow(url, cookiename, width, height){
  if (getCookie(cookiename) != "done"){
    popWin = window.open(url, '', "toolbar=no,location=no,directories=no,status=1,menubar=no,scrollbars=no,resizable=no,width="+width+",height="+height+",top=0,left=0");
    popWin.focus();
  }
}

// ÆË¾÷Ã¢ ¿­±â : ÀÀ¿ë
function openPopupWindow2(url, cookiename, width, height, top, left){
  if (getCookie(cookiename) != "done")
  {
    popWin = window.open(url, '', "toolbar=no,location=no,directories=no,status=1,menubar=no,scrollbars=no,resizable=no,width="+width+",height="+height+",top="+top+",left="+left);
    popWin.focus();
  }
}

// ÆË¾÷Ã¢ ´Ý±â (1) : Ã¼Å© »óÅÂ¿¡ µû¶ó¼­ ÆË¾÷Ã¢À» ¶ç¿ìÁö ¾Êµµ·Ï ÄíÅ°¸¦ ¼³Á¤ÇÑ´Ù.
function closeWin(cookiename){
  if (document.forms[0].NeverMind.checked){
    setCookie(cookiename, "done", 1);
  }
  self.close();
}

// ÆË¾÷Ã¢ ´Ý±â (2) : ÇÏ·ç µ¿¾È ÀÌº¥Æ® ÆË¾÷Ã¢À» ¶ç¿ìÁö ¾Êµµ·Ï ÄíÅ°¸¦ ¼³Á¤ÇÑ´Ù.
function closePopupWindow(cookiename) {
  setCookie(cookiename, "done", 1);
  self.close();
}

// ÆË¾÷Ã¢ ´Ý±â (3) : ÁöÁ¤µÈ ÀÌº¥Æ® ÆäÀÌÁö·Î ÀÌµ¿ÇÑ´Ù.
function goEvnetPage(url) {
  opener.top.location=url;
  self.close();
}

// ÆË¾÷Ã¢ ´Ý±â (4) : ÁöÁ¤µÈ ÀÌº¥Æ® ÆäÀÌÁö·Î ÀÌµ¿ÇÑ´Ù.
function goEvnetPage2(url) {
  self.close();
  window.open(url, '', '');
}

// ÆË¾÷Ã¢ ¿ÀÇÂ : ±âº»
function MM_openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);
}

//##############################################################################
//  °øÅë¸µÅ© : Main Navigation Bar
//##############################################################################

// ¿À´Ã°ú³»ÀÏ °Ô½ÃÆÇ °Ë»ö
function tt_search(form) {
  if(form.select.options[form.select.selectedIndex].value != '') {
    if(form.select.options[form.select.selectedIndex].value == 'http://tt.co.kr:8080/apply01_2003/agreement.html') {
      window.open(form.select.options[form.select.selectedIndex].value, 'agreement','scrollbars=1,width=450,height=400,top=0,left=0') ;
      return false;
    }
    if(form.select.options[form.select.selectedIndex].value == 'http://ttpia.com/service/s_index.php' || form.select.options[form.select.selectedIndex].value == 'http://ttstreaming.com'){
      window.open(form.select.options[form.select.selectedIndex].value, '','scrollbars=1,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,top=0,left=0') ;
    }
    else
      location = form.select.options[form.select.selectedIndex].value ;
  }
  else {
  }
}

// ÆË¾÷Ã¢ ¿ÀÇÂ : ¿µÈ­½Ã»çÈ¸ Àü¿ë
function goPop(code){
	window.open('https://domain.tt.co.kr:8080/mytt/event/event_app.php?f_code='+code,'','width=470,height=600,left=0,top=0');
	window.close();
}

//##############################################################################
//  °øÅë¸µÅ© : Side Navigation Bar
//##############################################################################

// ³×ÀÓ¼­¹ö Å¬¸³º¸µå ÀúÀåÇÏ±â
function CtrlV(CVMessage, CVType){
	window.clipboardData.setData('Text', CVMessage);
	var message = "'" + CVMessage + "' ÀÌ Å¬¸³º¸µå¿¡ ÀÓ½ÃÀúÀåµÇ¾ú½À´Ï´Ù.\n\nÀÔ·ÂÇÏ½Ç °÷¿¡ 'Ctrl+V' ·Î ÆíÇÏ°Ô ºÙ¿©³ÖÀ¸¼¼¿ä.";
	if (CVType == "host")
		msg = "HOST Name " + message;
	else if (CVType == "ip")
		msg = "IP Address " + message;
	alert(msg);
}

// °í°´Áö¿ø : 1:1°í°´»ó´ã
function one2oneCounsel(){
  location.href = "http://domain.tt.co.kr:8080/cs/cs.php?cmd=write&type=counsel";
  //parent.location.href = "http://tt.co.kr/cs/counsel/question.php";
}
function CSanything(){
  parent.location.href = "http://tt.co.kr/tt/site/ttboard.cgi?db=help_anything";
}
function CSone2one(){
  parent.location.href = "http://support.tt.co.kr/qna.php";
}
function CSone2onemall(){
  parent.location.href = "http://support.tt.co.kr/qna.php";
}
function CSnumber(){
  window.open('http://support.tt.co.kr/info/cs_call.php','','scrollbars=no,status=no,left=0,top=0,width=600,height=575');
}
function CSnumbermall(){
  window.open('http://support.tt.co.kr/info_cs_number_mall.php','','scrollbars=yes,status=no,left=0,top=0,width=617,height=536');
}
function CSaccount(){
  window.open('http://support.tt.co.kr/info_cs_account.php','','scrollbars=no,status=no,left=0,top=0,width=400,height=330');
}
function MallSkin(){
  window.open('http://partner.tt.co.kr/db/site/ttboard.cgi?act=write&db=fancy&s_mode=def&s_cate=1&s_key=1','','scrollbars=no,status=no,left=0,top=0,width=440,height=560');
}
// ¿ø°ÝÁö¿ø
function RemoteConnect() {
	window.open('http://as82.kr/ttcokr', '', 'status=no, scrollbars=no, menubar=no,resizable=no, width=930, height=450');
}
// ¼­¹öÈ£½ºÆÃ ¿Â¶óÀÎ °ßÀû ¹× ¼­ºñ½º½ÅÃ»
function serverApply(){
	window.open('http://domain.tt.co.kr:8080/my/idc/service_apply.php?from=main', '', 'status=no, scrollbars=yes, menubar=no, resizable=no, width=760, height=700, align=center');
}
// È£½ºÆÃ ÄÁ¼³ÆÃ
function HostingConsulting() {
	window.open('http://tt.co.kr/hosting/feature/hosting_consulting_hasdomain.html', '', 'status=no, scrollbars=no, menubar=no,resizable=no, width=420, height=433');
}
// ¿µ¼öÁõ °¨Ãß±â
function change_receipt()
{
  if(document.all['receipt'].style.display=='inline')
  {
  document.all['receipt'].style.display='none';
  }
  else
  document.all['receipt'].style.display='inline';
}

// ÇÃ·¡½Ã ¹è³Ê ·£´ýÀ¸·Î º¸¿©ÁÖ±â
function banner_random2() {
	n = Math.round(Math.random()*2+.5)
	switch(n) {
		case 1:
			document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='230' height='104'>");
			document.write("<param name='movie' value='img_m51213/ba_64bit.swf'>");
			document.write("<param name='quality' value='high'>");
			document.write("<embed src='img_m51213/ba_64bit.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='230' height='104'></embed></object>");
			break;
		case 2:
			document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='230' height='104'>");
			document.write("<param name='movie' value='img_m51213/ba_cdn.swf'>");
			document.write("<param name='quality' value='high'>");
			document.write("<embed src='img_m51213/ba_cdn.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='230' height='104'></embed></object>");
			break;
		default:
			break;
	}
}



//100310 ±è¼±¾ÆÃß°¡ : http://dom.tt.co.kr/domain/reg/requirement.php »ó¼¼º¸±â ·¹ÀÌ¾î ÆË¾÷À» À§ÇØ.. ¹®Á¦ÀÖÀ¸½Ã¸é ¸»¾¸ÇØÁÖ¼¼¿ä 

function popUp(str) {
    //coverDiv¸¦ display:blockÀ¸·Î º¯°æÇØÁà¾ß ÇÕ´Ï´Ù.
    //popUpÀ» °¡¿îµ¥ Á¤·Ä½ÃÅ°±â À§ÇØ ÇöÀç Ã¢ÀÇ Å©±â¸¦ ¾ò¾î¿Í¼­
    //±× ¾ò¾î¿Â Å©±â - 100px / 2¸¦ ÇÕ´Ï´Ù.
    //±×¸®°í ±× ¼ö¸¦ marginTop¿¡ ´ëÀÔ½ÃÅµ´Ï´Ù.
    var height = 0;

    if(window.ActiveXObject) {
        //ÀÎÅÍ³Ý ÀÍ½ºÇÃ·Î·¯¶ó´Â ÀÇ¹Ì
        height = document.documentElement.clientHeight;
    }else {
        //±× ¿Ü ºê¶ó¿ìÁ®
        height = window.innerHeight;
    }

    if(height > 100) {
        height = (height - 100) /2;
    }else {
        height = 0;
    }

    document.getElementById("popUp_"+str).style.marginTop = height + "px";

    document.getElementById("coverDiv_"+str).style.display = "block";

}

function unPopUp() {
    document.getElementById("coverDiv").style.display = "none";
    
}

// ¸¶¿ì½º ÁÂÇ¥¿¡ ·¹ÀÌ¾î ¶ì¿ì±â
function pop_show(e, obj_id)
{
	
	var body = returnBody();
	
	document.getElementById("pop_msg").innerHTML = document.getElementById(obj_id+"_msg").innerHTML;
	//document.getElementById("popUp_"+obj_id).style.left = e.clientX - 3+'px';
	//document.getElementById("popUp_"+obj_id).style.top = e.clientY + body.scrollTop - 3+'px';
	document.getElementById("coverDiv").style.left = e.clientX - 200+'px';
	//document.getElementById("coverDiv").style.right = e.clientX+'px';
	document.getElementById("coverDiv").style.top = e.clientY + body.scrollTop - 3+'px';
	document.getElementById("coverDiv").style.display = "block";
	
	//console.log( document.getElementById('coverDiv_cn').style.display );
	
	//document.getElementById(obj_id).show();
	//chk_layer = 1;
}

// body return
function returnBody(){
	var body;
	
	if(
		navigator.userAgent.toLowerCase().indexOf("chrome") > -1 ||
		navigator.userAgent.toLowerCase().indexOf("safari") > -1
	){
		body = document.body;
	}else{
		body = ietruebody();
	}
	
	return body;
}
