// Flashのバージョン reqVersion
// Flash Player のチェック

function validFlash(){
	/*if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
	var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=reqVersion)
	return true;
	}else if(navigator.appName && navigator.appName.indexOf("Microsoft")!=-1 && navigator.userAgent.indexOf("Windows")!=-1 && navigator.userAgent.indexOf("Windows 3.1")==-1){
	return true;
	}else{
	return false;
	}*/
	return true;
}

// MAIN部の書き出し
function writeFlashMAIN(){
	if(!validFlash()){
		document.open();  
		document.write(altContent);
		document.close();
	} else {

		if(!swfQuality){var swfQuality="high";}
		if(!swfLiveConnect){var swfLiveConnect="false";}
		if(!swfMenu){var swfMenu="false";}

		// .swf ファイルの定義
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"');
		document.write(' id="' + swfId + '" width="' + swfWidth + '" height="' + swfHeight + '">');
		
		if(!swfBgcolor){
			document.write('<param name="wmode" value="transparent">');
			var bg='" wmode="transparent';
			
		}else{
			document.write('<param name="bgcolor" value="' + swfBgcolor + '">');
			var bg='" bgcolor="' + swfBgcolor ;
		}

		document.write('<param name="movie" value="' + swfFile + '">');
		document.write('<param name="quality" value="' + swfQuality + '">');
		document.write('<param name="menu" value="' + swfMenu + '">');
		document.write('<embed src="' + swfFile + '" width="' + swfWidth + '" height="' + swfHeight + '" menu="' + swfMenu + '" quality="' + swfQuality + '" swLiveConnect="' + swfLiveConnect +  bg + '" name="' + swfId + '" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
		document.write('</object>');
	}
}


function SB(SoutIMG,SoverIMG,Sw,Sh,SgoURL,Starget,SonFunc,SonFuncP,SoffFunc,SoffFuncP){
	//alert("SB");
	reqVersion=8;
	swfId="swfbtn";
	swfFile ="btn.swf";
	onImgName=SoverIMG;
	offImgName=SoutIMG;
	goURL=SgoURL;
	targetWin = Starget;
	swfWidth = Sw;
	swfHeight = Sh;
	if(SonFunc){onFunc = SonFunc;}else{onFunc = "on_fade";}
	if(SonFuncP){onFuncP = SonFuncP;}else{onFuncP = 10;}
	if(SoffFunc){offFunc = SoffFunc;}else{offFunc = "off_fade";}
	if(SoffFuncP){offFuncP = SoffFuncP;}else{offFuncP = 1;}
	swfBtn();
}

function FB(SWFDIR,IMGDIR,SoutIMG,SoverIMG,Sw,Sh,SgoURL,Starget,SonFunc,SonFuncP,SoffFunc,SoffFuncP){
	reqVersion=8;
	swfId="swfbtn";
	swfFile =SWFDIR+"btn.swf";
	onImgName=SWFDIR+IMGDIR+SoverIMG;
	offImgName=SWFDIR+IMGDIR+SoutIMG;
	goURL=SgoURL;
	targetWin = Starget;
	swfWidth = Sw;
	swfHeight = Sh;
	if(SonFunc){onFunc = SonFunc;}else{onFunc = "on_fade";}
	if(SonFuncP){onFuncP = SonFuncP;}else{onFuncP = 10;}
	if(SoffFunc){offFunc = SoffFunc;}else{offFunc = "off_fade";}
	if(SoffFuncP){offFuncP = SoffFuncP;}else{offFuncP = 1;}
	swfBtn();
}

function swfBtn(){

	if(targetWin){
		targetSTR = '&targetWin=' + targetWin ;
	}else{
		targetSTR ="";
	}
	
	swfFile = swfFile + "?onFunc="+onFunc+"&onFuncP="+onFuncP+"&offFunc="+offFunc+"&offFuncP="+offFuncP+"&onImgName="+onImgName+"&offImgName="+offImgName+"&goURL="+goURL+targetSTR;
	//alert(swfFile);
	swfBgcolor="#FFFFFF";
	swfQuality="high";
	swfLiveConnect="false";
	swfMenu="false";


	if(!validFlash()){
		document.open();  
		document.write(altContent);
		document.close();
	} else {
		// .swf ファイルの定義
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"');
		document.write(' id="' + swfId + '" width="' + swfWidth + '" height="' + swfHeight + '">');
		document.write('<param name="wmode" value="transparent">');
		document.write('<param name="movie" value="' + swfFile + '">');
		document.write('<param name="quality" value="' + swfQuality + '">');
		document.write('<param name="bgcolor" value="' + swfBgcolor + '">');
		document.write('<param name="menu" value="' + swfMenu + '">');
		document.write('<embed src="' + swfFile + '" width="' + swfWidth + '" height="' + swfHeight + '" menu="' + swfMenu + '" quality="' + swfQuality + '" swLiveConnect="' + swfLiveConnect + '" bgcolor="' + swfBgcolor + '"name="' + swfId + '" wmode="transparent" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
		document.write('</object>');
	}
}


//---------------------------------------------------------------------------
// 変数
//---------------------------------------------------------------------------

    var Name = new Array();
    var Value = new Array();
    var Keys = 0;

//---------------------------------------------------------------------------
// 変数を追加する(内部用)
//---------------------------------------------------------------------------
function AddString(name, value)
{
    Name[Keys]  = name;
    Value[Keys] = value;
    Keys++;
}

//---------------------------------------------------------------------------
// 指定された変数の登録番号を返す(内部用)
//---------------------------------------------------------------------------
function SearchString(name)
{
    var num = -1;

    for(ct = 0; ct <= Keys; ct++){
        if(name == Name[ct]){
            num = ct;
            break;
        }
    }
    return num;
}

//---------------------------------------------------------------------------
// 指定された変数の値を返す
//---------------------------------------------------------------------------
function GetString(name)
{
    var value = '';

    if((num = SearchString(name)) >= 0){
        value = Value[num];
    }
    return value;
}

//---------------------------------------------------------------------------
// 変数を追加・修正する
//---------------------------------------------------------------------------
function SetString(name, value)
{
    if(name.length == 0){
        return 0;
    }

    if((num = SearchString(name)) >= 0){
        Value[num] = value;
    }
    else{
        AddString(name, value);
    }
    return 0;
}

//---------------------------------------------------------------------------
// 変数を削除する
//---------------------------------------------------------------------------
function DeleteString(name)
{
    if((num = SearchString(name)) >= 0){
        Name[num]  = '';
        Value[num] = '';
    }
    return 0;
}

//---------------------------------------------------------------------------
// クエリ文字列を解析する
//---------------------------------------------------------------------------
function CreateQuetyStringList()
{
    var name  = '';
    var value = '';
    var flag  = false;

    for(ct = 1; ct <= location.search.length - 1; ct++){
        ch = location.search.charAt(ct);
        if(ch == '?'){
            flag = false;
            continue;
        }
        if(ch == '='){
            flag = true;
            if(value.length > 0){
                name = value;
            }
            value = '';
            continue;
        }
        if((ch == '&') || (ch == '#')){
            flag = false;
            if((name.length > 0) && (value.length > 0)){
                AddString(name, value);
            }
            name  = '';
            value = '';
            continue;
        }
        value += ch;
    }
    if(value.length > 0){
        if(flag == true){
            AddString(name, value);
        }
    }
    return 0;
}


    /* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
    charset = shift_jis

    +++ UTF8/16 ライブラリ +++


    LastModified : 2006-11/08
    
    Powered by kerry
    https://202.248.69.143/~goma/
    
    動作ブラウザ :: IE4+ , NN4.06+ , Gecko , Opera6+



    * [RFC 2279] UTF-8, a transformation format of ISO 10646
    ftp://ftp.isi.edu/in-notes/rfc2279.txt
    
    * [RFC 1738] Uniform Resource Locators (URL)
    ftp://ftp.isi.edu/in-notes/rfc1738.txt

    /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
    
    Usage:
    
    // 文字列を UTF16 (文字コード) へ
    utf16code_array = utf.unpackUTF16( my_string );

    // 文字列を UTF8 (文字コード) へ
    utf8code_array = utf.unpackUTF8( my_string );
    
    // UTF8 (文字コード) から文字列へ。 utf.unpackUTF8() したものを元に戻す
    my_string = utf.packUTF8( utf8code_array );

    // UTF8/16 (文字コード) を文字列へ
    my_string = utf.packChar( utfCode_array );
    
    // UTF16 (文字コード) から UTF8 (文字コード) へ
    utf8code_array = utf.toUTF8( utf16code_array );
    
    // UTF8 (文字コード) から UTF16 (文字コード) へ
    utf16code_array = utf.toUTF16( utf8code_array );



    // URL 文字列へエンコード
    url_string = utf.URLencode( my_string );

    // URL 文字列からデコード
    my_string = utf.URLdecode( url_string );

    /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */



utf = new function()
{
    this.unpackUTF16 = function(_str)
    {
        var i, utf16=[];
        for (i=0; i<_str.length; i++) utf16[i] = _str.charCodeAt(i);
        return utf16;
    }
    
    this.unpackChar = function(_str) 
    {
    	var utf16 = this.unpackUTF16(_str);
    	var i,n, tmp = [];
    	for (n=i=0; i<utf16.length; i++) {
    		if (utf16[i]<=0xff) tmp[n++] = utf16[i];
    		else {
    			tmp[n++] = utf16[i] >> 8;
    			tmp[n++] = utf16[i] &  0xff;
    		}	
    	}
    	return tmp;
    }
    
    this.packChar  =
    this.packUTF16 = function(_utf16)
    {
        var i, str = "";
        for (i in _utf16) str += String.fromCharCode(_utf16[i]);
        return str;
    }

    this.unpackUTF8 = function(_str)
    {
       return this.toUTF8( this.unpackUTF16(_str) );
    }

    this.packUTF8 = function(_utf8)
    {
        return this.packUTF16( this.toUTF16(_utf8) );
    }
    
    this.toUTF8 = function(_utf16)
    {
        var utf8 = [];
        var idx = 0;
        var i, j, c;
        for (i=0; i<_utf16.length; i++)
        {
            c = _utf16[i];
            if (c <= 0x7f) utf8[idx++] = c;
            else if (c <= 0x7ff)
            {
                utf8[idx++] = 0xc0 | (c >>> 6 );
                utf8[idx++] = 0x80 | (c & 0x3f);
            }
            else if (c <= 0xffff)
            {
                utf8[idx++] = 0xe0 | (c >>> 12 );
                utf8[idx++] = 0x80 | ((c >>> 6 ) & 0x3f);
                utf8[idx++] = 0x80 | (c & 0x3f);
            }
            else
            {
                j = 4;
                while (c >> (6*j)) j++;
                utf8[idx++] = ((0xff00 >>> j) & 0xff) | (c >>> (6*--j) );
                while (j--) 
                utf8[idx++] = 0x80 | ((c >>> (6*j)) & 0x3f);
            }
        }
        return utf8;
    }
    
    this.toUTF16 = function(_utf8)
    {
        var utf16 = [];
        var idx = 0;
        var i,s;
        for (i=0; i<_utf8.length; i++, idx++)
        {
            if (_utf8[i] <= 0x7f) utf16[idx] = _utf8[i];
            else 
            {
                if ( (_utf8[i]>>5) == 0x6)
                {
                    utf16[idx] = ( (_utf8[i] & 0x1f) << 6 )
                                 | ( _utf8[++i] & 0x3f );
                }
                else if ( (_utf8[i]>>4) == 0xe)
                {
                    utf16[idx] = ( (_utf8[i] & 0xf) << 12 )
                                 | ( (_utf8[++i] & 0x3f) << 6 )
                                 | ( _utf8[++i] & 0x3f );
                }
                else
                {
                    s = 1;
                    while (_utf8[i] & (0x20 >>> s) ) s++;
                    utf16[idx] = _utf8[i] & (0x1f >>> s);
                    while (s-->=0) utf16[idx] = (utf16[idx] << 6) ^ (_utf8[++i] & 0x3f);
                }
            }
        }
        return utf16;
    }
    
    this.URLencode = function(_str)
    {
        return _str.replace(/([^a-zA-Z0-9_\-\.])/g, function(_tmp, _c)
            { 
                if (_c == "\x20") return "+";
                var tmp = utf.toUTF8( [_c.charCodeAt(0)] );
                var c = "";
                for (var i in tmp)
                {
                    i = tmp[i].toString(16);
                    if (i.length == 1) i = "0"+ i;
                    c += "%"+ i;
                }
                return c;
            } );
    }

    this.URLdecode = function(_dat)
    {
        _dat = _dat.replace(/\+/g, "\x20");
        _dat = _dat.replace( /%([a-fA-F0-9][a-fA-F0-9])/g, 
                function(_tmp, _hex){ return String.fromCharCode( parseInt(_hex, 16) ) } );
        return this.packChar( this.toUTF16( this.unpackUTF16(_dat) ) );
    }
}



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function openDetails(courseNo){
  var url='coursedata.php?cno='+courseNo;
  window.open(url, "coursedata", "scrollbars=yes,resizable=no,width=950,height=760");
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function chClursor(c){
	document.body.style.cursor = c;
}

function imgWin(url){
  url="imgwin.php?imgsrc="+url;
  window.open(url, "imgWin", "scrollbars=yes,resizable=no,width=818,height=600");
}

function init(){
	//MM_preloadImages('./images/up_over.gif','./images/down_over.gif');
	//Shadowbox.init();
	//alert('test2');
}
//window.onload=init();
function rollover(){
	//alert("rollover");
	var targetClassName = "hoverImg";
	var suffix = "_ov";

	var overReg = new RegExp("^(.+)(\\.[a-z]+)$");
	var outReg = new RegExp("^(.+)" + suffix + "(\\.[a-z]+)$");

	var preload = new Array();
	var images = document.getElementsByTagName("img");

	for (var i = 0, il = images.length; i < il; i++) {
		var classStr = images[i].getAttribute("class") || images[i].className;
		var classNames = classStr.split(/\s+/);
		for(var j = 0, cl = classNames.length; j < cl; j++){
			if(classNames[j] == targetClassName){
				//preload
				preload[i] = new Image();
				preload[i].src = images[i].getAttribute("src").replace(overReg, "$1" + suffix + "$2");
				//mouseover
				images[i].onmouseover = function() {
					this.src = this.getAttribute("src").replace(overReg, "$1" + suffix + "$2");
				}
				//mouseout
				images[i].onmouseout = function() {
					this.src = this.getAttribute("src").replace(outReg, "$1$2");
				}
			}
		}
	}
}