// util.js가 열려진 상태에서
// 이미지 보기
function cf_imageView(picname){
	jf_openWindow('/app/prc_image_view.jsp?p=' + picname, 'imgView', 'yes', 'yes', 700, 700, 10, 10, 0);
}

// 우편번호
function cf_zipcode(zip, addr1){
	zip = "document.getElementById('writeProc')."+ zip;
	addr1 = "document.getElementById('writeProc')."+addr1;
	jf_openWindow('/app/zipcode/prc_zipcode_form.jsp?zipCode=' + zip + "&addr1="+addr1, 'formmail', 'no', 'yes', 363, 212, 1, 1, 1);
}

function cf_searchWord(title){
	location.href="/page/home/service/search.jsp?mode=commonForm&query=" + encodeURI(title);
}

// 파일 다운로드
function cf_download(fm, s, d, articleSeq){
	fm.s.value = s;
	if (d != null)
		fm.d.value = d;
	
	if (articleSeq != null) {
		fm.articleSeq.value = articleSeq;
	}	
	fm.submit();
}

// 이미지 등록 
// sendForm: 이미지가 추가될 fckeditor 인스턴스  이름. 기본값 : content
function cf_imageForm(sendForm){
	var url = "/app/image_reg/prc_image_form.jsp";
	if(sendForm != null){
		url += "?sendForm=" + sendForm;
	}
	
	jf_openWindow(url, "imageForm", 0, 1, 550, 380, 1, 1, 1);  
}

// 이메일 접근
function cf_emailck(val) {
	jf_openWindow('/app/email_prevention/prc_email_form.jsp?q=' + val, 'emailcheck', 'no', 'no', 280, 190, 1, 1, 1);
}

// 사용자 정보 보기
function cf_userInfo(memberID){
	jf_openWindow('/adm_site/app/member/pra_member_info.jsp?memberID=' + memberID, 'memberInfo', 0, 1, 700, 650, 1, 1, 1);
}

// 로그인페이지 이동 여부 물어 보기  
function cf_loginConfirm(msg, rtnUrl){
	if(confirm(msg)){
		cf_login(rtnUrl);
	}
	else{
		history.back();
	}
}

// 콘텐츠 열람 팝업창 
function cf_contentView(articleID){
	jf_openWindow("/app/erms_xml/prc_erms_content_view.jsp?articleSeq="+articleID, "contentView", 0, 1, 760, 600, 1, 1, 1);  
}

//행정
function cf_selFuncBox(returnURL) {		// function버튼 IE, Firefox 처리
	var htmlCode = "";
	var rtnURL = "/app/enjoysearch/prc_enjoysearch_common.jsp?rtnUrl=" + returnURL;

	if (navigator.userAgent.toLowerCase().indexOf("msie") != -1){	// IE 인경우
		htmlCode += "<table border='0' cellspacing='5' cellpadding='0'>";
		htmlCode += "<form name='frm_EmailContents' method='post'>";
		htmlCode += "<input type='hidden' name='emailContents' value=''>";
		htmlCode +=	"	<tr>";
		htmlCode += "		<td>";
		htmlCode += "			<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
		htmlCode +=	"				<tr>";
		htmlCode += "					<td><img src='/image/common/commonutil_screen_origin.gif' width='30' height='20' alt='기본크기' onClick='javascript:jf_setFontSize(\"restore\");' style='cursor:hand'></td>";
		htmlCode += "					<td><img src='/image/common/commonutil_screen_up.gif' width='20' height='20' alt='크게보기' onClick='javascript:jf_setFontSize(\"magnify\");' style='cursor:hand'></td>";
		htmlCode += "					<td><img src='/image/common/commonutil_screen_down.gif' width='20' height='20' alt='작게보기' onClick='javascript:jf_setFontSize(\"reduce\");' style='cursor:hand'></td>";
		htmlCode += "				</tr>";
		htmlCode += "			</table>";
		htmlCode += "		</td>";
		htmlCode += "		<td><img src='/image/common/commonutil_print.gif' width='44' height='20' alt='인쇄' onClick='javascript:cf_print();' style='cursor:hand'></td>";
		htmlCode += "		<td><img src='/image/common/commonutil_copyad.gif' width='65' height='20' alt='주소복사' onClick='javascript:jf_copyClipboard(location.href);' style='cursor:hand'></td>";
		htmlCode += "		<td><img src='/image/common/commonutil_mail.gif' width='79' height='20' alt='메일보내기' onClick='javascript:cf_content_email();' style='cursor:hand'></td>";
		htmlCode += "		<td><img src='/image/common/commonutil_scrab.gif' width='57' height='20' alt='스크랩' onClick='javascript:jf_openWindow(\"" + rtnURL + "\", \"markWindow\",0,0,365,285,365,365,0);' style='cursor:hand'></td>";
		htmlCode += "	</tr>";
		htmlCode += "</form>";
		htmlCode += "</table>";
	} else {
		htmlCode += "&nbsp;";
	}

	document.write(htmlCode);
}

//관광
function cf_selTourFuncBox(returnURL) {		// function버튼 IE, Firefox 처리
	var htmlCode = "";
	var rtnURL = "/app/enjoysearch/prc_enjoysearch_common.jsp?rtnUrl=" + returnURL;

	if (navigator.userAgent.toLowerCase().indexOf("msie") != -1){	// IE 인경우
		htmlCode += "<table border='0' cellspacing='3' cellpadding='0'>";
		htmlCode += "<form name='frm_EmailContents' method='post'>";
		htmlCode += "<input type='hidden' name='emailContents' value=''>";
		htmlCode +=	"	<tr>";
		htmlCode += "		<td><img src='/image/common/commonutil_screen_origin.gif' width='30' height='20' alt='기본크기' onClick='javascript:jf_setFontSize(\"restore\");' style='cursor:hand'><img src='/image/common/commonutil_screen_up.gif' width='20' height='20' alt='크게보기' onClick='javascript:jf_setFontSize(\"magnify\");' style='cursor:hand'><img src='/image/common/commonutil_screen_down.gif' width='20' height='20' alt='작게보기' onClick='javascript:jf_setFontSize(\"reduce\");' style='cursor:hand'></td>";
		htmlCode += "		<td><img src='/image/common/commonutil_print.gif' width='44' height='20' alt='인쇄' onClick='javascript:cf_print();' style='cursor:hand'></td>";
		htmlCode += "		<td><img src='/image/common/commonutil_copyad.gif' width='65' height='20' alt='주소복사' onClick='javascript:jf_copyClipboard(location.href);' style='cursor:hand'></td>";
		htmlCode += "		<td><img src='/image/common/commonutil_mail.gif' width='79' height='20' alt='메일보내기' onClick='javascript:cf_content_email();' style='cursor:hand'></td>";
		htmlCode += "		<td><img src='/image/common/commonutil_scrab.gif' width='57' height='20' alt='스크랩' onClick='javascript:jf_openWindow(\"" + rtnURL + "\", \"markWindow\",0,0,365,285,365,365,0);' style='cursor:hand'></td>";
		htmlCode += "	</tr>";
		htmlCode += "</form>";
		htmlCode += "</table>";
	} else {
		htmlCode += "&nbsp;";
	}

	document.write(htmlCode);
}

//예시 <script>cf_flashWrite('./image/swf/sub1.swf','100%','300','sub1','#ffffff','','transparent')</script>
// cf_flashWrite(파일경로, 가로, 세로, 아이디, 배경색, 변수, 윈도우모드) 
function cf_flashWrite(url,w,h,id,bg,vars,win){
	 // 플래시 코드 정의 
	var flashStr= 
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+ 
	"<param name='allowScriptAccess' value='always' />"+ 
	"<param name='movie' value='"+url+"' />"+ 
	"<param name='FlashVars' value='"+vars+"' />"+ 
	"<param name='wmode' value='"+win+"' />"+ 
	"<param name='wmode' value='opaque'>"+  
	"<param name='menu' value='false' />"+ 
	"<param name='quality' value='high' />"+ 
	"<param name='bgcolor' value='"+bg+"' />"+ 
	"<param name='wmode' value='transparent'>"+
	"<embed src='"+url+"' FlashVars='"+vars+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' value='opaque' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+ 
	"</object>";
	 // 플래시 코드 출력 
	document.write(flashStr);
} 
//동영상
function cf_aviPlay(src, id, control_f, w, h, autoplay) {
	var autoplayFlag
	if (autoplay == "true") {
		autoplayFlag = "true";
	} else {
		autoplayFlag = "false";
	}
	
	if (navigator.appName == "Microsoft Internet Explorer") {
		cf_aviPlayIE(src, id, control_f, w, h, autoplayFlag);
	}
	else {
		cf_aviPlayFF(src, id, control_f, w, h, autoplayFlag);
	}
}

// 동영상 재생 :: 파이어폭스용
function cf_aviPlayFF(src,id,control_f,w,h, autoplay) {
	var vodStr =
			"<embed id='" + id + "' classid='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95' width='" + w + "' height='" + h + "'" +
				" animationatstart='" + autoplay + "' " +
				" autostart='" + autoplay + "' " +
				" displaybackcolor='black' " +
				" showcontrols='" + control_f + "' " +
				" showstatusbar='0' " +
				" showtracker='1' " +
				" showpositioncontrols='0' " +
				" pluginspage='http://www.microsoft.com/korea/windows/windowsmedia/' " +
				" src='" + src + "'" +
				"	type='video/x-ms-asf-plugin' " +
				" > " +
			"</embed>";

	document.write(vodStr);
}

// 동영상 재생 :: 익스플로우용
function cf_aviPlayIE(src,id,control_f,w,h, autoplay) {
	var vodStr =
			"<object id='" + id + "' classid='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95' width='" + w + "' height='" + h + "'>" + 
			"<param name='AutoStart' value='" + autoplay + "'>" + 
		    "<param name='TransparentAtStart' value='True'> " +
		    "<param name='ShowControls' value='" + control_f + "'>" + 
		    "<param name='ShowDisplay' value='0'>" +
		    "<param name='ShowStatusBar' value='0'>" +
		    "<param name='AutoSize' value='1'>" +
		    "<param name='AnimationAtStart' value='" + autoplay + "'>" +
		    "<param name='FileName' value='" + src + "'>" +
			"</object>";

	
	document.write(vodStr);
	//document.write(document.getElementById(id).value);
}

// 동영상 교체
function cf_sw_vod(vod_src, title, id, mode, curPage, searchField, searchWord) {
	//if (navigator.appName == "Microsoft Internet Explorer") {
	//	cf_sw_vodIE(vod_src, id);
	//}
	//else {
		cf_sw_vodFF(vod_src, title, id, mode, curPage, searchField, searchWord);
	//}
}

// 동영상 교체 :: 파이어폭스용
function cf_sw_vodFF(vod_src, title, id, mode, curPage, searchField, searchWord) {
	var pageSrc = location.href;
	pageSrc = pageSrc.substr(0, pageSrc.indexOf("?"));
	pageSrc +=  "?vodSrc=" + vod_src + "&vodTitle=" + title + "&mode=" + mode + "&curPage=" +curPage+ 
			"&searchField=" +searchField+ "&searchWord=" +searchWord;
	location.href = pageSrc
}

// 동영상 교체 :: 익스플로우용
function cf_sw_vodIE(vod_src, id) {
	var obj = eval("document.getElementById('" + id + "')");
	obj.FileName = vod_src;
}



//============== 

// 로그인
function cf_login(rtnUrl){
	location.href="/site/home/page/sub06/sub06_08.jsp?returnURL=" + rtnUrl;
}

// 로그아웃
function cf_logout(rtnUrl){
	var rtn;
	if(rtnUrl == null){
		rtn = "";
	}
	else{
		rtn = rtnUrl;
	}

	if(parent.location != null){
		parent.location.href="/app/member/login/prc_member_logout_proc.jsp?returnURL=" + rtn;
	}
	else{
		location.href="/app/member/login/prc_member_logout_proc.jsp?returnURL=" + rtn;
	}
}

// 마이페이지 이동
function cf_mypage(){
	alert("마이페이지(구현해야됨)");
	return;
	
  location.href="/site/tour/page/10/sub_10_01.jsp";
}


// 회원가입
function cf_memberJoin(){
	alert("회원가입(구현해야됨)");
	return;

	location.href="/site/tour/page/10/sub_10_07_01.jsp";
}

// 회원 수정
function cf_modifyUser(){
	alert("회원수정(구현해야됨)");
	return;

	location.href="/site/tour/page/10/sub_10_07_02.jsp";
}

// 회원탈퇴
function cf_memberDelete(){
	alert("회원탈퇴(구현해야됨)");
	return;

	location.href="/site/tour/page/10/sub_10_07_03.jsp";
}

// 아이디/패스워드 찾기(팝업)
function cf_findIDPasswd(type, rtnUrl){
	switch(type) {
		case 'findid' :	// 아이디 찾기
      location.href = "/page/executive/service/findid.jsp";
			break;		

		case 'findpasswd' :	// 비밀번호 찾기
      location.href = "/page/executive/service/findpasswd.jsp";
			break;
	}
}

// 컨텐츠 이메일 보내기
function cf_content_email() {

	var contentData = cf_getContents();
	var obj_frm_email = frm_EmailContents;

	// 컨텐츠 내용을 추출함
	obj_frm_email.emailContents.value = "";
	obj_frm_email.emailContents.value = contentData;

	var obj_eMail_Window;
	obj_eMail_Window = window.open('', 'eMail_Window', 'width=700, height=380, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0, left=300, top=200' );
	obj_frm_email.action = '/app/content_email/prc_contentemail_frm.jsp';
	obj_frm_email.target = 'eMail_Window';
	obj_frm_email.submit();
}

// 컨텐츠 이메일 보낼때 보내지는 내용 추출
function cf_getContents() {
	var objContent = document.getElementById("contentsArea");
	
	var printHTML = "";
	printHTML += " <html>                                                         		";
	printHTML += " <head>   																														";
	printHTML += " <title>양양군청입니다.</title>                   								    ";
	printHTML += " <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> ";
	printHTML += " <link href='/common/css/tour.css' rel='stylesheet' type='text/css'>         ";
	printHTML += " </head>                                                             	";
	printHTML += " <body>										                                          	";
	printHTML += " <table>                                                            	";
	printHTML += objContent.outerHTML;
	printHTML += " </table>																															";
	printHTML += "</body>																																";
	printHTML += "</html>																																";

	return printHTML;
}

// 컨텐츠 프린트
function cf_print() {
	
	// var objContent = document.getElementById("contentsArea");
	// 변경 (2008.4.27)
	var objContent = document.getElementById("contents");
	
	var printHTML = " <html>                                                            ";
	printHTML += " <head>                                                               ";
	printHTML += " <title>양양군청 - 프린트 페이지입니다.</title>                       		";
	printHTML += " <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> ";
	printHTML += " <link href='/common/css/tour.css' rel='stylesheet' type='text/css'>         ";
	printHTML += " <link href='/common/css/executive.css' rel='stylesheet' type='text/css'>         ";
	printHTML += " <link href='/common/css/common.css' rel='stylesheet' type='text/css'>         ";
	printHTML += " <style type='text/css'>body {margin-left: 0px;margin-top: 0px;margin-right: 0px;	margin-bottom: 0px;}</style>";
	printHTML += " </head>                                                             	";
	printHTML += " <body onload='javascript:print();'>										                      										";
	printHTML += " <table>                                                             ";
	printHTML += objContent.outerHTML;												
	printHTML += " </table >																													";
	printHTML += "</body></html>";

	var objID =parseInt(Math.random()*100000);	// 창마다 고유값 부여
	var printWin = jf_openWindowRtn('about:blank', objID, 'yes', 'yes', 820, 730, 1, 1, 0);
	printWin.document.write(printHTML);
	printWin.location.reload();
}

//================








// 타이틀 바 
var pathUrl = new Array(); 
pathUrl=String(window.location).split("/")[4];
if(pathUrl == "executive"){
	document.title="해 오름의 고장 양양에 오신 것을 환영합니다.";
}
else if(pathUrl == "tour"){
	document.title="해 오름의 고장 양양에 오신 것을 환영합니다.";
}

