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_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_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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*========================================================
!!!! kokokarashitawa sagyouyou desu. by tsunoda !!!!
========================================================== */

/*get Path*/
function getPath(URI){
	arrayPath=[];
	file=String(URI);
	
	file=file.replace('http://','');
	//domain=file.substring(0,file.indexOf('/',0));
	//path=file.replace(domain,'');
	arrayPath['fullPath']=URI;
	arrayPath['domain']=file.substring(0,file.indexOf('/',0));
	arrayPath['siteRoot']=file.replace(arrayPath['domain'],'');
	arrayPath['firstDir']=arrayPath['siteRoot'].substring(1,arrayPath['siteRoot'].indexOf('/',2));
	return arrayPath;

}
function setSelectedNavi(){
	
		var Navi=document.getElementById("Navigation");
		var anchors = Navi.getElementsByTagName("a");
		currentURL= String(document.URL);
	
		for(i=0;i<anchors.length;i++){
			if(currentURL.indexOf(anchors[i],0)!=-1){
				obj=anchors[i].firstChild;
				RollOver(obj); 
				getBrowser();
				if(this.Win){	
					obj.setAttribute("onmouseover", new Function(""));
					obj.setAttribute("onmouseout", new Function(""));
					}else{
					obj.removeAttribute("onmouseover");
					obj.removeAttribute("onmouseout");
				}
			}
	
		}
		
	
}
//====================================================================
// get browser
//-------------------------------------------------------------------
function getBrowser(){
	
	var ua = navigator.userAgent;

	this.NN4  = (document.layers);
	this.IE5 = (ua.indexOf("MSIE 5") != -1);
	this.IE50 = (ua.indexOf("MSIE 5.0") != -1);
	this.IE55 = (ua.indexOf("MSIE 5.5") != -1);
	this.IE6 = (ua.indexOf("MSIE 6") != -1);
	this.IE4  = (ua.indexOf("MSIE 4") != -1);
	this.IE   = (ua.indexOf("MSIE") != -1);
	this.Moz  = (ua.indexOf("Gecko") != -1);
	this.Op6  = (ua.match(/Opera.6/) != null); // Opera "6" only
	this.Omn  = (ua.indexOf("OmniWeb") != -1);
	this.Safari  = (ua.indexOf("Safari") != -1);
	this.FF   =  (ua.indexOf("Firefox") != -1);
	this.Win  = (ua.indexOf("Windows") != -1);
	this.Mac  = (ua.indexOf("Mac") != -1);
	if (this.Op6) this.IE50 = this.IE = false; 
	if (this.Omn) this.NN4            = false; 
	}

/*=====================================================================================
RollOver Image
---------------------------------------------------------------------------------------*/

function RollOver(obj) {
	getBrowser();
	if(this.Win){	
		obj.setAttribute("onmouseout", new Function("RollOver(this);"));
		}else{
			obj.setAttribute("onmouseout", 'RollOver(this);');
			}
	ext=obj.src.slice(-6);
	oldImage=obj.src.replace(ext,'');
	if((navigator.userAgent.indexOf("Mac")!=-1)&&(navigator.userAgent.indexOf("MSIE")!=-1)) {
		void(0);
		}else{
			if(obj.src.slice(-7)!='o'+ext){
				newImage=oldImage+'o'+ext;
			}else{
				newImage=obj.src.replace('o'+ext,ext);
				}
			obj.src=newImage;
			}
	} 


/*================
add CSS
----------------------*/
function applyCSS(doc, cssfile, overwrite){
  if (typeof overwrite == "undefined")
    overwrite = 0;      // default

  // remove
  if (overwrite && doc.styleSheets.length >= 1) {
    var links = doc.getElementsByTagName("link");
    for (var i = 0 ; i < links.length ; i++) {
      if (links[i].rel == "stylesheet")
        links[i].parentNode.removeChild(links[i]);
    }
  }

  // add
  if (document.all) {
    doc.createStyleSheet(cssfile);
  } else {
    var link = doc.createElement("link");
    link.rel = "stylesheet";
    link.href = cssfile;
    link.type = "text/css"
    doc.getElementsByTagName('head')[0].appendChild(link);
  }
}
/*================
Event addition
----------------------*/
function addLoadEvent(func) {
 if(typeof window.addEventListener == 'function'){ // If addEventListener can be used
  window.addEventListener('load', func, false);
  return true;
 } else if(typeof window.attachEvent == 'object'){ // If attachEvent can be used (for IE)
  window.attachEvent('onload', func);
  return true;
 }

 var oldonload = window.onload; // If both cannot be used
 if (typeof window.onload != 'function') {
  window.onload = func;
 } else {
  window.onload = function() {
   oldonload();
   func();
  }
 }
}
/*=======================*/
if(getPath(document.URL)['firstDir']=='html'){
	addLoadEvent(function(){
	applyCSS(document,'/common/html.css',0);
	setSelectedNavi();
	});
}

