
function openWindow(url,w,h) {
   day = new Date();
   id = day.getTime();
   return openWindow2(id,url,w,h)
}
function openWindow2(id,url,w,h) {
   eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=no,scrollbars=yes,location=no,status=yes,menubar=no,resizable=yes,width='+w+',height='+h);");
   return eval("page" + id );
}
function centerWindow(fenster,w,h){
   fenster.moveTo(screen.width/2-w/2,screen.height/2-h/2);
}


function checkBoxChecks(NameBeginsWith,checkState){
 cks=document.getElementsByTagName('INPUT');
 for(i=0;i<cks.length;i++){
  if(cks[i].type=='checkbox'){
   if(cks[i].name.substring(0,NameBeginsWith.length)==NameBeginsWith){
      cks[i].checked = checkState;
   }
  }
 }
}


var ClientHeight, ClientWidth, ScreenHeight, ScreenWidth, ClientBitDepth;

// Reset Parameters in Form-Action for Browser-Client-Width and -Height
function SubmitIt() {
	url = document.forms[0].action;
   url = ReplaceQueryParam( url, "runquery", "" );
   url = ReplaceQueryParam( url, "st", "" );

	if( ClientWidth>0 && ClientHeight>0 ) {
		url = ReplaceQueryParam( url, "cw", ClientWidth );
		url = ReplaceQueryParam( url, "ch", ClientHeight );
		document.forms[0].action = url;
	}
	return true;
}
function SubmitLink() {
   SubmitIt();
   document.forms[0].submit();
}
function SubmitPage(page) {
	url = document.forms[0].action;
   url = ReplaceQueryParam( url, "page", page );
   url = ReplaceQueryParam( url, "runquery", document.forms[0].currentQuery.value );
	if( ClientWidth>0 && ClientHeight>0 ) {
		url = ReplaceQueryParam( url, "cw", ClientWidth );
		url = ReplaceQueryParam( url, "ch", ClientHeight );
	}
   location.href = url;
   return true;
}
function Link( url ) {
	if( ClientWidth>0 && ClientHeight>0 ) {
		url = ReplaceQueryParam( url, "cw", ClientWidth );
		url = ReplaceQueryParam( url, "ch", ClientHeight );
	}
	location.href=url+'&z=0.23';
	return true;
}
function LinkTarget( target, url ) {
	if( ClientWidth>0 && ClientHeight>0 ) {
		url = ReplaceQueryParam( url, "cw", ClientWidth );
		url = ReplaceQueryParam( url, "ch", ClientHeight );
	}
	target.location.href=url;
	return true;
}







function ReplaceQueryParam( url, p, v ) {
	url = RemoveQueryParam( url, p );
	url = AddQueryParam( url, p, v );
	return url;
}

function AddQueryParam( url, p, v ) {
	if( url.indexOf('?')>=0 ) {
		url = url+'&';
	} else {
		url = url+'?';
	}
	url=url+p+'='+v;
	return url;
}

function RemoveQueryParam( url, p ) {
	// Removes only one Param of this that Name yet!
	pos1 = url.indexOf(p+'=');
	if( pos1>0 ) {
		pos2 = url.indexOf('&',pos1);
		if( pos2<0 ) {
			url=url.substring(0,pos1);
		} else {
			url=url.substring(0,pos1)+url.substring(pos2+1,url.length);
		}
		if( url.indexOf('?')>=0 && url.indexOf('=')<0 ) {
			url=url.substring(0,url.length-1);
		}
	}
	return url;
}

function LoadFrameSet(home) {
   if( top.window.location.href == window.location.href ) {
      url = "/index.aspx?load="+escape(window.location.href);
   	if( ClientWidth>0 && ClientHeight>0 ) {
   		url = ReplaceQueryParam( url, "cw", ClientWidth-164 );
   		url = ReplaceQueryParam( url, "ch", ClientHeight );
   	}
      top.window.location.href = url;
   }
}

var StateTimer;
// Get Client-Area-Width and -Height
// Not for older Browsers (>=IE4,NS5,Opera,Firefox)
function BrowserState() {
 try{
  if(document.all){
   ClientHeight = top.CONTENTS.document.body.clientHeight;
	ClientWidth = top.CONTENTS.document.body.clientWidth;
  } else {
   ClientHeight = top.CONTENTS.innerHeight;
	ClientWidth = top.CONTENTS.innerWidth;
  }
  ScreenHeight = screen.height;
  ScreenWidth = screen.width;
  ClientBitDepth = screen.colorDepth;
 }
 catch(e){}	
 clearTimeout(StateTimer);
 StateTimer = setTimeout("BrowserState()",5000);
}

var myTimer;
function SubmitSize() {
   clearTimeout(myTimer);
   myTimer = setTimeout("DoResize()",1000);
} 
function DoResize() {
   clearTimeout(myTimer);
   BrowserState();
   //if(confirm('Die Groesse des Fensters hat sich geaendert.\nMoechten Sie die Suche neu laden, um die Bilder optimal anzuordnen?')) {
      Link(location.href);
   //}
}


function updateFormsInFrames(obj1,obj2,obj3,frame) {
  try {
   eval('top.'+frame+'.window.document.forms[0].'+obj1+'.value = document.forms[0].'+obj1+'.value');
  }
  catch(e) {}

  try {
   eval('top.'+frame+'.window.document.forms[0].'+obj2+'[0].checked = window.document.forms[0].'+obj2+'[0].checked;');
   eval('top.'+frame+'.window.document.forms[0].'+obj2+'[1].checked = window.document.forms[0].'+obj2+'[1].checked;');
   eval('top.'+frame+'.window.document.forms[0].'+obj2+'[2].checked = window.document.forms[0].'+obj2+'[2].checked;');
  }
  catch(e) {}

  try {
   eval('top.'+frame+'.window.document.forms[0].'+obj2+'.value = GetRadioVal(window.document.forms[0].'+obj2+');');
  }
  catch(e) {}

  try {
   eval('top.'+frame+'.window.document.forms[0].'+obj3+'[0].checked = window.document.forms[0].'+obj3+'[0].checked;');
   eval('top.'+frame+'.window.document.forms[0].'+obj3+'[1].checked = window.document.forms[0].'+obj3+'[1].checked;');
   eval('top.'+frame+'.window.document.forms[0].'+obj3+'[2].checked = window.document.forms[0].'+obj3+'[2].checked;');
  }
  catch(e) {}

  try {
   eval('top.'+frame+'.window.document.forms[0].'+obj3+'.value = GetRadioVal(window.document.forms[0].'+obj3+');');
  }
  catch(e) {}
}

function FormatDetailsLeft(text) {
 s="";
 s+="<table width=100% cellpadding=0 cellspacing=1 border=0 bgcolor=#888888 style='filter:Alpha(opacity=90, finishopacity=90, style=1)'><tr><td class=bggray><img src=/i/b.gif width=12 height=1></td><td>";
 s+="<table cellpadding=3 cellspacing=0 border=0 bgcolor=#ffffff width=100%><tr><td class=ntext>";
 s+=text;
 s+="</td></tr></table>";
 s+="</td></tr></table>";
 return s;
}
function FormatDetailsRight(text) {
 s="";
 s+="<table width=100% cellpadding=0 cellspacing=1 border=0 bgcolor=#888888 style='filter:Alpha(opacity=90, finishopacity=90, style=1)'><tr><td>";
 s+="<table cellpadding=3 cellspacing=0 border=0 bgcolor=#ffffff width=100%><tr><td class=ntext>";
 s+=text;
 s+="</td></tr></table>";
 s+="<td class=bggray><img src=/i/b.gif width=12 height=1></td></td></tr></table>";
 return s;
}



function ShowHelp(topic) {
 openWindow2("HELP","/help.aspx?content="+escape('HelpTopic_'+topic),700,500);
}
function ShowEditor(cat,lang,topic,divname) {
 openWindow2("WYSIWYG","/admin/contentedit.aspx?divname="+divname+"&CategoryID="+cat+"&lang="+lang+"&text="+topic,600,500);
}
function ShowTextEditor(cat,lang,topic,divname) {
 openWindow2("WYSIWYG","/admin/contentedit.aspx?divname="+divname+"&type=text&CategoryID="+cat+"&lang="+lang+"&text="+topic,600,500);
}
function EditNews(ID) {
 openWindow2("NEWS","/admin/newsedit.aspx?id="+ID,800,600);
}
function DeleteNews(ID) {
 location.href='/news.aspx?delid='+ID;
}
function NewNews() {
 openWindow2("NEWS","/admin/newsedit.aspx",800,600);
}
function Detail(type,p,id){
 openWindow('StatDetail.aspx?type='+type+'&p='+p+"&id="+id,800,800);
}

function GetRadioVal(obj){
 for(var i=0;i<obj.length;i++) if(obj[i].checked) return obj[i].value;
 return false;
}
function GetSelectVal(obj){
 return obj.options[obj.selectedIndex].value;
}
function GetSelectMultiVal(obj){
 s='';
 for(i=0;i<obj.options.length;i++){
  if(obj.option[i].selected) s=s+obj.options[i].value+',';
 }
 if(s!='') s=s.substring(0,s.length-1);
 return s;
}
function AddOption(obj,text,value){
 obj.options[obj.options.length] = new Option(text,value);
}
function DelOption(obj,value){
 for(i=0;i<obj.options.length;i++){
  if(obj.options[i].value==value){
   //alert(i+','+obj.options.length);
   for(k=i;k<obj.options.length-2;k++){
    obj.options[k]=obj.options[k+1];
   }
   obj.options[k]=null;
   return null;
  }
 }
}
function ExistOption(obj,value){
 for(i=0;i<obj.options.length;i++){
  if(obj.options[i].value==value) return true;
 }
 return false;
}
function DelFromSeperatedList(s,remove){
 i=s.indexOf(','+remove+',');
 if(i>=0){
  return s.substring(0,i)+s.substring(i+remove.length+1);
 }
 i=s.indexOf(remove+',');
 if(i==0){
  return s.substring(remove.length+1);
 }
 if(s.substring(s.length-remove.length-1)==','+remove){
  return s.substring(0,s.length-remove.length-1);
 }
 if(s==remove) return '';
 return s;
}

function divInline(name){
 getElement('id',name).style.display='inline';
}
function divNone(name){
 getElement('id',name).style.display='none';
}

function hideAllSelect(){
 cks=document.getElementsByTagName('SELECT');
 for(i=0;i<cks.length;i++){
   cks[i].style.visibility = "hidden";
 }
}
function showAllSelect(){
 cks=document.getElementsByTagName('SELECT');
 for(i=0;i<cks.length;i++){
   cks[i].style.visibility = "visible";
 }
}
