// ==================================================================================
// Avatar Constructor - Dressing Room
// ==================================================================================

	function init() { 

		focus();
		toolTipsEnable=1;
	//	if(ie) { document.body.scroll="yes"; }
		setImage();

		return 0;
	}

// ==================================================================================

	function cacheButtons() {
	
		var imagesArr = new Array();
		var maxNum = numStyleBut > numColorBut ? numStyleBut : numColorBut;
		for(i=1,k=0; i < maxNum + 1; i++) {
		
			imagesArr[k] = new Image();
			imagesArr[k].src = imgDir + "/buttons/active/" + i + defPostfix;
			k++;
			imagesArr[k] = new Image();
			imagesArr[k].src = imgDir + "/buttons/active/" + i + overPostfix;
			k++;
		}
		
		imagesArr[k] = new Image();
//		imagesArr[k].src = imgDir + "/save_down.gif";
		
		return 0;
	}

// ==================================================================================
// new wave ...
// ==================================================================================

	function setImage() {

		var room=document.forms.roomForm.room_image;
		showButton(room.value.substring(0,1),room.value.substring(1,2));
		var roomPref=document.forms.roomForm.room;

		imgSrc=location.protocol+"//"+location.host+"/lc/images/private_rooms/room_constructor/"+roomPref.value+room.value+".jpg";
		document.images.room.src=imgSrc;

		return 0;
	}

// ==================================================================================

	function showButton(num_style, num_color) {

		for(i=1; i<numStyleBut+1; i++) { document.images["s"+i].src = imgDir + "/buttons/active/" + i + defPostfix; }
		for(i=1; i<numColorBut+1; i++) { document.images["c"+i].src = imgDir + "/buttons/active/" + i + defPostfix; }

		document.images["s"+num_style].src = imgDir + "/buttons/active/" + num_style + overPostfix;
		document.images["c"+num_color].src = imgDir + "/buttons/active/" + num_color + overPostfix;
	}

// ==================================================================================

	function testButton(but_name, but_part) {
	
		num_but = parseInt(but_name.substring(1));

		if(but_part == "style") { setRoomStyle(num_but); setImage(); }
		if(but_part == "color") { setRoomColor(num_but); setImage(); }
	}

// ==================================================================================

	function makeStyleButton() {

		for(i=1; i<numStyleBut+1; i++) {
		
			document.write("<a name='b" + i + "' href='#' onclick='testButton(\"b" + i + "\", \"style\"); return false;'>");
			document.write("<img name='s" + i + "' src='" + imgDir + "/buttons/active/" + i + defPostfix + "' border='0'>");
			document.write("</a>");
		}

		return 0;
	}

// ==================================================================================

	function makeColorButton() {

		for(i=1; i<numColorBut+1; i++) {
		
			document.write("<a name='b" + i + "' href='#' onclick='testButton(\"b" + i + "\", \"color\"); return false;'>");
			document.write("<img name='c" + i + "' src='" + imgDir + "/buttons/active/" + i + defPostfix + "' border='0'>");
			document.write("</a>");
		}

		return 0;
	}

// ==================================================================================

	function setRoomColor(colorNum) {
	
		var room=document.forms.roomForm.room_image;
		roomStyle=room.value.substring(0,1);
		colorNum=parseInt(colorNum);
		room.value=roomStyle+colorNum;
	
		return 0;
	}

// ==================================================================================

	function setRoomStyle(styleNum) {
	
		var room=document.forms.roomForm.room_image;
		roomColor=room.value.substring(1,2);
		styleNum=parseInt(styleNum);
	    room.value=styleNum+roomColor;
	
		return 0;
	}

// ==================================================================================

	function saveRoom() {
	
//		document.images.save.src=imgDir + "/save_down.gif";
		
		if(!is_save_press) {

			is_save_press = true;
			document.forms.roomForm.submit();
		}

		return 0;
	}

// ==================================================================================
// ==================================================================================

