var crealytics_conversion_id;
var crealytics_conversion_value;
var crealytics_conversion_ncc;
function showLoad(){
    $('loader').style.display='';
}

function hideLoad(){
    $('loader').style.display='none';
}

function showPhoto(id,num){
    for(i=0;i<num;i++){
        document.getElementById("photo"+i).style.display="none";
    }
    document.getElementById("photo"+id).style.display="";
}

function md5(string){
	var postBody = 'action=md5&string='+string;

    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onSuccess:
        function(t){
            return t.responseText;
        }
    });
}

function sendRequest(){
    if(document.contactForm.name.value=='' || document.contactForm.last_name.value=='' || document.contactForm.email.value=='')
        document.getElementById('error').style.display='';
    else
        document.contactForm.submit();
}

function searchFormPage(pagenum) {
    var url=location+"";
    if(/spage\/\d+/.test(url)) {
        location=url.replace(/spage\/\d+/,'spage/'+pagenum);
    } else {
        location=url.replace('.html','/spage/'+pagenum+'.html');
    }
}

function searchEscape(str) {
    return str.replace(/[^a-z0-9.]+/gi,'-').replace(/^-+|-+$/g, '');
}

function searchInt(str) {
    var ret=parseInt(str);
    if(ret) return ret;
    return 0;
}

function searchFloat(str) {
    var ret=parseFloat(str);
    if(ret) return ret;
    return 0;
}

function searchForm(url,returnUrl){
    var str=new Array();
    var link='';
    if(returnUrl==true){
        str[0]=($('boatManufacturerQuick').value);
        str[1]='';
        str[2]=searchEscape($('boatTypeQuick').value);
        str[3]=searchEscape($('charterCountryQuick').value);
        str[4]=searchEscape($('charterAreaQuick').value);
        str[5]=searchEscape($('charterPortQuick').value);
        str[6]=searchEscape($('charterSkipperQuick').value);
        str[7]=searchFloat($('lengthFromQuick').value)+'-'+searchFloat($('lengthToQuick').value);
        str[8]=searchInt($('cabinsFromQuick').value)+'-'+searchInt($('cabinsToQuick').value);
        str[9]=searchInt($('builtYearFromQuick').value)+'-'+searchInt($('builtYearToQuick').value);
        str[10]=[];
        if($('luxusYachtQuick').checked==true) str[10].push('luxus');
        if($('berthCharterQuick').checked==true) str[10].push('berth');
        if($('cabinCharterQuick').checked==true) str[10].push('cabin');
        str[10]=str[10].join('.');
        str[11]=searchInt($('scheduled_departure_dayQuick').value)+'-'+searchEscape($('scheduled_departure_month_yearQuick').value);
		
    }
    else{
        str[0]=($('boatManufacturer').value);
        str[1]=($('boatModel').value);
        str[2]=searchEscape($('boatType').value);
        str[3]=searchEscape($('charterCountry').value);
        str[4]=searchEscape($('charterArea').value);
        str[5]=searchEscape($('charterPort').value);
        str[6]=searchEscape($('charterSkipper').value);
        str[7]=searchFloat($('lengthFrom').value)+'-'+searchFloat($('lengthTo').value);
        str[8]=searchInt($('cabinsFrom').value)+'-'+searchInt($('cabinsTo').value);
        str[9]=searchInt($('builtYearFrom').value)+'-'+searchInt($('builtYearTo').value);
        str[10]=[];
        if($('luxusYacht').checked==true) str[10].push('luxus');
        if($('berthCharter').checked==true) str[10].push('berth');
        if($('cabinCharter').checked==true) str[10].push('cabin');
        str[10]=str[10].join('.');
        str[11]=searchInt($('scheduled_departure_day').value)+'-'+searchEscape($('scheduled_departure_month_year').value);
    }
    link=str.join(',');
    //if(parseInt($('search_page').value)>0) link+='/spage/'+$('search_page').value;
    var ret=url.replace('--search-data-marker--',link);
    var bases=document.getElementsByTagName('base');
    if(bases.length>0) {
        ret=bases[0].href+ret;
    }
    //	alert(ret);
    if(returnUrl==true){
        return ret;
    }
    else{
        location.assign(ret);
        return false;
    }
}

function searchMiniForm(boat_type)
{
    var str=new Array();
    if(boat_type=='sailing' || boat_type=='sailing_de')
    {
        str[0] = 'all-regions';
        str[1] = 'all-areas';
        if($('charterCountry1').value != '')
            str[2]=searchEscape($('charterCountry1').value);
        else
            str[2]='all-countries';
        str[3]='all-ports';
        str[4]=searchInt($('charterDay1').value)+'-'+searchEscape($('charterDate1').value);
        str[5]=searchInt($('charterCabins1').value);
        var link = str.join('/');
        if(boat_type=='sailing')
            var ret = 'sailboat-charter/search/'+link+'.html';
        else if(boat_type='sailing_de')
            var ret = '/de/segelboot-charter/search/'+link+'.html';
    }
    else if(boat_type=='powerboat' || boat_type=='powerboat_de')
    {
        str[0] = 'all-regions';
        str[1] = 'all-areas';
        if($('charterCountry2').value != '')
            str[2]=searchEscape($('charterCountry2').value);
        else
            str[2]='all-countries';
        str[3]='all-ports';
        str[4]=searchInt($('charterDay2').value)+'-'+searchEscape($('charterDate2').value);
        if($('charterCabins2').value != 0)
            str[5]=searchInt($('charterCabins2').value);
        var link = str.join('/');
        if(boat_type=='powerboat')
            var ret = 'powerboat-charter/search/'+link+'.html';
        else if(boat_type='powerboat_de')
            var ret = '/de/motoryacht-mieten/search/'+link+'.html';
    }
    else if(boat_type=='luxury' || boat_type=='luxury_de')
    {
        str[0] = 'all-regions';
        str[1] = 'all-areas';
        if($('charterCountry3').value != '')
            str[2]=searchEscape($('charterCountry3').value);
        else
            str[2]='all-countries';
        str[3]='all-ports';
        str[4]=searchInt($('charterDay3').value)+'-'+searchEscape($('charterDate3').value);
        str[5]=searchInt($('charterCabins3').value);
        var link = str.join('/');
        if(boat_type=='luxury')
            var ret = 'luxury-yacht-charter/search/'+link+'.html';
        else if(boat_type='luxury_de')
            var ret = '/de/luxusyacht/search/'+link+'.html';
    }
	
    location.assign(ret);
}

function searchFormUrl(url,returnUrl){
    $('search_loader').style.display='';
    var str=new Array();
    var link='';
    if(returnUrl==true){
        str[0]=($('boatManufacturerQuick').value);
        str[1]='';
        str[2]=searchEscape($('boatTypeQuick').value);
        str[3]=searchEscape($('charterCountryQuick').value);
        str[4]=searchEscape($('charterAreaQuick').value);
        str[5]=searchEscape($('charterPortQuick').value);
        str[6]=searchEscape($('charterSkipperQuick').value);
        str[7]=searchFloat($('lengthFromQuick').value)+'-'+searchFloat($('lengthToQuick').value);
        str[8]=searchInt($('cabinsFromQuick').value)+'-'+searchInt($('cabinsToQuick').value);
        str[9]=searchInt($('builtYearFromQuick').value)+'-'+searchInt($('builtYearToQuick').value);
        str[10]=[];
        if($('luxusYachtQuick').checked==true) str[10].push('luxus');
        if($('berthCharterQuick').checked==true) str[10].push('berth');
        if($('cabinCharterQuick').checked==true) str[10].push('cabin');
        str[10]=str[10].join('.');
        str[11]=searchInt($('scheduled_departure_dayQuick').value)+'-'+searchEscape($('scheduled_departure_month_yearQuick').value);
    }
    else{
        if($('charterRegion').value!='')
            str[0]=searchEscape($('charterRegion').value);
        else
            str[0]='all-regions';
        if($('charterArea').value != '')
            str[1]=searchEscape($('charterArea').value);
        else str[1] = 'all-areas';
        if($('charterCountry').value != '')
            str[2]=searchEscape($('charterCountry').value);
        else str[2] = 'all-countries';
        if($('charterPort').value != '_' && $('charterPort').value != $('charterCountry').value)
        {
            str[3]=$('charterPort').value;
            str[3]=(str[3].split(',')).join(',');
        }
        else str[3] = 'all-ports';
        str[4]=searchInt($('scheduled_departure_day').value)+'-'+searchEscape($('scheduled_departure_month_year').value);
        str[5]=searchInt($('charterCabins').value);
    }
    link=str.join('/');
    //alert(link);
    //if(parseInt($('search_page').value)>0) link+='/spage/'+$('search_page').value;
    var ret=url.replace('--search-data-marker--',link);
    ret=ret.replace('--search-type-marker--',$('boatType').value);
    ret=ret.split('//').join('/');
    if(ret.charAt(0)=='/') ret=ret.substring(1);
    //ret=ret.replace('de-',
    var bases=document.getElementsByTagName('base');
    if(bases.length>0) {
        ret=bases[0].href+ret;
    }
    if(returnUrl==true){
        return ret;
    }
    else{
        location.assign(ret);
        return false;
    }
}

function quickSearch(lang,page){
    if(page=='')
        page='0';
    var ajaxRequest;
    var boatType=$('boatTypeQuick').value;
    var manufacturer=$('boatManufacturerQuick').value;
    var country=$('charterCountryQuick').value;
    var skipper=$('charterSkipperQuick').value;
    var area=$('charterAreaQuick').value;
    var port=$('charterPortQuick').value;
    var lengthFrom=$('lengthFromQuick').value;
    var lengthTo=$('lengthToQuick').value;
    var personFrom=$('cabinsFromQuick').value;
    var personTo=$('cabinsToQuick').value;
    var yearFrom=$('builtYearFromQuick').value;
    var yearTo=$('builtYearToQuick').value;
    var link=searchForm($('url').value,true);
    var linkPager=link.replace('.html','/spage/1.html');
    if($('luxusYachtQuick').checked==true)
        var lux='1';
    else
        var lux='';
    if($('berthCharterQuick').checked==true)
        var berth='1';
    else
        var berth='';
    if($('cabinCharterQuick').checked==true)
        var cabin='1';
    else
        var cabin='';
    var departDay=$('scheduled_departure_dayQuick').value;
    var departMonth=$('scheduled_departure_month_yearQuick').value;
    var postBody = 'action=quickSearch&linkPager='+linkPager+'&link='+link+'&boatType='+boatType+'&manufacturer='+manufacturer+'&country='+country+'&skipper='+skipper+'&area='+area+'&port='+port+'&lengthFrom='+lengthFrom+'&lengthTo='+lengthTo+'&personFrom='+personFrom+'&personTo='+personTo+'&yearFrom='+yearFrom+'&yearTo='+yearTo+'&lux='+lux+'&berth='+berth+'&cabin='+cabin+'&departDay='+departDay+'&departMonth='+departMonth+'&L='+lang+'&page='+page;
    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onLoading: showLoad, 
        onComplete: hideLoad, 
        onSuccess: 
        function(t){
            $('search-results').innerHTML=t.responseText;
        }
    });
}

function flashText(id,color,color2){
    $(id).style.color=color;
    setTimeout('flashText("'+id+'","'+color2+'","'+color+'")',1000);
}

function contactFormShow(id){
    if($(id).style.display=='none'){
        $(id).style.display='';
    }
    else{
        $(id).style.display='none';
    }
}

function sendContactForm(id,lang,boat){
	var postBody='';
	//debug
	postBody = 'action=emailDebug&boatId='+id+'&name='+document.forms['contactForm'+id].name.value+'&last_name='+document.forms['contactForm'+id].last_name.value+'&address='+document.forms['contactForm'+id].address.value+'&city='+document.forms['contactForm'+id].city.value+'&zip='+document.forms['contactForm'+id].zip.value+'&country='+document.forms['contactForm'+id].country.value+'&phone='+document.forms['contactForm'+id].phone.value+'&email='+document.forms['contactForm'+id].email.value+'&people='+document.forms['contactForm'+id].people.value+'&trip_start='+document.forms['contactForm'+id].trip_start.value+'&trip_length='+document.forms['contactForm'+id].trip_length.value+'&similar='+similar+'&more_info='+document.forms['contactForm'+id].more_info.value+'&L='+lang+'&apikey='+apikey;
        new Ajax.Request('http://www.rentabo.com/fileadmin/templates/ajax/ajax.php', {
            method:'post', 
            postBody:postBody, 
            onSuccess: 
            function(t){
            }
     });
	//end debug
	
    if(document.forms['contactForm'+id].name.value=='' || document.forms['contactForm'+id].last_name.value=='' || document.forms['contactForm'+id].email.value=='' || document.forms['contactForm'+id].phone.value==''){
        document.getElementById('error'+id).style.display='';
        $('send'+id).style.display='none';
    }
    else{
        if(document.forms['contactForm'+id].similar.checked==true)
            var similar='1';
        else
            var similar='';
        if(document.getElementById('apikey').value!='')
            var apikey=document.getElementById('apikey').value;
        else
            var apikey='';
        postBody = 'action=sendContactFormQuery&boatId='+id+'&name='+document.forms['contactForm'+id].name.value+'&last_name='+document.forms['contactForm'+id].last_name.value+'&address='+document.forms['contactForm'+id].address.value+'&city='+document.forms['contactForm'+id].city.value+'&zip='+document.forms['contactForm'+id].zip.value+'&country='+document.forms['contactForm'+id].country.value+'&phone='+document.forms['contactForm'+id].phone.value+'&email='+document.forms['contactForm'+id].email.value+'&people='+document.forms['contactForm'+id].people.value+'&trip_start='+document.forms['contactForm'+id].trip_start.value+'&trip_length='+document.forms['contactForm'+id].trip_length.value+'&similar='+similar+'&more_info='+document.forms['contactForm'+id].more_info.value+'&L='+lang+'&apikey='+apikey;
		new Ajax.Request('http://www.rentabo.com/fileadmin/templates/ajax/ajax.php', {
            method:'post', 
            postBody:postBody, 
            onSuccess: 
            function(t){
			crealytics_conversion_id = 150;
			crealytics_conversion_value = t.responseText;
			crealytics_conversion_ncc = 1;
			

			
			(function(){var j,n,f;
			j=document;
			function k(d){if(d!=null){return escape(d.toString());
			}return"";
			}function m(d){if(d!=null){return d.toString().substring(0,256);
			}return"";
			}function g(d,p){return e(d,k(p));
			}function e(d,p){if(p!=""){d=k(d);
			if(d!=""){return"&".concat(d,"=",p);
			}}return"";
			}function c(p,d){var q=[];
			if(p){p.history&&q.push(g("u_his",p.history.length));
			}d&&typeof d.getTimezoneOffset=="function"&&q.push(g("u_tz",-d.getTimezoneOffset()));
			return q.join("");
			}function l(q,p){var r,d;
			r="";
			if(p){d=p.referrer;
			if(q&&q.top&&p.location&&q.top.location==p.location){r+=g("ref",m(d));
			d=p.location;
			}r+=g("url",m(d));
			}return r;
			}function o(d){if(d&&d.location&&d.location.protocol&&d.location.protocol.toString().toLowerCase()=="https:"){return"https:";
			}return"http:";
			}function b(p,d){return o(p)+"//tracking.crealytics.com/"+d;
			}function h(q,p){var d="/check.php?";
			d=b(q,[k(q.crealytics_conversion_id),d,"random=",k(q.crealytics_conversion_time)].join(""));
			d+=[g("cv",q.crealytics_conversion_js_version),g("fst",q.crealytics_conversion_first_time),g("num",q.crealytics_conversion_snippets),e("data",q.crealytics_conversion_value),g("ncc",q.crealytics_conversion_ncc),g("frame","1"),c(q,q.crealytics_conversion_date),l(q,p)].join("");
			return d;
			}function i(q,p){var r,d;
			r=h(q,p),d=function(u,t,s){return'<img height="'+s+'" width="'+t+'" border="0" src="'+u+'" />';
			};
			return'<iframe name="crealytics_conversion_frame" width="0" height="0" src="'+r+'" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no">'+d(r.replace(/\frame=1/,"frame=0"),1,1)+"</iframe>";
			}n=window;
			if(n){try{if(!n.crealytics_conversion_id){f=false;
			}else{if(n.crealytics_conversion_id==29){n.crealytics_conversion_ncc=1;
			}n.crealytics_conversion_date=new Date;
			n.crealytics_conversion_time=n.crealytics_conversion_date.getTime();
			if(typeof n.crealytics_conversion_snippets=="number"&&n.crealytics_conversion_snippets>0){n.crealytics_conversion_snippets+=1;
			}else{n.crealytics_conversion_snippets=1;
			}if(typeof n.crealytics_conversion_first_time!="number"){n.crealytics_conversion_first_time=n.crealytics_conversion_time;
			}n.crealytics_conversion_js_version="1";
			f=true;
			}
			//f&&j.write(i(n,j));
			document.getElementById('codeAdwords').innerHTML=i(n,j);
			}catch(a){}n.crealytics_conversion_date=null;
			n.crealytics_conversion_time=null;
			n.crealytics_conversion_js_version=null;
			n.crealytics_conversion_id=null;
			n.crealytics_conversion_value=null;
			n.crealytics_conversion_ncc=null;
			}})();
			
			
			
            }
        });
		
		
		
		postBody = 'action=sendContactForm&boatId='+id+'&name='+document.forms['contactForm'+id].name.value+'&last_name='+document.forms['contactForm'+id].last_name.value+'&address='+document.forms['contactForm'+id].address.value+'&city='+document.forms['contactForm'+id].city.value+'&zip='+document.forms['contactForm'+id].zip.value+'&country='+document.forms['contactForm'+id].country.value+'&phone='+document.forms['contactForm'+id].phone.value+'&email='+document.forms['contactForm'+id].email.value+'&people='+document.forms['contactForm'+id].people.value+'&trip_start='+document.forms['contactForm'+id].trip_start.value+'&trip_length='+document.forms['contactForm'+id].trip_length.value+'&similar='+similar+'&more_info='+document.forms['contactForm'+id].more_info.value+'&L='+lang+'&apikey='+apikey;
		
        new Ajax.Request('http://www.rentabo.com/fileadmin/templates/ajax/ajax.php', {
            method:'post', 
            postBody:postBody, 
            onSuccess: 
            function(t){
			
            }
        });
		
        if(boat=='boat'){
            $('error'+id).style.display='none';
            $('send'+id).style.display='';
            document.forms['contactForm'+id].name.value='';
            document.forms['contactForm'+id].last_name.value='';
            document.forms['contactForm'+id].address.value='';
            document.forms['contactForm'+id].city.value='';
            document.forms['contactForm'+id].zip.value='';
            document.forms['contactForm'+id].country.value='';
            document.forms['contactForm'+id].phone.value='';
            document.forms['contactForm'+id].country.value='';
            document.forms['contactForm'+id].email.value='';
            document.forms['contactForm'+id].trip_start.value='';
            document.forms['contactForm'+id].trip_length.value='7';
            document.forms['contactForm'+id].people.value='';
            document.forms['contactForm'+id].similar.checked=false;
            document.forms['contactForm'+id].more_info.value='';
        }
        else{
            $('error'+id).style.display='none';
            $('contactForm'+id).style.display='none';
            $('send'+id).style.display='';
            document.forms['contactForm'+id].name.value='';
            document.forms['contactForm'+id].last_name.value='';
            document.forms['contactForm'+id].address.value='';
            document.forms['contactForm'+id].city.value='';
            document.forms['contactForm'+id].zip.value='';
            document.forms['contactForm'+id].country.value='';
            document.forms['contactForm'+id].phone.value='';
            document.forms['contactForm'+id].country.value='';
            document.forms['contactForm'+id].email.value='';
            document.forms['contactForm'+id].trip_start.value='';
            document.forms['contactForm'+id].trip_length.value='7';
            document.forms['contactForm'+id].people.value='';
            document.forms['contactForm'+id].similar.checked=false;
            document.forms['contactForm'+id].more_info.value='';
        }
		
		
    }
}

function sendLuxusContactForm(id,lang,boat){

	var postBody='';
	
	//debug
	postBody = 'action=emailDebug&boatId='+id+'&name='+document.forms['contactForm'+id].name.value+'&last_name='+document.forms['contactForm'+id].last_name.value+'&address='+document.forms['contactForm'+id].address.value+'&city='+document.forms['contactForm'+id].city.value+'&zip='+document.forms['contactForm'+id].zip.value+'&country='+document.forms['contactForm'+id].country.value+'&phone='+document.forms['contactForm'+id].phone.value+'&email='+document.forms['contactForm'+id].email.value+'&people='+document.forms['contactForm'+id].people.value+'&trip_start='+document.forms['contactForm'+id].trip_start.value+'&trip_length='+document.forms['contactForm'+id].trip_length.value+'&similar='+similar+'&more_info='+document.forms['contactForm'+id].more_info.value+'&L='+lang+'&apikey='+apikey;
        new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
            method:'post', 
            postBody:postBody, 
            onSuccess: 
            function(t){
            }
     });
	//end debug
    if(document.forms['contactForm'+id].name.value=='' || document.forms['contactForm'+id].last_name.value=='' || document.forms['contactForm'+id].email.value=='' || document.forms['contactForm'+id].phone.value=='')
        document.getElementById('error'+id).style.display='';
    else{
        if(document.forms['contactForm'+id].similar.checked==true)
            var similar='1';
        else
            var similar='';
        if(document.getElementById('apikey').value!='')
            var apikey=document.getElementById('apikey').value;
        else
            var apikey='';
        postBody = 'action=sendLuxusContactForm&boatId='+id+'&name='+document.forms['contactForm'+id].name.value+'&last_name='+document.forms['contactForm'+id].last_name.value+'&address='+document.forms['contactForm'+id].address.value+'&city='+document.forms['contactForm'+id].city.value+'&zip='+document.forms['contactForm'+id].zip.value+'&country='+document.forms['contactForm'+id].country.value+'&phone='+document.forms['contactForm'+id].phone.value+'&email='+document.forms['contactForm'+id].email.value+'&people='+document.forms['contactForm'+id].people.value+'&trip_start='+document.forms['contactForm'+id].trip_start.value+'&trip_length='+document.forms['contactForm'+id].trip_length.value+'&similar='+similar+'&more_info='+document.forms['contactForm'+id].more_info.value+'&L='+lang+'&apikey='+apikey;
        var loc='';
        if(boat=='boat')
            loc=location;
        new Ajax.Request(loc+'fileadmin/templates/ajax/ajax.php', {
            method:'post', 
            postBody:postBody, 
            onSuccess: 
            function(t){
            }
        });
        if(boat=='boat'){
            $('error'+id).style.display='none';
            $('send'+id).style.display='';
            document.forms['contactForm'+id].name.value='';
            document.forms['contactForm'+id].last_name.value='';
            document.forms['contactForm'+id].address.value='';
            document.forms['contactForm'+id].city.value='';
            document.forms['contactForm'+id].zip.value='';
            document.forms['contactForm'+id].country.value='';
            document.forms['contactForm'+id].phone.value='';
            document.forms['contactForm'+id].country.value='';
            document.forms['contactForm'+id].email.value='';
            document.forms['contactForm'+id].trip_start.value='';
            document.forms['contactForm'+id].trip_length.value='7';
            document.forms['contactForm'+id].people.value='';
            document.forms['contactForm'+id].similar.checked=false;
            document.forms['contactForm'+id].more_info.value='';
        }
        else{
            $('error'+id).style.display='none';
            $('contactForm'+id).style.display='none';
            $('send'+id).style.display='';
            document.forms['contactForm'+id].name.value='';
            document.forms['contactForm'+id].last_name.value='';
            document.forms['contactForm'+id].address.value='';
            document.forms['contactForm'+id].city.value='';
            document.forms['contactForm'+id].zip.value='';
            document.forms['contactForm'+id].country.value='';
            document.forms['contactForm'+id].phone.value='';
            document.forms['contactForm'+id].country.value='';
            document.forms['contactForm'+id].email.value='';
            document.forms['contactForm'+id].trip_start.value='';
            document.forms['contactForm'+id].trip_length.value='7';
            document.forms['contactForm'+id].people.value='';
            document.forms['contactForm'+id].similar.checked=false;
            document.forms['contactForm'+id].more_info.value='';
        }
    }
}

function showInfo(){

    $$('.extraClass').invoke('observe', 'mouseover', function(event) { 
        this.childElements()[1].childElements()[0].toggle();   
    });
    $$('.extraClass').invoke('observe', 'mouseout', function(event) { 
        this.childElements()[1].childElements()[0].toggle();   
    });

}

function getPhotos(id, name)
{
    var postBody = 'action=getPhotos&luxusBoatId='+id+'&name='+name;
    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onSuccess: 
        function(t){
            $('luxury_boat_photos').innerHTML=t.responseText;
        }
    });
}

function ajaxCharterCountry(id, lang)
{
    var postBody = 'action=ajaxCharterCountry&CharterCountryId='+id+'&lang='+lang;
    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onSuccess:
        function(t){
            //$('charterPort').innerHTML=t.responseText;
            $('ports_div').innerHTML=t.responseText;
        }
    });
}

function ajaxCharterCountry1(id, lang)
{
    var postBody = 'action=ajaxCharterCountrySingle&CharterCountryId='+id+'&lang='+lang+'&type=1';
    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onLoading: showLoad1, 
        onComplete: hideLoad1, 
        onSuccess:
        function(t){
            $('search_box_select_1').innerHTML=t.responseText;
        }
    });
}

function ajaxCharterCountry2(id, lang)
{
    var postBody = 'action=ajaxCharterCountrySingle&CharterCountryId='+id+'&lang='+lang+'&type=2';
    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onLoading: showLoad2, 
        onComplete: hideLoad2, 
        onSuccess:
        function(t){
            $('search_box_select_2').innerHTML=t.responseText;
        }
    });
}

function ajaxCharterCountry3(id, lang)
{
    var postBody = 'action=ajaxCharterCountrySingle&CharterCountryId='+id+'&lang='+lang+'&type=3';
    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onLoading: showLoad3, 
        onComplete: hideLoad3, 
        onSuccess:
        function(t){
            $('search_box_select_3').innerHTML=t.responseText;
        }
    });
}

function map_display_none(id1, id2, title1, title2)
{
    if(document.getElementById) {
        element1 = document.getElementById(id1);
        element2 = document.getElementById(id2);
        element3 = document.getElementById(title1);
        element4 = document.getElementById(title2);
    } else return;

    if(element1.style) {
        if(element1.style.display == 'block' ){
            element1.style.display = 'none';
            element2.style.display = 'block';
            element3.style.display = 'none';
            element4.style.display = 'block';
        } else {
            element2.style.display = 'none';
            element1.style.display = 'block';
            element4.style.display = 'none';
            element3.style.display = 'block';
        }
    }
}

function gMapLoad(url, country, lang)
{
    url = url.split('/');
    url = url.join(',');
    var postBody = 'action=gMapLoad&url='+url+'&country='+country+'&lang='+lang;
    new Ajax.Request('fileadmin/templates/ajax/ajax.php',{
        method:'post',
        postBody:postBody,
        onSuccess:
        function(t){
            alert(t.responseText);
            $('map').innerHTRML=t.responseText;
        }
    });
}

        
function div_toggle(element1, element2) {
    var div1 = document.getElementById(element1).className;

    if(div1=='hidden') {       
        document.getElementById(element2).className ='hidden';
        document.getElementById(element1).className ='img_arrow';
    } else {
        document.getElementById(element1).className ='hidden';
        document.getElementById(element2).className ='img_arrow2';
    }
    
    
//alert(element+' '+element2);

}


function showLoad1(){
    $('box_loader1').style.display='';
}

function hideLoad1(){
    $('box_loader1').style.display='none';
}

function showLoad2(){
    $('box_loader2').style.display='';
}

function hideLoad2(){
    $('box_loader2').style.display='none';
}

function showLoad3(){
    $('box_loader3').style.display='';
}

function hideLoad3(){
    $('box_loader3').style.display='none';
}
function showLoadSearch(){
    $('showLoadSearch').style.display='';
}

function hideLoadSearch(){
    $('showLoadSearch').style.display='none';
}


function changeDiscount(dir,box,current,l){
    var postBody = 'action=changeDiscount&dir='+dir+'&box='+box+'&current='+current+'&l='+l;
    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onSuccess:
        function(t){
            $('discount_box'+box).innerHTML=t.responseText;
        }
    });
}
function selectCountry(country) {
    $("charterCountry").value=country;
}

function ajaxSearchLoad(x)
{
    var search_boat_type = $("boatType").value;
    var search_area = $("charterArea").value;
    var search_country = $("charterCountry").value;
    var search_cabins = $("charterCabins").value;
    var day = $("scheduled_departure_day").value;
    var month_year = $("scheduled_departure_month_year").value;
    var region = $("charterRegion").value;
    //var ports = $("charterPort").value.replace(/^,|,$/,'');
    var ports = $$("input[port_id]").findAll(function(el) {
        return el.checked;
    }).invoke('getAttribute','port_id').join();
    var lang = $("lang").value;
    var searchdata = $("searchdata").value;

    var postBody = 'action=searchLoad&search_boat_type='+search_boat_type+'&search_area='+search_area+'&search_country='+search_country+'&search_cabins='+search_cabins+'&day='+day+'&month_year='+month_year+'&region='+region+'&lang='+lang+'&origsearchdata='+searchdata+'&ports='+ports;
        
    new Ajax.Request('fileadmin/templates/ajax/ajax.php', {
        method:'post', 
        postBody:postBody, 
        onLoading: showLoadSearch, 
        onComplete: hideLoadSearch, 
        onSuccess:
        function(t){
            $('tabSearch').innerHTML=t.responseText;
			if(x!='1'){
				$('refresh').innerHTML='('+document.search.submit_bt.value+')';
				$('refresh').style.display='';
				}
        }
    });
}

function searchLoadMap(link) {
    var postBody = 'action=searchLoadMap';

    new Ajax.Request(link, {
        method:'post', 
        postBody:postBody, 
        onLoading: showLoad3, 
        onComplete: hideLoad3, 
        onSuccess:
        function(t){
            $('top_search').innerHTML=t.responseText;
        }
    });
}

function setback(){
	if(Position.realOffset($('result_start'))[1]>640){
		$('goTop').style.display='';
	}
	else{
		$('goTop').style.display='none';
	}
}
