// Initialization
$.page = {
	init: function() {
		for (module in $.page) {
			if ($.page[module].init)
				$.page[module].init();
		}
	}
};

$(document).ready($.page.init);

$.page.fn = {
	init: function() {
		$('a').not('.outerText, .naviImage').bind('click', this.click);
		$(window).bind('unload', this.unload);
	},
	click: function() {
		var t;var l;var w;var h;
		var isLink = ($(this).attr('class').match(/linkNone/))?true:false;
		if(isLink) return false;
		var loc = this.href;
		var isSplash = ($(this).attr('class').match(/splash/))?true:false;
		if(isSplash){
			var t = (screen.height-($(window).height() + 110))/2;
			var l = (screen.width-$(window).width())/2;
			t=0;l=0;w=screen.availWidth;h=screen.availHeight;
			winObj = window.open(loc, 'SplashWindow', "toolbar=yes,resizable=yes,height="+h+",width="+w+",left="+l+",screenX="+l+",top="+t+",screenY="+t);
			winObj.focus();
			swfobject.embedSWF("/assets/apps/sound.swf", "sounds", "0", "0", "9.0.0", "expressInstall.swf");
			return false;
		}
		var isPopup = ($(this).attr('class').match(/popup/))?true:false;
		if(isPopup){
			winObj = window.open(loc, 'PopUpWindow');
			winObj.focus();
			return false;
		}
		var snum = $('#main').children().length-1;
		var swait = 0;
		if(loc){
			if(this.className.match(/pageChange/)){
				$('#header').animate({opacity:0},1000);
				$('#footer').animate({opacity:0},1000);
			}
			$('#main').children().each(function(){
				var pos = $(this).position();
				$(this).find('h2,p,span,a').animate({color:'#ffffff'},1000);
				$(this).find('video').each(function(){$(this).css({display:"none"})});
				h = $(this).outerHeight({margin:true})+7;
				w = $(this).outerWidth({margin:true})+7;
				if(525<w){w=(w<h)?w+200:w;}
				this.sid = $(this).attr("id")+'_shade';
				pos.top=(pos.top)?pos.top:0;
				pos.left=(pos.left)?pos.left:0;
				$(this).after('<div id="'+this.sid+'" style="z-index:990;position:absolute;background-color:white;opacity:0;top:'+(pos.top-3)+'px;left:'+(pos.left-3)+'px;width:'+w+'px;height:'+h+'px;"></div>');
				if(swait<snum || snum==0){
					$('#'+this.sid).animate({opacity:1},1000, function(){location.href=loc;});
				}else{
					$('#'+this.sid).animate({opacity:1},1000)
					swait++;
				}
			});
		}
		return false;
	},
	unload : function(){
		$.isReady = false
	}
};

//window.location.reload();

//EOF
