// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// show_flash_movie
var debugFlag=false;
function show_flash_movie(swf_name, swf_width, swf_height, swf_src, swf_wmode) {
	var buffer = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+swf_width+"' height='"+swf_height+"' id='"+swf_name+"' swliveconnect='true'>";
	buffer += "<param name='allowScriptAccess' value='sameDomain' />";
	buffer += "<param name='movie' value='"+swf_src+"' />";
	buffer += "<param name='menu' value='false' />";
	buffer += "<param name='quality' value='high' />";
	if(swf_wmode != "") buffer += "<param name='wmode' value='"+swf_wmode+"' />";
	buffer += "<embed src='"+swf_src+"' menu='false' quality='high' width='"+swf_width+"' height='"+swf_height+"' name='"+swf_name+"'	allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	buffer += "</object>";
	document.write(buffer);
}

function show_flash_movie_with_style(swf_name, swf_width, swf_height, swf_src, swf_wmode, style) {
	var buffer = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+swf_width+"' height='"+swf_height+"' id='"+swf_name+"' swliveconnect='true' style='"+style+"'>";
	buffer += "<param name='allowScriptAccess' value='sameDomain' />";
	buffer += "<param name='movie' value='"+swf_src+"' />";
	buffer += "<param name='menu' value='false' />";
	buffer += "<param name='quality' value='high' />";
	if(swf_wmode != "") buffer += "<param name='wmode' value='"+swf_wmode+"' />";
	buffer += "<embed src='"+swf_src+"' menu='false' quality='high' width='"+swf_width+"' height='"+swf_height+"' name='"+swf_name+"'	allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' style='"+style+"' />";
	buffer += "</object>";
	document.write(buffer);
}

function targetedAnchor(url, target) {
	//new Ajax.Updater(target, url );
	new Ajax.Request(url, 
		{
			method:'get',
			onSuccess: function(transport) {
				var response= transport.responseText;
				debug("Success\n\n"+transport.responseText);
				$(target).innerHTML = transport.responseText;
			},
			onFailure:function(){alert('Failed to load this page.\n\n'+url +'\n Please Ask to Webmanager.');}	});
}

function debug(str) {
	if (debugFlag == true)
	{
		alert(str);
	}
}


/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Casey Ryan :: http://www.ebooger.com */

function detectPopupBlocker() {
  var myTest = window.open("about:blank","","directories=no,height=100,width=100,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");
  if (!myTest) {
	return true;
  } else {
    myTest.close();
	return false;
  }
}


//*** 최상단 메뉴 로케이션 함수 모음

function top_go_course(num) {
	switch(num) {
		case 0:      // 과정검색 or 과정 메인
			location.href= "/Cylearn2007/course/course_list_search.asp";
			break;
		case 1: // 기업고용보험제도
			location.href= "/Cylearn2007/course/course_list_insurance.asp?group2=1&group3=1";
			break;
		case 2:      // 개인수강지원금제도
			location.href= "/Cylearn2007/course/course_list_individual.asp";
			break;
		case 3:      // 능력개발카드제
			location.href= "/Cylearn2007/course/course_list_card.asp";
			break;
		case 4:   // 미니모듈과정
			location.href="/Cylearn2007/course/course_list_minimodule.asp";
			break;
	}
}

function top_go_network(num) {
	switch(num) {
		case 0: // HR 동향
			location.href="/Cylearn2007/bbs/bbs_list.asp?bbs_id=2007_HRIssue&page=1";
			break;
		case 1:  // HR 동향
			location.href="/Cylearn2007/bbs/bbs_list.asp?bbs_id=2007_HRIssue&page=1";
			break;
		case 2: // Chairperson Note
			location.href="/Cylearn2007/bbs/bbs_list.asp?bbs_id=2007_chairperson&page=1";
			break;
		case 3: //WLP Forum
			location.href="/Cylearn2007/bbs/bbs_list.asp?bbs_id=2007_wlp&page=1";
			break;
		case 4: // 지식공유
			location.href="/Cylearn2007/bbs/bbs_list.asp?bbs_id=2007_knowledge&page=1";
			break;
		case 5: // HRD 용어사전
			location.href="/Cylearn2007/network/dictionary.asp";
			break;
	}
}

function top_go_info(num) {
	switch(num) {
		case 0: // Cy-learn 소개
			location.href="/cylearn2007/info/cy-learn.asp"
			break;
	}
}

//*** 메인페이지 신규/추천과정 carousel 로케이션 함수 모음

// 플래시 대응 함수
// @param  page : 1: 추천과정 2: 신규교육과정 3: 인기교육과정
// @param  num 
function carousel_flash_open(page, num) {
	var courseCodes = new Array(4);
	courseCodes[1] = new Array("", "CA0253","CA0158", "CA0244");
	courseCodes[2] = new Array("", "CA0253","CA0209", "CA0292");
	courseCodes[3] = new Array("", "CA0244", "CM0094", "CA0105");

	carousel_open(courseCodes[page][num]);
}

/* @param courseCode : 열고자 하는 과정의 cy-learn courseCode 
*/
function carousel_open(courseCode) {
	location.href="/Cylearn2007/course/course_view_normal.asp?CourseCode=" + courseCode;
}



//*** 좌측 메뉴 오픈 함수 모음

// 교육체계도
function left_help_open_education() {
	window.open("/Cylearn2007/course/popup/education.html", "education", "width=800,height=650,statusbar=no,titlebar=no,scrollbars=auto,resizable=yes");
}


// 패턴 검증 함수. 패턴이 맞으면 주어진 메시지를 출력하고 true를 리턴
// @param pattern : 걸러낼 패턴의 정규식
// @param string : 검증대상 문자열
// @param message : 필터링 될 때 나올 에러 메시지
// @return : true - 패턴 일치. 필터링 되었음. false= 패턴 불일치. 필터 통과
function filter_pattern(pattern, string, message) {
	if( string.search(pattern) == -1) {
		if( message != null) { alert(message);}
		return true;
	} else
		return false;
}

// 주어진 엘리먼트의 클래스 바꾸는 함수
function changeClass(Elem, myClass) {
	var Elem;
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all) {
		var elem = document.all[Elem];
	}
	elem.className = myClass;
}

// 회사소개 > 사업영역 에서 왼쪽 사이드 메뉴 스타일 바꾸는 함수
function change_left_activity(num) {
	for (i=1; i <=4; i++) {
		$("left_activity_li"+i).className = "level2";
		$("left_activity_a"+i).style.color="black";
	}
	str = "left_activity_li" + num;
	changeClass(str, "level2_2");
	anchor = "left_activity_a" + num;
	$(anchor).style.color="#B52829";
}

// 창 띄우고 가운데로 보내는 함수
function openWinCenter(url, wind, width, height, option) {
	if(option != "" && option != null) 
		option = ", " + option 
	else 
		option = "";
	posX = parseInt(((screen.availWidth - width)/2) < 0 ? 0 : ((screen.availWidth - width)/2));
	posY = parseInt(((screen.availHeight- height)/2) < 0 ? 0 : (screen.availHeight- height)/2); 
	optionlist= "width="+width+", height=" + height + ",screenX=" + posX + ",screenY=" +posY+",top="+posY+",left="+posX + option;
	var wind5 = window.open(url, wind, optionlist);
	wind5.focus();
}

// 메뉴창 로그인 처리
function login_submit() {
	var user_id = document.getElementById('user_id');
	if(user_id.value == "" || user_id.value.length < 2) {
		alert('아이디를 입력해 주세요');
		return;
	}

	var user_pw = document.getElementById('user_pw');
	if(user_pw.value== "" || user_pw.value.length < 2) {
		alert('패스워드를 입력해 주세요');
		return;
	}
	var form = document.getElementById('myForm');
	form.submit();
}


/*
2008-08-23
박경태 : 이미지 링크 클릭할때마다 점선 테두리 생기는것 방지용으로 코드 삽입
*/
function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document.onfocusin=bluring; 


function monitorClassroomOpen(ClassroomCode, FrameWidth, FrameHeight, Mode) {
	winURL = "/platform/Learner/Classroom/Classroom.asp?ClassroomCode=" + ClassroomCode + "&CourseLearnerCode=Admin&Mode=" + Mode;
	PosX = (screen.availWidth - FrameWidth) / 2;
	PosY = (screen.availHeight - FrameHeight) / 2;
	var winHandle = window.open(winURL, ClassroomCode, "z-title=no, status=no, scrollbars=yes, resizable=yes, width=" + FrameWidth + ", height=" + FrameHeight);
	winHandle.moveTo(PosX, PosY);
}
