function ReloadImage(imgName, stringSrc)
{
	imgName.src = stringSrc;
}

// ----------------------- //
// --	Menu Function	-- //
// ----------------------- //
function InitMenu()
{
	var showMenu = GetCookie("ShowMenu");
	if(showMenu == "False")
	{
		var mainDiv = document.getElementById("Div_Menu");
		var leftImg = document.getElementById("btn_MoveLeft");
		var rightImg = document.getElementById("btn_MoveRight");
		mainDiv.style.left = "-220px";
		leftImg.style.display = "none";
		rightImg.style.display = "block";
	}
}
function StratMove(moveDirection)
{
	var mainDiv = document.getElementById("Div_Menu");
	var leftImg = document.getElementById("btn_MoveLeft");
	var rightImg = document.getElementById("btn_MoveRight");

	var currentLeftStr = mainDiv.style.left;
	currentLeftStr = currentLeftStr.substring(0, currentLeftStr.length - 2);
	var currentLeft = parseInt(currentLeftStr);
	if(moveDirection == 0 && currentLeft <= -220)
	{
		leftImg.style.display = "none";
		rightImg.style.display = "block";
		SetCookie("ShowMenu", "False", 0);
		return;
	}
	if(moveDirection == 1 && currentLeft >= 0)
	{
		leftImg.style.display = "block";
		rightImg.style.display = "none";
		SetCookie("ShowMenu", "True", 0);
		return;
	}
	var perMoveLength = 0;
	if(moveDirection == 0)
		perMoveLength = -20;
	else
		perMoveLength = 20;
	mainDiv.style.left = (currentLeft + perMoveLength) + "px";
	window.setTimeout("StratMove(" + moveDirection + ");", 10);
}

// ----------------------- //
// --	Cookie Function	-- //
// ----------------------- //
function SetCookie(name, value, expiresMins)
{
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (expiresMins > 0) ? expiresMins * 60 : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString())) +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain)) +((secure == true) ? "; secure" : "");
}
function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie(name) 
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break; 
	}
	return null;
}

// ----------------------- //
// --	View Course 	-- //
// ----------------------- //

function ViewCourse(serialNo)
{
	var x =window.open("../Course/" + serialNo + "/Enter.ppc", "Course", "height=572,width=807,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
	if(x != null)
		x.focus();
}
/*
function ViewCourse(serialNo,CourseID)
{
	var x =window.open("../Index/LearnCourse.aspx?serialNo="+serialNo+"&CourseID="+CourseID, "Course", "height=572,width=807,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
	if(x != null)
	   x.focus();
}
*/
// ----------------------- //
// --	Overview Course	-- //
// ----------------------- //
function ViewCourseOverview(courseID)
{
	var x = window.open("../CourseCenter/CourseOverview.aspx?ID=" + courseID, "CourseOverview", "height=350,width=400,top=100,left=200,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
	if(x != null)
		x.focus();
}
function GotoMe(url)
{
	var iWidth=1024;
	var iHeight=768;
	var iTop = (window.screen.height-iHeight)/2;
	var iLeft = (window.screen.width-iWidth)/2;
	window.open(url, "DemoCourse","Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no,Width="+iWidth+",Height="+iHeight+",top="+iTop+",left="+iLeft);
}

// ----------------------- //
// --	PlanCourseList	-- //
// ----------------------- //
function ViewPlanCourseList(planID)
{
	var x = window.open("../StudyPlan/ViewPlanCourse.aspx?ID=" + planID, "PlanCourse", "height=350,width=500,top=80,left=150,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
	if(x != null)
		x.focus();
}

// ----------------------- //
// --	Elearning Info	-- //
// ----------------------- //
function ViewELearningInfo()
{
	var x = window.open("../Popup/AboutElearning.aspx", "AboutELearning", "height=300,width=400,top=100,left=200,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
	if(x != null)
		x.focus();
}

// ----------------------- //
// --	Monthly Detail	-- //
// ----------------------- //
function ViewMonthDetail(year, month)
{
	var x = window.open("../Popup/MonthlyDetail.aspx?Year=" + year + "&Month=" + month, "MonthlyDetail", "height=400,width=690,top=100,left=200,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
	if(x != null)
		x.focus();
}

// ----------------------- //
// --	Get Resource 	-- //
// ----------------------- //
function GetResource(resourceID)
{
	var x = window.open("GetResource.aspx?ResourceID=" + resourceID, "Resource", "height=150,width=150,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
	if(x != null)
		x.focus();
}

// ----------------------- //
// --	Tech Check	 	-- //
// ----------------------- //
function TechCheck()
{
	var x = window.open("../Popup/TechCheck_1.aspx", "TechCheck", "height=430,width=650,top=100,left=50,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
	if(x != null)
		x.focus();
}

// ----------------------- //
// --	Client Check 	-- //
// ----------------------- //
function Trim(valueString)
{
	valueString = valueString.replace(/\ /g, "");
	return valueString;
}

function isValidPhone(phonenum)
{
	//var regu	= "^([0-9(]+)+([0-9-.()]*)+([0-9)]+)$"
    //var reg		= new RegExp(regu);
    //return (phonenum.search(reg) > -1);
    return true;
}

function isValidEmail(email)
{
	var regu	= "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*))@([a-zA-Z0-9-]+[.])+([a-zA-Z]+)$";
    var reg		= new RegExp(regu);
    return (email.search(reg) > -1);
}

function isValidPassword(pass)
{
	var regu = "^[_\.0-9a-zA-Z-]+$";
    var reg		= new RegExp(regu);
    return (pass.search(reg) > -1);
}
function isNumberic(checkStr)
{
	var i,j,strTemp;
	strTemp="0123456789";
	if(checkStr.length == 0)
		return false;
	for(i = 0;i < checkStr.length;i++)
	{
		j = strTemp.indexOf(checkStr.charAt(i)); 
		if (j == -1)
		{
			return false;
		}
	}
	return true;
}