$(window).bind("load",function(){

$("#pagetop").click(function(){
	pageScroll();
	return false;
});

bodyHeight();
recentList();
$(window).resize(function(){
bodyHeight();
recentList();
});

});

$(document).ready(function(){
//$(window).bind("load",function(){
//$(function(){

//////////////////////

var aPreLoad = new Array();
var sTempSrc;
var aImages = document.getElementsByTagName('img');
for (var i = 0; i < aImages.length; i++) {
	var tgtClass = aImages[i].className;
	if (tgtClass == 'btn') {
		var src = aImages[i].getAttribute('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(ftype, '_o'+ftype);
		aImages[i].setAttribute('hsrc', hsrc);
		aImages[i].setAttribute('dsrc', src);
		aPreLoad[i] = new Image();
		aPreLoad[i].src = hsrc;
		
		if(aImages[i].parentNode.className == "sel") {
			aImages[i].setAttribute('src', hsrc);
			continue;
		}
		aImages[i].onmouseover = function() {
			this.setAttribute('src', this.getAttribute('hsrc'));
		}
		aImages[i].onmouseout = function() {
			this.setAttribute('src', this.getAttribute('dsrc'));
		}
	}
	
	if (tgtClass == 'tab') {
		var src = aImages[i].getAttribute('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(ftype, '_o'+ftype);

		aImages[i].setAttribute('hsrc', hsrc);
		aPreLoad[i] = new Image();
		aPreLoad[i].src = hsrc;
		
		aImages[i].setAttribute('dsrc', src);
	}
}


//////////////////////

if($("body#index").size()) {
	$("#recent").height($("#recent li:eq(0)").height());
	$("#recent li").each(function(){
		$(this).mouseover(function(){
		$(".textbox", $(this)).stop(true, false).animate({
		opacity:1
		}, "fast");
		});
		$(this).mouseout(function(){
		$(".textbox", $(this)).stop(true, false).animate({
		opacity:0
		}, "fast");
		});
	});
	
	$("#menu li:last a").mouseover(function(){
		recentApper(1);
	});
	$("#menu li:last a").mouseout(function(){
		recentApper(0);
	});
}

//////////////////////

if($("body#company").size()) {
	$("#panes").insertAfter("#content");
	if($.browser.msie && $.browser.version < 7) {
	$(".pane").css('background-image','url(../img/company_paper_png8.png)');
	}
}



});

////////////////////////////////////////////

function pageScroll(o){
	if(!o) o=0;
	$.scrollTo(o,250);
}

function bodyHeight() {
	if(!$.browser.msie) {
		$(document.body).height($("#wrapper").height());
	}else{
		$("#footer").css({'bottom':0});
	}
}


function recentList() {
	//var baseWidth = $("#recent").width();
	var baseWidth = $("#page").width();//-190
	var totalWidth = 0;
	var offFlag = false;
	$("#recent li").each(function(){
		totalWidth += $(this).width()+30;
		if(totalWidth > baseWidth){
			$(this).hide();
		}else{
			$(this).show();
		}
	});
}

function recentApper(n){
	if(n==1){
		$("#recent .textbox").each(function(){
			$(this).animate({
			opacity:1
			}, "fast");
		});
	}else{
		$("#recent .textbox").each(function(){
			$(this).animate({
			opacity:0
			}, "fast");
		});
	}
}


function companyPane(n) {
	if(n==1){
		$("#profile").show();
		$("#map").hide();
	}else if(n==2){
		$("#map").show();
		$("#profile").hide();
	}else{
		$("#map").hide();
		$("#profile").hide();
	}
	return false;
}

