function imagechg(savefilename){
	//document.getElementById("productViewForm:bigImage").src="http://localhost/"+savefilename;
	//alert(document.getElementById("view:form:bigImage"));
	document.getElementById("view:form:bigImage").src=savefilename;
	ImageReSize();
}

function ImageReSize() {
	if(document.getElementById("view:form:bigImage").width>490) {
		document.getElementById("view:form:bigImage").width = 490;
	}
}


function imageChange(id, src){
	document.getElementById(id).src = src;
}
/*
* input box의 이벤트를 무효화시켜 readonly와 비슷한 효과를 준다.
*/
function readonly(evt) {
	/*
	var evCode = ( window.netscape ) ? evt.which : evt.keyCode ; // FF는 which, IE는 keyCode
	if ( window.netscape ) { // FF일 경우
		if( evCode == 0 ) return; //한글일때
    	evt.preventDefault() ;
    } else {                  // IE일 경우

    	//document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);

        evt.returnValue=false;

    }
    */

}

/**
* 오른쪽 마우스 버튼 막기
*/
function jsEventAntiRight(e) {
 	evt = e || event;
    try{
    	if (document.all){
	  		if(evt.button == 2 || evt.button == 3) {
	    		jsEventAntiStopEvent(evt);
	    		return false;
	    	}
  		}else {
  			if(evt.which == 3 || evt.which == 2) {
	    		jsEventAntiStopEvent(evt);
	    		return false;
	    	}
  		}
    }catch(ex){
  		if( isDebug ) alert(ex);
  		return false;
    }
}

/**
* 키보드 입력 막기
*/
function jsEventAntiProcessKey(e){
	evt = e || event;
  	try{
  		jsEventAntiStopEvent(evt);
  		return false;
    }catch(ex){
    	if( isDebug ) alert(ex);
  		return false;
    }
}

/*
* 이벤트 동작 무시!
*/
function jsEventAntiStopEvent(evt) {
 	if(window.event){
 		window.event.keyCode = 0;
 		window.event.cancelBubble = true;
 		window.event.returnValue = true;
 	}else{
 		evt.stopPropagation();
 		evt.preventDefault();
 		evt.initEvent;
 	}
 	return false;
}


function readonly(evt, this_s){
 	//문제점 : FF에서는 드래그 이벤트를 제어할 수 없다.
 	if(!this_s){this_s = window.document;}
 	if(document.attachEvent){
 		jsEventAntiProcessKey( evt );
 		jsEventAntiRight( evt );
 		/*
	 	this_s.attachEvent("onkeydown", jsEventAntiProcessKey );
	 	this_s.attachEvent("onmousedown", jsEventAntiRight );
	 	this_s.attachEvent("onselectstart", jsEventAntiStopEvent );
	 	this_s.attachEvent("ondragstart", jsEventAntiStopEvent );
	 	*/
	 } else {
	 	window.captureEvents(Event.MOUSEDOWN);
	 	window.captureEvents(Event.ONKEYDOWN);
	 	jsEventAntiProcessKey( evt );
 		jsEventAntiRight( evt );
	 /*
	 	window.captureEvents(Event.MOUSEDOWN);
	 	window.captureEvents(Event.ONKEYDOWN);
	 	this_s.addEventListener("keydown", jsEventAntiProcessKey , false);
	 	this_s.addEventListener("mousedown", jsEventAntiRight , false);
	 	this_s.addEventListener("dragstart", jsEventAntiStopEvent , false);  //FF에서 지원되지 않는다.
	 	this_s.addEventListener("selectstart", jsEventAntiStopEvent , false);  //FF에서 지원되지 않는다.
	 */
	 }
}

/**
* 페이지 전체에 오른쪽마우스를 막는다.
*/
function documnetAntiEvent() {
	 if(document.attachEvent){
	 	window.document.attachEvent("onmousedown", jsEventAntiRight );
	 } else {

	 	window.captureEvents(Event.MOUSEDOWN);
	 	window.document.addEventListener("mousedown", jsEventAntiRight , false);
	 }
}

function drawInputBox( id, able ) {
	try{

		var obj = document.getElementById(id);
		if( obj == null ) return false;

		if( able ) {
			obj.style.backgroundColor = '#FFFFFF';
			obj.style.borderColor = '#FFFFFF';
			obj.style.borderWidth = '1px;';
			obj.style.borderStyle = 'solid';
		} else {
			obj.style.backgroundColor = '#f3f9eb';
			obj.style.borderColor = '#c1d6a5';
			obj.style.borderWidth = '1px;';
			obj.style.borderStyle = 'solid';
		}
	}catch(e){
		if( isDebug ) alert(e);
	}
}

var pop;

 function openPopup(uri, queryParam, popnm, width, heigth ) {

    var openUri = uri +'?' + queryParam;
    var window_left = ( screen.width - width ) / 2;
    var window_top = ( screen.height - heigth ) / 2;
 	pop = window.open(openUri,popnm,
 						'width='+width+',height='+heigth+',scrollbars=no,status=no,resizable=no,top=' + window_top + ',left=' + window_left + '');

 	//setTimeout("popFocus();", 500 );

 }

 function popFocus() {
 	if( pop ) {
 		pop.focus();
 		pop = null;
 	}
 }

 function firePopFocus() {
 	setTimeout("popFocus();", 100 );
 }


documnetAntiEvent();


//레이어 drag
<!--
var dragapproved=false;
var tempX;
var tempY;
var iex = null;
var iey = null;
var dragId = null;

function drag_dropie(e) {
	if (!dragapproved) return false;
    if (document.all){
        document.getElementById(dragId).style.pixelLeft=tempX+event.clientX-iex;
        document.getElementById(dragId).style.pixelTop=tempY+event.clientY-iey;
    	return false;
    } else {
    	//alert(tempX+ '  ' + pntX + '  ' + e.pageX );
    	if( iex == null ) iex = e.clientX;
    	if( iey == null ) iey = e.clientY;
    	document.getElementById(dragId).style.left= parseInt(tempX)+e.clientX-iex;
        document.getElementById(dragId).style.top= parseInt(tempY)+e.clientY-iey;
        return false;
    }

}

function releaseDrag() {
	dragapproved = false;
	iex = null;
	iey = null;
}

function initializedragie(id){
	dragId = id;
	if (document.all) {
		iex=event.clientX;
    	iey=event.clientY;
    	tempX=document.getElementById(id).style.pixelLeft;
    	tempY=document.getElementById(id).style.pixelTop;
	} else {
		document.captureEvents(Event.MOUSEMOVE);

		tempX=document.getElementById(id).style.left;
    	tempY=document.getElementById(id).style.top;
    	tempX = tempX.substr(0,tempX.length-2);
    	tempY = tempY.substr(0,tempY.length-2);
	}
    dragapproved=true;
    document.onmousemove=drag_dropie;
}


function submitaction(id,save) {
	var iceInstance = id;
    //var iceInstance = Ice.Repository.getInstance(editorInstance.Name);

	var all = Ice.Repository.getAll();
	for (i=0; i < all.length; i++) {
		var instanceName = all[i].thirdPartyObject.InstanceName;
		var editIns = FCKeditorAPI.GetInstance(instanceName);
		//if the editor is not visible on this view, just skip and continue
		if (editIns == null) continue;
		//clear malformed parameters
		var unwantedField = $(instanceName + "___Config");
		if (unwantedField){
		    unwantedField.value = "";
		    unwantedField.name = unwantedField.id;
		}
		var element = $(editIns.Name);
		//Save the dirty editor only that had the focus
		if(editIns.IsDirty()) {
		element.value = editIns.GetXHTML(true);
		        //set the value for editor
		var valueHolder = $(editIns.Name + 'valueHolder');
		    valueHolder.value = editIns.GetXHTML(true);
		    editIns.ResetIsDirty();
		}
	}

	var editIns = FCKeditorAPI.GetInstance(id);
	if( editIns.GetXHTML(true) != '') {
		var inputid = document.getElementById('tfSub:saninfo:regdocContent');
		inputid.value =  editIns.GetXHTML(true);
	}

	var form = Ice.util.findForm(element);
	iceSubmit(form,element,new Object());
	//return false;
	if(save != '') {
		var fld = $(save);
		var nothingEvent = new Object();
		var form = Ice.util.findForm(fld);
		iceSubmit(form, fld, event);
	}
	return false;
}

 function openPopuptax(uri, queryParam, popnm, width, heigth ) {
 	alert(uri);
 	if(uri == ''){return;}
 	queryParam = queryParam.replace(/;/g, '&');
    var openUri = uri +'?' + queryParam;

    var window_left = ( screen.width - width ) / 2;
    var window_top = ( screen.height - heigth ) / 2;

 	pop = window.open(openUri,popnm,
 						'width='+width+',height='+heigth+',scrollbars=no,status=no,resizable=no,top=' + window_top + ',left=' + window_left + '');

 	//setTimeout("popFocus();", 500 );

 }
///////////////

function setCheckbox(chknum){
	document.getElementById("view:form:productTable:chkboxAll").checked=false;

	for (i=0;i<chknum;i++){
		document.getElementById("view:form:productTable:"+i+":chkboxList").checked = false;
	}
}


function setCheckbox4Table(preid, postid, max){
	for (var i = 0; i < max; i++){
		document.getElementById(preid+":"+i+":"+postid).checked = false;
	}
}

/**
textarea 글자수 체크
메인입력 function
*/

function cal_pre(maxbyte, textareaid, byteid)
{
	var brTag = '<br/>';
	evt =  event;
    try{
    	if (document.all){

	    	if (evt.keyCode == '13') {
	    		var txt = document.getElementById(textareaid).value;
	    		//document.getElementById(textareaid).value = txt + brTag;
	    	}

  		}else {
  			if(evt.which == 3 || evt.which == 2) {
	    		jsEventAntiStopEvent(evt);
	    		return false;
	    	}
  		}
    }catch(ex){
  		alert(ex);
  		return false;
    }
	var tmpStr;
	//textareaid입력
	tmpStr = document.getElementById(textareaid).value;
	cal_byte(tmpStr, maxbyte, textareaid, byteid);
}

function cal_clear(textareaid) {
	document.getElementById(textareaid).value = "";
}

function cal_byte(aquery, maxbyte, textareaid, byteid)
{
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for (i=0;i<temp;i++)
	{
		onechar = tmpStr.charAt(i);
		if (escape(onechar) =='%0D') { } else if (escape(onechar).length > 4) { tcount += 2; } else { tcount++; }
	}

	//폼명 및 현제 몇자리까지 입력이 되었는지 보여줄 부분.
	document.getElementById(byteid).innerHTML = tcount;
	if(tcount>maxbyte) {
		reserve = tcount;
		nets_check(document.getElementById(textareaid).value, maxbyte, textareaid,byteid);
	return;
	}

}

function nets_check(aquery, maxbyte, textareaid,byteid)
{
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for(k=0;k<temp;k++)
	{
		onechar = tmpStr.charAt(k);

		if(escape(onechar).length > 4) {
			tcount += 2;
		} else {
			// 엔터값이 들어왔을때 값(\r\n)이 두번실행되는데 첫번째 값(\n)이 들어왔을때 tcount를 증가시키지 않는다.
			if(escape(onechar)=='%0A') {
			} else {
				tcount++;
			}
		}

		if(tcount>maxbyte) {
			tmpStr = tmpStr.substring(0,k);
			break;
		}

	}
	document.getElementById(textareaid).value = tmpStr;
	cal_byte(tmpStr,maxbyte, textareaid,byteid);

}
////////////////////////////////////


function testSpan(id) {
	document.getElementById(id).innerHTML = '10';
}

/**
* 검색 시 조건에 따라서 검색 버튼을 바꾼다.
*/
function swapSearchBtnImage(id, itemtyp) {
	var width = '';
	var src = '';
	if (itemtyp == 'A') {
		src = '/images/bt_search_all.gif';
		width = '57px';
	} else if (itemtyp == 'P') {
		src = '/images/bt_search_products.gif';
		width = '90px';
	} else if (itemtyp == 'B') {
		src = '/images/bt_search_buying.gif';
		width = '110px';
	} else if (itemtyp == 'S') {
		src = '/images/bt_search_selling.gif';
		width = '110px';
	} else if (itemtyp == 'C') {
		src = '/images/bt_search_companies.gif';
		width = '100px';
	}
	var button = document.getElementById(id);
	button.src = src;
	button.style.width = width;

}


function enableButton(id) {
	document.getElementById(id).disabled = false;
}

function loadMessage_DivOn(id) {
	document.getElementById(id).style.display = "block";
}

function loadMessage_DivOff(id) {
	document.getElementById(id).style.display = "none";
}

function SelectBox_Clear(id) {
	document.getElementById(id).selectedIndex = 0;
}

//엔터키 입력시 
//event.keyCode(IE), event.which(FF) 
function enterCheck(evt) { 
    var evCode = ( window.netscape ) ? evt.which : event.keyCode ; 
    if(evCode==13) { 
        return false; 
    } else {
		return evCode;
	}

} 

