﻿// Add an event handler
// Thanks to John Resig, via QuirksMode
function addEvent(obj,type,fn)
{
 if(obj.attachEvent)
  {
  obj['e'+type+fn] = fn;
  obj[type+fn] = function(){obj['e'+type+fn](window.event);}
  obj.attachEvent('on'+type,obj[type+fn]);
  
  }
 else
  obj.addEventListener(type,fn,false);
}

// Remove  an event handler
// Thanks to John Resig, via QuirksMode
function removeEvent(obj,type,fn)
{
 if(obj.detachEvent)
  {
  obj.detachEvent('on'+type,obj[type+fn]);
  obj[type+fn] = null;
  }
 else
  obj.removeEventListener(type,fn,false);
}

// image roll
function menuOver() {
	this.src = this.src.replace(".gif", "_on.gif");
}
function menuOut() {
	this.src = this.src.replace("_on.gif", ".gif");
}

function imageOver(imgEl) {
	var obj = imgEl.getElementsByTagName("img")[0];
	var pattern = /_on.gif/i;
	var rok = pattern.test(obj.src);
	if(rok == false)
	{
		obj.src = obj.src.replace(".gif", "_on.gif");
		
	}
}

 
function winClose()
{
	window.close();
}


var prevBtn = 0;
var prevBtn02 = 0;

 
var MenuT = function(tagId,tag) {
	this.tagId = tagId;
	this.tag = tag;
}
MenuT.prototype = {
	carMenuTab : function() {
	
		var carMenu = document.getElementById(this.tagId).getElementsByTagName(this.tag);
		var urlV = /(on|over)\.gif$/ ;
		var isClick='false';
		var isFirstOver='false';
		var isFirstOutFlag= 'false';
		var isSelected = 'false';
		
		for(i=0 ; i < carMenu.length ; i++)
		{
			if(carMenu.item(i).firstChild==null) continue;
	
			carMenu.item(i).firstChild.onmouseover = function()
			{	
				isFirstOver= 'true';
				
				if(!urlV.test(this.src)){
					this.src = this.src.replace(".gif", "_on.gif");
					isSelected = 'false';
				}
				else isSelected = 'true';
			}
			
			carMenu.item(i).firstChild.onmouseout = function()
			{
				
				if((isClick=='false' || isFirstOutFlag== "true")&& isSelected == 'false'){
				
					
					this.src = this.src.replace("_on.gif", ".gif");
					
				}
				else isClick='false';
				
				isFirstOutFlag= 'false';
			}
			
			carMenu.item(i).onclick = function()
			{ 
				if(isFirstOver== 'false' || !urlV.test(this.firstChild.src)){
					this.firstChild.src = this.firstChild.src.replace(".gif", "_on.gif");
					isClick='false';
					isFirstOutFlag= 'true';
				}
				else isClick='true';
			
				for(x=0; x<carMenu.length; x++){
					
					if(carMenu.item(x).firstChild.src != this.firstChild.src){
						carMenu.item(x).firstChild.src = carMenu.item(x).firstChild.src.replace("_on.gif", ".gif");
					}
				}
			}	
		}
	},
	
	storeInfo : function() {
		
		if(!document.getElementById(this.tagId)) return false;
		
		var topMenu = document.getElementById(this.tagId).getElementsByTagName(this.tag);
		var urlV = /(on|over)\.gif$/ ;
		for(i=0 ; i < topMenu.length ; i++)
		{
			
			if(topMenu.item(i).firstChild) 
			{

			
				topMenu.item(i).firstChild.onmouseover = function()
				{
					if(!urlV.test(this.src))
						this.src = this.src.replace(".gif", "_on.gif");

				}
				topMenu.item(i).firstChild.onmouseout = function()
				{
					this.src = this.src.replace("_on.gif", ".gif");
				}
			}else
				{
					topMenu.item(i).onmouseover = function()
					{
						if(!urlV.test(this.src))
							this.src = this.src.replace(".gif", "_on.gif");

					}
					topMenu.item(i).onmouseout = function()
					{
						this.src = this.src.replace("_on.gif", ".gif");
					}
				}

		}

	},
	
	tabMName : function(btnId,btnTag,showLayer) {
		this.btnId = btnId;
		this.btnTag = btnTag;
		this.showLayer = showLayer;
	},

	tabMenu : function() {
		
		var btn = document.getElementById(this.btnId).getElementsByTagName(this.btnTag);
		//var who = new Array( 'searchCarCon', 'searchCarCon02', 'service', 'Postscript', 'qna' );
		var showLayerName = this.showLayer;
		var pattern = /_on.gif/i;
		

		for(i=0 ; i < btn.length  ; i++)
		{
			if(btn.item(i).src)
			{
				btn.item(i).setAttribute("rok",i);

				btn.item(i).onclick = function()
				{   
					
				
						showL = showLayerName + this.getAttribute('rok');
						
						var txtOn = pattern.test(this.src);
						for(i=0 ; i < btn.length  ; i++) 
						{
							
							if(txtOn != false) return false;
							if(i == this.getAttribute('rok') ) 
							{	
								this.src = this.src.replace(".gif", "_on.gif");
								showL = showLayerName + i;
								document.getElementById(showL).style.display = 'block';
							}else {
								hiddenL = showLayerName + i;
								document.getElementById(hiddenL).style.display = 'none';
								btn.item(i).src = btn.item(i).src.replace("_on.gif", ".gif");
							}
							
						}

					
				}
			}else if(!btn.item(i).src)
			{
				btn.item(i).firstChild.setAttribute("rok",i);

				btn.item(i).firstChild.onclick = function()
				{   
					
					showL = showLayerName + this.getAttribute('rok');
						
					var txtOn = pattern.test(this.src);
					for(i=0 ; i < btn.length  ; i++) 
					{
						
						if(txtOn != false) return false;
						if(i == this.getAttribute('rok') ) 
						{	
							this.src = this.src.replace(".gif", "_on.gif");
							showL = showLayerName + i;
							document.getElementById(showL).style.display = 'block';
						}else {
							hiddenL = showLayerName + i;
							document.getElementById(hiddenL).style.display = 'none';
							btn.item(i).firstChild.src = btn.item(i).firstChild.src.replace("_on.gif", ".gif");
						}
						
					}
					
				}

			}
		}

	}
}

 
function currentMenu(Num)
{
	
	threeDepth = Num.substring(0,6);
	fourDepth = parseInt(Num.substring(7));

	currentM = document.getElementById("menu"+threeDepth);
	currentMOver = document.getElementById("menu"+threeDepth+"_over");
	currentS = document.getElementById("menu"+threeDepth+"_over").getElementsByTagName('img');

	currentM.style.display = 'none';
	currentMOver.style.display = 'block';

	if(fourDepth != 0)
		currentS.item(fourDepth).src = currentS.item(fourDepth).src.replace(".gif", "_on.gif");

	currentS.item(fourDepth).onmouseover = function(){};
	currentS.item(fourDepth).onmouseout = function(){};
}

//topArea searchBox 
var inputBg = function(tagId) {
	this.tagId = tagId;
}
inputBg.prototype = {
	storeInfo : function() {
		
		var inputId = document.getElementById(this.tagId);

		inputId.onfocus = function()
		{
			this.className = "focus";
		}

		inputId.onblur = function()
		{
			
			if(inputId.value == '')
			{
				this.className = "";
			}
			
		}
	}
}


//topArea searchBox 
var inputBg02 = function(tagId, classN) {
	this.tagId = tagId;
	this.classN = classN;
}
inputBg02.prototype = {
	storeInfo : function() {
		
		var inputId = document.getElementById(this.tagId);
		var cName = this.classN
		inputId.onfocus = function()
		{
			this.className = "";
		}

		inputId.onblur = function()
		{
			
			if(inputId.value == '')
			{
				this.className = cName ;
			}
			
		}
	}
}

 