function copyUrl(url) {
	if (copyclipboard(url)){ 
		alert('Å¬¸³º¸µå¿¡ ÁÖ¼Ò°¡ º¹»çµÇ¾ú½À´Ï´Ù.');
	}
}

function copyRSSUrl(url, type) {
	if (copyclipboard(url)) 
	{
		window.clipboardData.setData("Text", url);
		if (type == "cafe"){
			alert('Ä«Æä RSSÁÖ¼Ò°¡ º¹»ç µÇ¾ú½À´Ï´Ù.');
		}else{
			alert('°Ô½ÃÆÇ RSSÁÖ¼Ò°¡ º¹»ç µÇ¾ú½À´Ï´Ù.');
		}
	}
}

function copyclipboard(intext) {
	if (window.clipboardData) {
		window.clipboardData.setData("Text", intext);
			return true;
	}
	alert("ÀÌ ºê¶ó¿ìÀú¿¡¼­´Â ÁÖ¼Ò º¹»ç ±â´ÉÀ» Á¦°øÇÏÁö ¾Ê½À´Ï´Ù.\n¾Æ·¡ ÁÖ¼Ò¸¦ Á÷Á¢ µå·¡±×ÇÏ¿© º¹»çÇØÁÖ¼¼¿ä.\n\n"+intext);
	return false;
}

function selectCheckboxes(combos){
	if(!combos) {
		return;
	}
	
	if(combos.length > 0){
		for(i = 0; i < combos.length; i++)
			combos[i].checked=true;
	}
	else 
		combos.checked=true;

}

function cancelCheckboxes(combos){
	if(!combos) {
		return;
	}
	
	if(combos.length > 0){
		for(i = 0; i < combos.length; i++)
			combos[i].checked = false;
	}
	else 
		combos.checked = false;

}

function toggleCheckboxes(combos) {
	if(!combos) {
		return;
	}

	if(combos.length > 0){
		for(i = 0; i < combos.length; i++)
			combos[i].checked= !combos[i].checked;
	}
	else 
		combos.checked=!combos.checked;

}

function toggleAll() {
	toggleCheckboxes(document.list.cart);
}


/**
 * [FROM] scriptForCookie.html
 * @param name
 * @return
 */
function getCookie(name) {

	var Found = false
	var start, end
	var i = 0
	// cookie ¹®ÀÚ¿­ ÀüÃ¼¸¦ °Ë»ö
	while(i <= document.cookie.length) {
		start = i
		end = start + name.length
		// name°ú µ¿ÀÏÇÑ ¹®ÀÚ°¡ ÀÖ´Ù¸é
		if(document.cookie.substring(start, end) == name) {
			Found = true
			break
		}
		i++
	}
	// name ¹®ÀÚ¿­À» cookie¿¡¼­ Ã£¾Ò´Ù¸é
	if(Found == true) {
		start = end + 1
		end = document.cookie.indexOf(';', start) 
		// ¸¶Áö¸· ºÎºÐÀÌ¶ó´Â °ÍÀ» ÀÇ¹Ì(¸¶Áö¸·¿¡´Â ';'°¡ ¾ø´Ù) 
		if(end < start)
			end = document.cookie.length 
			// name¿¡ ÇØ´çÇÏ´Â value°ªÀ» ÃßÃâÇÏ¿© ¸®ÅÏÇÑ´Ù. 
		return document.cookie.substring(start, end) 
	} 
		//Ã£Áö ¸øÇß´Ù¸é
}

function setCookie( name, value, expiredays ) { 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; domain=daum.net; expires=" + todayDate.toGMTString() + ";" 
}

function openIcon(obj){ 
	var eventCookie=getCookie('pop_receipt');			//ÆË¾÷ÇÒ ÄíÅ°ÀÇ ÀÌ¸§	
	if (eventCookie == 'no') {	
		document.getElementById(obj).style.display = "none";
	} 
}
function closeIcon(obj) {
	setCookie("pop_receipt", "no" , 1000);
	document.getElementById(obj).style.display = "none";
}


/**
 * [FROM] scriptsForExif.html
 * @param num
 * @return
 */
function toggle_exif(num) {
	var photoExif = document.getElementById('photo_'+num).style.display;
	document.getElementById('photo_'+num).style.display = (photoExif=='none')?'block':'none';
}



/**
 * [FROM] scriptsForString.html
 * @param str
 * @return
 */
function isEmptyString(str) {
	var splits = str.split(" ");
	if (str.length + 1 == splits.length) {
		return true;
	} else {
		return false;
	}	
}

function trim(s) {
	while (s.substring(0,1) == ' ') {
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ') {
		s = s.substring(0,s.length-1);
	}
	return s;
}

function strtrim(str) {
	while (str.charAt(0) == ' ')
		str = str.substring(1);
	while (str.charAt(str.length - 1) == ' ')
		str = str.substring(0, str.length - 1);
	return str;
}
// strÀÌ length byte ³Ñ¾î°¡¸é .. Ç¥½Ã
function chop(str, length) {
	var strLength = 0;
	var retstr = "";
	
	for ( var i = 0; i < str.length ; i++) {
		if (escape(str.charAt(i)).length > 3) {
			strLength +=2;
			if (strLength > length) {
				retstr = retstr+"..";
				break;
			}
			retstr+= str.charAt(i);
		} else {
			strLength++;
			if (strLength > length) {
				retstr = retstr+"..";
				break;
			}
			retstr += str.charAt(i);
		}
	}
	return retstr;
}

function isContainQuote(str) {
	for (var i = 0; i < str.length; i++) {
		if (str.charAt(i) == "'" || str.charAt(i) == '"') {
			return true;
		}
	}

	return false;
}

function isContainBracket(str) {
	for (var i = 0; i < str.length; i++) {
		if (str.charAt(i) == "<" || str.charAt(i) == ">") {
			return true;
		}
	}

	return false;
}

function isContainBackslash(str) {
	for (var i = 0; i < str.length; i++) {
		if (str.charAt(i) == "\\") {
			return true;
		}
	}

	return false;
}

// ¹®ÀÚ¿­ÀÇ ±æÀÌ¸¦ ¹ÙÀÌÆ® ´ÜÀ§·Î ¸®ÅÏ. i.e. ¿µ¹®ÀÚ = 1 byte, ÇÑ±Û = 2 bytes
function getKEStringBytes(str) {
	return(str.length + (escape(str) + "%u").match(/%u/g).length - 1);
}

// ¹®ÀÚ¿­ÀÇ ±æÀÌ¸¦ ¹ÙÀÌÆ® ´ÜÀ§·Î Àß¶ó¼­ ¸®ÅÏ. i.e. ¿µ¹®ÀÚ = 1 byte, ÇÑ±Û = 2 bytes
function cutKEString(str, cut) {
	var ulen = str.length;
	var i;
	var res = "";
	var count = 0;

	for (i = 0; i < str.length; i++) {
		if (count >= cut) {
			return res;
		}
		var ch = str.charAt(i);
		if (escape(ch).length > 4) {
			if (count + 2 <= cut) {
				res += ch;
			}
			count += 2;
		} else {
			res += ch;
			count++;
		}
	}

	return res;
}

var mangerform_type = "";

function adminFormOn(type){
    
	obj  = document.getElementById("mangerform");
	if ( obj ) {
		
		if (type == "login") {
			
			if(mangerform_type == type){
				mangerform_type = "";
				obj.style.visibility = "hidden";
				return;
			}
				
			obj.innerHTML = "<iframe src='../modules/login/login.php' width='188' height='120' frameborder='0' scrolling='no'></iframe>";
			obj.style.visibility = "visible";
			
			mangerform_type = type;
		}
		else if (type == "logout") {
			
			if(mangerform_type == type){
				mangerform_type = "";
				obj.style.visibility = "hidden";
				return;
			}					
			obj.innerHTML = "<iframe src='../modules/login/loginOk.php?act=logout' width='0' height='0' frameborder='0' scrolling='no'></iframe>";
			obj.style.visibility = "visible";
			mangerform_type = type;
		}
		
	}
}
function adminFormOff(){
	obj = document.getElementById("mangerform");
	if ( obj ) {
		obj.innerHTML = "";
		obj.style.visibility = "hidden";
		mangerform_type = "";
	}
}


