var onLoadFunctions="loadCart();";
function initCB(){
	eval(onLoadFunctions);
}
window.onload =initCB;
var world_id =2679;
function loadDistricts(district_oid,target,level,event){
	if(!district_oid)district_oid=world_id;
	var select = document.getElementById("district1Div").getElementsByTagName("select")[0];
	select.style.backgroundColor="#ffffff";
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=1&District="+district_oid+"&level="+level;
	var nextLevel= document.getElementById(target+(level+1)+"Div");
	if(nextLevel){
		nextLevel.innerHTML="<select class='select1' ></select>";
	}
	AJAXloadHTMLinTarget(url,target+level+"Div",null,event);	
}
function searchDistrict1(){
	loadDistricts(document.getElementById("district1").value,"district",2,null);
}
function searchDistrict2(){
	loadDistricts(document.getElementById("district2").value,"district",3,null);
}
function searchDistrict3(){}

function searchDistrict1Detail(){
	var district_oid=document.getElementById("district1").value;
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=1&District="+district_oid+"&level=2Detail";
	hideDiv("addMarinaButton");
	AJAXloadHTMLinTarget(url,"district2Div",null,null);	
}
function searchDistrict2Detail(){
	var district_oid=document.getElementById("district2Detail").value;
	if(district_oid>-1){
		showDiv("addMarinaButton");
	}else{
		hideDiv("addMarinaButton");
	}
}
function showDistrict3Detail(){
	var district_oid=document.getElementById("district2Detail").value;
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=12&District="+district_oid+"&level=2Detail";
	AJAXsendRequest(url,"processReqDistrictCheck(\""+district_oid+"\")",null,null);
}
function processReqDistrictCheck(district_oid){
	if(document.getElementById("district"+district_oid))return;
	document.getElementById("district3Div").innerHTML += req.responseText;	
}
function searchMini(){
	if(!document.getElementById("district1") || document.getElementById("district1").value=='-1'){
		var select = document.getElementById("district1Div").getElementsByTagName("select")[0];
		select.style.backgroundColor="#ff7070";
		return;
	}
	if(!document.getElementById("district2") || document.getElementById("district2").value=='-1'){
		var select = document.getElementById("district2Div").getElementsByTagName("select")[0];
		select.style.backgroundColor="#ff7070";
		return;
	}
	document.forms["miniSucheForm"].submit();
}

function searchAndResetYachtDetail(event){
	/*if(!checkMarinas()){
		alert("bitte Hafen wählen");
		return;
	}*/
	var yfForm = document.getElementById("YachtFinderForm");
	yfForm.elements["length_slider_max"].value=0;
	yfForm.elements["length_slider_min"].value=0;
	yfForm.elements["bunk_slider_max"].value=0;
	yfForm.elements["bunk_slider_min"].value=0;
	yfForm.elements["price_slider_max"].value=0;
	yfForm.elements["price_slider_min"].value=0;
	resetSlider();
	searchYacht(event);
}
function searchAndResetYacht(event){
	var yfForm = document.getElementById("YachtFinderForm");
	yfForm.elements["length_slider_max"].value=0;
	yfForm.elements["length_slider_min"].value=0;
	yfForm.elements["bunk_slider_max"].value=0;
	yfForm.elements["bunk_slider_min"].value=0;
	yfForm.elements["price_slider_max"].value=0;
	yfForm.elements["price_slider_min"].value=0;
	resetSlider();
	searchYacht(event);
}
function resetSlider(){
	document.getElementById("sliders").innerHTML="";
}
function searchYacht(event){
	var url = AJAXgetForm("YachtFinderForm");
	AJAXloadHTMLinTarget(url,"YachtListDiv","showSlider();",event);
}
function showSlider(){
	if(document.getElementById("sliders").innerHTML.length==0){
		AJAXloadHTMLinTarget(absolutePath+"AJAXSlider.jsp"+sessionid,"sliders",null,null);
	}
}
function sortOfferList(sortOrder){
	var url = AJAXgetForm("YachtFinderForm");
	url +="&order="+sortOrder;
	AJAXloadHTMLinTarget(url,"YachtListDiv",null,null);
}
function posOfferList(pos){
	var url = AJAXgetForm("YachtFinderForm");
	url +="&limit="+pos;
	AJAXloadHTMLinTarget(url,"YachtListDiv",null,null);
}	
function setOfferListPosCount(){
	var url = AJAXgetForm("YachtFinderForm");
	url +="&poscount="+document.getElementById("posCount").value;
	AJAXloadHTMLinTarget(url,"YachtListDiv",null,null);
}
function show_value(x){
	document.getElementById(x).style.display="block";
}
function hide_value(x){
	document.getElementById(x).style.display="none";
}
function showWeeks(){
	showDiv("weeks");
	hideDiv("moreWeeksBtn");
}
function loadAval(yacht_oid,event){
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=3&yacht_oid="+yacht_oid+"&duration="+document.getElementById("DurationSelect").value;
	AJAXloadHTMLinTarget(url,"WeekSelectDiv","loadPrice(null)",event);		
}
function openPrintView(yacht_oid,event){
	var url = absolutePath+"PrintView.jsp"+sessionid;
	url +="?yacht_oid="+yacht_oid;
	PrintView = window.open(url,"PrintView"+yacht_oid,"height=650,width=1050,scrollbars=yes");
	PrintView.focus();
}
function addToCart(yacht_id,event){	
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=7&yacht_oid="+yacht_id;
	AJAXloadHTMLinTarget(url,"CartMini",null,event);
}
function loadCart(){	
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=7";
	AJAXloadHTMLinTarget(url,"CartMini",null,null);
}
function openImagesPopup(event){
	var YachtImagesPopupContainer = document.getElementById('YachtImagesPopupContainer');
	var LightWindow = document.getElementById('LightWindow');
	LightWindow.innerHTML=YachtImagesPopupContainer.innerHTML;
	showLightWindow(100,0,712,452);
	showDiv('ImagesPopup');	
	slider = new UI.Carousel('ImagesPopup',{direction:'vertical'});
}
/*function showYachtImageSlider(){
	slider = new UI.Carousel('YachtImagesPopup',{direction:'vertical'});
	slider.observe('scroll:ended', function(event) {
		  alert("Carousel with id " + event.memo.carousel.currentPosition() + " has just been scrolled");
		});
}*/
function submitCompare(){
	var url = AJAXgetForm("CompareForm");
	AJAXloadHTMLinTarget(url,"LightWindow",null,null);
}
function openCompare(event){
	var url = absolutePath+"Compare.jsp"+sessionid+"?";
	var elements = document.forms["CartForm"].elements;
	var hit=0;
	for(var i=0;i<elements.length;i++){
		if(elements[i].name!="yacht" || !elements[i].checked)continue;
		url +="&yacht="+elements[i].value;	
		hit++;
	}
	if(hit<2){
		alert("Bitte wählen Sie mindestens zwei Yachten aus.");
		return;
	}else if(hit>4){
		alert("Bitte wählen Sie maximal 4 Yachten aus.");
		return;
	}
	showLightWindow(150,0,785,0);
	AJAXloadHTMLinTarget(url,"LightWindow",null,event);
}
function openCartSaveForm(event){
	showLightWindow(0,0,500,0);
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid+"?action=9";
	AJAXloadHTMLinTarget(url,"LightWindow",null,event);
}
function saveCart(){
	var url = AJAXgetForm("CartSaveOffer");
	url +="&action2=save";
	var offerDiv = document.getElementById("LightWindow");
	AJAXloadHTMLinTarget(url,"LightWindow",null,null);	
}
function openOrderForm(yw,duration,event){
	showLightWindow(100,0,610,680);
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=5&week="+yw+"&duration="+duration;
	AJAXloadHTMLinTarget(url,"LightWindow",null,event);
}
function loadOrderForm(yacht_oid,week_oid,event){
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid+"?action=4&yacht="+yacht_oid;
	if(document.getElementById("WeekSelect")){
		var week = document.getElementById("WeekSelect").value;
		var duration = document.getElementById("DurationSelect").value;
		url +="&duration="+duration+"&week="+week;
	}else if(week_oid){
		url +="&duration=1&week="+week_oid;
	}
	AJAXloadHTMLinTarget(url,"OrderFormDiv",null,event);	
}
function openInquiryForm(yacht_oid,event){	
	showLightWindow(100,0,560,450);
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid+"?action=10&yacht="+yacht_oid;
	AJAXloadHTMLinTarget(url,"LightWindow",null,event);	
}
function sendInquiry(){
	var url = AJAXgetForm("YachtOffer");
	AJAXloadHTMLinTarget(url,"LightWindow",null,null);
}
function continueBooking(action){
	var url = AJAXgetForm("YachtOffer");
	if(action!=null){
		url += "&action2="+action;
	}
	AJAXloadHTMLinTarget(url,"LightWindow",null,null);
}
function setBgBlack(divName){
	var bodyhight=document.getElementsByTagName('body')[0].scrollHeight;
	var bodywidth=document.getElementsByTagName('body')[0].scrollWidth;
	document.getElementById(divName).style.width=bodywidth+'px';
	document.getElementById(divName).style.height=bodyhight+'px';
	showDiv(divName);
}
function loadDistrictChooser(district1_oid,district2_oid,event){
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=1&District="+world_id+"&level=1";
	AJAXloadHTMLinTarget(url,"district1Div","setSelect('district1',"+district1_oid+")",event);

	url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=1&District="+district1_oid+"&level=2";
	AJAXloadHTMLinTarget(url,"district2Div","setSelect('district2',"+district2_oid+")",event);	
}
function setSelect(district,district_oid){
	var select = document.getElementById(district);
	for(var i=0;i<select.options.length;i++){
		if(!select.options[i].value)continue;
		//alert(select.options[i].value+" "+district_oid);
		if(select.options[i].value==district_oid){
			select.selectedIndex=i;
			break;
		}
	}	
}
function openDistrict(selectName,event){
	//var name = document.getElementById(selectName).options[document.getElementById(selectName).selectedIndex].text;encodeURIComponent(name)
	window.location.href=absolutePath+"Charter-Revier/"+document.getElementById(selectName).value+".html";
}
function charterAngebote(selectName,event){
	window.location.href=absolutePath+"Charter-Yacht-finden//district2/"+document.getElementById(selectName).value+".html";
}
function hideLightWindow(){
	hideDiv("LightWindow");
	hideDiv("BlackBackground");
}
function hideImagesPopup(){
	hideDiv("ImagesPopup");hideDiv("LightWindow");
	hideDiv("BlackBackground");
}
function loadYachtDetailSelect( event){
	url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=11&vendor_oid_fk="+document.getElementById("vendor_oid_fk").value;
	AJAXloadHTMLinTarget(url,"yachtmodellDiv",null,event);	
}
function showDistrictCheck3(){
	var url = absolutePath+"AJAXYachtRequest.jsp"+sessionid;
	url +="?action=12&District="+district_oid+"&level="+level;
	AJAXloadHTMLinTarget(url,target+"3Div",null,event);	
}
function setImagesPopup(imageUrl,name){
	document.getElementById("PopupTopImage").style.background="url("+imageUrl+") center no-repeat";
	document.getElementById("PopupTopImageName").innerHTML=name;
}
function changeStyle(className,styleName,styleValue){
	for(var j=0;j<document.styleSheets.length;j++){
		var rules = document.styleSheets[j].cssRules;
		if(!rules)rules = document.styleSheets[j].rules ;
		for(var i=0;i<rules.length;i++){
			if(rules[i].selectorText==className){
				rules[i].style[styleName]=styleValue;
				return;
			}
		}
	}
}