/********************************************************************************************************
*
*    REVIEW
*
********************************************************************************************************/
function Resizing(img, Size){
	if(img.width > Size) img.width = Size;
}
//TAB
var val = location.href.split("/");
var fn = val[val.length-1].replace(".asp","");
var fn2 = fn.split("_")[0];

//REVIWE
function initReview() {

	if(document.getElementById("consulting_paging")){

		a = document.getElementById("consulting_paging").getElementsByTagName("A");

		for (i = 0; i < a.length; i++) {
			a[i].onclick = function () {
				var href = this.href,
					id = "consultingList";

				loading(id);
				Async.send("/common/async/consulting_list.asp", function ( send_ ) {
					setTimeout( function () {
						insertNodes(id, send_.responseText, initReview);
					}, random(100, 300));
				}, getQueryString(href));
				return false;
			};
		};
	}

	if(document.getElementById("consultingView")){

		a = document.getElementById("consultingView").getElementsByTagName("A");

		for (i = 0; i < a.length; i++) {
			a[i].onclick = function () {
				var href = this.href,
					id = "consultingList";				

				if (this.parentNode.parentNode.className == "locked")
				{
					openViewPwd();
					document.viewPwdForm.I_idx.value = this.parentNode.parentNode.name;
					return false;
				}
				else{
					loading(id);
					Async.send("/common/async/consulting_view.asp", function ( send_ ) {
						setTimeout( function () {
							insertNodes(id, send_.responseText, initReview);
						}, random(100, 300));
					}, getQueryString(href));
					return false;
				}
			};
		};
	}


	if  (document.writeForm){

		var theForm = document.writeForm;
		
		document.writeForm.onsubmit = function (){

			if (theForm.VC_pass.value)	{
				if (!/^[0-9a-z_]/g.test(theForm.VC_pass.value)) {
					alert("¿µ¹® ¼Ò¹®ÀÚ ¶Ç´Â ¼ýÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù!      ");
					theForm.VC_pass.focus();
					theForm.VC_pass.select();
					return false;
				};
			};

			
			if(theForm.VC_name.value == ""){
				alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				theForm.VC_name.focus();
				return false;
			}

			if(theForm.VC_age.value == ""){
				alert('³ªÀÌ¸¦ ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				theForm.VC_age.focus();
				return false;
			}

			if(theForm.VC_email.value == ""){
				alert('ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				theForm.VC_email.focus();
				return false;
			}

			if(theForm.VC_title.value == ""){
				alert('Á¦¸ñÀ» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				theForm.VC_title.focus();
				return false;
			}

			

			if(document.getElementById('ContentsFrame').contentWindow.document.body.innerHTML == ""){
				alert('³»¿ëÀ» µî·Ï ÇÏ¿©ÁÖ¼¼¿ä');
				return false;
			}

			theForm.fContents.value = document.getElementById('ContentsFrame').contentWindow.document.body.innerHTML;

			//alert(formQueryString(this));
			//boxLoading("filling_table");
			Async.send("./consulting_write_reg.asp", function (send_) {
				setTimeout( function () {
					closeWrite();
					//alert(send_.responseText);
					theForm.VC_name.value = "";
					theForm.VC_age.value = "";
					theForm.VC_email.value = "";
					theForm.VC_title.value = "";
					document.getElementById('ContentsFrame').contentWindow.document.body.innerHTML = ""
					//theForm.VC_name.focus();

					var id = "consultingList",
						href = location.href;
					
					loading(id);
					Async.send("/common/async/consulting_list.asp", function ( send_ ) {
						setTimeout( function () {
							insertNodes(id, send_.responseText, initReview);
						}, random(300, 500));
					}, formQueryString(this));
					alert('µî·ÏµÇ¾ú½À´Ï´Ù.');
					return false;
					//document.getElementById("photo_review_list").innerHTML = send_.responseText;

				}, random(100, 400));
			}, formQueryString(this));
			return false;
		};

	};

	if (document.pwdForm){
		var pwdForm = document.pwdForm;	

		pwdForm.onsubmit = function (){
			if(pwdForm.passWrd.value == ""){
				alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				pwdForm.passWrd.focus();
				return false;
			};
			Async.send("/common/async/consulting_pwd.asp", function (send_) {
				setTimeout( function () {
					pwdForm.passWrd.value = "";
					execScript(send_.responseText);					
				}, random(100, 400));
			}, formQueryString(this));
			return false;
		};
	};

	if (document.viewPwdForm){
		var viewPwdForm = document.viewPwdForm;	

		viewPwdForm.onsubmit = function (){
			if(viewPwdForm.passWrd.value == ""){
				alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				viewPwdForm.passWrd.focus();
				return false;
			};
			Async.send("/common/async/consulting_viewPwd.asp", function (send_) {
				setTimeout( function () {
					viewPwdForm.passWrd.value = "";
					execScript(send_.responseText);					
				}, random(100, 400));
			}, formQueryString(this));
			return false;
		};
	};

	if  (document.EditForm){

		var EditForm = document.EditForm;
		
		document.EditForm.onsubmit = function (){

			if (EditForm.VC_pass.value != "")	{
				if (!/^[0-9a-z_]/g.test(theForm.VC_pass.value)) {
					alert("¿µ¹® ¼Ò¹®ÀÚ, ¼ýÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù!      ");
					EditForm.VC_pass.focus();
					EditForm.VC_pass.select();
					return false;
				};
			};

			if(EditForm.VC_name.value == ""){
				alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				theForm.VC_name.focus();
				return false;
			}

			if(EditForm.VC_age.value == ""){
				alert('³ªÀÌ¸¦ ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				theForm.VC_age.focus();
				return false;
			}

			if(EditForm.VC_email.value == ""){
				alert('ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				theForm.VC_email.focus();
				return false;
			}

			if(EditForm.VC_title.value == ""){
				alert('Á¦¸ñÀ» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.');
				theForm.VC_title.focus();
				return false;
			};			

			EditForm.fContents.value = document.getElementById('ContentsFrame').contentWindow.document.body.innerHTML;

			var id = "consultingList",
				lodingId = "Ins",
				href = location.href;

			loading(lodingId);
			Async.send("./consulting_write_reg.asp", function (send_) {
				setTimeout( function () {
					closeEdit();
					EditForm.VC_name.value = "";
					EditForm.VC_age.value = "";
					EditForm.VC_email.value = "";
					EditForm.VC_title.value = "";
					document.getElementById('ContentsFrame').contentWindow.document.body.innerHTML = "";
					alert('¼öÁ¤µÇ¾ú½À´Ï´Ù.');
					insertNodes(id, send_.responseText, initReview);
				}, random(100, 400));
			}, formQueryString(this));
			return false;
		};
	};

	var formSearch = document.forms["formSearch"];
	
	if(formSearch){

		var id = "consultingList";

		formSearch.onsubmit = function () {
			
			if (formSearch.isSubmit)
				return false;
			if (this.searchString.value.length < 2) {
				alert("°Ë»ö¾î¸¦ 2ÀÚÀÌ»ó ÀÔ·Â ÇØÁÖ¼¼¿ä!     ");
				this.searchString.focus();
				return false;
			}

			loading(id);
				Async.send("/common/async/consulting_list.asp", function ( send_ ) {
					setTimeout( function () {
						insertNodes(id, send_.responseText, initReview);
					}, random(100, 300));
				}, formQueryString(this));
			return false;
		};
	}
};
initReview();

		function openWrite(){			
			removeClass(document.getElementById("consultingWriteBox"), "dsp_none");
			return false;
		};

		function closeWrite() {
			document.writeForm.reset();
			addClass(document.getElementById("consultingWriteBox"), "dsp_none");
			return false;
		};

		function imgOpen(Num){
			window.open("/common/uploadImg.asp", "uploadfile", "scrollbars=no,resizable=no,width=420, height=247");
		};

		function insertImg(ImgObj){

			var objChk
			var frameInsert = document.getElementById('ContentsFrame').contentWindow.document;
			var frameInsertImg = frameInsert.createElement("IMG");
			frameInsertImg.src = ImgObj;
			frameInsert.body.appendChild(frameInsertImg);
		};

		function openPwd(val_){
			closeWrite();
			removeClass(document.getElementById("consultingPwdBox"), "dsp_none");
			document.pwdForm.val_.value = val_;
			return false;
		};

		function closePwd() {
			document.pwdForm.reset();
			addClass(document.getElementById("consultingPwdBox"), "dsp_none");
			return false;
		};

		function openEdit(){
			var result = document.getElementById("result").getElementsByTagName("span"),
				EditForm = document.forms["EditForm"];
			
			for (var i = 0; i < EditForm.reason.length; i++)
			{
				if (EditForm.reason[i].value == result[5].innerHTML)
				{
					EditForm.reason[i].checked = true;
				}
			}
			EditForm.VC_idx.value = result[0].innerHTML;
			EditForm.VC_name.value = result[7].innerHTML;
			EditForm.VC_age.value = result[8].innerHTML;
			EditForm.VC_email.value = result[9].innerHTML;
			EditForm.VC_title.value = result[2].innerHTML;
			EditForm.VC_pass.value = result[6].innerHTML;
			document.getElementById('ContentsFrame').contentWindow.document.body.innerHTML = result[3].innerHTML;

			removeClass(document.getElementById("consultingEditBox"), "dsp_none");
			return false;
		};

		function closeEdit() {
			document.EditForm.reset();
			addClass(document.getElementById("consultingEditBox"), "dsp_none");
			return false;
		};


		function openViewPwd(val_){
			removeClass(document.getElementById("consultingViewPwdBox"), "dsp_none");
			return false;
		};

		function closeViewPwd() {
			document.viewPwdForm.reset();
			addClass(document.getElementById("consultingViewPwdBox"), "dsp_none");
			return false;
		};

		var contentsFrame = document.getElementById("ContentsFrame");
		if (contentsFrame) {
			(contentsFrame.contentDocument || contentsFrame.contentWindow.document).designMode = "on";
		}