function respondToColorClick(event) {
	// set element variable fo rthe current event
	var element = event.element();
	// get array of all color links
	var all_paper_menu_color_links = $('paper_menu_colors').getElementsByClassName('paper_menu_attribute_link');
	// loop through array of all color links	
	//for ( var color = 0; color < all_paper_menu_color_links.size(); color++ ) {
	for ( var color = 0; color < 3; color++ ) {
		// identify currently active color
		if(all_paper_menu_color_links[color].hasClassName('paper_menu_attribute_link_active')) {
			// remove class that shows color link as active
			all_paper_menu_color_links[color].removeClassName('paper_menu_attribute_link_active');
		}
    }
	// turn link on for current element (newly activated color) only
	element.addClassName('paper_menu_attribute_link_active');
	// set new color variable based on the id of the current element
	var new_color = element.identify();
	// get array of all view links
	var all_paper_menu_view_links = $('paper_menu_views').getElementsByClassName('paper_menu_attribute_link');
	// loop through array of all view links	
	//for ( var view = 0; view < all_paper_menu_view_links.size(); view++ ) {	
	for ( var view = 0; view < 3; view++ ) {	
		// identify currently active view
		if(all_paper_menu_view_links[view].hasClassName('paper_menu_attribute_link_active')) {
			// set current view variable to the id of the currently active view
			var current_view = all_paper_menu_view_links[view].identify();
		}
    }
	// set wallpaper background image using the new color and the current view
	//alert("new_color = " + new_color);
	//alert("current_view = " + current_view);
	setWallpaper(new_color,current_view);
}

function respondToViewClick(event) {
	// set element variable fo rthe current event
	var element = event.element();
	// get array of all view links
	var all_paper_menu_view_links = $('paper_menu_views').getElementsByClassName('paper_menu_attribute_link');
	// loop through array of all view links	
	//for ( var view = 0; view < all_paper_menu_view_links.size(); view++ ) {
	for ( var view = 0; view < 3; view++ ) {
		// identify currently active view
		if(all_paper_menu_view_links[view].hasClassName('paper_menu_attribute_link_active')) {
			// remove class that shows view link as active
			all_paper_menu_view_links[view].removeClassName('paper_menu_attribute_link_active');
		}
    }
	// turn link on for current element (newly activated view) only
	element.addClassName('paper_menu_attribute_link_active');
	// set new view variable based on the id of the current element
	var new_view = element.identify();
	// get array of all color links
	var all_paper_menu_color_links = $('paper_menu_colors').getElementsByClassName('paper_menu_attribute_link');
	// loop through array of all color links	
	//for ( var color = 0; color < all_paper_menu_color_links.size(); color++ ) {	
	for ( var color = 0; color < 3; color++ ) {	
		// identify currently active color
		if(all_paper_menu_color_links[color].hasClassName('paper_menu_attribute_link_active')) {
			// set current color variable to the id of the currently active color
			var current_color = all_paper_menu_color_links[color].identify();
		}
    }
	// set wallpaper background image using the current color and the new view
	//alert("new_view = " + new_view);
	//alert("current_color = " + current_color);
	setWallpaper(current_color,new_view);
}

function syncLinkColors(color,view) {
	$('' + color + '').addClassName('paper_menu_attribute_link_active');
	$('' + view + '').addClassName('paper_menu_attribute_link_active');
}

function syncDetails(color) {
	$('paper_details_text_color').update('Color: ' + $('' + color + '').readAttribute('details_color'));
}

function setWallpaper(color, view) {
	//alert("setWallpaper called.");
	// check to see that the active links are correct and make corrections if necessary
	syncLinkColors(color,view);
	// change the content within the details module
	syncDetails(color);	
	// construct paper background image path
	paper_background_image_path = '/images/collection/' + pattern + '/' + color + '/' + view + '.gif';
	// set paper background
	$('paper').setStyle({background:'url(' + paper_background_image_path + ')'});
}
