var submitRolls = new Object();
var ActivTab =false;
var errorMessages  = new Object();
var win;
var wurl=location.host;
var feedcount=0;
var activfeed=1;
var imagerota=0;

function getElById(id){
	return(document.getElementById==null) ?
   (document.all==null ? null : document.all[id]) : document.getElementById(id);
}

function submitroll(src, oversrc, name){
	this.src=src;
	this.oversrc=oversrc;
	this.name=name;
	this.alt="Submit Query";
	this.write=submitroll_write;
}

function submitroll_write(){
	var thisform = 'document.forms[' + (document.forms.length - 1) + ']';
	submitRolls[this.name] = new Object();
	submitRolls[this.name].over = new Image();
	submitRolls[this.name].over.src = this.oversrc;
	submitRolls[this.name].out = new Image();
	submitRolls[this.name].out.src = this.src;

	document.write
		(
		'<A onClick="DoSearch();" onMouseOver="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].over.src"' + 
		' onMouseOut="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].out.src"' + 
		' HREF="javascript:'
		);

	if (this.sendfield){
		if (! this.sendvalue){
			this.sendvalue = 1;
		}
		document.write(thisform, ".elements['", this.sendfield, "'].value='", this.sendvalue, "';");
	}

	document.write('void(0);"');
	if (this.msg){
		document.write(' onClick="return confirm(\'' , this.msg, '\')"');
	}
	document.write('>');

	document.write('<IMG SRC="' + this.src + '" ALT="' + this.alt + '" BORDER=0 NAME="' + this.name + '"');
	if (this.height)document.write(' HEIGHT=' + this.height);
	if (this.width)document.write(' WIDTH='  + this.width);
	if (this.otheratts)document.write(' ' + this.otheratts);
	document.write('></A>');
	if (this.sendfield){
		document.write('<INPUT TYPE=HIDDEN NAME="' + this.sendfield + '">');
		document.forms[document.forms.length - 1].elements[this.sendfield].value='';
	}
}


function show_mode(id,mode){
	if(document.getElementById(id)){
		getElById(id).style.display = mode;
	}	
	
}

function pic_change(img_src, idClicked){
 
 document.getElementById(idClicked).src = img_src;

}
function trim (value) {
	return value.replace (/^\s+/, '').replace (/\s+$/, '');
}

function InitTabS(){
	show_mode('main_'+ActivTab,'block');
	t=getElById('top_'+ActivTab);
	if(t){
		t.className='reiter_oben1_act';
	}
	b=getElById('bottom_'+ActivTab);
	if(b){
		b.className='reiter_unten1_act';
	}
	
}

function SwitchTabs(id){
	if(id==ActivTab){
		return;
	}
	show_mode('main_'+ActivTab,'none');
	t=getElById('top_'+ActivTab);
	if(t){
		t.className='reiter_oben1';
	}
	b=getElById('bottom_'+ActivTab);
	if(b){
		b.className='reiter_unten1';
	}	
	ActivTab=id;
	InitTabS();
}


function ImageSwap(path){
	img=getElById('bigone');
	if(path!='' && img){
		img.src=path;
	}
	
}

function printPage(){
	if(close && win && win.open){
		win.close();
	}
	var link=location.href+(location.search==''?'?':'&')+'print=true';

	var param='top=10,left=10,width=800,height=600,scrollbars=yes,resizable=no';
	win= window.open(link,'PRINT',param);
	 if(win){
		win.focus();	
	 }
}

function OverviewPage(){
	if(close && win && win.open){
		win.close();
	}
	var link=location.href+(location.search==''?'?':'&')+'overview=true';

	var param='top=10,left=10,width=800,height=600,scrollbars=yes,resizable=no';
	win= window.open(link,'PRINT',param);
	 if(win){
		win.focus();	
	 }
}

function DoPrint(){

	window.print();
	if(window.print){
		self.close();
	}	
	
}

function OpenRequest(){
	bo=getElById('body');
	if(bo){
		h=bo.offsetHeight;
		w=bo.offsetWidth;
	}
  getElById('abdeckung').style.height=(h+50)+'px';

	show_mode('abdeckung','block');
	show_mode('popup','block');
	window.scrollTo(100, 100);
	return false;
	
}



function ResetForm(fo){
	
	
	show_mode('abdeckung','none');
	show_mode('popup','none');
	
	var validator = $("#"+fo+"").validate();
	validator.resetForm();
	
	return false;	
}

function DoSearch(){
	
	var f=getElById('term');
	var str='';
	if(f){
		str=f.value;
	
	}
	if(str.length>2){
		document.location.href='/suche?term='+str;
	}
}

function selectAll(allbox,name,ename){
	var box=document.forms[name].elements[ename];

	for(i=0; i< box.length;i++){
		box[i].checked=allbox.checked;

	}	
}


function InitFeedTab(id){
	
	
	show_mode('feed_links','none');	


	if(id==activfeed){
		return;
	}
	show_mode('feed_nr_'+activfeed,'none');
	show_mode('feed_nr_'+id,'block');
	activfeed=id;
	if(activfeed<=1){
    show_mode('feed_links','none');	
	}
	else{
		show_mode('feed_links','block');
	}
	if(activfeed>=feedcount){
		show_mode('feed_rechts','none');	
		
	}
	else{
		show_mode('feed_rechts','block');	
	}	
}

function switchFeedTab(id){
	set=activfeed+id;
	InitFeedTab(set);
	
}

function theRotator() {
	
	
	$('div#rotator ul li').css({opacity: 0.0});
	$('div#rotator ul li:first').css({opacity: 1.0});
	
	
	setInterval('rotate()',5000);
	
}
 
function rotate() {	
	//Get the first image
	

	if(imagerota<=1){
		return;
	}
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 3000);
	current.animate({opacity: 0.0}, 3000)
	.removeClass('show');
	
};


function OrderGS(){
	
	var url=document.location.href;
	var uri='subject=Weitersagen&body='+url;
	var text="mailto:?"+uri;
	location.href=text;
	return;
}

