function crImmo(funcname, id, pic)
{
	new Ajax.Updater('mainpart-inside', '/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});

}

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();
}

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', '/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 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)
{
  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)
{
	new Ajax.Updater('crCalendar', '/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});
  
}

function PreviewNumResults()
{
	//$('crNumresults').hide();
	$('crNumresults').update("<img src='/img/ajaxloading-klein.gif' alt='...'>");
	new Ajax.Updater('crNumresults', '/mod_crimmo/crimmo_ajax.php', {asynchronous:false, evalScripts:false, 
	                                                        parameters:"funcname=searchpv&" + $('crsearchform').serialize()});
  //$('crNumresults').show();
}

function crYellowpage(index, isMain, itemid)
{
  if(index==0)
  {
	  new Ajax.Updater('crypmain', '/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', '/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', '/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, '/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) 
	{
		$("maxzimmer")[$("maxzimmer").selectedIndex].selected = false;
		for(i=0; i<$("maxzimmer").length; i++)
		{
			if($("maxzimmer")[i].value==min) 
			{
				$("maxzimmer").selectedIndex = i;
				break;
			}
		}
		//alert("Mummpitz");
	}
}
