// JavaScript Document
var MM_contentVersion = 7;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}

function navigate(url) { //alert(ddaccordion);

	document.navigation.action = url;// alert(url);
	document.navigation.submit();
	//if(el!="") { expandCollapse(el, "block"); }
}

function expandCollapse(el, val) {
	//for (var i=0; i<expandCollapse.arguments.length; i++) {
		//if(expandCollapse.arguments[i]!=""){//expandCollapse.arguments[i]
			var element = document.getElementById(el);
			if(val=='none'){
				element.style.display = "none";
			}else{
				element.style.display = "block";
			}
			
			//element.style.display = (element.style.display == "none") ? "block" : "none";
		//}
	//}
}

function pop_up(txt, banlink, win, page, w, h){
  while (txt.indexOf('"')!=-1) {
    txt=txt.replace('"',"`");
  }
  while (txt.indexOf('“')!=-1) {
     txt=txt.replace('“',"`");
  }
  while (txt.indexOf('„')!=-1) {
     txt=txt.replace('„',"~");
  }
  win=page+'?ban_text='+txt+'&ban_link='+banlink+'&ban_win='+win;
  w_h='width='+w+',height='+h;
  window.open(win, 'preview', w_h);
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function checkDate(which) {
	if(which==1){
	   d=document.update.dd.options[document.update.dd.selectedIndex].value;
	   m=document.update.mm.options[document.update.mm.selectedIndex].value;
	   y=document.update.yy.options[document.update.yy.selectedIndex].value;
	}
	if(which==2){
		d=document.updatetarif.dd.options[document.updatetarif.dd.selectedIndex].value;
		m=document.updatetarif.mm.options[document.updatetarif.mm.selectedIndex].value;
	    y=document.updatetarif.yy.options[document.updatetarif.yy.selectedIndex].value;
	}
	if(which==3){
		d=document.updatetarif.ddn.options[document.updatetarif.ddn.selectedIndex].value;
	    m=document.updatetarif.mmn.options[document.updatetarif.mmn.selectedIndex].value;
		y=document.updatetarif.yyn.options[document.updatetarif.yyn.selectedIndex].value;
	}
	if(which==4){
		d=document.verand.ddn.options[document.verand.ddn.selectedIndex].value;
	    m=document.verand.mmn.options[document.verand.mmn.selectedIndex].value;
		y=document.verand.yyn.options[document.verand.yyn.selectedIndex].value;
	}
	if(which==5){
		d=document.verand.dd.options[document.verand.dd.selectedIndex].value;
	    m=document.verand.mm.options[document.verand.mm.selectedIndex].value;
		y=document.verand.yy.options[document.verand.yy.selectedIndex].value;
	}
		

   if (m==04 || m==06 || m==09 || m==11) {
      if (d>30) {
		  if(which==1){
			 document.update.dd.selectedIndex=30;
		  }
		  if(which==2){
			document.updatetarif.dd.selectedIndex=30;
		 }
		  if(which==3){
			document.updatetarif.ddn.selectedIndex=30;
		  }
          if(which==4){
			document.verand.ddn.selectedIndex=30;
		  }
		  if(which==5){
			document.verand.dd.selectedIndex=30;
		  }
		  
		  alert("Dieser Monat hat 30 Tage.");
      }
   } else {
               if (m==02) {
                  if (d>28 && (y%4)!=0) {
						if(which==1){
							 document.update.dd.selectedIndex=28;
						  }
						 if(which==2){
							document.updatetarif.dd.selectedIndex=28;
						 }
						 if(which==3){
							 document.updatetarif.ddn.selectedIndex=28;
						 }
						 if(which==4){
							 document.verand.ddn.selectedIndex=28;
						 }
						 if(which==5){
							document.verand.dd.selectedIndex=28;
						 }
							  
                        alert("Dieser Monat hat 28 Tage.");
                     } else {
                          if (d>29 && (y%4)==0) {
							if(which==1){
								document.update.dd.selectedIndex=29;
							}
							if(which==2){
								document.updatetarif.dd.selectedIndex=29;
							}
						    if(which==3){
								document.updatetarif.ddn.selectedIndex=29;
							}
							if(which==4){
								document.verand.ddn.selectedIndex=29;
							}
							if(which==5){
								document.verand.dd.selectedIndex=29;
							}
								
                             alert("Dieser Monat hat 29 Tage.");
                          }
                      }
                }
           }
		   
		 if(which==1){  
		   document.upload_pic.dd2.value=document.delete_pic.dd2.value=document.update.dd.options[document.update.dd.selectedIndex].value;
		   document.upload_pic.mm2.value=document.delete_pic.mm2.value=document.update.mm.options[document.update.mm.selectedIndex].value;
		   document.upload_pic.yy2.value=document.delete_pic.yy2.value=document.update.yy.options[document.update.yy.selectedIndex].value;
		 }
  // alert(document.upload_pic.mm2.value);
}

function DoNav(theUrl)  {
  document.location.href = theUrl;
  }
  
  function ChangeColor(tableRow, highLight){
    if (highLight){
      tableRow.style.backgroundColor = '#FFCC69';
    }else{
      tableRow.style.backgroundColor = 'white';
    }
  }
  
function ConfirmDel(loc){
	answer = confirm("Are you sure you want to delete the record?");
		
	if (answer !=0){ 
	  location = loc; 
	} 
}  

function deletePicture(who){
	//alert(document.delete_pic.del_id);
	document.delete_pic.del_id.value=who; 
	document.delete_pic.submit();
}
function setStatus(who, which){ //alert(who);
	//alert(document.delete_pic.del_id);
	document.akt_pic.akt_id.value=who; 
	document.akt_pic.akt_id_val.value=which; //eval("document.reg.ptype"+who+".value");
	document.akt_pic.submit();
}
function setTitle(who, which){ //alert(who);
	//alert(document.delete_pic.del_id);
	document.title_pic.title_id.value=who; 
	document.title_pic.title_val.value=which; //eval("document.reg.ptype"+who+".value");
	document.title_pic.submit();
}

function check(file) {
  var ext = file;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  if(ext != 'jpg' && ext!='gif' && ext!='png') {
	 upl_win=window.open('upload.html', 'up', 'width=300,height=150,left='+((screen.availWidth/2)-150)+',top='+((screen.availHeight/2)-150)+',screenX=0,screenY=100');
	 upl_win.close("up"); 
    alert('Please choose a picture file (jpg, gif or png)!');
    return false; }
  else
    return true; 
}

/*function expandCollapse() {
	for (var i=0; i<expandCollapse.arguments.length; i++) {
		var element = document.getElementById(expandCollapse.arguments[i]);
		element.style.display = (element.style.display == "none") ? "block" : "none";
	}
}*/


function changeImage(element, pic, thumb, big_pic, print_btn)
{ 
  var x = document.getElementById("big");
  var b = document.getElementById("big_pic");
  b.href=big_pic;
  
  var c = document.getElementById("print_btn"); //alert(c);
  if(print_btn==1){ c.style.visibility="visible";
	}else{c.style.visibility="hidden";}

  for(i=1; i<=4; i++){
	  z = document.getElementById("thumb"+i);
	 // z.style.border="none";
	// alert(z);
	 if(z != null){
	  z.style.borderColor="#555553";
	 }
  }
 var y = document.getElementById(thumb);
 y.style.border="2px";
 y.style.borderStyle="solid";
 y.style.borderColor="#FF9900";
//var v = x.getAttribute("src");
 x.src=pic;
 x.width=532; x.height=331;

}
////////////////////////////////////////////////////////////////////////////

function popMenusToShow()
{
	var obj = divToScroll;
	var endArray = new Array();
	while(obj && obj.tagName!='BODY'){
		if(obj.tagName=='DIV' && obj.id.indexOf('slideDiv')>=0){
			var objFound = -1;
			for(var no=0;no<otherDivsToScroll.length;no++){
				if(otherDivsToScroll[no]==obj){
					objFound = no;		
				}					
			}	
			if(objFound>=0){
				otherDivsToScroll.splice(objFound,1);	
			}		
		}	
		obj = obj.parentNode;
	}	
}

function showSubMenu(e,inputObj)
{

	if(this && this.tagName)inputObj = this.parentNode;
	if(inputObj && inputObj.tagName=='LI'){
		divToScroll = inputObj.getElementsByTagName('DIV')[0];
		for(var no=0;no<otherDivsToScroll.length;no++){
			if(otherDivsToScroll[no]==divToScroll)return;
		}			
	}
	hidingInProcess = false;
	if(otherDivsToScroll.length>0){
		if(divToScroll){				
			if(otherDivsToScroll.length>0){
				popMenusToShow();
			}
			if(otherDivsToScroll.length>0){	
				autoHideMenus();
				hidingInProcess = true;
			}
		}	
	}		
	if(divToScroll && !hidingInProcess){
		divToScroll.style.display='';
		otherDivsToScroll.length = 0;
		otherDivToScroll = divToScroll.parentNode;
		otherDivsToScroll.push(divToScroll);	
		while(otherDivToScroll && otherDivToScroll.tagName!='BODY'){
			if(otherDivToScroll.tagName=='DIV' && otherDivToScroll.id.indexOf('slideDiv')>=0){
				otherDivsToScroll.push(otherDivToScroll);
									
			}
			otherDivToScroll = otherDivToScroll.parentNode;
		}			
		ulToScroll = divToScroll.getElementsByTagName('UL')[0];
		if(divToScroll.style.height.replace('px','')/1<=1)scrollDownSub();
	}	
	

}



function autoHideMenus()
{
	if(otherDivsToScroll.length>0){
		divToHide = otherDivsToScroll[otherDivsToScroll.length-1];
		parentDivToHide.length=0;
		var obj = divToHide.parentNode.parentNode.parentNode;
		while(obj && obj.tagName=='DIV'){			
			if(obj.id.indexOf('slideDiv')>=0)parentDivToHide.push(obj);
			obj = obj.parentNode.parentNode.parentNode;
		}
		var tmpHeight = (divToHide.style.height.replace('px','')/1 - slideMenuHeightOfCurrentBox);
		if(tmpHeight<0)tmpHeight=0;
		if(slideMenuHeightOfCurrentBox)divToHide.style.height = tmpHeight  + 'px';
		ulToHide = divToHide.getElementsByTagName('UL')[0];
		slideMenuHeightOfCurrentBox = ulToHide.offsetHeight;
		scrollUpMenu();		
	}else{
		slideMenuHeightOfCurrentBox = 0;
		showSubMenu();			
	}
}


function scrollUpMenu()
{

	var height = divToHide.offsetHeight;
	height-=15;
	if(height<0)height=0;
	divToHide.style.height = height + 'px';

	for(var no=0;no<parentDivToHide.length;no++){	
		parentDivToHide[no].style.height = parentDivToHide[no].getElementsByTagName('UL')[0].offsetHeight + 'px';
	}
	if(height>0){
		setTimeout('scrollUpMenu()',5);
	}else{
		divToHide.style.display='none';
		otherDivsToScroll.length = otherDivsToScroll.length-1;
		autoHideMenus();			
	}
}	

function scrollDownSub()
{
	if(divToScroll){			
		var height = divToScroll.offsetHeight/1;
		var offsetMove =Math.min(15,(ulToScroll.offsetHeight - height));
		height = height +offsetMove ;
		divToScroll.style.height = height + 'px';
		
		for(var no=1;no<otherDivsToScroll.length;no++){
			var tmpHeight = otherDivsToScroll[no].offsetHeight/1 + offsetMove;
			otherDivsToScroll[no].style.height = tmpHeight + 'px';
		}			
		if(height<ulToScroll.offsetHeight)setTimeout('scrollDownSub()',5); else {
			divToScroll = false;
			ulToScroll = false;
			if(objectsToExpand.length>0 && initExpandIndex<(objectsToExpand.length-1)){
				initExpandIndex++;
				
				showSubMenu(false,objectsToExpand[initExpandIndex]);
			}
		}
	}
}
	
function initSubItems(inputObj,currentDepth)
{		
	divCounter++;		
	var div = document.createElement('DIV');	// Creating new div		
	div.style.overflow = 'hidden';	
	div.style.position = 'relative';
	div.style.display='none';
	div.style.height = '1px';
	div.id = 'slideDiv' + divCounter;
	div.className = 'slideMenuDiv' + currentDepth;		
	inputObj.parentNode.appendChild(div);	// Appending DIV as child element of <LI> that is parent of input <UL>		
	div.appendChild(inputObj);	// Appending <UL> to the div
	var menuItem = inputObj.getElementsByTagName('LI')[0];
	while(menuItem){
		if(menuItem.tagName=='LI'){
			var aTag = menuItem.getElementsByTagName('A')[0];
			aTag.className='slMenuItem_depth'+currentDepth;	
			var subUl = menuItem.getElementsByTagName('UL');
			if(subUl.length>0){
				initSubItems(subUl[0],currentDepth+1);					
			}
			aTag.onclick = showSubMenu;				
		}			
		menuItem = menuItem.nextSibling;						
	}		
}

function initSlideDownMenu()
{
	dhtmlgoodies_slmenuObj = document.getElementById('dhtmlgoodies_slidedown_menu');
	dhtmlgoodies_slmenuObj.style.visibility='visible';
	var mainUl = dhtmlgoodies_slmenuObj.getElementsByTagName('UL')[0];		
	var mainMenuItem = mainUl.getElementsByTagName('LI')[0];
	mainItemCounter = 1;
	while(mainMenuItem){			
		if(mainMenuItem.tagName=='LI'){
			var aTag = mainMenuItem.getElementsByTagName('A')[0];
			aTag.className='slMenuItem_depth1';	
			var subUl = mainMenuItem.getElementsByTagName('UL');
			if(subUl.length>0){
				mainMenuItem.id = 'mainMenuItem' + mainItemCounter;
				initSubItems(subUl[0],2);
				aTag.onclick = showSubMenu;
				mainItemCounter++;
			}				
		}			
		mainMenuItem = mainMenuItem.nextSibling;	
	}		
	
	if(location.search.indexOf('mainMenuItemToSlide')>=0){
		var items = location.search.split('&');
		for(var no=0;no<items.length;no++){
			if(items[no].indexOf('mainMenuItemToSlide')>=0){
				values = items[no].split('=');
				showSubMenu(false,document.getElementById('mainMenuItem' + values[1]));	
				initMenuIdToExpand = false;				
			}
		}			
	}else if(expandFirstItemAutomatically>0){
		if(document.getElementById('mainMenuItem' + expandFirstItemAutomatically)){
			showSubMenu(false,document.getElementById('mainMenuItem' + expandFirstItemAutomatically));
			initMenuIdToExpand = false;
		}
	}

	if(expandMenuItemByUrl)
	{
		var aTags = dhtmlgoodies_slmenuObj.getElementsByTagName('A');
		for(var no=0;no<aTags.length;no++){
			var hrefToCheckOn = aTags[no].href;				
			if(location.href.indexOf(hrefToCheckOn)>=0 && hrefToCheckOn.indexOf('#')<hrefToCheckOn.length-1){// 
				initMenuIdToExpand = false;
				var obj = aTags[no].parentNode;
				while(obj && obj.id!='dhtmlgoodies_slidedown_menu'){
					if(obj.tagName=='LI'){							
						var subUl = obj.getElementsByTagName('UL');
						if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
						if(subUl.length>0){								
							objectsToExpand.unshift(obj);
						}
					}
					obj = obj.parentNode;	
				}
				showSubMenu(false,objectsToExpand[0]);
				break;					
			}			
		}
	}
			
	if(initMenuIdToExpand)
	{
		objectsToExpand = new Array();
		var obj = document.getElementById(initMenuIdToExpand)
		while(obj && obj.id!='dhtmlgoodies_slidedown_menu'){
			if(obj.tagName=='LI'){
				var subUl = obj.getElementsByTagName('UL');
				if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
				if(subUl.length>0){						
					objectsToExpand.unshift(obj);
				}
			}
			obj = obj.parentNode;	
		}
		
		showSubMenu(false,objectsToExpand[0]);

	}
}