Vidar = Array();
Vidar.active_tab = false;
Vidar.tabs_height = 0;
Vidar.tab_content_height = 0;
Vidar.tabs = false;
function activate_tab(obj) {
	if(!obj && document.getElementById('tab-1')) {
		obj = document.getElementById('tab-1');
	}
	if(!Vidar.tabs) { Vidar.tabs= obj.parentNode.parentNode; }
	div = false; tmp = obj; c=0;
   while(!div && c < 7) {
   	tmp = tmp.nextSibling
       if(tmp.nodeType == 1) { div = tmp }
       c++;
   }
   // div = obj.nextSibling.nextSibling
	obj.parentNode.className = 'active tab';
	if((Vidar.active_tab) && (obj.parentNode != Vidar.active_tab)){
		Vidar.active_tab.className = 'inactive tab';
	}
	Vidar.active_tab = obj.parentNode;
	height = div.clientHeight + div.offsetTop
	if(Vidar.tabs.clientHeight < height) { 
		Vidar.tab_content_height = div.clientHeight
		Vidar.tabs_height = height;
		Vidar.tabs.style.height = height+"px";
	}
	if(Vidar.tabs_height > 0){
		div.style.height = (Vidar.tab_content_height-30)+"px";
	}
}
function show_me_the_money() {
	document.getElementById('hide').style.display = 'block';
	ul = false;
	i = 0;
	uls = document.getElementsByTagName('ul')
	while((!ul) && (i < uls.length)) {
		if(uls[i].className == 'wizard') {
			ul = uls[i];
		}
		i++;
	}
	lis = ul.getElementsByTagName('li')
	for(i = 0;i<lis.length;i++) {
		lis[i].className = (lis[i].className == 'active') ? '' : 'active';
	}
	if(document.getElementById('tab-1')) { activate_tab(); }
	if(document.getElementById('mailform')) { self_label(document.getElementById('mailform')); }
}
function self_label(form) {
	if(!form) {
		form = document.getElementById('mailform');
	}
	if(form) {
		elements_c = form.elements.length;
		_labels = form.getElementsByTagName('label');
		Vidar.labels = Array();
		for(i = 0;i < _labels.length; i++) {
			label = _labels[i];
			str = label.htmlFor || label.getAttribute('for');
			text = label.textContent || label.innerHTML
			Vidar.labels[str] = text;
		}
		for(i = 0;i < elements_c; i++) {
			if(form.elements[i].type == 'text') {
				input = form.elements[i];
				input.title = Vidar.labels[input.id];
				input.onfocus = function() {label_focus(this)} ;
				input.onblur = function() {label_blur(this)} ;
				if(input.value == '') {
					input.value = Vidar.labels[input.id]
				}
			}
		}
	}
	if(document.getElementById('tab-1')) {
		activate_tab();
	}
}
function label_focus(obj) {
	if(obj.value == Vidar.labels[obj.id]) {
		obj.value = '';
	}
}
function label_blur(obj) {
	if(obj.value == '') {
		obj.value = Vidar.labels[obj.id];
	}
}
function tt_news_click(obj) {
	link = obj.getElementsByTagName('a')[0];
	document.location = link.href;
	obj.setAttribute('title',link.title);
}
function tt_news_hover(obj) {
	link = obj.getElementsByTagName('a')[0];
	window.status = link.href;
}
function tt_news_out(obj) {
	window.status = '';
}
function fix_all_addies(text) {
	all_links = document.getElementsByTagName("a")
	for(var i=0;i<all_links.length;i++)	{
		if(all_links[i].href.indexOf("linkTo_UnCryptMailto") != -1) {
			start = all_links[i].href.indexOf("Mailto('")+8
			end = all_links[i].href.indexOf("')")
			text = all_links[i].href.substring(start,end)
			all_links[i].innerHTML = email_descramble(unescape(text))
		}
	}
}
function email_descramble(text){
	text = decryptString(text, 2);
	return text.substring(7);

}

