function crImmo(funcname, id, pic, href)
{
	new Ajax.Updater('mainpart-inside', basehref + '/mod_crimmo/crimmo_ajax.php', {asynchronous:true, evalScripts:true, 
  			                	                                onComplete:function(request){ Element("ladestatusdiv").hide(); }, 
        			        	                                  onLoading:function(request){ Element("ladestatusdiv").show(); },
              				                                    parameters:'funcname=showpic&offerID='+id+"&pic="+pic});
  try
  { 
  	//window.history.pushState(pic, funcname, href); 
  	
  }
  catch(e)
  {
  	
  }
  finally
  {
  	
  }
}

function setTitle(title)
{
	if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
      && typeof(parent.document.title) == 'string') 
  {
    parent.document.title = title;
  }
}

function writeOption( value, setit)
{
  foundone=true;
  $('crOptions').innerHTML = extoptionheadline;
  for(i=0; i<extoption.length; i++)
	{
		if(extoption[i][0]==value) extoption[i][1]=setit;
  
	  if(extoption[i][1]==true)
		{
  		$('crOptions').innerHTML += "<label for='lbl" + extoption[i][0] + "'>&middot;&nbsp;" + extoption[i][2] + "</label><br>";
  		foundone = false;
		}
	}
	if(document.forms["crsearchform"].personen[document.forms["crsearchform"].personen.selectedIndex].value>0)
	{	
		$('crOptions').innerHTML += "&middot;&nbsp;"+document.forms["crsearchform"].personen[document.forms["crsearchform"].personen.selectedIndex].text;
	  foundone = false;
	}
	ShowOrHide('crOptions', foundone);
	PreviewNumResults();
}
var CalendarType=1;
function showCalendar()
{
  frommonth = document.forms["crsearchform"]["frommonth"][document.forms["crsearchform"]["frommonth"].selectedIndex].value;
  fromyear  = document.forms["crsearchform"]["fromyear"][document.forms["crsearchform"]["fromyear"].selectedIndex].value;
  
	new Ajax.Updater('crCalendar', basehref + '/mod_crimmo/crimmo_calendar.php', {asynchronous:true, evalScripts:true, 
  			                	                                onComplete:function(request){ $("ladestatusdiv").hide(); }, 
        			        	                                  onLoading:function(request){ $("ladestatusdiv").show(); },
              				                                    parameters:"m=" + frommonth + "&y=" + fromyear});
	ShowOrHide('crCalendar', true);

}

function showCalendar2()
{
	CalendarType=2;
	fromdate = document.forms["crsearchform"]["fromdate"].value;
  //$('crCalendar').setStyle({left:$('fromdate').getStyle(left), top:$('fromdate').getStyle(top)});
	new Ajax.Updater('crCalendarContent', basehref + '/mod_crimmo/crimmo_calendar2.php', {asynchronous:true, evalScripts:true, 
  			                	                                onComplete:function(request){ $("ladestatusdiv").hide(); }, 
        			        	                                  onLoading:function(request){ $("ladestatusdiv").show(); },
              				                                    parameters:"from=" + fromdate + "&v=2"});
	ShowOrHide('crCalendar', true);

}

function ShowOrHide(divid, checkDisplay)
{
	if($(divid).style.display=="none") 
	{
		//Effect.Appear(divid);
		$(divid).show();
	}
	else if(checkDisplay==true)
	{
		//Effect.Fade(divid);
		$(divid).hide();
	}
		
	return;
}

function ShowOrHideIcon(icon)
{
  if(icon.src==basehref+'img/closedfolder.gif') 
  {
    icon.src = basehref+'img/openfolder.gif';
  }
  else
  {
    icon.src = basehref+'img/closedfolder.gif'
  }
}

function CalendarSetFrom(d, m, y)
{
	if(CalendarType==2)
	{
		$("fromdate").value=d +"."+ m +"."+y;
	  ShowOrHide('crCalendar', true);
	  PreviewNumResults(2);	
	  return;
	}
  sform = document.forms["crsearchform"];
	for(i=0; i<sform.fromday.length; i++)
	{
    if(sform.fromday[i].value==parseFloat(d))
    {
      sform.fromday.selectedIndex = i;
      break;
    }
  }
  for(i=0; i<sform.frommonth.length; i++)
	{
    if(sform.frommonth[i].value==parseFloat(m))
    {
      sform.frommonth.selectedIndex= i;
    }
  }
  for(i=0; i<sform.fromyear.length; i++)
	{
    if(sform.fromyear[i].value==y)
    {
      sform.fromyear.selectedIndex= i;
    }
  }
  ShowOrHide('crCalendar', true);
  PreviewNumResults();	
}

function CalendarChgPage(m, y)
{
	if(CalendarType==2) targetDiv='crCalendarContent';
	else targetDiv='crCalendar';
	new Ajax.Updater(targetDiv, basehref + '/mod_crimmo/crimmo_calendar.php', {asynchronous:true, evalScripts:true, 
  			                	                                onComplete:function(request){ Element("ladestatusdiv").hide(); }, 
        			        	                                  onLoading:function(request){ Element("ladestatusdiv").show(); },
              				                                    parameters:"m=" + m + "&y=" + y});
  
}

version=1;
function PreviewNumResults(version)
{
	
	if(version!=2) version=1;
	
	if($('gebiethome')) el_gebiet = "gebiethome";
	else el_gebiet = "gebiet";
	if($(el_gebiet)[$(el_gebiet).selectedIndex].value<0)
	{
	  $('crNumresults').hide();
	  if($(el_gebiet)[$(el_gebiet).selectedIndex].value==-8)
		{
			self.location.replace("http://www.city-residence.de/wiesbaden/");
		}
		else
		{
			self.location.replace("http://www.city-residence.de/");
		}
	  return;
	}
	$('crNumresults').update("<img src='/img/ajaxloading-klein.gif' alt='...'>");
	new Ajax.Updater('crNumresults', basehref + '/mod_crimmo/crimmo_ajax.php', {asynchronous:false, evalScripts:true, 
	                                                                            parameters:"funcname=searchpv&v=" + version + "&" + $('crsearchform').serialize()});
  //$('crNumresults').show();
}

function crYellowpage(index, isMain, itemid)
{
  if(index==0)
  {
	  new Ajax.Updater('crypmain', basehref + '/mod_crimmo/crimmo_ajax.php', {asynchronous:true, evalScripts:true, 
  			                	                                   onComplete:function(request){ $("ladestatusdiv").hide(); }, 
        			        	                                     onLoading:function(request){ $("ladestatusdiv").show(); },
              				                                       parameters:"funcname=yellowpage&init=1&offerID=" + itemid});
  	return;
  }
	if(isMain)
  {
	  new Ajax.Updater('crypsub', basehref + '/mod_crimmo/crimmo_ajax.php', {asynchronous:true, evalScripts:true, 
  			                	                                   onComplete:function(request){ $("ladestatusdiv").hide(); }, 
        			        	                                     onLoading:function(request){ $("ladestatusdiv").show(); },
              				                                       parameters:"funcname=yellowpage&ypmain=" + $('ypmain')[$('ypmain').selectedIndex].value
              				                                                + "&offerID=" + itemid});
  }
  else
  {
	  new Ajax.Updater('crypresult', basehref + '/mod_crimmo/crimmo_ajax.php', {asynchronous:true, evalScripts:true, 
  			                	                                   onComplete:function(request){ $("ladestatusdiv").hide(); }, 
        			        	                                     onLoading:function(request){ $("ladestatusdiv").show(); },
              				                                       parameters:"funcname=yellowpage&ypmain=" 
              				                                                + $('ypmain')[$('ypmain').selectedIndex].value 
              				                                                + "&ypsub=" + $('ypsub')[$('ypsub').selectedIndex].value
	                                                                    + "&offerID=" + itemid});
  }
}

var sub0="";
function YellowMap(id, sub0)
{
	if(sub0==0) target='crYMsub0';
	else 'crYMsub1'
	new Ajax.Updater(target, basehref + '/mod_crimmo/crimmo_ajax.php', {asynchronous:true, evalScripts:true, 
  			                	                                onComplete:function(request){ Element("ladestatusdiv").hide(); }, 
        			        	                                  onLoading:function(request){ Element("ladestatusdiv").show(); },
              				                                    parameters:"funcname=yellowmap&offerID="+id+"&sub0=" + sub0});
  

}

function YellowmapSendBtn(id)
{
	myform = document.forms["itemid"+id];
	if(myform["BC"][myform["BC"].selectedIndex].value>0)
	{
		$('YMsendbtn').show();
	}
	else
	{
		$('YMsendbtn').hide();
	}
}

function YMsend(id, strasse, plz, ort, std)
{
	myform = document.forms["itemid"+id];
	link = "http://www.yellowmap.de/partner/citymitwohnzentrale/aufruf.asp";
	link += "?TYP=GEN&ZART=DS";
	link += "&BC=" + myform["BC"][myform["BC"].selectedIndex].value;
	link += "&Rad=" + myform["Rad"][myform["Rad"].selectedIndex].value;
	link += "&STRASSE="+strasse+"+1&PLZ="+plz+"&HAUPTORT="+ort+"&TEILORT=std";	
	window.open(link, "YM", "width=508,height=500,left=100,top=200,resizeable=yes,scrollbars=yes");
}

function crCheckZimmer()
{
	min = $("minzimmer")[$("minzimmer").selectedIndex].value;
	max = $("maxzimmer")[$("maxzimmer").selectedIndex].value;
	if(max<min && max>0) 
	{
		$("maxzimmer")[$("maxzimmer").selectedIndex].selected = false;
		for(i=0; i<$("maxzimmer").length; i++)
		{
			if($("maxzimmer")[i].value==min) 
			{
				$("maxzimmer").selectedIndex = i;
				break;
			}
		}
		//alert("Mummpitz");
	}
}

function crLangSwitch(newlangid)
{
	//$("ladestatusdiv").show();
	new Ajax.Updater('mainpart-inside', basehref + '/mod_crimmo/crimmo_ajax.php', {asynchronous:true, evalScripts:true, 
  			                	                                            parameters:'funcname=newlang&new_lang='+newlangid});

}

function crFotoPrintSwitch(id, value)
{
	new Ajax.Updater('crFotoPrintDiv', basehref + '/mod_crimmo/crimmo_ajax.php', {asynchronous:true, evalScripts:true, 
  			                	                                 onComplete:function(request){ Element("ladestatusdiv").hide(); }, 
        			        	                                   onLoading:function(request){ Element("ladestatusdiv").show(); },
              				                                     parameters:"funcname=fotoprintswitch&offerID="+id+"&" + $('crFotoPrintForm').serialize()});
  

}

var crPopupTimeout;
var crPopupOffernr;
function crOfferPopupDelayed(offernr)
{
	if(crPopupOffernr == offernr)
	{
	  $('crDivPopup').show();
		return;
	}
	crPopupOffernr = offernr;
	crPopupTimeout = setTimeout("crOfferPopup(crPopupOffernr)", 2000);
}

function crOfferPopup(offernr)
{
	$('crDivPopupContent').innerHTML="<img src='img/ajaxloading.gif' alt='... Moment ... Vorschau wird geladen ...'>";
	if(!$('crPopupContent'))
	{
		$('crDivPopup').innerHTML = '<div id="crDivPopupContent"></div>';
	}
	popup_content = "";
	popup_content = "<iframe src='"+basehref+"Angebot_"+offernr+".html?tpl=print2' width='780' height='600'></iframe>";
  $('crDivPopupContent').innerHTML="<a href=\"#\" onclick=\"crDivPopupClose(); return false;\">"+popup_content+"<img src=\"img/icon_close.png\" border=0 alt=\"\" align=\"top\"><br>Schlie&szlig;en</a>";
  $('crDivPopup').show();
}

function crDivPopupClose()
{
	$('crDivPopup').hide();
	clearTimeout(crPopupTimeout);
}

