/* -----------------------------
   function smartRollover
------------------------------- */

function smartRollover() {
	var func = smartRollover.func;
	
	if(document.getElementsByTagName) {
		if($tagname = "img"){
			var $target = document.getElementsByTagName($tagname);
			for(var i=0; i < $target.length; i++) {
				func.replace($target[i]);
			}
		}
		if($tagname = "input"){
			var $target = document.getElementsByTagName($tagname);
			for(var i=0; i < $target.length; i++) {
				if($target[i].getAttribute("src")){	
					func.replace($target[i]);
				}
			}
		}
	}
}
smartRollover.func = {
	replace : function($target){
		if($target.getAttribute("src").match(/_off\.(jpe?g|gif|png)/)){
			$target.onmouseover = function() {
				// this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				this.style.filter = 'alpha(opacity=50)';// Internet Explorer用
				this.style.MozOpacity = 0.5;// Firefox用
				this.style.opacity = 0.5;// Safari用
			}
			$target.onmouseout = function() {
				// this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				this.style.filter = 'alpha(opacity=100)';// Internet Explorer用
				this.style.MozOpacity = 1;// Firefox用
				this.style.opacity = 1;// Safari用
			}
		}
	}
}

/* -----------------------------
   function gNaviPullDown
------------------------------- */

gNaviPullDown.ini = {
	targetDivIdFlash:"mainvisual",
	targetUlId		:"g_navi"
}

function gNaviPullDown() {
	var ini = gNaviPullDown.ini;
	var func = gNaviPullDown.func;
	
	if(document.getElementById(ini.targetUlId)) {
		var $main_li = document.getElementById(ini.targetUlId).getElementsByTagName("ul")[0].childNodes;
		
		for (var i = 0; i < $main_li.length; i++) {
			if($main_li[i].innerHTML){

				$main_li[i].gnvpdID = i;

				$main_li[i].onmouseover = function(){
					func.opengNavi($main_li[this.gnvpdID]);
				}
				$main_li[i].onmouseout = function(){
					func.closegNavi($main_li[this.gnvpdID]);
				}
			}
		}
		
	}
}

gNaviPullDown.func = {
		opengNavi:function ($target){
			var ini = gNaviPullDown.ini;
		
			$target.getElementsByTagName("ul")[0].style.display = 'block'; 
			if(document.getElementById(ini.targetDivIdFlash)){
				document.getElementById(ini.targetDivIdFlash).style.zIndex = '-9999';
			}
		},
		closegNavi:function($target){
			var ini = gNaviPullDown.ini;
		
			$target.getElementsByTagName("ul")[0].style.display = 'none'; 
			if(document.getElementById(ini.targetDivIdFlash)){
				document.getElementById(ini.targetDivIdFlash).style.zIndex = '9999';
			}
		}
}

/* -----------------------------
   function textInput
------------------------------- */
textInput.ini = {
	defaultColor:"#aaaaaa",
	inputColor	:"#000000"
}
function textInput() {
		var ini = textInput.ini;
	
	 	$targets = document.getElementsByTagName("input");
		var target;
		for(var i=0; target=$targets[i]; i++){
			if(target.type == "text"){

				$targets[i].index = i;
// 				$targets[i].style.color = ini.defaultColor;

				if($targets[i].value==$targets[i].defaultValue){
					$targets[i].style.color = ini.defaultColor;
				}


				$targets[i].onfocus = function(){
						if($targets[this.index].value==$targets[this.index].defaultValue){
							$targets[this.index].value="";
							$targets[this.index].style.color = ini.inputColor;
						}
		  		}

				$targets[i].onblur = function(){
					if($targets[this.index].value==""){
						$targets[this.index].style.color = ini.defaultColor;
						$targets[this.index].value = $targets[this.index].defaultValue;
					}
		  		}
			}
	 	}
}

/* -----------------------------
   function JStemplate
   # don't delete
------------------------------- */

if(!JStemplate) var JStemplate = new Object();

JStemplate = {
	addevent:function ($funcname){
		if(window.addEventListener) {
			window.addEventListener("load", $funcname, false);
		}
		else if(window.attachEvent) {
			window.attachEvent("onload", $funcname);
		}
	}
}


/* -----------------------------
   setting function
   # don't delete
------------------------------- */

try{
	JStemplate.addevent(smartRollover);
	JStemplate.addevent(gNaviPullDown);
	// JStemplate.addevent(textInput);

}catch(thisError){
	alert(thisError);
}

/* 　function func(val1, val2){
　　　　val2 = val2 || '0';

　　}
 		if(typeof $funcname != "function"){
 			alert($funcname.name);
 		}else{
 			alert("none");
 		}

*/
