﻿function set_info(module_value) {
	//alert("1 : " + module_value);
	progress_info=module_value.substring(0,8)+progress_info.substring(8,10);
	flag=true;
	//alert("1 : " + module_value+" / " + progress_info);
	if(progress_info.length==10){
		for(i=0;i<progress_info.length;i++){
			if(progress_info.charAt(i) != isNaN){
				flag=flag && true;
			}else{
				flag=flag && false;
			}
		}
		if(flag){
			parent.setCookie("sinf",progress_info, null, "/");
			parent.on_exit(progress_info);
		}
	}
}
function set_info1(module_value) {
	//alert("2 : " + module_value);
	progress_info=module_value.substring(0,8)+progress_info.substring(8,10);
	flag=true;
	//alert("2 : " + module_value+" / " + progress_info);
	if(progress_info.length==10){
		for(i=0;i<progress_info.length;i++){
			if(progress_info.charAt(i) != isNaN){
				flag=flag && true;
			}else{
				flag=flag && false;
			}
		}
		if(flag){
			parent.setCookie("sinf",progress_info, null, "/");
			parent.on_savesinf(progress_info);
		}
	}
}
function set_info2(module_value) {
	//alert("3 : " + module_value);
	//?´ì¦ˆ ?€??
	flag=true;
	if(parseInt(module_value.substring(0,2),10) >parseInt(progress_info.substring(8,10),10) ){
		progress_info=module_value.substring(0,8)+module_value.substring(0,2);
		if(progress_info.length==10){
			for(i=0;i<progress_info.length;i++){
				if(progress_info.charAt(i) != isNaN){
					flag=flag && true;
				}else{
					flag=flag && false;
				}
			}
			if(flag){
				parent.setCookie("sinf",progress_info, null, "/");
				parent.on_savesinf(progress_info);
				//contents.swfcontent.setVariable("progress_info", progress_info);
			}
		}
	}
}

//dir= dir.split("/"+course_code+"/");
//dir=dir[1];
function callProgressP(module_value,flag){
	//alert(module_value+","+flag+" / "+ progress_info);
	//if(parseInt(module_value.substring(0,2),10)<1 || !module_value.substring(0,2)){
		//aa = confirm("第一页\n\r点击确认键盘，转入简介");
	//}else{
		//aa = confirm("第一页\n\r点击确认键盘，转入前一节");
	//}
	//if(aa){
		callProgress(module_value,flag)
	//}
}
function callProgressN(module_value,flag){
	//alert(module_value+","+flag+" / "+ progress_info);
	//if(parseInt(module_value.substring(0,2),10)>6 || !module_value.substring(0,2)){
		//chk();
		//aa = confirm("最后一页\n\r点击确认键盘，转入简介");
		//if(aa){
			//top.close();
		//}
	//}else{
		//aa = confirm("最后一页\n\r点击确认键盘，转入下一节");
	//}
	//if(aa){
		callProgress(module_value,flag)
	//}

}
function callProgress(module_value,flag){
	//alert(module_value+","+flag+" / "+ progress_info);
	chap	    = parseInt(module_value.substring(0,2),10);
	subject	    = parseInt(module_value.substring(2,4),10);
	page	    = parseInt(module_value.substring(6,8),10);
	open_info = parseInt(progress_info.substring(8,10),10);
	
	ichap	    = itostr(parseInt(module_value.substring(0,2),10));
	isubject    = itostr(parseInt(module_value.substring(2,4),10));
	ipage	    = itostr(parseInt(module_value.substring(6,8),10));
	iopen_info = itostr(parseInt(progress_info.substring(8,10),10));
	
	var dir=document.location.href;
	/*
	if (!dir || dir==null){
		var dir=document.location.href;
	}
	*/
	dir=dir.split("/"+course_code+"/");
	dir=dir[0]+"/"+course_code;
	//dir=dir[0]+"/guest/fire12/";
	
	//alert(dir);
		if(flag){
			if(chap == part_array[1]+1 ){
				progress_info=module_value.substring(0,8)+progress_info.substring(8,10);
				document.location=dir+"/intro/partIntro_02.htm";
			}else if(chap == part_array[2]+1){
				progress_info=module_value.substring(0,8)+progress_info.substring(8,10);
				document.location=dir+"/intro/partIntro_03.htm";
			}else if(chap > part_array[3]+1){
				progress_info="1108010112";
				document.location=dir+"/intro/partOuttro_03.htm";
			}else{
				progress_info=module_value.substring(0,8)+progress_info.substring(8,10);
				document.location=dir+"/"+module_array[chap]+"/intro.htm";
			}
		}else{
			if(chap>5){
				if(chap<7){
					progress_info="05060101"+progress_info.substring(8,10);
					//document.location=dir+"/intro/partOuttro_03.htm";
					document.location = dir+"/fire12_06/moduleframe.htm";
				}else{
					progress_info="05060101"+progress_info.substring(8,10);
					document.location = dir+"/intro/moduleframe.htm";
				}
			}else if(chap<1 || !module_value || module_value==null){
				progress_info="01010101"+progress_info.substring(8,10);
				document.location = dir+"/intro/moduleframe.htm";
			}else{
				progress_info=module_value.substring(0,8)+progress_info.substring(8,10);
				//alert(module_array[chap]+"/"+isubject+" / "+ ipage);
				if(module_array[chap]!="fire12_01") {
						return;
				} else {
					document.location=dir+"/"+module_array[chap]+"/"+isubject+"/01"+ipage+".htm";
				}
			}
		}
	
}

function callexit() {
	answer = confirm("您想结束学习吗？");
	if(answer){
		var dir=document.location.href;
		/*
		if (!dir || dir==null){
			var dir=document.location.href;
		}
		*/
		dir=dir.split("/"+course_code+"/");
		dir=dir[0]+"/"+course_code;
		
		//alert(dir);
		top.close();
		return;
		if(document.contents){
			document.location = dir+"/intro/moduleframe.htm";
		}else if(parent.contents){
			document.location = dir+"/intro/moduleframe.htm";
		}else{
			document.location = dir+"/intro/moduleframe.htm";
		}
		//top.close();
	}
}

function down(val){
	//alert(val);
	dir=dir.split("/"+course_code+"/");
	dir=dir[0]+"/"+course_code;
	authwin = window.open(dir+"/down.htm", "downPage", "menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,left=0,top=0,width=250,height=150");
	downVal=val;
}

function startchap(ichap,isubject,ipage){
	var dir=document.location.href;
	dir=dir.split("/"+course_code+"/");
	dir=dir[0]+"/"+course_code;
	if(ichap==1 || ichap==6 || ichap==11){
		window.open(dir+"/"+course_code+"_"+itostr(ichap)+'/moduleIntro.htm','newwin','fullscreen=1,scrollbars=no,resizable=yes');
	}
	callchap(ichap,1,1);
}

function callchapN(ichap,isubject,ipage){
	//if(ichap==6){
		//answer = confirm("您想转入到参考网页吗？\r请点击确认");
		//if(answer){
			on_help1();
		//}
	//}else{
		/*if(ichap==1) {
				answer = confirm("您想转入到第一节吗？\r请点击确认");
		} else if(ichap==2) {
				answer = confirm("您想转入到第二节吗？\r请点击确认");
		} else if(ichap==3) {
			answer = confirm("您想转入到第三节吗？\r请点击确认");
		} else if(ichap==4) {
			answer = confirm("您想转入到第四节吗？\r请点击确认");
		} else if(ichap==5) {
			answer = confirm("您想转入到第五节吗？\r请点击确认");
		}
		if(answer){*/
			//callchap(ichap,isubject,ipage);
		//}
	//}
}

function callchap(ichap,isubject,ipage){
/*
	if(ichap>1){
		alert("?„ìž¬ Open ì¤€ë¹?ì¤??…ë‹ˆ??");
	}else{
*/	
alert("dd");
	if(!isubject || isubject==null){
		isubject=0;
	}
	if(!ipage || ipage == null){
		ipage=0;
	}
	ichap=parseInt(ichap,10);
	isubject=parseInt(isubject,10);
	ipage=parseInt(ipage,10);
	
	temp_sub=itostr(parseInt(ichap),10) +""+ itostr(parseInt(isubject),10)+"01"+itostr(parseInt(ipage),10);
	chap=parseInt(ichap,10);
	subject=parseInt(isubject,10);
	page=parseInt(ipage,10);
	//
	old_chap=parseInt(progress_info.substring(0,2),10);
	old_subject=parseInt(progress_info.substring(2,4),10);;
	open_info=parseInt(progress_info.substring(8,10),10);
	//
	//alert(ichap+","+isubject+","+ipage);
	//alert(document.location.href);
	var dir=document.location.href;
	/*
	if (!dir || dir==null){
		var dir=document.location.href;
	}
	*/
	dir=dir.split("/"+course_code+"/");
	dir=dir[0]+"/"+course_code;
	
	//alert(dir);
		
		if(parseInt(temp_sub.substring(0,2),10)>11){
			progress_info="11080101"+progress_info.substring(8,10);
		}else if(parseInt(temp_sub.substring(0,2),10)<1){
			progress_info="01010101"+progress_info.substring(8,10);
		}else{
			//progress_info=temp_sub+progress_info.substring(8,10);
		}
		if(isubject==99){
		//?ŒíŠ¸ ?„ì›ƒ?¸ë¡œë¡??´ë™
			if(chap == 4){
				document.location=dir+"/intro/partOuttro_01.htm";
			}else if(chap == 8){
				document.location=dir+"/intro/partOuttro_02.htm";
			}else if(chap == 12){
				document.location=dir+"/intro/partOuttro_03.htm";
			}
		}else if(isubject==0 && ipage==0){
		//?ŒíŠ¸ ?¸íŠ¸ë¡œë¡œ ?´ë™
			document.location=dir+"/"+module_array[chap]+"/intro.htm";
		}else if(isubject != 0 && ipage==0){
		//ì±•í„° ?¸íŠ¸ë¡œë¡œ ?´ë™
			document.location=dir+"/"+module_array[chap]+"/intro.htm";
		}else{
		//?˜ì´ì§€ë¡??´ë™
			isubject=itostr(parseInt(isubject,10));
			ipage=itostr(parseInt(ipage,10));
			progress_info=temp_sub+progress_info.substring(8,10);
			document.location=dir+"/"+module_array[chap]+"/"+isubject+"/01"+ipage+".htm";
		}
	/*
	}
	*/
 }
 

function itostr(inum){
	return inum<10?"0"+inum:inum;
}


 function calllast(){
	//alert(progress_info);
	chap=parseInt(progress_info.substring(0,2),10);
	subject=parseInt(progress_info.substring(2,4),10);
	page=parseInt(progress_info.substring(6,8),10);
	
	ichap=itostr(parseInt(progress_info.substring(0,2),10));
	isubject=itostr(parseInt(progress_info.substring(2,4),10));
	ipage=itostr(parseInt(progress_info.substring(6,8),10));
	
	document.location="../"+module_array[chap]+"/"+isubject+"/01"+ipage+".htm";
}

 
function callchap1(ichap,subject){
 	callchap(ichap,subject);
 }

function gotoNextModule(ichap){
	if(ichap>=25){
		bb = confirm("最后一页\ 点击确认键盘，转入简介");
		if(bb){
			document.location="../intro/moduleframe.htm";
		}
	}else{
		if(ichap!=26){
			nextChap = ichap + 1;
		}
		aa = confirm("最后一页\ 点击确认会转移到下一程序。");
		if(aa){
			nextChap = ichap+1;
			if(nextChap==26){
				alert("这是最后程序。 转向索引。");
				document.location="../intro/moduleframe.htm";
			} else{
				temp_sub=itostr(parseInt(nextChap,10)) +""+ itostr(parseInt(1,10));			
				set_info(temp_sub);
				temp_sub = temp_sub;
				if(nextChap==1){
					document.location="../"+module_array[nextChap]+"/moduleframe.htm";
				}else{
					document.location="../swf/moduleframe.htm";
				}
			}
		}
	}
 }
 
 function gotoPrevModule(){
	if(parseInt(temp_sub.substring(0,2),10)==1){
		bb = confirm("最后一页。\ 点击确认键盘，转入简介");
		if(bb){
			document.location="../intro/moduleframe.htm";
		}
	}else{
		aa = confirm("这是第一页。\ 点击确认转到前一个程序");
		 	if(aa){
				prevChap = temp_sub.substring(0,2);
				prevChap= parseInt(prevChap,10);
				prevChap = prevChap-1;
				if (prevChap==0) {
					alert("这是第一个程序。 转向索引。");
					document.location="../intro/moduleframe.htm";
				}else {
					subject=parseInt(module_last_page[prevChap],10);
					temp_sub=itostr(prevChap)+""+itostr(subject);
					callchap(prevChap,subject);
				}
			}
		 }
 }
 
function gotoNextPageAction(ichap,subject,thisLoadPage){
	callchap(ichap,subject);
}


function viewFlagAction(flag){
}

function exit_help() {
		top.close();
}
function on_help(){
	//alert("?„ìž¬ Open ì¤€ë¹?ì¤??…ë‹ˆ??");
	url = "../help/moduleframe.htm";
	authwin = window.open(url, "help", "menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,left=0,top=0,width=800,height=600");
}
function on_help1(){
	//alert("?„ìž¬ Open ì¤€ë¹?ì¤??…ë‹ˆ??");
	var dir=document.location.href;
	dir=dir.split("/"+course_code+"/");
	dir=dir[0]+"/"+course_code;
	document.location=dir+"/fire12_06/moduleframe.htm";
}
function on_proc(){
	//alert("?„ìž¬ Open ì¤€ë¹?ì¤??…ë‹ˆ??");
	url = "../map/moduleframe.htm";
	authwin = window.open(url, "map", "menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,left=0,top=0,width=800,height=600");
}

function on_list(){
	//alert("ë³?ê²Œì‹œ?ì? ì¤€ë¹?ì¤??…ë‹ˆ??");
	//?„ëž˜ ì£¼ì„???†ì• ê³?url ?˜ì •
	url="http://www.samsungfire.com/bbs/other/2000017/2000017_bbs_e_list.jsp"
	//url ?˜ì •
	authwin = window.open(url, "help", "menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,left=0,top=0,width=800,height=650");
}


function saveCookie(inputTxt){
	var sDir=document.location.href;
	sDir=sDir.split("/"+course_code+"_");
	sDir=sDir[1].substring(0,2);
	alert("已储存");
	setCookie("inputTxt"+sDir,inputTxt, null, "/");
}
function popwin(theURL,x,y){
	//alert(theURL);
	var dir=document.location.href;
	dir=dir.split("/"+course_code+"/");
	dir=dir[0]+"/"+course_code;
	htmlURL=dir+"/popup.htm";
	//
	swfURL=document.location.href.split(".htm");
	swfURL1=theURL.split("/");
	swfURL1=swfURL1[3].split(".htm");
	swfURL1=swfURL1[0].split("p");
	swfURL=swfURL[0]+"p"+swfURL1[1]+".swf";
	//alert(swfURL);
	//i++;
	popNum = progress_info +""+ swfURL1[1];
	//alert(popNum);
	if(popNum && theURL){
		aa = window.open(htmlURL, "popWin"+popNum ,"toolbar=no, menubar=no, scrollbars=no, resizable=no, width="+x+", height="+y+", status=no,top=0");
		aa.focus();
	}else{
		popwin(theURL,x,y)
	}
	popVal=swfURL;
	xVal=x;
	yVal=y;
}
function down(val){
	//alert(val);
	authwin = window.open("../../down.htm", "downPage", "menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,left=0,top=0,width=250,height=150");
	downVal=val;
}
function on_print(x,y){
	var dir=document.location.href;
	var theURL = document.location.href;
	dir=dir.split("/"+course_code+"/");
	dir=dir[0]+"/"+course_code;
	
	//htmlURL=dir+"/print.htm";
	//
	swfURL=theURL.split("0101");
	swfURL=swfURL[0]+"print_mc.htm";
	//theURL=theURL[1];
	//alert(swfURL);
	//
	i++;
	y=y+30;
	window.open(swfURL, "print"+i ,"toolbar=no, menubar=no, scrollbars=no, resizable=yes, width="+x+", height="+y+", status=no,align=left,left=0,top=0");
	//printVal=swfURL;
	xVal=x;
	yVal=y;
}

/****** ?ì—…ì°?ë¦¬ì‚¬?´ì¦ˆ **************************************************************/
function popResize() {
	var thisX = document.getElementById("offsetTable").offsetWidth;
	var thisY = document.getElementById("offsetTable").offsetHeight;
	var headerY = document.getElementById("offsetTableHeader").offsetHeight;
	var footerY = document.getElementById("offsetTableFooter").offsetHeight;
	var maxThisX = screen.width - 50;
	var maxThisY = screen.height - 80;
	if (window.navigator.userAgent.indexOf("SV1") != -1){
	var marginY = headerY + footerY +58; //ë§ˆì?ë§??˜ëŠ” ?í™©?ë”°???Œë§žê²??£ìœ¼?¸ìš”. (?œí”Œë¦¿ì˜ ?¤ë”?’ì´ + ?‹í„° ?’ì´ + ?ŒíŒŒ)
	} else {
	var marginY = headerY + footerY + 29; //ë§ˆì?ë§??˜ëŠ” ?í™©?ë”°???Œë§žê²??£ìœ¼?¸ìš”. (?œí”Œë¦¿ì˜ ?¤ë”?’ì´ + ?‹í„° ?’ì´ + ?ŒíŒŒ)
	}
	
	if (thisX > maxThisX) {
		window.document.body.scroll = "yes";
		thisX = maxThisX;
	}
	if (thisY > maxThisY - marginY) {
		window.document.body.scroll = "yes";
		thisX += 19;
		thisY = maxThisY - marginY;
	}
	
	var windowX = (screen.width - (thisX+10))/2;
	var windowY = (screen.height - (thisY+marginY))/2 - 20;
	window.moveTo(windowX,windowY);
	
	window.resizeTo(thisX+10,thisY+marginY);
}


