//initLibrary

function initLibrary(){
	if(navigator.appVersion.indexOf("Mac") > -1 && navigator.appName.charAt(0) == "M"){
		//MacIE
  	}else{
		//Others
		document.write('<script src="common/js/prototype.js" type="text/javascript"></script>');
		document.write('<script src="common/js/rico.js" type="text/javascript"></script>');
	}
}



//loadRSS
function loadRSS () {
    var url = "/event/feed.rss";
    var http = new JKL.ParseXML( url );
    var func = function ( data ) {
        var items = data["rdf:RDF"].item;
           for( var i=0; i<items.length; i++ ) {
               var dd = new Date();
               dd.setW3CDTF( items[i]["dc:date"] );
               var date = dd.getFullYear() + "/" + (dd.getMonth()+1) + "/" +
                          dd.getDate();
               items[i]["dc:date"] = date;
           }
        var items = data["rdf:RDF"].item;
            if ( items.length > 3 ) items.length = 3;
        var hina = new JKL.Hina( "rssbox" );
        var dest = hina.expand( data, "rssbox" );
        dest.style.display = "";
    };
    http.async( func );
    http.parse();
}

//initAccordion
function initAccordion (){
	if(navigator.appVersion.indexOf("Mac") > -1 && navigator.appName.charAt(0) == "M"){
		//MacIE
  	}else{
		new Rico.Accordion( $('visitNav'), { panelHeight:95, borderColor:'#fff', onLoadShowTab:0 } );
	}
}

//rollOver.js
function initRollovers() {
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'btn') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);	//.jpg	_current.jpg

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'btn2') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);	//.jpg	_current.jpg

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}

			aImages[i].onmouseup = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}	
		}
	}
}

//window.onload = initRollovers;

//swapImage
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];}}
}

//search
function setHeaderForm (){
	document.write('<div id="top-search">');
	document.write('<form action="http://www.saitama-u.ac.jp/cgi-bin/search.cgi" name="search_form" onsubmit="return sendHeaderForm();" id="searchbox_011514390577796484903:yl0wc_qoxli">');
	document.write('<input type="radio" name="radiobutton" value="google" checked>');
	document.write('サイト内検索&nbsp;&nbsp;');
	document.write('<input type="radio" name="radiobutton" value="people">');		
	document.write('研究者情報検索&nbsp;&nbsp;');
	document.write('<input type="hidden" name="cx" value="011514390577796484903:yl0wc_qoxli" />');
    document.write('<input type="hidden" name="cof" value="FORID:11" />');
	document.write('<input name="q" type="text" size="20" />&nbsp;');
	document.write('<input type="submit" name="sa" value="検索" />');
	document.write('<input type="hidden" name="ie" value="Shift-JIS" />');
	document.write('<input type="hidden" name="oe" value="Shift-JIS" />');
	document.write('<input type="hidden" name="cof" value="FORID:11" />');
   	document.write('</form>');
	document.write('</div>');
}

function sendHeaderForm(){
	var formData;
	for(var i=0; i<document.search_form.radiobutton.length; i++){
		if(document.search_form.radiobutton[i].checked == true){
			formData = document.search_form.radiobutton[i].value;
		}
	}
	
	if(formData == 'people'){
		document.search_form.target = '_blank';
	}else{
		document.search_form.target = '';
	}
	
	document.search_form.submit();
	
	return false;
}

//search
function setHeaderFormE (){
	document.write('<div id="top-search">');
	document.write('<form action="http://www.saitama-u.ac.jp/cgi-bin/search.cgi" name="search_form" onsubmit="return sendHeaderForm();" id="searchbox_011514390577796484903:yl0wc_qoxli">');
	document.write('<input type="radio" name="radiobutton" value="google" checked>');
	document.write(' Search Web&nbsp;&nbsp;');
	document.write('<input type="radio" name="radiobutton" value="people">');		
	document.write(' Researcher Database&nbsp;&nbsp;');
	document.write('<input type="hidden" name="cx" value="011514390577796484903:yl0wc_qoxli" />');
    document.write('<input type="hidden" name="cof" value="FORID:11" />');
	document.write('<input name="q" type="text" size="20" />&nbsp;');
	document.write('<input type="submit" name="sa" value="Search" />');
	document.write('<input type="hidden" name="ie" value="Shift-JIS" />');
	document.write('<input type="hidden" name="oe" value="Shift-JIS" />');
	document.write('<input type="hidden" name="cof" value="FORID:11" />');
   	document.write('</form>');
	document.write('</div>');
}

function sendHeaderFormE(){
	var formData;
	for(var i=0; i<document.search_form.radiobutton.length; i++){
		if(document.search_form.radiobutton[i].checked == true){
			formData = document.search_form.radiobutton[i].value;
		}
	}
	
	if(formData == 'people'){
		document.search_form.target = '_blank';
	}else{
		document.search_form.target = '';
	}
	
	document.search_form.submit();
	
	return false;
}


//search
function setLeftForm_cie (){
	document.write('<div id="search">');
	document.write('<form action="http://www.isc.saitama-u.ac.jp/search/index.html" id="searchbox_006873136480438588895:s_ks6w22fb8">');
 	document.write('<input type="hidden" name="cx" value="006873136480438588895:s_ks6w22fb8" />');
    document.write('<input type="hidden" name="cof" value="FORID:11" />');
	document.write('国際交流センターサイト内検索<br>');
	document.write('<input name="q" type="text" size="20" />&nbsp;');
	document.write('<input type="submit" name="sa" value="検索" />');
	document.write('<input type="hidden" name="ie" value="Shift-JIS" />');
	document.write('<input type="hidden" name="oe" value="Shift-JIS" />');
	document.write('<input type="hidden" name="cof" value="FORID:11" />');
   	document.write('</form>');
	document.write('</div>');

}

//search
function setLeftForm_cieE (){
	document.write('<div id="search">');
	document.write('<form action="http://www.isc.saitama-u.ac.jp/search/index.html" id="searchbox_006873136480438588895:s_ks6w22fb8">');
 	document.write('<input type="hidden" name="cx" value="006873136480438588895:s_ks6w22fb8" />');
    document.write('<input type="hidden" name="cof" value="FORID:11" />');
	document.write('Center for International Exchange Search Web<br>');
	document.write('<input name="q" type="text" size="20" />&nbsp;');
	document.write('<input type="submit" name="sa" value="Search" />');
	document.write('<input type="hidden" name="ie" value="Shift-JIS" />');
	document.write('<input type="hidden" name="oe" value="Shift-JIS" />');
	document.write('<input type="hidden" name="cof" value="FORID:11" />');
   	document.write('</form>');
	document.write('</div>');

}
