// 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 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 expandCollapse() {
	for (var i=0; i<expandCollapse.arguments.length; i++) {
		if(expandCollapse.arguments[i]!=""){
			var element = document.getElementById(expandCollapse.arguments[i]);
			element.style.display = (element.style.display == "none") ? "block" : "none";
		}
	}
}
function expandCollapse2(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('test');
	document.delete_pic.del_id.value=who; 
	document.delete_pic.submit();
}
function setPermission(who){
	document.akt_buyer.bid.value=who; 
	var access= confirm("Möchten Sie diesem Nutzer zulassen?");
	 if (access== true){
		document.akt_buyer.submit();
	 }else{
		 pp="document.emailsend.p"+who;
		 eval(pp).checked=false;
	 }
}
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; //alert(document.akt_pic.akt_id_val.value);//eval("document.reg.ptype"+who+".value");
	document.akt_pic.submit();
}

function setDirection(who, which){
	//alert(document.delete_pic.del_id);
	document.direction_status.direction_id.value=who; 
	document.direction_status.direction_val.value=which; //alert(document.akt_pic.akt_id_val.value);//eval("document.reg.ptype"+who+".value");
	document.direction_status.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 navigate(url) {
	document.navigation.action = url;
	//alert(document.navigation.sid);
	document.navigation.submit();
}
