var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000);
function getCookie(name) {
	var re = new RegExp(name + "=([^;]+)");
	var value = re.exec(document.cookie);
	return (value != null) ? unescape(value[1]) : null;
}
function setCookie(name, value) {
	document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
}
function a(module, action, id, msg) {
//	setCookie(module + "-action", action);
//	setCookie(module + "-id", id);
	if(typeof(msg)== 'string') {
		if (! confirm(msg)) {
			return;
		}
	}
	setCookie(module + "-" +action, id);
	var url = document.location.href;
	var re = new RegExp("^(.+?)\#?$");
	var value = re.exec(url);
	url=value[1];
	document.location.href=url;
}

// Popup
function popup(url, width, height) {
	//alert(width);
	window.open(url,'livestylewin','width=' + width + ',height=' + height + ',left=300,top=300,scrollbars=yes,menubar=no,resizable=no,toolbar=no,status=no'); 
	//return true;
}

// Formdiv einblenden
function showdiv(name) {
	document.getElementById(name).style['display']='block';
	document.getElementById('g1_big').style['display']='none';
}


function hidediv(name) {
	document.getElementById(name).style['display']='none';
}

// Slideshow
var gSlideshows=new Array();

function gSlideshow(name) {

gSlideshows[name]=this;

this.name=name;
this.texts=new Array();
this.linkIds=new Array();
this.divid='';
this.linkid='';
this.playing=true;
this.countTexts=0;
this.wait=15000;
this.id=0;
this.textColor=0;
this.href='';

this.writeContent=function(text){
	eval('document.getElementById("' + this.divid + '").innerHTML=text');
}

this.createlink=function(text, lid) {
	return "<a href=\"javascript:popup('" + this.href + lid + "', '500', '300')\" id=\"" + this.linkid + "\" onmouseover=\"" + name + ".stop();\" onmouseout=\"" + name + ".con();\">" + text + "</a>";
}

this.setTexts=function(texts) {
	this.texts=texts;
	this.countTexts=this.texts.length-1;
	this.id=Math.round(Math.random()*this.countTexts);
} 

this.setLinkIds=function(idarray) {
	this.linkIds=idarray;
}

this.slide2next=function() {
	if (this.playing==true) {
		if (this.id==this.countTexts) 
			this.id=0;
		else 
			this.id++;
					
		this.writeContent(this.createlink(this.texts[this.id], this.linkIds[this.id]));
		this.textColor=219;
		this.fadein();
		setTimeout('gSlideshows["' + this.name + '"].slide2next()', this.wait);
		setTimeout('gSlideshows["' + this.name + '"].fadeout()', this.wait-1500);
	}
	
}

this.fadein=function() {
	this.textColor=this.textColor-25;
	this.changeColor(this.textColor);
	if (this.textColor>0) 
		setTimeout('gSlideshows["' + this.name + '"].fadein()', 150);
}

this.fadeout=function() {
	if (this.playing==false) return;	
	this.textColor=this.textColor+25;
	this.changeColor(this.textColor);
	if (this.textColor<219) 
		setTimeout('gSlideshows["' + this.name + '"].fadeout()', 150);
}

this.changeColor=function(c) {
	eval('document.getElementById("' + this.linkid + '").style[\'color\']="rgb(' +  c + ',' + c + ',' + c + ')"');
}

this.play=function() {
	this.playing=true;
	this.slide2next();
}

this.stop=function() {
	this.playing=false;
}

this.con=function() {
	if (this.playing==false)
		this.playing=true;
}

}




<!-- Change after select
function live_goToURL() { //v3.0
  var i, args=live_goToURL.arguments; document.live_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->

function close_div(name, value) {
	document.cookie=name + "=" + escape(value) + "; path=/";
}


function setNav(name, value) {
	document.cookie=name + "=" + escape(value) + "; path=/";
}


function setPos(name, value) {
	//document.cookie=name + "=" + escape(value) + "; path=/";
	document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/";
}





//Tabs
var tabs=new Array();
function getTabKey(id) {
	var re = new RegExp("^.+_([^_]+)_a$");
	var value = re.exec(id);
	return value[1]
}
function getTabName(id) {
	var re = new RegExp("^(.+)_[^_]+_a$");
	var value = re.exec(id);
	return value[1]
}

function selectTab(what) {
	var id=getTabKey(what.id);
	var name=getTabName(what.id);
	oldTab=tabs[name]['active'];
	if (oldTab==id) return false;
	var el=document.getElementById (name+'_'+id+'_d');
	el.className=el.className=="tabactive"?"tabinactive":"tabactive";
	var old_el=document.getElementById (name+'_'+oldTab+'_d');
	old_el.className="tabinactive";
	var old_link=document.getElementById (name+'_'+oldTab+'_a');
	old_link.className="";
	var old_link=document.getElementById (name+'_'+id+'_a');
	old_link.className="active";
	
	tabs[name]['active']=id;
	return true;
}

