function open_popup(url,text)
{
	if(text==null || text.length<=0){
		text="popup";
	}
	//IE doesn't like them...
	text=text.str_replace('-',' ');
	w=(screen.availWidth>1000)?1000:screen.availWidth;
	h=screen.availHeight-150;
	
    var padding;
   (navigator.appName == "Microsoft Internet Explorer") ? (padding = 10) : (padding = 0);

   var screenw = screen.availWidth;
   var screenh = screen.availHeight;
   var winw = (w + 15 + padding);
   var winh = (h + 15 + padding);
   var posx = (screenw / 2) - (winw / 2);
   var posy = (screenh / 2) - (winh / 2);

   var newwin = window.open(url,text,"top="+posy+",left="+posx+",width="+winw+",height="+winh+",menubar=no,locationbar=yes,statusbar=no,resizable=yes,toolbar=no,dependent=yes,scrollbars=yes");
   newwin.focus();
}

function showbutton(prop_type)
{
	val=prop_type.options[prop_type.selectedIndex].value;
	if(val=='1'){
		$('#div_no_rooms').hide();
	}else{
		$('#div_no_rooms').show();
	}
}

function city_search_suggest(){
	if($('#id_city_select').attr('value')==0){
		$('#id_city_select').attr('name','city_suggest');
		$('#id_city_field').attr('name','city');
		
		$('#id_city_select').hide();
		$('#id_city_field').show();
		$('#id_city_field').focus();
	}else{
		$('#id_city_select').attr('name','city');
		$('#id_city_field').attr('name','city_suggest');
		$('#id_city_field').hide();
	}
}

var save_for_later_timeout=null;

function save_for_later(provider,id,loading_field)
{
	if(loading_field==null)
	loading_field="status";	
	
  data_string="id="+id+"&provider="+escape(provider);
   $.ajax({
       type: "POST",
       url: link_to_save_for_later,
       dataType: "html",
       cache: false,
       data:data_string  ,
       success: function(msg)
       {
       if(save_for_later_timeout!=null){
       	clearTimeout(save_for_later_timeout);
       	$('#'+loading_field).fadeOut("slow");
       	save_for_later_timeout=null;           	
       }
          $('#'+loading_field).html(msg);
          $('#'+loading_field).fadeIn("slow");
          save_for_later_timeout=setTimeout("$('"+'#'+loading_field+"').fadeOut('slow');save_for_later_timeout=null;",3000);
       }
   });
}

/*
 * alert("My world is biiiiiiiiiiiiig".wordWrap(10, "\n+", true)); Cuts words 
 * alert("My world is biiiiiiiiiiiiig".wordWrap(10, "\n>", false)); Leave words together
 * last parameter: 0 = words longer than "maxLength" will not be broken
 * 				   1 = words will be broken when needed
 * 				   2 = any word that trespass the limit will be broken
 */
String.prototype.wordWrap = function(m, b, c){
    var i, j, l, s, r;
    if(m < 1)
        return this;
    for(i = -1, l = (r = this.split("\n")).length; ++i < l; r[i] += s)
        for(s = r[i], r[i] = ""; s.length > m; r[i] += s.slice(0, j) + ((s = s.slice(j)).length ? b : ""))
            j = c == 2 || (j = s.slice(0, m + 1).match(/\S*(\s)?$/))[1] ? m : j.input.length - j[0].length
            || c == 1 && m || j.input.length + (j = s.slice(m).match(/^\S*/)).input.length;
    return r.join("\n");
};

String.prototype.str_replace=function(SuchText, ErsatzText)
{   // Erstellt von Ralf Pfeifer
	ausgabe="";
    // Fehlerpruefung
    if ((this == null) || (SuchText == null))           { return null; }
    if ((this.length == 0) || (SuchText.length == 0))   { return this; }

    // Kein ErsatzText ?
    if ((ErsatzText == null) || (ErsatzText.length == 0))    { ErsatzText = ""; }

    var LaengeSuchText = SuchText.length;
    var LaengeErsatzText = ErsatzText.length;
    var Pos = this.indexOf(SuchText, 0);

    while (Pos >= 0)
    {
        ausgabe = this.substring(0, Pos) + ErsatzText + this.substring(Pos + LaengeSuchText);
        Pos = this.indexOf(SuchText, Pos + LaengeErsatzText);
    }
    return ausgabe;
}