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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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];}
}

////////////////////////////////////////////////////////////////////////////////////
//
//	¹ÙÀÌÆ®¼ö Ã¼Å©
//
////////////////////////////////////////////////////////////////////////////////////
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;
}


////////////////////////////////////////////////////////////////////////////////////
//
//	ÆäÀÌÁö ÀüÃ¼ ÀÌ¹ÌÁö ¸®»çÀÌÁî & º¸Á¤
//
////////////////////////////////////////////////////////////////////////////////////
function autosize() {

	for (i = 0; i < document.images.length; i++) {
		obj = document.images[i];
		pr = obj.parentNode;
		prsize = obj.offsetWidth;
		prsize = 600;

		if (pr.offsetWidth && obj.alt == "zardsama.net") {
			if (obj.width > prsize){
				obj.width = prsize;
				obj.filename = obj.src;

				allowExt = /jpg|png|gif/i;
				if (allowExt.test (obj.src)) obj.src = "/inc/img_gdresize.php?filename="+obj.src+"&width="+obj.width;
			}

			obj.onclick = function() { pview(this); }
			obj.style.cursor = "pointer";
		}
	}
}


////////////////////////////////////////////////////////////////////////////////////
//
//	Use Ajax
//
////////////////////////////////////////////////////////////////////////////////////
function getHttpRequest(URL) { 
	
	nochache = new Date();

	URL = URL+"&ncache="+nochache;

	var xmlhttp = null; 
	
	if(window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
	else 	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

	xmlhttp.open('GET', URL, false); 

	// °ªÀ» °¡Á® ¿ÔÀ»°æ¿ì È£ÃâÇÒ ¸Þ¼Òµå¸¦ ¹Ù·Î ¼±¾ð 
	xmlhttp.onreadystatechange = function() { 

		if(xmlhttp.readyState==4 && xmlhttp.status == 200 && xmlhttp.statusText=='OK') { // readyState °¡ 4 °í status °¡ 200 ÀÏ °æ¿ì ¿Ã¹Ù¸£°Ô °¡Á®¿È 
			responseText = xmlhttp.responseText; 
		} 
	} 
	xmlhttp.send(''); 

	return responseText = xmlhttp.responseText; 
} 


////////////////////////////////////////////////////////////////////////////////////
//
//	Iframe auto resize
//
////////////////////////////////////////////////////////////////////////////////////
function fr_resize(frm){
	fn = eval(frm.name);
	frm.style.height = fn.document.body.scrollHeight + 25;
}

function show(rep){
	if (rep.style.display == "block") {
		 rep.style.display = "none";
	} else{
		rep.style.display = "block";
	}
}

function f_check(f,mode){
	var msg = "";
	for(i = 0; i < f.length; i++){
		fe = f.elements[i];
		if (fe.title && !fe.limit){
			if (fe.maxbytes && fe.value.bytes() > fe.maxbytes) msg = fe.titie + " ÇÑ±Û "+fe.maxbytes/2+"ÀÚ ÀÌÇÏ, È¤Àº ¿µ¹® "+fe.maxbytes+"ÀÚ ÀÌÇÏ·Î ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À";
			if (fe.minbytes && fe.value.bytes() < fe.minbytes) msg = fe.title + " ÇÑ±Û "+fe.minbytes/2+"ÀÚ ÀÌ»ó, È¤Àº ¿µ¹® "+fe.minbytes+"ÀÚ ÀÌ»óÀ¸·Î ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À";
			if (!fe.value.length) msg = fe.title;
			if (msg)	{
				window.alert (msg);
				if (fe.style.display != "none") fe.focus();
				return false;
			}
		}
	}

	if (!msg && mode != 1) {
		inputs = document.getElementsByTagName("INPUT");
		for(i = 0; i < inputs.length; i++){
				fe = inputs[i];
				if ((fe.type == "submit" || fe.type == "image") && fe.form == f) {
					fe.style.visibility = "hidden";
				}
		}
	}
}

function colourOn(obj, code) {
	if (code) obj.style.backgroundColor = code;
	else obj.style.backgroundColor = "";
}

function pview(obj) {
	filename = (obj.filename) ? obj.filename : obj.src;

	var browser = navigator.appName;

	explorer = browser.indexOf("Explorer");

	if (explorer > 0) window.showModalDialog ("/inc/image_viewer.php?filename="+filename,self, "center:true;resizable:no;scroll:no;status:no");
	else window.open ("/inc/image_viewer.php?filename="+filename, "imageView","menubar=no scrollbars=no statusbar=no toolbar=no resizable=no");
}

function load_modal_window(file,arg,width,height){
	a = window.showModalDialog(file,arg,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:true;resizable:no;scroll:no;status:no");
	return false;
}


function confirmid () { // ¾ÆÀÌµð Áßº¹°Ë»ç

	logid = document.getElementsByName ("log_id")[0];
	val = getHttpRequest ("/member/idcheck.php?log_id="+logid.value);

	if ( !logid.value ) {
		window.alert ("Áßº¹È®ÀÎÇÒ ¾ÆÀÌµð¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À");
		logid.focus();
		return;
	}

	if (!val) {
		conf = confirm ("["+logid.value+"]\n\n»ç¿ëÇÏ½Ç¼ö ÀÖ´Â ¾ÆÀÌµð ÀÔ´Ï´Ù\nÀÌ ¾ÆÀÌµð¸¦ »ç¿ëÇÏ½Ã°Ú½À´Ï±î?");
		if (conf == false) logid.value = "";
	} else {
		window.alert ("["+logid.value+"]\n\n»ç¿ëÇÏ½Ç¼ö ¾ø´Â ¾ÆÀÌµð ÀÔ´Ï´Ù");
		logid.value = "";
	}

}

function query(msg){ // Query
	if (!msg) msg = "Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?";

	conf = confirm (msg);
	if (!conf) return false;
}

function loginplz() {

	window.alert ("·Î±×ÀÎ ÇØÁÖ¼¼¿ä!");

}