var acePopupWindow=null;
function insurance(){
    if (document.all['INSURANCE'].checked==true){
       document.getElementById('ensurancediv').style.visibility='visible';
       document.getElementById('noensurancediv').style.visibility='hidden';
    } else {
       document.getElementById('ensurancediv').style.visibility='hidden';
       document.getElementById('noensurancediv').style.visibility='visible';
    }
}
function acePopup(mypage,myname,w,h,pos,infocus)
{
        if(pos=='random')
                {
                        LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
                        TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
                }
        if(pos=='center')
                {
                        LeftPosition=(screen.width)?(screen.width-w)/2:100;
                        TopPosition=(screen.height)?(screen.height-h)/2:100;
                }
        else
                if((pos!='center' && pos!='random') || pos==null){LeftPosition=100;TopPosition=100;}
                        settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,dependent=no';
        acePopupWindow=window.open('',myname,settings);
        if(infocus=='back')
        {
                acePopupWindow.blur();
                acePopupWindow.location=mypage;
                acePopupWindow.blur();
        }
        else
                acePopupWindow.location=mypage;
 return false;
}



function openMess(user)
{
        myname='mess_window'+user;
        LeftPosition=20;
        TopPosition=50;
        w=300;
        h=400;
        settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no';
        PopupWindow=window.open('',myname,settings);
        PopupWindow.location="messenger.php?action=runmess&mode=app&id="+user;
}


function addBookmark()
{
        window.external.addFavorite('http://stuzim.com.il/', 'stuzim.com.il');
        return false;
}

function openInfo(what, id, wi, he)
{
        myname='Preview_'+ what;
        LeftPosition=(screen.width)?(screen.width-wi)/2:100-wi;
        TopPosition=(screen.height)?(screen.height-he)/2:100-he;
        w=wi+100;
        h=he+200;
        settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no';
        PopupWindow=window.open('',myname,settings);
        PopupWindow.location="info.php?action=" + what + "&id=" + id;
}

function cleaner(frm) {
        for(i=0;i<(frm.elements.length-1);i++){
                if( (frm.elements[i].type == "radio") || (frm.elements[i].type == "checkbox") ) frm.elements[i].checked=0;
                if( (frm.elements[i].type == "select") ) frm.elements[i].selected=0;
                if( (frm.elements[i].type == "text") ) frm.elements[i].value="";
        }
}

function setvis(id){
        if (id=='fluss'){
                document.getElementById('fluss').style.visibility='visible';
                document.getElementById('ship_fluss').style.visibility='visible';
                document.getElementById('all').style.visibility='hidden';
                document.getElementById('all').selectedIndex=0;
                document.getElementById('hochsee').style.visibility='hidden';
                document.getElementById('hochsee').selectedIndex=0;
                document.getElementById('ship_hochsee').style.visibility='hidden';
                document.getElementById('ship_hochsee').selectedIndex=0;
                } else {
                document.getElementById('fluss').style.visibility='hidden';
                document.getElementById('fluss').selectedIndex=0;
                document.getElementById('ship_fluss').style.visibility='hidden';
                document.getElementById('ship_fluss').selectedIndex=0;
                document.getElementById('all').style.visibility='hidden';
                document.getElementById('all').selectedIndex=0;
                document.getElementById('hochsee').style.visibility='visible';
                document.getElementById('ship_hochsee').style.visibility='visible';
                }

        }


function changePassagier(value,id,where)
{
         document.getElementById(where).value=value;
}

function GetDatum(offset) { 
	var DatArray = new Array("So","Mo","Di","Mi","Do","Fr","Sa","??" );
	var time = new Date();
	
	time.setTime( time.getTime()+offset*86400000);
	tag = time.getDate();
	monat   = time.getMonth()+1;
	jahr    = time.getYear();
	if (tag   < 10)   tag   = "0"+tag;
	if (monat < 10)   monat = "0"+monat;
	if (jahr  < 2000) jahr += 1900;
	
	return tag+'.'+monat+'.'+jahr+' - '+DatArray[time.getDay()];
}

function sel_von() {
    document.write('Von: <select name="vnd" size="1" style="width:130px">');

    for (var i=1; i<=364; i++) {
        var sel='';
        if (i==7) sel=' selected';
        document.write('<option'+sel+' value='+i+'>'+GetDatum(i)+'</option>')
    }
    document.write('</select>');
}

function sel_bis() {
    document.write('Bis: <select name="bsd" size="1" style="width:130px">');
    for (var i=3; i<=365; i++) {
        var sel='';
        if (i==21) sel=' selected';
        document.write('<option'+sel+' value='+i+'>'+GetDatum(i)+'</option>')
    }
    document.write('</select>');
}

function setFromToDate(id){
	var selectBoxFrom = document.getElementById(id + "_yymm");
	var selectBoxDay = document.getElementById(id + "_dd");
	var monthes = new Array("Jan.","Feb.","Mär.","Apr.","Mai","Jun.","Jul.","Aug.","Sep.","Okt.","Nov.","Dez.");
	var curDate = new Date();
	var curYear = curDate.getFullYear();
	var curMonth = curDate.getMonth();
	var curDay = curDate.getDate();
	var deltaDays;
	if(id == "von")
		deltaDays = 1;
	else
		deltaDays = 16;
		
	var curOpenedDate = new Date();
	curOpenedDate.setFullYear(curYear,curMonth,curDay + deltaDays);
		
	if(selectBoxFrom){

		var years = new Array(curYear,curYear + 1);
	
		var maxMonthesAmount = 12;
		var monthesCounter = 0;
		// fill in monthes/years boxes
		for(var j =0; j< years.length;j++){
			for(var i =0; i< monthes.length;i++){
				var myDate = new Date();
				myDate.setFullYear(years[j],i);
				if(myDate >= curDate && monthesCounter <= maxMonthesAmount){
					var newOption = document.createElement("option");
					newOption.innerHTML = monthes[i] + " " + years[j];
					var showMonth = myDate.getMonth() + 1;
					if(showMonth < 10) showMonth = "0" + showMonth;
					newOption.value = years[j] + "-" + showMonth;
					newOption.label = newOption.innerHTML;
					selectBoxFrom.appendChild(newOption);
					monthesCounter++;
				}
			}
		}
		
		// set selected index for monthes/years boxes
		for (var i=0; i < selectBoxFrom.length;i++){
			stringDate = new String(selectBoxFrom.options[i].value);
			if((stringDate.substr(0,4) == curOpenedDate.getFullYear()) && (stringDate.substr(5,2) == (curOpenedDate.getMonth()) + 1)){
				selectBoxFrom.options[i].selected = true;
			}
		}
	}
	
	if(selectBoxDay){
		for (var i=0; i < selectBoxDay.length;i++){
			if(selectBoxDay.options[i].value == curOpenedDate.getDate()){
				selectBoxDay.options[i].selected = true;
			}
		}
	}
	return true;
}