// Funktion um Flash ohne den Mist von Microsoft dazustellen
function showFlash(src, movie, width, height)
{
    document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\"" +width+ "\" height=\"" +height+ "\" align=\"middle\" id=\"" +movie+ "\">");
		document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
    document.write("<param name=\"movie\" value=\"" +src+ "\" />");
    document.write("<param name=\"quality\" value=\"high\" />");
		document.write("<param name=\"wmode\" value=\"transparent\" />");
    document.write("<embed src=\"" +src+ "\" swLiveConnect=\"true\" quality=\"high\" wmode=\"transparent\" allowScriptAccess=\"sameDomain\" width=\"" +width+ "\" height=\"" +height+ "\" align=\"middle\" name=\"" +movie+ "\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");
    document.write("</object>");
}

function picview(src){
	
	document.getElementById("img-holder").src = src;
	document.getElementById("pic-holder").style.visibility = 'visible';
	
}

function pichide(){
	document.getElementById("pic-holder").style.visibility = 'hidden';
	document.getElementById("img-holder").src = '/images/loading.gif';
	
}

function edit(id,name,typ,start,end){
	
	var start_day = start.substr(8, 2);
	var start_month = start.substr(5, 2);
	var start_year = start.substr(0, 4);
	
	var end_day = end.substr(8, 2);
	var end_month = end.substr(5, 2);
	var end_year = end.substr(0, 4);
	
	var allMonths = new Array('Jänner','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');
	
	//var row = document.getElementById("tr"+id);
  //row.innerHTML = '';
	
	var td = document.createElement('td');
	td.setAttribute("colspan","6");
	td.setAttribute("class","no-padding");
	var table = document.createElement('table');
	table.setAttribute("border","0");
	table.setAttribute("cellpadding","0");
	table.setAttribute("cellspacing","0");
	var tr = document.createElement('tr');
	
	var form = document.createElement('form');
	form.setAttribute("action","index.php");
	form.setAttribute("name","edit"+id);
	form.setAttribute("method","post");
		
	var name_td = document.createElement('td');
	name_td.setAttribute("class","name");
	
	var name_input = document.createElement('input');
	name_input.setAttribute("type","text");
	name_input.setAttribute("name","name");
	name_input.setAttribute("value",name);
	
	var typ_td = document.createElement('td');
	typ_td.setAttribute("class","typ");
	
	var typ_select = document.createElement('select');
	typ_select.setAttribute("name","typ");
	var option_buchung = document.createElement('option');
	option_buchung.setAttribute("value","Buchung");
	var text_buchung = document.createTextNode("Buchung");
	option_buchung.appendChild(text_buchung);
	if(typ == 'Buchung') option_buchung.setAttribute("selected", "selected");
	var option_reservierung = document.createElement('option');
	option_reservierung.setAttribute("value","Reservierung");
	var text_reservierung = document.createTextNode("Reservierung");
	option_reservierung.appendChild(text_reservierung);
	if(typ == 'Reservierung') option_reservierung.setAttribute("selected", "selected");
	typ_select.appendChild(option_buchung);
	typ_select.appendChild(option_reservierung);
	
	var start_td = document.createElement('td');
	start_td.setAttribute("class","start");
	
	var start_select_day = document.createElement('select');
	start_select_day.setAttribute("name","day_start");
	for (var i = 1; i <= 31; i++){
		var option = document.createElement('option');
		option.setAttribute("value",i);
	  var text = document.createTextNode(i);
	  option.appendChild(text);
		if(i == start_day) option.setAttribute("selected","selected");
		start_select_day.appendChild(option);
	}
	var start_select_month = document.createElement('select');
	start_select_month.setAttribute("name","month_start");
	start_select_month.setAttribute("class","month");
	for (var i = 1; i <= 12; i++){
		var option = document.createElement('option');
		option.setAttribute("value",i);
	  var text = document.createTextNode(allMonths[i-1]);
	  option.appendChild(text);
		if(i == start_month) option.setAttribute("selected","selected");
		start_select_month.appendChild(option);
	}
	var start_select_year = document.createElement('select');
	start_select_year.setAttribute("name","year_start");
	for (var i = parseInt(start_year)-2; i <= parseInt(start_year)+4; i++){
		var option = document.createElement('option');
		option.setAttribute("value",i);
	  var text = document.createTextNode(i);
	  option.appendChild(text);
		if(i == start_year) option.setAttribute("selected","selected");
		start_select_year.appendChild(option);
	}
	
	var end_td = document.createElement('td');
	end_td.setAttribute("class","end");
	
	var end_select_day = document.createElement('select');
	end_select_day.setAttribute("name","day_end");
	for (var i = 1; i <= 31; i++){
		var option = document.createElement('option');
		option.setAttribute("value",i);
	  var text = document.createTextNode(i);
	  option.appendChild(text);
		if(i == end_day) option.setAttribute("selected","selected");
		end_select_day.appendChild(option);
	}
	var end_select_month = document.createElement('select');
	end_select_month.setAttribute("name","month_end");
	end_select_month.setAttribute("class","month");
	for (var i = 1; i <= 12; i++){
		var option = document.createElement('option');
		option.setAttribute("value",i);
	  var text = document.createTextNode(allMonths[i-1]);
	  option.appendChild(text);
		if(i == end_month) option.setAttribute("selected","selected");
		end_select_month.appendChild(option);
	}
	var end_select_year = document.createElement('select');
	end_select_year.setAttribute("name","year_end");
	for (var i = parseInt(end_year)-2; i <= parseInt(end_year)+4; i++){
		var option = document.createElement('option');
		option.setAttribute("value",i);
	  var text = document.createTextNode(i);
	  option.appendChild(text);
		if(i == end_year) option.setAttribute("selected","selected");
		end_select_year.appendChild(option);
	}
	
	var submit_td = document.createElement('td');
	submit_td.setAttribute("class","submit");
	
	var submit_ = document.createElement('input');
	submit_.setAttribute("type","submit");
	submit_.setAttribute("value","Save");
	
	var hidden_step = document.createElement('input');
	hidden_step.setAttribute("type","hidden");
	hidden_step.setAttribute("name","step");
	hidden_step.setAttribute("value",2);
	
	var hidden_id = document.createElement('input');
	hidden_id.setAttribute("type","hidden");
	hidden_id.setAttribute("name","id");
	hidden_id.setAttribute("value",id);
	
	name_td.appendChild(name_input);
	tr.appendChild(name_td);
		
	typ_td.appendChild(typ_select);
	tr.appendChild(typ_td);

	start_td.appendChild(start_select_day);
	var space = document.createTextNode(" ");
	start_td.appendChild(space);
	start_td.appendChild(start_select_month);
	var space = document.createTextNode(" ");
	start_td.appendChild(space);
	start_td.appendChild(start_select_year);
	tr.appendChild(start_td);
	
	end_td.appendChild(end_select_day);
	var space = document.createTextNode(" ");
	end_td.appendChild(space);
	end_td.appendChild(end_select_month);
	var space = document.createTextNode(" ");
	end_td.appendChild(space);
	end_td.appendChild(end_select_year);
	tr.appendChild(end_td);
	
	submit_td.appendChild(submit_);
	submit_td.appendChild(hidden_step);
	submit_td.appendChild(hidden_id);
	tr.appendChild(submit_td);
	
	table.appendChild(tr)
	form.appendChild(table)
	
	td.appendChild(form);
	//row.appendChild(form);
	
	Element.update("tr"+id, td);
}
