
function GetDays(num_day, day, month, year)
{
  var DateNow = new Date();
  var Ta1,Ta2,Ta3;
  var Mo1,Mo2,Mo3;
  var Ja1,Ja2,Ja3;
  var status_day = false;
  
  Ta1 = document.Trolley.day1.value;
  Mo1 = document.Trolley.month1.value;
  Ja1 = document.Trolley.year1.value;

  Ta2 = document.Trolley.day2.value;
  Mo2 = document.Trolley.month2.value;
  Ja2 = document.Trolley.year2.value;
  
  Ta3 = DateNow.getDate();
  Mo3 = DateNow.getMonth()+1;
  Ja3 = DateNow.getFullYear();
  
  DateStart2 = Date.UTC(Ja1, Mo1, Ta1);
  DateStop2 = Date.UTC(Ja2, Mo2, Ta2);
  DateNow = Date.UTC(Ja3, Mo3, Ta3);
    
  ZTage = (DateStop2 - DateStart2) / 86400000;
  ZTageNow = (DateStart2 - DateNow) / 86400000;
  
  if(Mo1 == Mo2)ZTage++;
  
  if(ZTageNow <= 3)
  {
  	status_day = true;
  	alert("Mietzeitraum zu kurzfristig!\n\nBitte rufen Sie uns für weitere Informationen an!\n\nDanke");
  }
  else if(ZTage > 7 && gigahertz_lan == 1)
  {
  	status_day = true;
  	alert("Mietzeitraum zu lang!\n\nBitte mieten Sie das Equipment unter http://b2b.gigahert-rent.de.\n\nDanke");
  }
  else if(ZTage == 0)
  {
  	status_day = true;
  	alert("Mindestmietzeit beträgt 1 Tag!");
  }
  else if(ZTage < 0)
  {
  	status_day = true;
  	alert("Rückgabedatum muss nach dem Mietbeginn liegen!");
  }
  else 
  {		
	document.getElementById("CheckBooking").style.display = 'none';
	document.getElementById("CheckBooking2").style.display = '';
	document.getElementById("CheckBooking3").style.display = 'none';
	  
	window.setTimeout("CheckBooking(ZTage)", 2000);
  }
  
  if (status_day == true)
  {
  	if (num_day == 1)
  	{
  		document.Trolley.day1.value = day;
		document.Trolley.month1.value = month;
		document.Trolley.year1.value = year;

		if(day<10)day = 0 + "" + day;
		if(month<10)month = 0 + "" + month;
	
		parent.frames['SetTrolleyData'].location.href = 'shop_SetTrolleyData.php?type=start&day=' + day + '&month=' + month + '&year=' + year;
		
		document.getElementById("DateStartTD").innerHTML = day + '.' + month + '.' + year;
		
	}
	else
	{
  		document.Trolley.day2.value = day;
		document.Trolley.month2.value = month;
		document.Trolley.year2.value = year;

		if(day<10)day = 0 + "" + day;
		if(month<10)month = 0 + "" + month;
		
		parent.frames['SetTrolleyData'].location.href = 'shop_SetTrolleyData.php?type=stop&day=' + day + '&month=' + month + '&year=' + year;
		
		document.getElementById("DateStopTD").innerHTML = day + '.' + month + '.' + year;
	}
  }
}

function CheckBooking2 ()
{
  document.getElementById("CheckBooking").style.display = '';
  document.getElementById("CheckBooking2").style.display = 'none';
  document.getElementById("CheckBooking3").style.display = 'none';
}
function CheckBooking (ZTage)
{
  document.all.DateDays.innerHTML = ZTage + " Tage";
  document.Trolley.days.value = ZTage;
  GetPrice(0);
  document.Trolley.submit.disabled = false;

  document.getElementById("CheckBooking2").style.display = 'none';
  document.getElementById("CheckBooking3").style.display = '';
  
  window.setTimeout("CheckBooking2()", 6000);
  
  <!-- document.getElementById("CheckBooking").style.MozOpacity = 1.00; -->
  <!-- document.getElementById("CheckBooking").style.filter = 'alpha(opacity=100)';-->
}

function StartCheck()
{
	document.getElementById("CheckBooking").style.display = 'none';
	document.getElementById("CheckBooking2").style.display = '';
	document.getElementById("CheckBooking3").style.display = 'none';
	  
	window.setTimeout("StartCheck1()", 2000);	
}

function StartCheck1()
{
  document.getElementById("CheckBooking2").style.display = 'none';
  document.getElementById("CheckBooking3").style.display = '';
  
  window.setTimeout("CheckBooking2()", 6000);	
}

function DateStartCallback(day, month, year)
{
	old_day = document.Trolley.day1.value;
	old_month = document.Trolley.month1.value;
	old_year = document.Trolley.year1.value;
	
	document.Trolley.day1.value = day;
	document.Trolley.month1.value = month;
	document.Trolley.year1.value = year;
	
	if(day<10)day = 0 + "" + day;
	if(month<10)month = 0 + "" + month;

	parent.frames['SetTrolleyData'].location.href = 'shop_SetTrolleyData.php?type=start&day=' + day + '&month=' + month + '&year=' + year;
	
	document.getElementById("DateStartTD").innerHTML = day + '.' + month + '.' + year;

	if(document.Trolley.day2.value != "" && document.Trolley.month2.value != "" && document.Trolley.year2.value != "")
	{
		GetDays(1,old_day,old_month,old_year);
	}
}

function DateStopCallback(day, month, year)
{
	old_day = document.Trolley.day2.value;
	old_month = document.Trolley.month2.value;
	old_year = document.Trolley.year2.value;
	
	document.Trolley.day2.value = day;
	document.Trolley.month2.value = month;
	document.Trolley.year2.value = year;
	
	if(day<10)day = 0 + "" + day;
	if(month<10)month = 0 + "" + month;
	
	parent.frames['SetTrolleyData'].location.href = 'shop_SetTrolleyData.php?type=stop&day=' + day + '&month=' + month + '&year=' + year;
	
	document.getElementById("DateStopTD").innerHTML = day + '.' + month + '.' + year;

	if(document.Trolley.day1.value != "" && document.Trolley.month1.value != "" && document.Trolley.year1.value != "")
	{
		GetDays(2,old_day,old_month,old_year);
	}
}

function GetTrolleyPrice (days, preis_tag, preis_bis8tage, preis_ab8tage, preis_monat) {
	price = 0;
	
	preis_tag = parseFloat(preis_tag);
	preis_bis8tage = parseFloat(preis_bis8tage);
	preis_ab8tage = parseFloat(preis_ab8tage);
	preis_monat = parseFloat(preis_monat);
	
	// Tagespreise
	if(days < 30)
	{
		if(days >= 1) 
		{
			price += preis_tag;
		}
		
		if(days > 1)
		{
			mul_days = days - 1;
			if(mul_days>6)mul_days = 6;
			price += mul_days * preis_bis8tage;
		}
        
        if(days > 7)
        {
        	mul_days = days - 7;
        	price += mul_days * preis_ab8tage;
        }
    }
    // Monatspreise
    else
    {
    	
    	mul_monate = parseInt(days / 30);
    	tage = days - (mul_monate*30);
    	price += (mul_monate * preis_monat) + (preis_ab8tage * tage);
    }
    
    return price;
}



set = "";
clear = "";
displayed = "";

NS = (navigator.appName == "Netscape");
IE = (document.all) ? 1: 0;

function SetDisplayed(n)
{
	displayed = n;
}

function move_in(id,countRows)
{
  rows = countRows;
  hgt = (rows*23)+0;
  head = 'head_'+id;
  
  if(IE)
  {
    if(document.all[id].style.pixelHeight < hgt)
    {
    	document.all[id].style.pixelHeight +=23;
    	if(document.all[id].style.pixelHeight >= hgt)
    	{
    		document.all[id].style.overflow="visible";
    		clearInterval(set);
    	}
    }
  }
  if(NS)
  {
    i = parseInt(document.getElementById(id).style.height);
    if(i < hgt){
      document.getElementById(id).style.height = i+23;
    }
    if(i >= hgt) clearInterval(set);
  }
  displayed = id;
  }

function move_out(id,countRows)
{
  rows = countRows;
  hgt = (rows*23)+0;
  head = 'head_'+id;
  
  if(IE)
  {
    //document.all[head].className = "";
    if(document.all[id].style.pixelHeight > 20)
    {
    	document.all[id].style.overflow="hidden";
    	document.getElementById(id).style.pixelHeight -= 23;
    }
    if(document.getElementById(id).style.pixelHeight <= 20)
    {
      document.all[id].style.pixelHeight = 1;
      clearInterval(clear);
      document.all[id].style.visibility = "hidden";
      document.all[id].style.position = "absolute";
      rueck = 'ja';
      return rueck;
    }
  }
  
  if (NS)
  {
    j = parseInt(document.getElementById(id).style.height);

    if (j> 1)
    {
      document.getElementById(id).style.height = j-23;
    }
    
    if(j <= 23)
    {
      document.getElementById(id).style.height = 1; 
      clearInterval(clear);
      document.getElementById(id).style.visibility = "hidden";
      document.getElementById(id).style.position = "absolute";
      rueck = 'ja';
      return rueck;
    }
  }
}

function move(id, countRows)
{
  if(set) {clearInterval(set);}
  if(clear) {clearInterval(clear);}
  rows = countRows;
  idd = id;
  rueck = false;
  
  if(IE && displayed != "") objct = document.all[displayed];
  if(NS && displayed != "")objct = document.getElementById(displayed);

  if(displayed != "" && objct && objct.style.visibility == "visible")
  {
    clear = setInterval("move_out(displayed,rows)",1);
    weiter = setInterval("check(idd)",1);
  }
  else
  {
    display(idd,rows);
  }
}

function check(id)
{
  idd = id;
  if(rueck == 'ja')
  {
    clearInterval(weiter);
    if(displayed != idd)
    {
      display(idd,rows)
    }
  }
}

function display (id,countRows)
{
  if(set) {clearInterval(set);}
  if(clear) {clearInterval(clear);}
  if(IE) objct = document.all[id];
  if(NS) objct = document.getElementById(id);
  rows = countRows;

  if(objct.style.visibility == "hidden")
  {
    head = 'head_'+id;
    objct.style.position = "relative";
    objct.style.top = 0;
    objct.style.visibility = "visible";
    objct.style.pixelHeight = 1;

    string = id;
    set = setInterval("move_in(string,rows)",1);
  }else{
    string = id;
    clear = setInterval("move_out(string,rows)",1);
  }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function switchImage(imgName, imgSrc)
{
	if (document.images)
	{
		if (imgSrc != "none") 
		{
			document.images[imgName].src = imgSrc;
		}
	} 
} 

function ChangeMenue(button_name)
{
		button_array = new Array();
		button_array["home"] = "button_home.gif";
		button_array["equipment"] = "button_equipment.gif";
		button_array["service"] = "button_service.gif";
		button_array["special"] = "button_special.gif";
		button_array["logistics"] = "button_logistics.gif";
		button_array["agb"] = "button_agb.gif";
		button_array["komplettpakete"] = "button_komplettpakete.gif";
		
		search_string = document.images[button_name].src;
		if(search_string.search(/hover/) != -1)
		{
			button_array[button_name] = "button_" + button_name + ".gif";
		}
		else
		{
			button_array[button_name] = "button_" + button_name + "_hover.gif";
		}
		
		document.images["home"].src = "gfx/lan/" + button_array["home"];
		document.images["equipment"].src = "gfx/lan/" + button_array["equipment"];
		document.images["service"].src = "gfx/lan/" + button_array["service"];
		document.images["special"].src = "gfx/lan/" + button_array["special"];
		document.images["logistics"].src = "gfx/lan/" + button_array["logistics"];
		document.images["agb"].src = "gfx/lan/" + button_array["agb"];
		document.images["komplettpakete"].src = "gfx/lan/" + button_array["komplettpakete"];
}