
/*********************************************************************
File Name:	tab.js
File Info:	Javascript
Author:		WEB DESIGN LAB
		http://www.webdlab.com/
Last Modified:	10.01.2009
*********************************************************************/

/*--------------------------------------------------------------------
Script
--------------------------------------------------------------------*/

function tabChange(){
var tabobj = document.getElementsByTagName('a');
for(var i=0; i < tabobj.length; i++){
if(tabobj[i].className == 'tab_A'){
	tabobj[i].onclick = function(){
	tab_h('tabA','url(images/tab/th1.gif)');
	tab_b('tab1');
	saveCookie('tabA','th1','tab1');
	return false;
	}
}else if(tabobj[i].className == 'tab_B'){
	tabobj[i].onclick = function(){
	tab_h('tabB','url(images/tab/th2.gif)');
	tab_b('tab2');
	saveCookie('tabB','th2','tab2');
	return false;
	}
}else if(tabobj[i].className == 'tab_C'){
	tabobj[i].onclick = function(){
	tab_h('tabC','url(images/tab/th3.gif)');
	tab_b('tab3');
	saveCookie('tabC','th3','tab3');
	return false;
	}
}
}
}

tab_head = getCookie("tab_head");
if(tab_head == ""){
	tab_head = "tabA";
}else{
	document.cookie = tab_head;
}

tab_head_img = getCookie("tab_head_img");
if(tab_head_img == ""){
	tab_head_img = "th1";
}else{
	document.cookie = tab_head_img;
}

tab_body = getCookie("tab_body");
if(tab_body == ""){
	tab_body = "tab1";
}else{
	document.cookie = tab_body;
}

function saveCookie(tab_h,tab_i,tab_b){
	setCookie("tab_head",tab_h);
	setCookie("tab_head_img",tab_i);
	setCookie("tab_body",tab_b);
	document.cookie = tab_h;
	document.cookie = tab_i;
	document.cookie = tab_b;
}

function setCookie(key,val){
	store = key+"="+escape(val)+";";
	store += "expires=Fri, 31-Dec-2030 23:59:59;";
	store += "path = /";
	document.cookie = store;
}

function getCookie(key){
	store = document.cookie+";";
	hangar = store.indexOf(key,0);
	if(hangar != -1){
		store = store.substring(hangar,store.length);
		start = store.indexOf("=",0);
		end = store.indexOf(";",start);
		return(unescape(store.substring(start+1,end)));
		}
	return("");
}

function addEvent(init) {
	if (window.addEventListener) {
		window.addEventListener("load",init, false);
	} else if (window.attachEvent) {
		window.attachEvent("onload",init);
	}
}

var tab_head_img_path = 'url(images/tab/'+tab_head_img+'.gif)';

addEvent(function(){ tabChange(); tab_h(tab_head,tab_head_img_path); tab_b(tab_body); });

function tab_h(tabh,tabi) {
	document.getElementById('tabA').style.backgroundImage = 'url(images/tab/th1_2.gif)';
	document.getElementById('tabB').style.backgroundImage = 'url(images/tab/th2_2.gif)';
	document.getElementById('tabC').style.backgroundImage = 'url(images/tab/th3_2.gif)';
if(tabh) {
	document.getElementById(tabh).style.backgroundImage = tabi;
	}
}

function tab_b(tabb) {
	document.getElementById('tab1').style.display = 'none';
	document.getElementById('tab2').style.display = 'none';
	document.getElementById('tab3').style.display = 'none';
if(tabb) {
	document.getElementById(tabb).style.display = 'block';
	}
}

