// ==========================================
//	v3.6, singlepage
//	diverse CMS Standard JavaScript-Funktionen
// ==========================================

//--------- FLASH-Player per JS einbinden ---------
function write_player_8(player_src, player_width, player_height, bgcolor)
{
	var t = '';
	t += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + player_width + '" height="' + player_height + '" id="cms4d_flv_videoplayer_2007" align="middle">\n';
	t += '<param name="allowScriptAccess" value="sameDomain" />\n';
	t += '<param name="movie" value="' + player_src + '" />\n';
	t += '<param name="loop" value="false" />\n';
	t += '<param name="menu" value="false" />\n';
	t += '<param name="quality" value="high" />\n';
	t += '<param name="scale" value="noscale" />\n';
	t += '<param name="salign" value="lt" />\n';
	t += '<param name="bgcolor" value="' + bgcolor + '" />\n';
	t += '<embed src="' + player_src + '" loop="false" menu="false" quality="high" scale="noscale" salign="lt" bgcolor="' + bgcolor + '" width="' + player_width + '" height="' + player_height + '" name="cms4d_flv_videoplayer_2007" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
	t += '</object>\n';
//alert(t);
	document.writeln(t);
}


//------------- Standard neues Fenster öffnen ------------
function neuwindow(fenstername, url, w, h, status_flag, resize_flag, scroll_flag)
{
	var aw = screen.availWidth;
	var ah = screen.availHeight;
	if(w == null || h == null)
	{
		wb = screen.availWidth - 100;
		wh = screen.availHeight - 100;
	}
	else
	{
		wb = w;
		wh = h;
	}
	var wx = (aw / 2) - (wb / 2) - 6;
	var wy = (ah / 2) - (wh / 2) - 30;

	var status_enable = 1;
	if(status_flag != null)status_enable = status_flag;
	var scroll_enable = 1;
	if(scroll_flag != null)scroll_enable = scroll_flag;
	var resize_enable = 1;
	if(resize_flag != null)resize_enable = resize_flag;

	var fenster = window.open(url,fenstername,'toolbar=0,location=0,directories=0,status=' + status_enable + ',menubar=0,scrollbars=' + scroll_enable + ',resizable=' + resize_enable + ',Width=' + wb + ',height=' + wh + ',left=' + wx + ',top=' + wy);
	//return(fenster);
}



//------- Bild Zoomfunktion ----------
//Veraltet. Aus Gründen der Rückwärtskompatibilität vor v1.6 beibehalten !
function zoomwindow(url) 
{
	var wb = 300;
	var wh = 300;
	var sx = screen.width;
	var sy = screen.height;
	var wx = (sx / 2) - (wb / 2);
	var wy = (sy / 2) - (wh / 2);

	//WICHTIG: das window MUSS resizeable sein, da sonst Netscape 4.x
	//die Grösse nachträglich nicht ändern kann !

	zoomwin=window.open(url,'Zoom',"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,WIDTH=" + wb + ",HEIGHT=" + wh + ",left=0,top=0,left=" + wx + ",top=" + wy)
	zoomwin.focus();
}
//ab v3.6
function zoom(id)
{
	var url = 'cmszoom.asp?id=' + id;
	//WICHTIG: BasisURL der aufrufenden Seite einbeziehen.
	if(page_baseurl)
	{
		url = page_baseurl + url;
	}
	zoomwindow(url);
}

//Für Suche
function suche(obj)
{
	var such_str = obj.suchbegriff.value;
	if(such_str != '')
	{
		obj.submit();
	}
}

function clear_bs_suchstr(obj)
{
	var such_str = obj.value;
	if(such_str == 'Ihr Suchbegriff') obj.value = '';
}


//Gästebuch in neuem Fenster öffnen
function open_gb()
{
	var url = page_baseurl + '../gbuch';
	var fenstername = 'nextshopcms_gaestebuch';
	var wb = 800;
	var wh = 600;

	var aw = screen.availWidth;
	var ah = screen.availHeight;

	var wx = (aw / 2) - (wb / 2) - 6;
	var wy = (ah / 2) - (wh / 2) - 30;

	var gb = window.open(url,fenstername,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,Width=' + wb + ',height=' + wh + ',left=' + wx + ',top=' + wy);
	gb.focus();
}


//ImageMap öffnen
function imagemap(id)
{
	var url = 'cmsimagemaps.asp?map_id=' + id;
	var w = 800;
	var h = 600;
	var z = neuwindow('imagemap', url, w, h, 0,0,1)
}


//360° Panorama öffnen
function show_panorama(p)
{
	var url = '360-panoramen/default.asp?p=' + p;
	//var url = 'http://www.nextshop.de/traben-trarbach/360-panoramen/default.asp?p=' + p;
	var w = 460;
	var h = 430;
	var z = neuwindow('360_panorama', url, w, h, 1,0,0)
}


//Für Suche und Buchen Formular
function validateForm(form)
{
	var d = parseInt( form.SrchFromDay.value )
	var m = parseInt( form.SrchFromMonth.value )
	var j = parseInt( form.SrchFromYear.value )

	if ( !checkDate(d,m,j) )
	{
		alert("Datum inkorrekt!") ;
		form.SrchFromDay.focus();
		return false;
	}
	return true;
}

function checkDate( d, m, j )
{
	var dt = new Date( j, m-1, d )
	if ( dt.getDate() != d || dt.getMonth()+1 != m ) return false;
	return true;
}

function setCurrentDay()
{
	//
	// Set Quickfinder date to current day
	//
	var today = new Date();
	var today_day   = today.getDate();
	var today_month = today.getMonth();
	var today_year  = today.getFullYear();

	window.document.frmQuickFind.SrchFromDay.options[today_day-1].selected = true;
	window.document.frmQuickFind.SrchFromMonth.options[today_month].selected = true;
	window.document.frmQuickFind.SrchFromYear.options[0].value = today_year;
	window.document.frmQuickFind.SrchFromYear.options[0].text = today_year;
}

function submitFORM()
{
	if ( validateForm(window.document.frmQuickFind) )
	{

	//
	// Open a new window named 'srch_result'.
	//
	window.open('','srch_result','height=600,width=700,toolbar=no,scrollbars=yes,resizable=yes').focus();

	//
	// Submit Form. Target is 'srch_result' (see <form ..> tag above)
	//
	document.frmQuickFind.submit();

	}

}


function submitFORM_events()
{
	if ( validateForm(window.document.frmQuickFind_events) )
	{
		var d = parseInt( window.document.frmQuickFind_events.SrchFromDay.value );
		var m = parseInt( window.document.frmQuickFind_events.SrchFromMonth.value );
		var j = parseInt( window.document.frmQuickFind_events.SrchFromYear.value );

		var t = parseInt( window.document.frmQuickFind_events.SrchDays.value );

		var dt = new Date( j, m-1, d );

		var ndt = new Date( dt.getTime() +  t * 24 * 60 * 60 * 1000);

		var nd = ndt.getDate();
       		var nm = ndt.getMonth() + 1;
	       	var ny = ndt.getFullYear();

		window.document.frmQuickFind_events.SrchToDay.value = nd;
		window.document.frmQuickFind_events.SrchToMonth.value = nm;
		window.document.frmQuickFind_events.SrchToYear.value = ny;

		window.open('','srch_result','height=600,width=700,toolbar=no,scrollbars=yes,resizable=yes').focus();

		document.frmQuickFind_events.submit();
	}
}

function setCurrentDay_events()
{
	var today = new Date();
	var today_day   = today.getDate();
	var today_month = today.getMonth();
	var today_year  = today.getFullYear();

	if(window.document.frmQuickFind_events)
	{
		window.document.frmQuickFind_events.SrchFromDay.options[today_day-1].selected = true;
		window.document.frmQuickFind_events.SrchFromMonth.options[today_month].selected = true;
		window.document.frmQuickFind_events.SrchFromYear.options[0].value = today_year;
		window.document.frmQuickFind_events.SrchFromYear.options[0].text = today_year;
	}
}
	



//Für Wetter
function write_wetter_flash()
{
	var t = '';
	t += '<object id="deutschland" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" height="150" width="100%">';
	t += '<param name="movie" value="http://wetter.rtl.de/extern/generell/generator/deutschland/wetter_home.swf?id=165075&key=059169d95e8b8e83a46905b9c6e633af">';
	t += '<param name="menu" value="false"/>';
	t += '<param name="quality" value="high"/>';
	t += '<param name="bgcolor" value="#FAF0D2"/>';
	t += '<embed height="150" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" src="http://wetter.rtl.de/extern/generell/generator/deutschland/wetter_home.swf?id=165075&key=059169d95e8b8e83a46905b9c6e633af" quality="high" menu="false" bgcolor="#FAF0D2" type="application/x-shockwave-flash" width="100%">';
	t += '</object>';
	document.write(t);
}