﻿// 준비중입니다 경고창
function CommingSoon() {
	alert("준비중입니다.");
}


// 윈도우 오픈 스크롤 없음
function WindowOpen(Url, popName, popwidth, popheight) {
    var valReturn;
    var height = screen.height;
    var width = screen.width;
    var left = width / 2 - (popwidth / 2);
    var top = height / 2 - (popheight / 2);
    popheight = popheight + 27;
    valReturn = window.open(Url, popName, "width=" + popwidth + ",height=" + popheight + ",scrollbars=no,toolbar=no,left=" + left + ",top=" + top + "")
    return valReturn;
}


// 윈도우 오픈 스크롤 있음
function WindowOpen2(Url, popName, popwidth, popheight) {
	var valReturn;
	var height = screen.height;
	var width = screen.width;
	var left = width / 2 - (popwidth / 2);
	var top = height / 2 - (popheight / 2);
	popheight = popheight + 27;
	valReturn = window.open(Url, popName, "width=" + popwidth + ",height=" + popheight + ",scrollbars=yes,toolbar=no,left=" + left + ",top=" + top + "")
	return valReturn;
}


// 해상도에 따른 Popup
function openPopUpFullScreenMoon(url) {
	var win;
	var width = screen.width;
	var height = screen.height;

	if (width <= 800 && height <= 600) {
		win = window.open(url, 'fullscreendemo', 'width=' + (screen.width - 8) + ', height=' + (screen.height - 55) + ',resizable=yes,statusbar=no,scrollbars=yes,left=0,top=0');
	} else if (height <= 768) {
		win = window.open(url, 'fullscreendemo', 'width=' + (screen.width - 8) + ', height=' + (screen.height - 55) + ',resizable=yes,statusbar=no,scrollbars=yes,left=0,top=0');
	} else {
		win = window.open(url, 'fullscreendemo', 'width=' + (screen.width - 8) + ', height=' + (screen.height - 55) + ',resizable=no,statusbar=no,scrollbars=yes,left=0,top=0');
	}
}

function openPopUpFullScreen(url, popname) {
	var win;
	var width = screen.width;
	var height = screen.height;

	if (width <= 800 && height <= 600) {
		win = window.open(url, popname, 'width=' + (screen.width - 8) + ', height=' + (screen.height - 55) + ',resizable=yes,statusbar=no,scrollbars=yes,left=0,top=0');
	} else if (height <= 768) {
	win = window.open(url, popname, 'width=' + (screen.width - 8) + ', height=' + (screen.height - 55) + ',resizable=yes,statusbar=no,scrollbars=yes,left=0,top=0');
	} else {
	win = window.open(url, popname, 'width=' + (screen.width - 8) + ', height=' + (screen.height - 55) + ',resizable=no,statusbar=no,scrollbars=yes,left=0,top=0');
	}
}


// 팝업창 닫기
function popClose() {
	window.close();
}


// 동영상 열기
function PlayMoviePop(path, file) {
	WindowOpen("/Common/Movie.aspx?path=" + path + "&file=" + file, "popMoviePlay", 460, 380);
}


// 화상수업 솔루션 실행
function WebClass() {
	WindowOpen("/Common/Saeha.aspx", "webclass", 1024, 830);
}


// 원격지원 열기
function Remote() {
	WindowOpen("http://rsup.net/edubox", "PWND_RCNT", 800, 600);
}


// 원격지원 프로그램 다운로드
function RemoteDown() {
	location.href = "/Common/Download.aspx?m=remote";
}


// 화상수업 솔루션 프로그램 다운로드
function WebClassDown() {
	//location.href = "http://121.125.69.35/download.asp?section=kor_client";
	location.href = "http://121.125.69.35:8081/files/client/Edubox57_5722(Kor).exe";
}


// 잉글리쉬와이즈 학습창
function EnglishWise() {
	WindowOpen2("/Common/EnglishWise.aspx", "EW_WIN", 1024, 768);
}


// 이지스 학습창
function Easys(uid, uname) {
	WindowOpen("/Common/Easys.aspx", "ES_WIN", 980, 705);
}


// 메가골 학습창
function MegaGoal(num) {
	WindowOpen("/Common/MegaGoal.aspx?num=" + num, "MG_WIN", 1024, 768);
}


// 동영상 강의
function MovieLesson(course, unit, lesson) {
	WindowOpen2("/Common/MovieLesson.aspx?c=" + course + "&u=" + unit + "&l=" + lesson, "popMovieLesson", 1024, 800);
}


// 동영상 강의 샘플
function MovieLessonSample(s) {
	WindowOpen2("/Common/MovieLessonSample.aspx?s=" + s, "popMovieSample", 1024, 800);
}


// 샘플용 e-book 보기
function SampleBook(num) {
	openPopUpFullScreenMoon("/Common/SampleBook.aspx?num=" + num);
}


// 내 책 진도 보기
function MyBooks() {
	WindowOpen2("/Common/MyBooks.aspx", "MyBooks", 726, 800);
}


// 음성파일 출력
function SoundPlay(path) {
	WindowOpen("/Common/SoundPlay.aspx?path=" + path, "popMusicPlay", 360, 100);
}


// 영문 타자연습
function EngPractice(keytype) {
	WindowOpen("/practice/eng_" + keytype + ".html", "popEngPractice", 820, 600);
}


// 녹화파일 리스트
function RecList(cyear, cmonth, cday, classnum, teacherid) {
	WindowOpen2("http://121.125.69.35:8081/recfile/path.asp?y=" + cyear + "&m=" + cmonth + "&d=" + cday + "&c=" + classnum + "&t=" + teacherid, "recfile", 300, 300);
}


// 숫자입력 체크 - onchange="CheckNum()"
function CheckNum() {
	var e1 = event.srcElement;
	var num = "0123456789-";
	var tmp = "";
	var str_yb = false;

	for (var i = 0; i < e1.value.length; i++) {
		if (-1 == num.indexOf(e1.value.charAt(i))) {
			str_yb = true;
		} else {
			tmp = tmp + e1.value.charAt(i);
		}
	}

	if (str_yb) {
		alert("숫자만 입력하셔야 합니다.");
		e1.value = tmp;
		e1.focus();
		return false;
	}
}


// 쿠키 정보 저장하기
function setCookie(name, value, expiredays) {
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() + expiredays);
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

// 쿠키 정보 가져오기
function getCookie(name) {
	var Found = false
	var start, end
	var i = 0

	while (i <= document.cookie.length) {
		start = i
		end = start + name.length

		if (document.cookie.substring(start, end) == name) {
			Found = true
			break
		}
		i++
	}

	if (Found == true) {
		start = end + 1
		end = document.cookie.indexOf(";", start)
		if (end < start)
			end = document.cookie.length
		return document.cookie.substring(start, end)
	}

	return ""
}

// 팝업 띄우기(공통)
function openPopup(src, name, top, left, width, height) {
	if (getCookie(name) != "no") {
		window.open(src, name, "top=" + top + ", left=" + left + ", width=" + width + ", height=" + height);
	}
}

// 라이트함수
function Right(str, n) {
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else {
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}

// 레프트함수
function Left(str, n) {
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else {
		return String(str).substring(0, n);
	}
}

// 숫자형 콤마 입력
function addCommas(strValue) {
	var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
	while (objRegExp.test(strValue)) {
		strValue = strValue.replace(objRegExp, '$1,$2');
	}
	return strValue;
} 

