$(document).ready(function(){
	var qs = window.top.location.search.substring(1);
	var destination = getParameter(qs, "destination");
	$("select#destinationWidgetOnCommunitySplashPageSelect option").each(function(){
		if( $(this).val() == destination ){
			$(this).attr("selected", "selected");
		}
	});

	  $(window).load(function(){
//		$('.sl_photowidget_table tr').eq(0).addClass('test');
		var count_trs = 1;
		for( count_trs; count_trs < 5; count_trs++ ){
			$('.sl_photowidget_table tr').eq(count_trs).css('backgroundColor', '#f3f3f3');
			$('.sl_photowidget_table tr').eq(count_trs).click( function(){
				apply_polaroid_frame( $('div#sl_PhotosWidget_0_gallery_space_main a img '),'large' );
			});
		}
	  });
});

function getParameter(queryString, parameterName) {
	if (queryString == null) {
		return "null";
	}
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	if (queryString.length > 0) {
		// Find the beginning of the string
		begin = queryString.indexOf(parameterName);
		// If the parameter name is not found, skip it, otherwise return the value
		if (begin != -1) {
			// Add the length (integer) to the beginning
			begin += parameterName.length;
			// Multiple parameters are separated by the "&" sign
			end = queryString.indexOf("&", begin);
			if (end == -1) {
				end = queryString.length
			}
			// Return the string
			return unescape(queryString.substring(begin, end));
		}
		// Return "null" if no parameter has been found
		return "null";
	}
}
