//	=========================	//
//		育官專用自定Java頁		//
//	=========================	//

function MsgLink( file , msg )
{
	if(confirm(msg))
	{
		eval("location='"+ file +"'");
	}
}

function GoLink( file )
{
	eval("location='"+file+"'");
}
  
function PopLink( page , width , height )
{
	window.open(page, "go_link" , "toolbar=no,scrollbars=auto,width=" + width + ",height=" + height + ",resizable=yes");
}





//=================================================================================
/* Samlpe
<input type="button" id="ChangeSubmit" value="開啟" onClick="ChangeVisible('Div',this.id,'DivAddTable','開啟','關閉');">
<div id="DivAddTable" style="padding:10px 0px 0px 0px; display:none">
</div>
*/
//=================================================================================
function ChangeVisible( UpdateObjectTypeString , getTaggerDiv , getUpdateObjectID , OpenedText, ClosedText)
{
	var getobject	= document.getElementById(getUpdateObjectID);
	var getTigger	= document.getElementById(getTaggerDiv);
	
	switch (UpdateObjectTypeString.toUpperCase())
	{
	case "DIV":
		if (getobject.style.display == "none") 
		{
			getTigger.value=ClosedText;
			getobject.style.display='block';
		}
		else
		{
			getTigger.value=OpenedText;
			getobject.style.display='none';
		}
	break;
	}
}









/***********************************************************************************************

*************************************************************************************************/
function ShowCharCode(name) //英文值檢測
{
//if(name.length == 0) { return false; }
	var Result = "";
	
	for(i = 0; i < name.length; i++)
	{ 
		Result += name.charAt(i) + "=" + name.charCodeAt(i) + ",";
		
		if(name.charCodeAt(i) > 128)
		{
			//return false;
		}
		
	}
	
	alert("getChar(" + Result + ")")
	//小寫的a-z是 91~122
	//大寫的A-Z是 65~90
	//數字的0-9是 48~57
}
function IsEnglishOrNumber(getString)
{
	var ReturnMe = true;
	for(i = 0; i < getString.length; i++)
	{ 
		var CharCode = getString.charCodeAt(i);		
		if( CharCode <= 47 || CharCode >= 58 && CharCode <= 64 ||  CharCode >= 123 )
		{
			ReturnMe = false;
			break;
		}
	}
	return ReturnMe;
}
/***********************************************************************************************

*************************************************************************************************/
function CheckIfEmail(email)
{
	invalid = "";
	if ( email.length== 0)
	return true;
	if (!email)
	invalid = "請輸入您的Email地址。";
	else {
	if ( (email.indexOf("@") == -1) || (email.indexOf(".") == -1) )
	invalid += "\\n\\nEmail地址不合法。應當包含\'@\'和\'.\'；例如(\'.com\')。請檢查後再遞交。";
	if (email.indexOf("your email here") > -1)
	invalid += "\\n\\nEmail地址不合法，請檢測您的Email地址，在域名內應當包含\'@\'和\'.\'；例如(\'.com\')。";
	
	
	
	if (email.indexOf("\\\\") > -1)
	invalid += "\\n\\nEmail地址不合法，含有非法字符(\\\\)。";
	if (email.indexOf("/") > -1)
	invalid += "\\n\\nEmail地址不合法，含有非法字符(/)。";
	if (email.indexOf("\'") > -1)
	invalid += "\\n\\nEmail地址不合法，含有非法字符(\')。";
	if (email.indexOf("!") > -1)
	invalid += "\\n\\nEmail地址不合法，含有非法字符(!)。";
	
	
	
	if ( (email.indexOf(",") > -1) || (email.indexOf(";") > -1) )
	invalid += "\\n\\n只輸入一個Email地址，不要含有分號和逗號。";
	if (email.indexOf("?subject") > -1)
	invalid += "\\n\\n不要加入\'?subject=...\'。";
	}
	if (invalid == "")
	{
	return true;
	}
	else
	{
	alert("輸入的Email可能包含錯誤：" + invalid);
	return false;}
}

function IsEmail(name) // E-mail值檢測
{
	if ( !IsEnglish(name) )
	{
		return false;	
	}
	
	var i = name.indexOf("@");
	var j = name.lastIndexOf("@");
	var x = name.indexOf(".");
	
	if ( i == -1 ) { return false; }
	if ( i != j ) { return false; }
	if ( x == -1 ) { return false; }
	if ( i == name.length ) { return false; }
	
	return true;
}

function IsEnglish(name) //英文值檢測
{
if(name.length == 0) { return false; }
	for(i = 0; i < name.length; i++)
	{ 
		if(name.charCodeAt(i) > 128)
		{
			return false;
		}
	}
return true;
}


//--------------------------------------------------------取得大小再彈出圖片====
var imgObj;
function checkImg(theURL,winName){
  if (typeof(imgObj) == "object"){
    if ((imgObj.width != 0) && (imgObj.height != 0)){
		
		if (imgObj.width > 1150 || imgObj.height > 1150){
			OpenFullSizeWindow(theURL,winName, ",width=" + ((imgObj.width/2)+20) + ",height=" + ((imgObj.height/2)+30));
		} else {
			OpenFullSizeWindow(theURL,winName, ",width=" + (imgObj.width+20) + ",height=" + (imgObj.height+30));
		}
		
	} else {
      setTimeout("checkImg('" + theURL + "','" + winName + "')", 100)
	}
  }
}

function OpenFullSizeWindow(theURL,winName,features) {
  var aNewWin, sBaseCmd;
  sBaseCmd = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,";
  if (features == null || features == ""){
    imgObj = new Image();
    imgObj.src = theURL;
    checkImg(theURL, winName)
  }
  else{
    aNewWin = window.open(theURL,winName, sBaseCmd + features);
    aNewWin.focus();
  }
}
//--------------------------------------------------------取得大小再彈出圖片====