// ÅÇ Å¬¸¯
function goTabClick(linkObj, tab) {
	var q = document.search.query.value;
	linkObj.href = if_url+"?where="+tab+"&query="+q+"&s=w";
	document.location.href = linkObj.href;
}

// À½¾Ç µè±â
function open_music(uid) {
	hompy = window.open('http://www.zagia.com/music/play.php?song_uid='+uid ,'music','height=538,width=932,scrollbars=no,resizable=yes');
	return false;
}

// ÀÌ¹ÌÁö Å©±â Á¶Àý
function limit_imgsize(imgname,w,h) {
	var img = document.images[imgname];
	if (w ==null) w = 110;
	if (h ==null) h = 110;
	if (img.height == 0) {
		setTimeout("limit_imgsize('"+imgname+"',"+w+","+h+");",100)
	} else {
		if (img.width >= w) {
			img.height=img.height*w/img.width;
			img.width=w;
		}
		if (img.height >= h) {
			img.width=img.width*h/img.height;
			img.height=h;
		}
	}
}

// ÀÌ¹ÌÁö ¿¡·¯
function noImage(o) {
	o.src='zmse2_image/img_none.gif';
	o.onerror=null;
	return;
}

// ¼³Á¤ ÆäÀÌÁö »õÃ¢ ¿­±â
function open_newwin(idx) {
	newwin = window.open('./search_setup.php?idx='+idx ,'setup','height=470,width=416,scrollbars=no,resizable=yes');
	newwin.focus();
	return false;
}

// ºÏ¸¶Å© ÆäÀÌÁö »õÃ¢ ¿­±â
function open_bookmark() {
	newwin2 = window.open('./search_bookmark.php' ,'bookmark','height=385,width=340,scrollbars=yes,resizable=yes');
	newwin2.focus();
	return false;
}

// XML °´Ã¼ »ý¼º
function getXmlHttpObject() {
	var request = null;
	try {
		request = new XMLHttpRequest();
	} catch(trymicrosoft) {
		try {
			request = new ActiveXObject("Msxml12.XMLHTTP");
		} catch(othermicrosoft) {
			try {
				request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(failed) {
				request = null;
			}
		}
	}
	if(request == null) {
		alert("Error creating request object!");
	} else {
		return request;
	}
}

// XML µ¥ÀÌÅÍ °¡Á®¿À±â
function getContent(url) {
	xmlHttp = getXmlHttpObject();
	xmlHttp.open('GET',url,false);
	xmlHttp.send(null);
	return xmlHttp.responseText;
}

// ºÏ¸¶Å© ¹öÆ° º¸±â
function viewBookmarkBtn(mode, idx) {
	var d = document.getElementById("bookmark_btn_"+idx);
	if (!d) return false;
	if(mode == "show") {
		d.style.display = "";
	} else {
		d.style.display = "none";
	}
	return false;
}

// ºÏ¸¶Å© Ãß°¡
function addBookmark(title, link) {
	var url = "_zmse2SkinBookmark.php?mode=add&title=" + encodeURIComponent(title) + "&link=" + encodeURIComponent(link) +"&if_query=" + encodeURIComponent(if_query);
	var data = decodeURIComponent(getContent(url));
	document.all.bookmark2.innerHTML=data;
	alert(title+' ºÏ¸¶Å© Ãß°¡!');
	return false ;
}

// ºÏ¸¶Å© »èÁ¦
function deleteBookmark(idx) {
	var url = "_zmse2SkinBookmark.php?mode=del&idx=" + encodeURIComponent(idx);
	var data = decodeURIComponent(getContent(url));
	document.all.bookmark2.innerHTML=data;
	return false ;
}

// ÄíÅ° ¼³Á¤
function setCookie(name, value, expiredays) {
	var today = new Date();
	today.setDate(today.getDate() + expiredays);
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + today.toGMTString() + ";";
}

// ÄíÅ° ÃßÃâ
function getCookie(name) {
	cookie = document.cookie;
	name = name + "=";
	idx = cookie.indexOf(name);
	if(cookie && idx >= 0) {
		tmp = cookie.substring(idx, cookie.length);
		deli = tmp.indexOf(";");
		if(deli > 0) {
			return unescape(tmp.substring(name.length, deli));
		} else {
			return unescape(tmp.substring(name.length));
		}
	}
}

// °´Ã¼ ¾ò±â
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); // IE4¿Í 5.0 
	}else if (document.layers && document.layers[objectId]){ 
		return document.layers[objectId];  // Netscape 4.x 
	}else{ 
		return false; 
	} 
}

// ÅÇ ¸Þ´º ÀÌ¹ÌÁö º¯°æ
function changeTabMenu(idx) {
	var sel = getObject(""+ idx +"");
	if(sel.parentNode.className == "") {
		sel.parentNode.className = "menu_on";
	} else {
		sel.parentNode.className += "menu_on";
	}
	var selSpan = sel.getElementsByTagName("span")[0];
	selSpan.innerHTML = "<strong>" + selSpan.innerHTML + "</strong>";
}

// ÅÇ ¸Þ´º ÀÌ¹ÌÁö º¯°æ2
function changeTabOut(idx,ov) {
	if(ov == "o") {
		try{getObject("tblit_"+ (idx-1) +"").style.visibility = "hidden";} catch(e){}
		try{getObject("tblit_"+ idx +"").style.visibility = "hidden";} catch(e){}
	} else {
		try{getObject("tblit_"+ (idx-1) +"").style.visibility = "";} catch(e){}
		try{getObject("tblit_"+ idx +"").style.visibility = "";} catch(e){}
	}
}