﻿//	=========================	//
//		育官專用自定Java頁		//
//	=========================	//


function RAZGRIZ_GOLINK(file)
{eval("location='"+file+"'");}

function RAZGRIZ_GOMSG(msg,file)
{  if(confirm(msg))
    eval("location='"+file+"'");}

function RAZGRIZ_POPGOMSG(msg,file,width,height)
{  if(confirm(msg))
    window.open(file,"_blank", "toolbar=no,scrollbars=yes,width=" + width + ",height=" + height + ",resizable=yes")	;}

/*  函數【go_link_noscrol】*/
function RAZGRIZ_POPGOLINK2(page,width,height)
{   if ((width < 1000) && (height < 1000)){
	window.open(page,"_blank", "toolbar=no,scrollbars=auto,width=" + width + ",height=" + height + ",resizable=yes")        }}

/*  函數【go_link】*/
function RAZGRIZ_POPGOLINK(page,width,height,target)
{	if ((width < 1000) && (height < 1000))
	{   	window.open(page,target, "toolbar=no,scrollbars=yes,width=" + width + ",height=" + height + ",resizable=yes")	}}

/*	onChange="RAZGRIZ_SELECTLINK(this,'this')	*/
function RAZGRIZ_SELECTLINK(target,file){
	eval(target+".location='"+file.options[file.selectedIndex].value+"'");}

//跳頁選單
function MM_jumpMenu(targ,ReValue,restore){ //v3.0
	eval(targ+".location='"+ReValue.options[ReValue.selectedIndex].value+"'");
  if (restore) ReValue.selectedIndex=0;
}

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值檢測
{
alert('觸發mail檢查');
if ( !IsEnglish(name) )
{
	return false;	
}

var i = name.indexOf("@");
var j = name.lastIndexOf("@");

if ( i == -1 ) { return false; }
if ( i != j ) { 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))
      // 根据取得的图像高度和宽度设置弹出窗口的高度与宽度，并打开该窗口
	  // 依取得圖片高和寬設定openwidows的w與h，並開視窗
      // 其中增加的是邊框
      OpenFullSizeWindow(theURL,winName, ",width=" + (imgObj.width+20) + ",height=" + (imgObj.height+30));
    else
      // 因為透過 Image 對像來動態設定圖片，不可能馬上得到圖的寬與高度，所以每隔100毫秒重復取得
      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,";
  // 檢查是否來自 checkImg 
  if (features == null || features == ""){
    // 建立圖像對像
    imgObj = new Image();
    // 設定來源
    imgObj.src = theURL;
    // 取得圖像大小
    checkImg(theURL, winName)
  }
  else{
    // 打開poplink
    aNewWin = window.open(theURL,winName, sBaseCmd + features);
    aNewWin.focus();
  }
}
//--------------------------------------------------------取得大小再彈出圖片====

