var tenScouts = 'http://www.10scouts.com/';

function init(json)
{
	if (!json){ $.get('start',{labels:1},function(json){ init(json); },'json'); return; } // get labels
	
	window.labels = json;
	window.scout = labels.scout; 
	window.city = labels.city;
	window.zip = labels.zip;
	var path = pValue();

	$('#menuTop a:last,#menu a:last').addClass('last'); // menu last
	$('#menu a[href='+path+']').addClass('blue'); // menu over
	if ($('#logon')[0]) logon();
	if ($('#callback')[0]) callback();
	if (window[labels.modul] && (labels.modul == 'listing' || labels.modul == 'landingpageRequest' || labels.modul == 'reg' || labels.modul == 'request' || !$('#content').html())) window[labels.modul](obj('content')); // js function 	
	else if (labels.modul == 'listingSearch') listingSearch();
	else if (scout == 108 && !labels.landingMass) ajax('startListing');
	if (labels.modul == 'tariff' && labels.independent) $('#tariff tr:last').remove();
	menuRight(); $(window).resize(menuRight); // menu right
	$('.listingImage').each(function(){ valign(this); }); // valign listing images	
	if (labels.listingData && window.google) listingSearchAnswer({data:labels.listingData}); // start listing

	//if (!$('#forumUser')[0]) setInterval(function(){ ajax('partnerShort',false,'toggle'); },30000);	
//	// landingpage
//	if (labels.landingpage){
//		$('#fullTopTitle').click(landingpageForm);
//		$('#home,#terms,#impressum,#topLeft a').click(function(){
//			var file = 'landings/'+labels.landingType; if (this.id == 'terms' || this.id == 'impressum') file += '_'+this.id;
//			$.ajax({type:'POST',data:{ajax:true,modul:'htmlAjax',file:file},success:function(html){
//				$('#content').html(html);
//				window.scrollTo(0,0);				
//				$('#fullTopTitle').html(function(){ return $(this).attr('text'); });			
//			}});
//		});
//		$('#topLeft a').removeAttr('href');
//	}	
	
	// additional links ex. 106
	if (labels.addLinks){
		createBreak(content,2);
		var add = createContainer(content,'links'); 
		var links = labels.addLinks.split(',');
		for (var i=0; i<links.length; i+=2) createLink(add,'','link',links[i],'link',links[i+1]);
		align(add);
	} 	
}
function menuRight()
{
	var width = $(window).width(); 
	if (width < 1300) $('#menuExtra').hide();
	else{
		var margin = (width-1110)/4-30;
		$('#menuExtra').css('right',margin).show();		
	}
}
function menuTop(parentObj)
{
	var cont = createContainer(parentObj,'menuTop');
	createLink(cont,'menuHome','link','','sendEvt',Array('htmlFile',object('file','start')));
	createLink(cont,'menuNews','link','','sendEvt','news');
	if (scout == 106 || scout == 103 || scout == 112) createLink(cont,'menuBlog','link','','link','http://blog.10scouts.com');		
	if (labels.listingOn && !labels.listingInclusive) createLink(cont,'menuListing','link','','sendEvt',Array('htmlFile',object('file','listing')));
	createLink(cont,'menuContact','link','','contactView');
	if (!labels.independent){
		createLink(cont,'menuTariff','bold link','','sendEvt',Array('htmlFile',object('file','tariff')));
		createLink(cont,'menuTalk','link','','link','http://www.10scouts.com/Talk');
		createLink(cont,'menuForum','white menuLast link','','sendEvt','forum');	
	} 	
	$(cont).children('span').mousedown(clearView);
	$(cont).children().last().addClass('last');
}
function menu(parentObj)
{
	var cont = createContainer(parentObj,'menu');
	createLink(cont,'menuRequests','white link','','sendEvt','requests');
	createLink(cont,'menuReg','white link','','sendEvt',Array('htmlFile',object('file','reg')));
	if (scout == 108) createLink(cont,'menuReferences','white menuLast link','','sendEvt','references');
	else createLink(cont,'menuReferences','white link','','sendEvt','references');
	if (scout == 117) createLink(cont,'menuRequest','white menuLast link','','requestForm');
	else if (scout != 108) createLink(cont,'menuRequest','white link','','requestForm');
	if (labels.listingOn) createLink(cont,'menuListingSearch','white menuLast link','','listing');
	$(cont).children('span:last').addClass('last');
}
function listingMember(answer) // set profile values after login
{
	var data = answer.data;	
	$('#listingMember').replaceWith(createText(false,'listingMemberName','header',data.vorname+' '+data.nachname));	
	$('#reg').append(createInput(false,'id','',data.id,'hidden'));
	$('#reg').attr('id','listingMemberReg'); 
	$('#regSubmit').unbind('click').click(function(){ submitForm(false,'listingMemberReg'); });
	
	// add stuff and hide it
//	$('#profile_txt').prevAll().hide();
	$('#prename').val(data.vorname);
	$('#name').val(data.nachname);
	$('#street').val(data.strasse); $('#postcode').val(data.plz); $('#location').val(data.ort);
	$('#mail').val(data.email); $('#mail2').val(data.email);
//	$('#password').remove(); $('#password2').remove();
	$('#telephonePre').val(data.telefonPre); $('#telephone').val(data.telefon);
	$('#faxPre').val(data.telefaxPre); $('#fax').val(data.telefax);
	$('#mobile').val(data.mobil); 
	$('#website').val(data.internet);
	$('#company').val(data.firma);
	$('#rank').val(data.titel);
	$('#specialism').val(data.spezial);
	if (data.anrede == 'Frau') $('#gender0')[0].checked = true; else $('#gender1')[0].checked = true;
	var profile = data.profile.split(', '); 
	$('#profileCont').children('.labelCheckbox').each(function(){ if ($.inArray(asci($(this).html()),profile)) $(this).prev()[0].checked = true; });
	image(object('address',data.id+'_small.jpg'));
}
function listingMemberReg(answer)
{
	$('#content').empty();
	window.scrollTo(0,0);
}
function listing(cont)
{
	// get member data
	var btn = createInput(cont,'listingMemberBtn','',labels.listingMember,'button'); align(btn);
	$(btn).click(function(){	
		var box = createContainer(false,'listingMember');
		createTextfield(box,'mail','','','mail');
		var pass = createTextfield(box,'password','','','password');
		var tip = createImage(false,'password_tip','','img/help.gif'); $(pass).after(tip); $(tip).tooltip(labels['password_tip']);
		createInput(box,'','',labels.submit,'button','submitForm','click','listingMember');	createBreak(box);
		createLink(box,'logonForget','link','','infoInput','mail');			
		$(this).replaceWith(box);	
	});
	
	// form
	var form = formular(cont,'reg',labels['reg_fields'].split(','),true); align(form); $('#regTitle').remove();		
	var cont = createContainer(false,'listingExtra','break'); $('#terms').before(cont);	
	
	// slide boxes
	//createText(cont,'reference_txt','label'); var img = createImage(cont,'','','img/open.gif'); var textarea = createTextarea(cont,'reference','input bigArea'); $(img).click(function(){ $(textarea).slideDown('slow'); $(this).remove(); }); $(textarea).hide(); createBreak(cont,2);	
	var img = createImage(false,'','','img/open.gif'); $(img).click(function(){ $('#profileCont').slideDown('slow'); $(this).remove(); }); $('#profile_txt').after(img); $('#profile_txt').attr('class','label'); $('#profileCont').hide();
	var img = createImage(false,'','','img/open.gif'); $(img).click(function(){ $('#specialism').slideDown('slow'); $(this).remove(); }); $('#specialism_txt').after(img); $('#specialism').addClass('bigArea'); $('#specialism').hide();
	
	createImageUpload(cont,'image'); createBreak(cont);
	var text = labels.listingCheck_txt; 	
	var pos = labels.title.lastIndexOf(' '); if (pos > 0) labels.title = labels.title.substr(pos);
	text = text.replace(/scout/,labels.title);
	text = text.replace(/__listingRate__/,labels.listingPrice.replace(/\./,','));
	createCheckbox2(cont,'listingCheck','',text); createBreak(cont);
	createText(cont,'listingDurationTitle'); createBreak(cont,2);
	
	// duration box
	var box = createSelection(cont,'listingDuration',labels.listingDuration_fields.split(','));
	createText(cont,'listingDuration2_txt'); createBreak(cont,2);
	$(box).click(function(){	
		var value = rValue('listingDuration',true);
		price = parseFloat(labels.listingPrice);
		if (value == 'listingDuration0') price *= 6;
		else if (value == 'listingDuration1') price *= 9;
		else if (value == 'listingDuration2') price *= 18;
		$('#listingPrice').html(price.toFixed(2));
	});	
	
	// payment type
	var className; if (labels.listingTransfer){
		var fields = labels.listingTransfer_fields.split(',');
		var type = createSelection(cont,'listingTransfer',fields,'listingTransfer0'); createBreak(cont,2);
		$(type).click(function(){ // hide bank data 
			if ($(this).children('input:checked').attr('id') == 'listingTransfer0') $('#bankData').hide(); 
			else $('#bankData').show(); 
		});
		className = 'hidden'; 
	} 
	
	// bank details
	var bank = createContainer(cont,'bankData',className);
	createText(bank,'bank_txt'); createBreak(bank,2);
	createTextfield(bank,'bankowner'); 
	createTextfield(bank,'bankno','','','bankno'); 
	createTextfield(bank,'bankcode','','','bankcode'); 	
	createTextfield(bank,'bankname'); createBreak(cont,2);
	
	// invoice data	
	createText(cont,'listingAddress_txt'); createBreak(cont,2);
	createTextfield(cont,'billSalut','','','',true); 
	createTextfield(cont,'billName1');
	createTextfield(cont,'billName2','','','',true); 
	createTextfield(cont,'billStreet'); 
	createTextfield(cont,'billPostcode');  
	createTextfield(cont,'billLocation'); createBreak(cont);
	
	createText(cont,'','',labels.listingPrice_txt); createBreak(cont,2);
	
	$('#dataprivacyLink').attr('class','blue');
	$('#dataprivacyLink').click(function(){ window.open(scout+'/privacy.html','AGB','width=600,height=400,status=yes,scrollbars=yes,resizable=yes'); });
	$('#dataprivacy')[0].checked = false;
	$('#termsLink').attr('class','blue');
	$('#termsLink').click(function(){ window.open(scout+'/termsListing.html','AGB','width=600,height=400,status=yes,scrollbars=yes,resizable=yes'); });
	$('#terms')[0].checked = false;
	
//	// preview
//	var btn = createInput(false,'','',labels.preview,'button','listingPreview','click'); $('#regSubmit').before(btn);
	
//	// listing address
//	$('#gender').click(function(){ $('#billSalut').val(rValue('gender')); });	
//	$('#prename').blur(function(){ $('#billName1').val($('#prename').val()+' '+$('#name').val()); });		
//	$('#name').blur(function(){ $('#billName1').val($('#prename').val()+' '+$('#name').val()); });
//	$('#street').blur(function(){ $('#billStreet').val($(this).val()); });
//	$('#postcode').blur(function(){ $('#billLocation').val($('#postcode').val()+' '+$('#location').val()); });
//	$('#location').blur(function(){ $('#billLocation').val($('#postcode').val()+' '+$('#location').val()); });
}
function listingPreview(element)
{	
	$('.boxListing2Top').remove(); $('.boxListing2').remove(); $('.boxListing2Bottom').remove();
	var cont = createBox(element.parentNode,'','boxListing2');

	var header = labels.listingProfile; 
	if (1 == 2) header += ' '+$('#company').val(); else header += ' '+$('#prename').val()+' '+$('#name').val();
	createText(cont,'','header2 orange',header); createBreak(cont);
	var img = $('#image_pre').attr('src'); 
	if (img) img = img.replace(/small/,'big');
	else if (rValue('gender') == 'Herr') img = 'http://www.10scouts.com/pic/male_big.jpg';
	else img = 'http://www.10scouts.com/pic/female_big.jpg';
	createImage(cont,'','',img);
	
	var nameBox = createContainer(cont,'listingName');
	if (1 == 2){ createText(nameBox,'','',$('#company').val()); createBreak(nameBox,2); }
	else{ createText(nameBox,'','',$('#prename').val()+' '+$('#name').val()); createBreak(nameBox,2); }	
	createText(nameBox,'','',$('#street').val()); createBreak(nameBox,2);
	createText(nameBox,'','',$('#postcode').val()+' '+$('#location').val()); createBreak(nameBox,2);
	createLink(nameBox,'','link',$('#website').val(),'link','http://'+$('#website').val());
	createBreak(cont,4);
	
	// boxes
	var box = createContainer(cont,'','listingBox');
	createText(box,'profile_txt','orange bold'); createBreak(box,2);
	createText(box,'','',cgValue2('profile'));	
	var box = createContainer(cont,'','listingBox');
	createText(box,'specialism_txt','orange bold'); createBreak(box,2);
	createText(box,'','',$('#specialism').val());	
	var box = createContainer(cont,'','listingBox');
	createText(box,'','orange bold',labels.menuReferences); createBreak(box,2);
	createText(box,'','',$('#reference').val());
}
//function listingSearch()
//{
//	// search form
//	var box = createBox(obj('listingRight'),'listingSearch');
//	createText(box,'listingSearch_txt','header2 orange');
//	createTextfield(box,'location','','','',true);
//	var field = createTextfield(box,'postcode','','','postcode',true);			 	
//	if (scout == 102 || scout == 106){
//		var fields = labels.profile_fields.split(','); fields.unshift('');
//		createSelectbox(box,'profile',fields); 
//	}
//	else if (scout == 108 || scout == 117){
//		var fields = labels.profile_fields.split(','); if (scout == 117) fields = labels.profileSpecial_fields.split(',');
//		createBreak(box,2);
//		createCheckboxes(box,'profile',fields,false,true); if (labels.listingProfile_txt) $('#profile_txt').html(labels.listingProfile_txt);
//		if (scout == 108) formHide(fields);
//	}
//	createImage(box,'listingSubmit','','img/listingSubmit.jpg','submitForm','click','listingSearch');
//	
//	ajax('listingSearch');
//}
function listingSearch()
{
	// profile fields
	var cont = $('#listingSearch .left').get(0);
	if (scout == 102 || scout == 106){
		var fields = labels.profile_fields.split(','); fields.unshift('');
		var select = createSelectbox(cont,'profile',fields);
	}
	else if (scout == 108 || scout == 117){
		var fields = labels.profile_fields.split(','); if (scout == 117) fields = labels.profileSpecial_fields.split(',');
		var boxes = createCheckboxes(cont,'profile',fields,false,true);
		if (labels.listingProfile_txt) $('#profile_txt').html(labels.listingProfile_txt);
		if (scout == 108) formHide(fields);
	}
	
	$('#submit').click(function(){ 
		var param = {};
		param.location = $('#location').val();
		param.postcode = $('#postcode').val();
		if (scout == 102 || scout == 106) param.profile = $('#profile').val(); else if (scout == 108 || scout == 117) param.profile = $('#profileCont input:checked').map(function(){ return $(this).next().text(); }).get();
		ajax('listingSearch',param); 
	}).trigger('click');		
}
function listingSearchAnswer(answer)
{		
	$('#info').remove();	
	var data = answer.data; if (!data) return;	
//	var profession = labels.profession2; if (!profession) profession = labels.profession;
//	var title = labels.listingHeader2+profession; if (answer.location) title += ' in '+answer.location; else title += labels.nearby;
//	$('#listingHeader').html(title);
	var listCont = $('#listingList').empty().get(0); //objEmpty('listingList');
	var mapCont = $('#listingMap').empty().get(0); $(mapCont).show();	//objEmpty('listingMap');
	
	// map	
	var zoom = 8; if (answer.top) zoom = 10;
    var options = {zoom:zoom,mapTypeId:google.maps.MapTypeId.ROADMAP,scrollwheel:false};		
	var map = new google.maps.Map(mapCont,options);
	map.markers = [];
	
	// set profiles
	window.listingIndex = 0;
	listingProfiles(listCont,map,data);
		
	// arrows
	$('#arrows').remove();
	if (data.length > 9){		
		var cont = createContainer(false,'arrows'); $('#listingList').after(cont); createBreak(cont);
		createLink(cont,'prev');
		createLink(cont,'next'); createBreak(cont);
		$('#prev,#next').click(function(){ 
			if (this.id == 'prev') listingIndex -= 8;
			else listingIndex += 8;  
			listingProfiles(listCont,map,data); 						
			if (!listingIndex) $('#prev').hide(); else $('#prev').show(); 
			if (data.length > listingIndex+8) $('#next').show(); else $('#next').hide();
		});
	} 
//	createBreak(list,2);
//	if (scout == 108 || scout == 117) var box = createContainer(cont,'','listingPreview',false,'link2','click','mailto:mertiny@10scouts.com?subject='+labels.listingMail);
//	else var box = createContainer(list,'','listingPreview',false,'sendEvt','click',Array('htmlFile',object('file','listing')));	
}
function listingProfiles(list,map,data)
{
	$('#listingList').empty();
	$.each(map.markers,function(i,marker){ marker.setMap(null); });
	if (map.center) delete map.center;
	for (var i=listingIndex;i<listingIndex+9;i++){	
		if (!data[i]) break;	
		var marker = listingFlag(map,data[i]);	
		var box = listingBox(list,data[i],marker,map);
		marker.box = box;
	};	
//	if (!labels.listingInclusive) createText(list,'listingBlank','listingImageCont');
	setTimeout(function(){ $('.listingImage').each(function(){ valign(this); }); },500); // valign profile box
}
function listingBox(cont,user,marker,map)
{
	var box = $('.listingPreview[userId='+user.id+']').get(0);
	if (box) $(box).click(function(){ listingProfile(this,user); }).removeAttr('href');
	else{
		box = createContainer(cont,'','listingPreview',false,'listingProfile','click',user);
		var imageCont = createContainer(box,'','listingImageCont');
		if (user.pic == '1') var img = 'http://www.10scouts.com/pic/'+user.id+'_big.jpg';
		else if (user.anrede == 'Herr') var img = 'img/male.jpg';
		else var img = 'img/female.jpg';
		createImage(imageCont,'','listingImage',img);
		var location = user.plz+' '+user.ort; if (location.length > 15) location = location.substr(0,15)+'..';
		var name = user.firma; if (!name) name = user.vorname+' '+user.nachname; if (name && name.length > 15) name = name.substr(0,15)+' ..';
		createText(box,'','',location); createBreak(box);
		createText(box,'','',name);			
	}	
	
	// mouseover -> map change	
	if (map){
		var infowindow;
		var position = map.center;
		var zoom = map.zoom;
		$(box).hover(function(){
			if (window.clicked) return;
			$.each(map.markers,function(i,marker2){ if (marker.title != marker2.title) marker2.setMap(null); });
			var position = marker.getPosition();
			map.setCenter(position);
			map.setZoom(14);				
			infowindow = new google.maps.InfoWindow({position:position,maxWidth:100,content:user.vorname+' '+user.nachname+'<br>aus '+user.plz+' '+user.ort});
			infowindow.open(map);
			$(this).addClass('hover');
		},function(){
			if (window.clicked) return;
			$.each(map.markers,function(i,marker){ marker.setMap(map); });
			map.setCenter(position);
			map.setZoom(zoom);			
			infowindow.close();
			$(this).removeClass('hover');
		});	
	}
	
	return box;	
}
function listingFlag(map,user)
{
	var position = new google.maps.LatLng(user.coo1,user.coo2);	
	var marker = new google.maps.Marker({map:map,position:position});
	google.maps.event.addListener(marker,'click',function(){ listingProfile(false,user); }); // click
	map.markers.push(marker);
	if (!map.center) map.setCenter(position); // center	
	
	google.maps.event.addListener(marker,'mouseover',function(){ $(marker.box).addClass('hover'); });
	google.maps.event.addListener(marker,'mouseout',function(){ $(marker.box).removeClass('hover'); });
	marker.setTitle(user.vorname+' '+user.nachname+' in '+user.plz+' '+user.ort);
	
	return marker;	
}
function listingProfile(element,user)
{
	window.clicked = true;
	$(element).siblings('.active').removeClass('active'); $(element).addClass('active');			
	$('#listingProfile').remove();	
	var cont = createBox(document.body,'listingProfile'); $(cont).css({left:$('#content').position().left,top:$(window).scrollTop()});
	var close = createText(cont,'close','','x'); $(close).click(function(){ 
		$(cont).fadeOut(); 
		$(element).removeClass('active'); 
		window.clicked = false;
		$(element).trigger('mouseout');
	});
	var header = labels.listingProfile; 
	if (user.firma) header += ' '+user.firma; else header += ' '+user.vorname+' '+user.nachname;
	createText(cont,'','header2 orange',header); createBreak(cont);	
	if (user.pic == '1') var img = 'http://www.10scouts.com/pic/'+user.id+'_big.jpg';
	else if (user.anrede == 'Herr') var img = 'img/male.jpg'; else var img = 'img/female.jpg';
	createImage(cont,'','',img);
	//createImage(cont,'','','http://www.10scouts.com/pic/'+user.id+'_big.jpg');
	
	var nameBox = createContainer(cont,'listingName');
	if (user.firma){ createText(nameBox,'','',user.firma); createBreak(nameBox,2); }
	if (user.nachname){ createText(nameBox,'','',user.vorname+' '+user.nachname); createBreak(nameBox,2); }	
	createText(nameBox,'','',user.strasse); createBreak(nameBox,2);
	createText(nameBox,'','',user.plz+' '+user.ort); createBreak(nameBox,2);
	createLink(nameBox,'','link',user.internet,'link','http://'+user.internet);
	createBreak(cont);
	
	// boxes
	if (user.profile){
		var box = createContainer(cont,'','listingBox');
		createText(box,'profile_txt','orange bold'); createBreak(box,2);
		createText(box,'','',user.profile);	
	}
	if (user.profile2){
		var box = createContainer(cont,'','listingBox');
		createText(box,'','orange bold',labels.profile2_txt); createBreak(box,2);
		createText(box,'','',user.profile2);
	}
	if (user.spezial){
		var box = createContainer(cont,'','listingBox');
		createText(box,'specialism_txt','orange bold'); createBreak(box,2);
		createText(box,'','',user.spezial);	
	}
//	if (user.reference){
//		var box = createContainer(cont,'','listingBox');
//		createText(box,'','orange bold',labels.menuReferences); createBreak(box,2);
//		createText(box,'','',user.reference);
//	}
	
	createBreak(cont,4);	
	var hr = document.createElement('HR'); cont.appendChild(hr); hr.id = 'listingLine';	
	createImage(cont,'listingContactField','','img/listingContact.gif');
//	createImage(cont,'listingContactField','link','img/listingContact.gif','listingContact','click',user.email);
	
	// request
	var fields = labels.listingContact_fields.split(',');
	var form = formular(cont,'listingContact',fields,true);	
	createInput(form,'mailTo','',user.email,'hidden');
	var submit = createImage(false,'listingMessage','link','img/messageSend.gif','submitForm','click','listingContact'); $(form).find('.submitCont').html(submit);
	
	// listing on start site
	if (element.parentNode && element.parentNode.id == 'startListing'){
		$(cont).find('div').css('opacity','100');
		//$.fancybox($(cont).html(),{'autoDimensions':false,'width':500,'height':500});
		$('#listingMessage').click(function(){ submitForm(this); });
	} 
}
function listingContact(element,mail)
{
	write2('listingContact',element.info.mailForm); 
	$('#listingContact').slideUp('slow');
}
function view(id,idMenu)
{
	var parentObj = objEmpty('main');
	var cont = createContainer(parentObj,id);	
	menuOver(idMenu);
	return cont;
}
function clearView(id)
{
	$('#content').show(); 
	$('#full').remove();
	$('.menuBlue').removeClass('menuBlue');
	$('#menu #'+id).addClass('menuBlue');
}
function menuOver(id)
{
	clearView(id);

	// for landingpage
	if (labels.landingType && labels.landingType != 'scout'){	
		$('.fullTopTitled span').show();	
		if (window.city){
			var title = $('.fullTopTitled span').html();
			title = title.replace(/Ihrer Nähe/,city);
			$('.fullTopTitled span').html(title);
		}
		return;
	}	
	
	// search logo
	if (scout != 106){
		if (id == 'menuRequest' || id == 'start') $('#buttonTopLeft').hide();
		else $('#buttonTopLeft').show();			
	}

	// clear the view
	if (id == 'start') $('#tagcloudFrame').fadeIn('slow'); else $('#tagcloudFrame').fadeOut('slow');
	if (id == 'menuRequest') $('#left,#right').fadeOut('slow'); else $('#left,#right').fadeIn('slow');
	$('.info').remove();
	$('#program').remove();
}
function htmlFile(answer,add)
{
	var id = answer.id;
	
	// landingpage or normal site
	if (id && id.substr(0,8) == 'landings') var cont = landingStart(answer);
	else if (id == 'tariff'){ // tariff
		$('#main').html(answer.message); 
		$('#left,#right').hide(); 
		$('#tagcloudFrame').fadeOut('slow');
		if (!labels.listingOn || labels.listingInclusive) $('#tariff').css('margin-left','-130px').find('tr').each(function(){ $(this).children('td:eq(2)').remove(); });
		if (labels.listingInclusive) $('#tariff tr:eq(6)').children('td:eq(2)').addClass('yes').append('<img src="img/yes.jpg">');
		if (labels.profileExample) $('#tariff #profileExample').attr('href',labels.profileExample);
		return; 
	}	
	else if (id == 'start' && scout == 108){ startListing(answer); return; }
	else if (add) var cont = obj('main');
	else var cont = objEmpty('main');
	
	var html = createContainer(cont,'html'); html.innerHTML = answer.message; // add text	
	if (id == 'references' || id == 'reg') menuOver('menu'+id.substr(0,1).toUpperCase()+id.substr(1)); else if (!add) menuOver(id); // menu over
	if (id == 'reg') regForm();	else if (id == 'listing') listingReg(cont,answer.price); // add formular
}
function startListing(answer)
{
	if (answer.city) window.city = answer.city;
	if (!city) city = ' ';
	
	var cont = createContainer(false,'startListing'); $('#startTitle').after(cont);	
	var data = answer.data; if (data) for (var i=0;i<data.length;i++) listingBox(cont,data[i]);
	setTimeout(function(){ $('.listingImage').each(function(){ valign(this); }); },500); // valign
	
	createBreak(cont); 
	createLink(cont,'','right link','&nbsp;- Stadt ändern','cityNew');  
	createText(cont,'citySpan','right',city);	
	createBreak(cont); 
}
function cityNew(element)
{
	var input = createInput(false,'cityInput','right',$('#citySpan').html()); $('#citySpan').replaceWith(input);
	var txt = createText(false,'','right','Bitte Ihre Stadt eingeben und Enter drücken'); $(input).after(txt);	
	$(input).select().focus().keyup(function(evt){ if (evt.keyCode == 13) $.ajax({type:'POST',data:{ajax:true,modul:'citySet',city:$(this).val()},success:function(){ refresh(); }}); });
}
function formHide(profile)
{
	$.each(profile,function(i,field){
		if (labels[field+'_hide']){
			var elements = parseInt(labels[field+'_hide'])*3; // checkbox,label,break
			$('#profileCont .labelCheckbox:contains('+field+')').next().nextAll(':lt('+elements+')').each(function(){ $(this).hide(); if ($(this).hasClass('checkbox')) $(this).css('margin-left','20px'); }); // hide and shift to right
			$('#profileCont .labelCheckbox:contains('+field+')').prev().click(function(){ // show next x elements
				if (this.checked) $(this).next().next().nextAll(':lt('+elements+')').slideDown(); 
				else $(this).next().next().nextAll(':lt('+elements+')').hide(); 
			});
		}
	});	
}
function landingpageNew(answer)
{	
	var cont = obj('landingNew');	
	
	// requests
	var requests = answer.requests;
	var boxFrame = createContainer(cont);
	var box = createBox(boxFrame,'requests','boxOrange');
	createText(box,'requestsTitle'); createBreak(box,2);
	for (var i=0; i<requests.length; i++){		
		var request = requests[i];
		var element = createListElement(box,'','requestLine','');
		createText(element,'','bold','plz '+request.plz+':&nbsp;');
		createText(element,'','',request.datum); createBreak(element);
		createText(element,'','',request.beschreibung);
		createBreak(box,2);
	}
	createBreak(cont,3);
	
	// form
	var site = substring2(pValue(),0,-4); // minus _neu
	var form = formular(cont,'landingpage',labels[site+'_fields'].split(','),true);
	createInput(form,'id','',site,'hidden');
	$(form).css('margin-left','180px');
	
	// focus on form
	$($(form).children('.input')[0]).click(function(){ 
		document.location = '#baugutachterTitle'; 
		this.focus();
		$(this).unbind('click'); 
	});
}
function landingpageForm()
{	
	window.location = labels.landingUri+'-Anfrage';
	
//	var site = labels.landingType; if (!site) site = 'request';
//	if (site == 'default') var fields = labels.request_fields.split(',');
//	else var fields = labels[site+'_fields'].split(',');
//	
//	var cont = objEmpty('content');
//	var mandatory = labels.mandatory.split(','); if (labels[site+'_mand']) $.merge(mandatory,labels[site+'_mand'].split(','));
//	var form = formular(cont,site,fields,true,mandatory,'landingpage');
//	createInput(form,'id','',site,'hidden');
//	if (labels[site+'Formtitle']) $('#fullTopTitle').html(labels[site+'Formtitle']);
//	else $('#fullTopTitle').html('');
//	$(form).find('.submit').val(labels.requestSubmit);
}
function landingpage(answer)
{
	if (answer.uncomplete) return;
	$('.form').slideUp('slow');
	window.scrollTo(0,0);
	
	// google conversion	
	eval(labels.conversion.replace(/&#x27;/g,'\''));	
	document.write = function(s){ $('body').append(s); }	
	var scr = $('<scr'+'ipt>');
	scr.attr({
	        'type':'text/javascript',
	        'src':'http://www.googleadservices.com/pagead/conversion.js'
	});	
	$('head').append(scr); 
	
	// yahoo conversion
	window.ysm_customData = new Object();
	window.ysm_customData.conversion = "transId=,currency=,amount=";
	window.ysm_accountid  = "1QD0PI53BL4GSQ977SODLLDB2US";
	document.write("<SCR" + "IPT language='JavaScript' type='text/javascript' " + "SRC=//" + "srv1.wa.marketingsolutions.yahoo.com" + "/script/ScriptServlet" + "?aid=" + ysm_accountid + "></SCR" + "IPT>");

	requestAd(answer.scouts);
}
function regAnswer(answer)
{
	$('#reg').slideUp('slow');
	window.scrollTo(0,0);
	write(answer.info);		
}
function reg(cont)
{
	formCheck('reg','reg');
	formHide(labels.profile_fields.split(',')); // hide pieces of formular	
	$('#dataprivacyLink').attr('class','blue').click(function(){ window.open(scout+'/privacy.html','AGB','width=600,height=400,status=yes,scrollbars=yes,resizable=yes'); });
	$('#termsLink').attr('class','blue').click(function(){ window.open(scout+'/terms.html','AGB','width=600,height=400,status=yes,scrollbars=yes,resizable=yes'); });
		
//	var form = formular(false,'reg',labels.reg_fields.split(','),true); $('#regForm').replaceWith(form);
//	$('#regTitle').remove(); 
//	if (labels.independent) $('#regForm').prev().remove();	
//	$('#image,#image_txt').hide();	
	
	// second profile form
	if (scout == 117) $('.checkbox').click(function(){
		if (this.checked && $(this).parent().attr('id') == 'profileSpecialCont'){
			var label = $(this).next().html();
			if (label == 'Miet- und Wohnungseigentumsrecht') var search = '#profileCont .labelCheckbox:contains(Mietrecht),#profileCont .labelCheckbox:contains(Wohnungseigentumsrecht)';
			else var search = '#profileCont .labelCheckbox:contains('+label+')';
			$(search).each(function(){
				var box = $(this).prev()
				box[0].checked = true;
				box.trigger('click');
				box[0].checked = true;
			});
		}			
	});
}
function requestAd(scouts) // requests from other scouts
{	
	var cont = obj('content'); createBreak(cont,2);
	createText(cont,'requestScouts1','header2 left'); createBreak(cont);
	createText(cont,'requestScouts2','header2 left'); createBreak(cont);
	for (var i=0; i<scouts.length; i++){
		createLink(cont,'','link',scouts[i],'link','http://www.'+scouts[i]);
		createBreak(cont);
	}
}
function mailForm(answer)
{
	if (!answer.success) return;	
	write2('contact',answer.info['mailForm']); 
	$('#contact').slideUp('slow');
}	
function requestForm()
{
	window.location = 'Anfrage';
}
function formCheck(id,modul)
{
	$('#'+id+' [check]').each(function(){
		var event = 'blur'; if (this.tagName == 'DIV') event = 'click';
		var optional = true; if ($(this).attr('mandatory')) optional = false;
		$(this).bind(event,function(){ checkElement(this,[$(this).attr('check'),optional]); }); 	
	});
	$('#'+id+' .submit[type=submit]').hide().next().show().click(function(){ 
		if (modul) submitForm(this,[id,modul]);
		else submitForm(this,id); 
	});	
	$('#'+id+' input[openId]').click(function(){ $('#'+$(this).attr('openId')+'.checkboxes').show(); });
}
function landingpageRequest()
{
	//formCheck($('.request').attr('id'),'landingpage');
	request(false,'landingpage');
}
function request(cont,modul)
{	
	// check and submit
	if (!modul) modul = 'request';
	formCheck($('.request').attr('id'),modul);

	// special chexboxes
	if (scout == 101 && (!labels.landingType || labels.landingMass)){
		var fieldId = 'wants'; if (!$('#'+fieldId)[0]) fieldId = $('.checkboxes:last').attr('id'); // functions for auto landingpages
		//labels[fieldId+'Add_type'] = labels['wantsAdd_type']; labels.reqAdd += ','+fieldId;
		$('#'+fieldId+'_0,#'+fieldId+'_8').next().addClass('bold');
		$('#'+fieldId+'_0').nextUntil('#'+fieldId+'_8').andSelf().wrapAll('<div class="half">');
		$('#'+fieldId+'_8').nextAll().andSelf().wrapAll('<div class="half">');
		$('#'+fieldId+'_1').nextUntil('#'+fieldId+'_7').andSelf('input').wrapAll('<div class="sub">');
		$('#'+fieldId+'_9').nextAll().andSelf('input').wrapAll('<div class="sub">');
		$('#'+fieldId).css('margin-top','10px');
	}

	// additional boxes
	if (labels.reqAdd){
		var fields = labels.reqAdd.split(',');
		for (var i=0; i<fields.length; i++){
			$('#'+fields[i]).click(function(){ 
				if (!this.checked){ $('#'+this.id+'Add').remove(); return; }
				if (labels[this.id+'Add_type'] == 'input'){ var input = createTextfieldNormal(false,this.id+'_add','input','','',true); $(this).unbind('click').next().after(input); return; } // single field
				var cont = createContainer(false,this.id+'Add','break'); $(this).next().after(cont);
				var fields2 = labels[this.id+'Add'].split(',');
				for (var j=0; j<fields2.length; j++){					
					if (labels[this.id+'Add_type'] == 'checkbox') createCheckbox(cont,this.id+'_'+j,'',fields2[j]); // other checkbox
					else{
						createText(cont,'','label',fields2[j]);
						createTextfieldNormal(cont,this.id+'_'+j,'input','','',true);
						createBreak(cont);
					} 				
				} 				
			});
		};
	}
	
	// additional click
	if (scout == 116){
		$('.checkbox[name=wants2]').click(function(){ $('#wants1')[0].checked = 'true'; }); 
		$('.checkbox[name=wants6]').click(function(){ $('#wants5')[0].checked = 'true'; });
		$('.checkbox[name=wants8]').click(function(){ $('#wants7')[0].checked = 'true'; });
		$('.checkbox[name=wants2]').css('margin-left','20px');
		$('.checkbox[name=wants6]').css('margin-left','20px');
		$('.checkbox[name=wants8]').css('margin-left','20px');	
		$('#wants2_txt').prev('.break').remove(); $('#wants2_txt').prev('.break').remove(); $('#wants2_txt').prev('.break').remove();
		$('#wants6_txt').prev('.break').remove(); $('#wants6_txt').prev('.break').remove(); $('#wants6_txt').prev('.break').remove();	
		$('#wants8_txt').prev('.break').remove(); $('#wants8_txt').prev('.break').remove(); $('#wants8_txt').prev('.break').remove();	
		$('#wants2_txt').hide();
		$('#wants6_txt').hide();
		$('#wants8_txt').hide();
	}
}
function requestAnswer(answer)
{
	if (answer.uncomplete) return;
	$('.form').slideUp();
	write(answer.info);
		
	// google conversion	
	eval(labels.conversion.replace(/&#x27;/g,'\''));	
	document.write = function(s){ $('body').append(s); }	
	var scr = $('<scr'+'ipt>');
	scr.attr({
	        'type':'text/javascript',
	        'src':'http://www.googleadservices.com/pagead/conversion.js'
	});	
	$('head').append(scr); 
	
	// yahoo conversion
	window.ysm_customData = new Object();
	window.ysm_customData.conversion = "transId=,currency=,amount=";
	if (labels.yahoo) window.ysm_accountid = labels.yahoo;
	else window.ysm_accountid = "1QD0PI53BL4GSQ977SODLLDB2US";
	var scr = $('<scr'+'ipt>');
	scr.attr({ 'type':'text/javascript', 'src':'//srv1.wa.marketingsolutions.yahoo.com/script/ScriptServlet?aid='+ysm_accountid });	
	$('head').append(scr); 

	// google analytics
	if (scout == 114){
		var scr = $('<scr'+'ipt>');
		scr.attr({ 'type':'text/javascript', 'src':'http://www.google-analytics.com/ga.js' });	
		$('head').append(scr); 
		var pageTracker = _gat._getTracker("UA-9499074-1"); 
		pageTracker._trackPageview(); 
	}
	
	requestAd(answer.scouts);
}
function image(answer)
{
	$('#uploadLoading').remove(); $('#image_pre').remove();
	var cont = obj('image'); createBreak(cont,2);
	createImage(cont,'image_pre','',tenScouts+'pic/'+answer.address);
}
function logon(parentObj)
{
//	var cont = obj('logon');
//	createText(cont,'logonTitle','header white');
//	createTextfieldBlock(cont,'logonMail');
//	createTextfieldBlock(cont,'logonPassword','','','password');
//	createSubmit(cont,'logonSubmit','submit');
//	createLink(cont,'logonForget','link','','infoInput','mail');
	
	formCheck('logon');
	$('#logonForget').click(function(){ infoInput(this,'mail'); $(this).unbind('click'); });
}
function logonAnswer(answer) // go to 10scouts
{
	$('#body').fadeOut('slow',function(){		
		document.location = tenScouts+'?action=logon&mail='+answer.mail+'&password='+answer.password;
	});
}
//function program(answer)
//{
//	var cont = objEmpty('content');
//	
//	if (labels.downloadOn){
//		var key = labels.profession;
//		var img = scout+'/'+key+'.png';
//		var url = 'http://'+document.location.host;
//		var code = '<a href="'+url+'" name="'+key+'" target="_blank"><img src="'+url+'/'+img+'" title="'+key+'" border="none"></a>'
//	
//		var cont = createContainer(cont,'download');
//		createText(cont,'seoText1','',labels.seoText1.replace(/__scout__/,labels.scoutTitle)); createBreak(cont,2);
//		createImage(cont,'','',img); createBreak(cont,2);
//		createText(cont,'seoText2'); createBreak(cont,2);
//		while (code.search(/</) != -1) code = code.replace(/</,'&lt;'); 
//		while (code.search(/>/) != -1) code = code.replace(/>/,'&gt;');
//		var area = createTextarea(cont,'code','input',code); area.readonly = true; createBreak(cont,2);
//		createText(cont,'seoText3');
//		align(cont);
//	}
//	else{
//		var pic = createImage(cont,'programPic','','img/program.jpg'); $(pic).fadeIn('slow');
//		createText(cont,'html','',answer.text); createBreak(cont,4);
//		formular(cont,'program',labels.program_fields.split(','),true,labels.program_mandatory.split(','));
//	}
//}
function contact(cont)
{
	formular(cont,'contact',labels.contact_fields.split(','),true,Array('mail','text'));
}
function callback(answer)
{
//	if (answer) return;
//	var cont = obj('callback');
//	createText(cont,'callbackTitle','header white');
//	createText(cont,'callbackSubtitle'); createBreak(cont,2);
//	createTextfieldBlock(cont,'callbackName');
//	createTextfieldBlock(cont,'callbackTelephone');
//	createTextfieldBlock(cont,'callbackTime');
//	createTextarea(cont,'callbackText','input'); createBreak(cont);
//	createText(cont,'callbackText_txt'); createBreak(cont,2);
//	createSubmit(cont,'submit','submit');

	formCheck('callback');
}
function partnerShort(answer,type)
{
	var cont = obj('partnerShort');	
	removeChildren(cont);
	var partner = answer.partnerShort;
	createText(cont,'partner2Title','header white center');
	createBreak(cont);

	if (partner.firma) var name = partner.firma; else name = partner.vorname+' '+partner.nachname;
	var imgCont = createContainer(cont,'','center');	
	if (partner.pic == '1') createImage(imgCont,'','partnerImage',tenScouts+'pic/'+partner.id+'_big.jpg'); createBreak(cont);
	createText(cont,'','bold center',name); createBreak(cont);
	createText(cont,'','center','aus '+partner.ort); createBreak(cont,2);
	partnerDetail(cont,'partner2Detail','',partner); createBreak(cont,2);
	//if ((labels.listingOn && !labels.listingInclusive) || scout == 117) createImage(cont,'','link','img/listingBanner.jpg','listing','click');		
	if ((labels.listingOn && !labels.listingInclusive) || scout == 117) createLink(cont,'profileButton','link','','link2','Listing');		
}
function partnerDetail(parentObj,id,className,partner)
{
	if (!labels.independent){
		var link = ((partner.vorname)?partner.vorname+',':'')+partner.nachname+','+labels.profession+','+partner.id; link = link.replace(/\//,'-');
		createLink(parentObj,'partner2Link','orange bold center link','','link',tenScouts+link);
	} 
	else {
		createLink(parentObj,'partner2Link','orange bold center link','','display',id);	
		var detail = createContainer(parentObj,id,className,true); createBreak(detail,2);
		createText(detail,'profession','bold'); createBreak(detail);
		createText(detail,'','',name); createBreak(detail);
		if (partner.firma){ createText(detail,'','',partner.firma); createBreak(detail); } 
		if (partner.ansprech){ createText(detail,'','',partner.ansprech); createBreak(detail,2); } 
		createText(detail,'','',partner.strasse+'&nbsp;'); createBreak(detail);
		createText(detail,'','',partner.plz+'&nbsp;'); createText(detail,'','',partner.ort); createBreak(detail,2);
		createText(detail,'','','Tel: '+partner.telefon); createBreak(detail);
		createText(detail,'','','Fax: '+partner.telefax); createBreak(detail);	
		createText(detail,'','',partner.email); createBreak(detail);
		createLink(detail,'','link',partner.internet,'link','http://'+partner.internet); createBreak(detail,2);
		createText(detail,'partnerProfile','bold'); createBreak(detail);
		if (partner.spezial) createText(detail,'','',partner.spezial);
		else createText(detail,'','',partner.profile);
	}
}





