// JavaScript for Skygate

function toggleContent(src, mid, title) {
	var effectDuration = 1.5;
	$('content_frame').innerHTML = '<div id="content_box"></div>';
	$('content_box').hide();
	new Ajax.Request(src, {
		method: 'get',
		onSuccess: function(transport) {
		$('content_box').innerHTML = transport.responseText;
		}
	});
	navItems = $('topnavi_list').childElements();
	//alert(navItems.length);
	for(i=0;i<navItems.length;i++) {
		navItems[i].className = "";
	}
	$(mid).className = 'active';
	/*
	$('l01').href = '/en/'+page;
	$('l02').href = '/de/'+page;
	*/
	window.document.title = title;
	new Effect.Appear('content_box', {duration: effectDuration});
	return false;
}

function calcPrice() {
	var f = $('input#mietflaeche').val();
    f.replace(/,/, '.');
	var fl = (f * 1) ? f : 'NaN';
	if(fl != '' && fl != 'NaN') {
		sgval = 7.5 * fl;
		gval = 18 * fl;
		val = gval - sgval;
		$('input#qm_skygate').val( sgval );
        $('input#qm_normal').val( gval );
		$('input#ersparnis').val( val );
	} else {
		alert('Bitte geben Sie eine korrekte Mietflaeche an');
	}
}

function chgImg(id) {
	$('img#gallery_bigimg').hide();
	$('img#galImgBig').attr( 'src', '/images/ansichten/ansicht_'+id+'_gross_gal.jpg' );
	thumbs = $('div#gallery_thumbs').children();
	for(i=0;i<thumbs.length;i++) {
		$(thumbs[i]).addClass( 'black' );
		$(thumbs[i]).removeClass( 'white' );
	}
	$("img#"+id).removeClass( 'black' );
	$("img#"+id).addClass( 'white' );
	$('img#gallery_bigimg').show();
}

function plop(openlink, iwidth, iheight)
	{
		userScreenWidth = screen.width;
		userScreenHeight = screen.height;
		posLeft = Math.abs((userScreenWidth - iwidth) / 2);
		posTop = Math.abs((userScreenHeight - iheight) / 2);
		<!--alert("userScreenWidth = " + userScreenWidth + "\nuserScreenHeight = " + userScreenHeight + "\nposLeft = " + posLeft + "\nposTop = " + posTop);-->
		popup = window.open(openlink, "PopUp", "width=" + iwidth + ",height=" + iheight + ",scrollbars=no,menubar=no,location=no,status=no,toolbar=no,resizable=no,top=" + posTop + ",left=" + posLeft);
		popup.focus();
	}
