/**_______________________________________
*
*    bytefx :: simple effects in few bytes
* ---------------------------------------
* @author Andrea Giammarchi@site  http://www.devpro.it/bytefx/@requires		anything *
* old browsers (IE <= 5) should require JSL * @credits Matteo Galli (aka Ratatuia) for Safari debug, *Boyan Djumakov, for debug and reports (http://webnos.blogspot.com/)
* Copyright (c) 2006 Andrea Giammarchi * * Permission is hereby granted, free of charge, * to any person obtaining a copy of this software and associated * documentation files (the "Software"), * to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: *  * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. *  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
 */
bytefx = new function(){this.alpha = function(element, opacity){var	style = $element(element).style;style.opacity = style.MozOpacity = style.KhtmlOpacity = opacity / 100;style.filter = "alpha(opacity=" + opacity + ")";};this.clear = function(element){var	interval = ["size", "scroll", "move", "fade", "color"],index = interval.length;while(index--)clearInterval($element(element).bytefx[interval[index]]);};this.color = function(element, style, start, end, speed, callback){end = bytefx.color$(end);clearInterval($element(element).bytefx.color);element.bytefx.color = setInterval(function(){var	color = bytefx.color$(start),index = 3;while(index--)color[index] = $end(color[index], end[index], speed);element.style[style] = start = bytefx.$color(color);if("" + color == "" + end)$callback(element, "color", callback);}, 1);};this.drag = function(element, start, end, callback, position){function $callback(evt, callback){if(callback)callback.call(element, evt);return false;};var	tmp = $element(element).bytefx.drag;bytefx.$event(element, "onmousedown", function(evt){tmp.start = true;tmp.onmousedown = d.onmousedown;tmp.onmouseup = d.onmouseup;d.onmouseup = element.onmouseup;d.onmousedown = $callback;return $callback(evt, start);});bytefx.$event(element, "onmouseup", function(evt){tmp.start = false;d.onmousedown = tmp.onmousedown;d.onmouseup = tmp.onmouseup;return $callback(evt, end);});bytefx.$event(d, "onmousemove", function(evt){var	x = evt.clientX,y = evt.clientY,size = {x: x - tmp.x, y: y - tmp.y};if(tmp.start) {if(position) {size.x = max(size.x, position.$x);size.y = max(size.y, position.$y);size.x = min(size.x, position.x$);size.y = min(size.y, position.y$);};bytefx.position(element, size);$callback(evt, callback);}else{tmp.x = x - element.offsetLeft;tmp.y = y - element.offsetTop;};return false;});};this.fade = function(element, start, end, speed, callback){clearInterval($element(element).bytefx.fade);element.bytefx.fade = setInterval(function(){start = $end(start, end, speed);bytefx.alpha(element, start);if(start == end)$callback(element, "fade", callback);}, 1);};this.move = function(element, position, speed, callback){var	start = bytefx.$position($element(element));$setInterval(element, "move", speed / 100, start, position, ["x", "y"], "position", callback);};this.position = function(element, position){var	style = $element(element).style;style.position = "absolute";style.left = position.x + "px";style.top = position.y + "px";};this.scroll = function(element, speed, callback){function scroll(position){return d.documentElement ? d.documentElement[position] : d.body[position];};var	start = bytefx.$scroll(),end = {x:start.x, y:min(bytefx.$position(element).y, max(scroll("offsetHeight"), d.body.offsetHeight) - min(scroll("clientHeight"), d.body.clientHeight))};$setInterval($element(bytefx), "scroll", speed / 100, start, end, ["x", "y"], "scroll$", callback ? function(){callback.call(element)} : null);};this.size = function(element, size, speed, callback){var	start = bytefx.$size($element(element)),tmp = w.opera;if(!/msie/i.test(navigator.userAgent) || (tmp && parseInt(tmp.version()) >= 9)){if(size.$width)start.width -= size.$width;if(size.$height)start.height -= size.$height;if(size.width$)size.width -= size.width$;if(size.height$)size.height -= size.height$;};element.style.overflow = "hidden";$setInterval(element, "size", speed / 100, start, size, ["width", "height"], "size$", callback);};this.$color = function(color){function tmp(index){var	tmp = color[index].toString(16);return tmp.length == 1 ? "0" + tmp : tmp;};return "#" + tmp(0) + tmp(1) + tmp(2);};this.color$ = function(color){function tmp(index){return color.charAt(index);};color = color.substring(1);if(color.length == 3)color = tmp(0) + tmp(0) + tmp(1) + tmp(1) + tmp(2) + tmp(2);return [parseInt(tmp(0) + tmp(1), 16), parseInt(tmp(2) + tmp(3), 16), parseInt(tmp(4) + tmp(5), 16)];};this.$event = function(element, tmp, callback){var	value = element[tmp];element[tmp] = function(evt){if(!evt)evt = w.event;if(value)value.call(this, evt);return callback.call(this, evt);};};this.$position = function(element){var	position = {x:element.offsetLeft, y:element.offsetTop};while(element = element.offsetParent){position.x += element.offsetLeft;position.y += element.offsetTop;};return position;};this.$scroll = function(){function scroll(position, scroll){return (d.documentElement ? d.documentElement[position] : w[scroll] || d.body[position]) || 0;};return {x:scroll("scrollLeft", "pageXOffset"), y:scroll("scrollTop", "pageYOffset")};};this.scroll$ = function(element, position){w.scrollTo(position.x, position.y);};this.$size = function(element){return {width:element.offsetWidth, height:element.offsetHeight};};this.size$ = function(element, size){var	style = element.style;style.width = size.width + "px";style.height = size.height + "px";};function $callback(element, interval, callback){clearInterval(element.bytefx[interval]);if(callback)callback.call(element);};function $element(element){if(!element.bytefx)element.bytefx = {color:0, drag:{}, fade:0, move:0, scroll:0, size:0};return element;};function $end(x, y, speed){return x < y ? min(x + speed, y) : max(x - speed, y);};function $setInterval(element, interval, speed, start, position, style, tmp, callback){clearInterval(element.bytefx[interval]);element.bytefx[interval] = setInterval(function(){start[style[0]] += (position[style[0]] - start[style[0]]) * speed;start[style[1]] += (position[style[1]] - start[style[1]]) * speed;bytefx[tmp](element, start);if(round(start[style[0]]) == position[style[0]] && round(start[style[1]]) == position[style[1]]){bytefx[tmp](element, position);$callback(element, interval, callback);}}, 1);};var	w = window,d = document,max = Math.max,min = Math.min,round = Math.round;};
function smartRollover() {if(document.getElementsByTagName) {var images = document.getElementsByTagName("img");for(var i=0; i < images.length; i++) {if(images[i].getAttribute("src").match("_off.")){images[i].onmouseover = function() {this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));}
images[i].onmouseout = function() {this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));}}}}}

//roll over
bytefx.$event(window, "onload", function(){
	
	//*******************************
	//メインナビゲーションの画像置換
	//*******************************
	
	var loc = location.href;
	var nav = document.getElementById("nav");
	var navlist = nav.getElementsByTagName("img");
	
	//var urlprefix = "http://fukuryou.co.jp";
	var urlprefix = "http://www.fsp.co.jp/demo/fukuryou/";
	
	if(loc.indexOf("/news/") != -1 && loc.indexOf("/city_fukuoka.html") == -1 || loc.indexOf("/news.html") != -1){
		navlist[1].src = urlprefix+"/common/image/nav1_on.gif";
	}
	if(loc.indexOf("/house/") != -1 || loc.indexOf("/house.html") != -1){
		navlist[2].src = urlprefix+"/common/image/nav2_on.gif";
	}
	
	
	
	smartRollover();
	
	if(document.getElementById("totop")){
		var toTop = document.getElementById("totop");
		toTop.href = "javascript:void(0)";
		
		bytefx.$event(document.getElementById("totop"),"onclick",function(){
			execScroll("container");
		});
	}
	
	if(document.getElementById("totop2")){
		var toTop2 = document.getElementById("totop2");
		toTop2.href = "javascript:void(0)";
		
		bytefx.$event(document.getElementById("totop2"),"onclick",function(){
			execScroll("container");
		});
	}
	
	
	if(document.getElementById("anch0")){
		
		var anch0 = document.getElementById("anch0");
		anch0.href = "javascript:void(0)";
		
		var anch1 = document.getElementById("anch1");
		anch1.href = "javascript:void(0)";
		
		bytefx.$event(anch0,"onclick",function(){
		execScroll("anchor0");
		});
		bytefx.$event(anch1,"onclick",function(){
		execScroll("anchor1");
		});
	}
});


function execScroll(ele){
	bytefx.scroll(document.getElementById(ele), 10);
}

function wopen(file){
window.open(file,"win","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1000,height=650");
}
