/*********************************************************
 * NaaN Grafix - We rock the web                         *
 * Projekt: Juss.at                                      *
 *********************************************************/
 
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

 
jQuery(function( $ ){
	var viewportHeight = $(window).height();
	var availableHeight = viewportHeight-591;
	
	var contentHeight = $('div#containerContent').height();
	if( $('div#containerContent').height() < availableHeight ) {
		var contentHeight = availableHeight;
		$('div#containerContent').height(contentHeight+'px');
		if( $('div#content').height() < contentHeight-130 ) {
			$('div#content').height((contentHeight-130)+'px');
		}
	}
	
	var sidebarHeight = $('div#sidebar').height();
	var elemDiff = 165;
	if( (contentHeight+elemDiff) < sidebarHeight ) {
		$('div#containerContent').height(sidebarHeight-elemDiff+'px');
	}
	else { $('div#sidebar').height( (contentHeight+elemDiff) +'px'); }
	
	$('div#footerToTop a').click(function(){
		$.scrollTo( 0, 300 );
	});
	//$('div.pageBrowserPageLinkInner span.pageBrowserLinkCont:last span').css('background-image', 'none');
});







function fillQuickAnfrageForm($, lang) {
	if( lang=='en' ) {
		monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	}
	else {
		monthNames = new Array("Jannuar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
	}
	
	// days
	var dayOptionsHtml = '';
	for( i=0; i<=31; i++ ) {
		if( i==0 ) {
			dayOptionsHtml = dayOptionsHtml + "\n"+'<option value="0">--</option>';
		}
		else {
			dayOptionsHtml = dayOptionsHtml + "\n"+'<option value="'+i+'">'+i+'</option>';
		}
	}
	$("#from_d").html(dayOptionsHtml);
	$("#to_d").html(dayOptionsHtml);
	
	// month
	var monthOptionsHtml = '';
	for( i=0; i<=11; i++ ) {
		monthOptionsHtml = monthOptionsHtml + "\n"+'<option value="'+(i+1)+'">'+ monthNames[i] +'</option>';
	}
	$("#from_m").html(monthOptionsHtml);
	$("#to_m").html(monthOptionsHtml);
	
	// year
	var yearOptionsHtml = '';
	var yearDateObj = new Date();
	var currYear = yearDateObj.getFullYear();
	for( i=currYear; i<=currYear+4; i++ ) {
		yearOptionsHtml = yearOptionsHtml + "\n"+'<option value="'+i+'">'+i+'</option>';
	}
	$("#from_y").html(yearOptionsHtml);
	$("#to_y").html(yearOptionsHtml);
	
	//preselect
	//getNextSaturday("to_d", "to_m", "to_y", getNextSaturday("from_d", "from_m", "from_y"));
    var currPageID = getURLParam(location.href, "id");
    var fromDay = getURLParam(location.href, "from_d");

    if( currPageID==50 && fromDay>0 ) {
        var fromDate = getURLParam(location.href, "from_d")+"."+getURLParam(location.href, "from_m")+"."+getURLParam(location.href, "from_y");
        var toDate = getURLParam(location.href, "to_d")+"."+getURLParam(location.href, "to_m")+"."+getURLParam(location.href, "to_y");

		document.getElementById("uid39_hr").value = fromDate;
		document.getElementById("uid40_hr").value = toDate;

		document.getElementById("from_d").value   = getURLParam(location.href, "from_d");
		document.getElementById("from_m").value = getURLParam(location.href, "from_m");
		document.getElementById("from_y").value  = getURLParam(location.href, "from_y");

		document.getElementById("to_d").value   = getURLParam(location.href, "to_d");
		document.getElementById("to_m").value = getURLParam(location.href, "to_m");
		document.getElementById("to_y").value  = getURLParam(location.href, "to_y");
    }
    else {
		getNextSaturday("to_d", "to_m", "to_y", getNextSaturday("from_d", "from_m", "from_y"));
    }

	
	
	
}


function getNextSaturday(dayId, monthId, yearId, giveDate) {
	giveDate = giveDate||false;

	if( giveDate ) { today = giveDate; }
	else { today = new Date(); }

	year = today.getFullYear();
	month = today.getMonth()+1;
	day = today.getDate();
	dayOfWeek = today.getDay();

	if( dayOfWeek == 6 ) {
		newDay = day+7;
	}
	else {
		addDays = 6-dayOfWeek;
		newDay = day+addDays;
	}

	newDate = new Date( year, month-1, newDay );

	newDay = newDate.getDate();
	newMonth = newDate.getMonth()+1;
	newYear = newDate.getFullYear();

	document.getElementById(dayId).value = newDay;
	document.getElementById(monthId).value = newMonth;
	document.getElementById(yearId).value = newYear;

	return( newDate );
}

function getURLParam(srch, strParamName) {
	var strReturn = "";
	var strHref = srch;
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ) {
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return unescape(strReturn);
}







