function checkAll(form, name, cnt) {
	var chk;
	var i;
	if (cnt < 1) return;
	//if (cnt > 500) { alert('Sorry, this function is blocked beacuse the count of target item is larger than 500.'); }
	eval('if (form.'+name+'_1.checked == true) chk = false; else chk = true;');
	for (i=1;i<=cnt;i++)
		eval('form.'+name+'_'+i+'.checked = chk;');
}

function resizeSelfIFrame(toHeight, toWidth, iframe_name) {
	if (!iframe_name) { iframe_name = 'content'; }
	eval("var target = parent.document.all."+iframe_name+";");
	if (target) {
		target.height = toHeight;
		if (toWidth > 0) {
			target.width = toWidth;
		} else {
			target.width = 800;
		}
	}
}

function openContentWindow(url) {
	parent.document.location.href=url;
}

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_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 openWindows(url,width,height,id) {
	if (width > 1000) { width = 1000; height = 720;}
	window.open('picture_view.php?url='+url+'&width='+width+'&height='+height+'&id='+id, 'Picture', 'status=no,resizable=no,scrollbars=no,width='+width+',height='+height);
}


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];
		}
}

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 isNumber(value) {
	for (i=0;i<value.length;i++) {
		temp = value.substring(i, i+1);
		if (!(temp >= '0' && temp <= '9' || temp == '.')) return false;
	}                       
	return true;
}

function checkNumberExist(data) {
	for (i=0;i<data.length;i++) 
		if (data.charCodeAt(i) > 47 && data.charCodeAt(i) < 59) return true;
	return false;
	}
function checkSpecialCharExist(data) {
	for (i=0;i<data.length;i++) 
	if ((data.charCodeAt(i) > 32 && data.charCodeAt(i) < 48) || (data.charCodeAt(i) > 57 && data.charCodeAt(i) < 63)) return true;
	return false;
}

function checkOnlyEnglish(data) {
	for (i=0;i<data.length;i++) 
		if (data.charCodeAt(i) > 255) return false;
	return true;
}

function replaceall(frm,resultfld,dowhat){
	var field = eval("frm."+resultfld);
	var FullString = field.value; //var FullString = resultfld.value;
	var SelectedString = document.selection.createRange().text;
	if (SelectedString != null && SelectedString != "") {
		var RegExpSelect = new RegExp(SelectedString, "gi")
		var ReplaceString = "<"+dowhat+">"+SelectedString+"</"+dowhat+">";
		var NewString = FullString.replace (RegExpSelect, ReplaceString);
		field.value = NewString;	//  resultfld.value = NewString;
	}
	else {
		alert("ÇØ´ç ´Ü¾î¸¦ ¸¶¿ì½º·Î ¼±ÅÃÇÏ½ÅÈÄ ¹öÆ°À» ´­·¯ÁÖ½Ê½Ã¿À.");
		field.focus();
	}
}

function toggleRightUnderMenu(i, o) {
	if (MM_findObj('RightUnderMenu_1') == null) {
		location.href='/?ro='+i;
		return;
	}
	for (j=1;j<6+1;j++) {
		if (j == i) {
			if (o == 0) {
				MM_showHideLayers('RightUnderMenu_'+j,'','show');
			} else {
				MM_showHideLayers('RightUnderMenu_'+j,'','hide');
			}
		} else {
			if (o == 0) {
				MM_showHideLayers('RightUnderMenu_'+j,'','hide');
			} else {
				MM_showHideLayers('RightUnderMenu_'+j,'','show');
			}
		}
	}
}

function toggleSubmenu(i, o) {
	for (j=1;j<4+1;j++) {
		if (j == i) {
			if (o == 0) {
				MM_showHideLayers('SubMenu_'+j,'','show');
			} else {
				MM_showHideLayers('SubMenu_'+j,'','hide');
			}
		} else {
			if (o == 0) {
				MM_showHideLayers('SubMenu_'+j,'','hide');
			} else {
				MM_showHideLayers('SubMenu_'+j,'','show');
			}
		}
	}
}

function validateEmail(email) {
	var atLoc = email.indexOf("@",1);
	var dotLoc = email.indexOf(".",atLoc+2);
	var len = email.length;

	if (!(atLoc > 0 && dotLoc > 0 && len > dotLoc+2)) {
		return false;
	}
	return true;
}

function send_message(id) {
	window.open('send_message.php?id='+id, 'Picture', 'status=no,resizable=no,scrollbars=no,width=420,height=270');
}

// Copyright ¨Ï 2000 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.
//
// ************************
// layer utility routines *
// ************************

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject

function getStyleObject (styleSheetIndex, ruleIndex) {
	if (document.styleSheets) {
		var styleSheet = document.styleSheets[styleSheetIndex];
		if (styleSheet) {
			var rule;
			if (styleSheet.cssRules) {
				rule = styleSheet.cssRules[ruleIndex];
			} else if (styleSheet.rules) {
				rule = styleSheet.rules[ruleIndex];
			}
			if (rule && rule.style) {
				return rule.style;
			} else {
				return null;
			}
		} else {
			return null;
		}
	} else {
		return null;
	}
}

function getStyleObjectFromSelector (selectorText) {
	if (document.styleSheets) {
		for (var i = document.styleSheets.length - 1; i >= 0; i--) {
			var styleSheet = document.styleSheets[i];
			var rules;
			if (styleSheet.cssRules) {
				rules = styleSheet.cssRules;
			} else if (styleSheet.rules) {
				rules = styleSheet.rules;
			}
			if (rules) {
				for (var j = rules.length - 1; j >= 0; j--) {
					if (rules[j].selectorText == selectorText) {
						return rules[j].style;
					}
				}
			}
		}
		return null;
	} else {
		return null;
	}
}
