function moneyFormat(price)
{
	return String((parseFloat(Number(price))).toFixed(2)).replace('.',',').replace(',00',',-')
}

function windowopener(ad,winname,breite,hoehe,scrollen,scale,leiste){
var werte = "width=" +breite +",height=" +hoehe +",scrollbars=" +scrollen +",resizable=" +scale +",toolbar=" +leiste;
window.open(ad, winname, werte);
}

var opened_submenu=0;
var timer;
function closeSubmenu(id)
{
	switch (id)
	{
		case 5:$('#dropdown_Language').slideUp(); break;		
	}
}

function init_tooltips()
{
	$('.tooltip_item').each(function(){$(this).tooltip({track:true, showURL:false, delay:0, fade:50}); });
}

function change_lang(lang)
{
	$.ajax({
	  type: "POST",
	  url: "jax/lang.jax.php",
	  data:'lang='+lang,
	  success: function(html){		  		
		if(html!=''){window.location.href=html;}else {window.location.reload();}
	  }
	});
}
function changeProfileTypeHome(profileType){
	$('#divAdditionalInformation').load('jax/loadProfileInfos.jax.php',{'pid':profileType}, function(){});
}
function changeProfileType2(profileType,def_val,def_val2,exist_preloading){
	
	$('#divAdditionalInformation').load('jax/loadProfileInfos_2.jax.php',{'pid':profileType,'def_val':def_val,'def_val2':def_val2}, function(){ if(exist_preloading==1){searchGEOCoordonate();}});
}
function searchGEOCoordonate(){
	var country = document.search_form.land.options[document.search_form.land.selectedIndex].text;
	var country_id = document.search_form.land.options[document.search_form.land.selectedIndex].value;
	var province = document.search_form.bundesland.value;
	var zip = document.search_form.plz.value;
	var distance= document.search_form.distance.options[document.search_form.distance.selectedIndex].value;
	var address_string = (zip!=''?(zip+', '):'')+(province!=''?(province+', '):'')+country;
	//alert(address_string);
	findAddress(address_string, function(lat,lng){handle_foundCoordonate(lat,lng,country_id,province,zip,distance);}, function(lat,lng){handle_foundCoordonate(0,0,country_id,province,zip,0);});
}

function handle_foundCoordonate(lat,lng,country,province,zip,distance){
	//alert(isdefined(document.search_form.category));
	$('#show_search_result_div').load('jax/loadSearchResult.jax.php',{'lat':lat,'lng':lng,'country':country,'province':province,'zip':zip,'distance':distance,'profiletype' :document.search_form.profiletype.value,'category':(document.search_form.category)?document.search_form.category.value:'','gender': (document.search_form.gender)?document.search_form.gender.value:'' }, function(){
			//alert('loaded');
			
			});
	//alert(lat+' '+lng);
}
function removeAllElement(array){
	array.splice(0,array.length);	
}

var userInGEOMap=new Array();
function searchGmapInfoWindow(marker_id,marker)
{
	$.ajax({
	   type: "POST",
	   url: "jax/load_Gmap_anchor_info.jax.php",
	   data: {'u_id':marker_id},
	   success: function(msg){			
			marker.openInfoWindowHtml(msg);
	   }
	 });
}
function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}
function changeProfileType(selectedPage){
	var nb_per_page=5;
	strList='';
	if(userInGEOMap.length<(selectedPage-1)*nb_per_page){
		selectedPage=1;
	}
	for(i=(selectedPage-1)*nb_per_page;i<Math.min((selectedPage)*nb_per_page,userInGEOMap.length);i++){ strList +=(strList!=''?',':'')+(userInGEOMap[i].id+'::'+userInGEOMap[i].ptypeid+'::'+userInGEOMap[i].pid);
	}
	$('#show_detail_result_div').load('jax/loadProfileDetail.jax.php',{'uids':strList,'page':selectedPage,'total' :userInGEOMap.length}, function(){});
}
