window.size = function()
{
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

var desInnotransOverlayDiv = '';
var desSwitchingUrl = '';
var desContentDiv = '';
var desInnotransTempDiv = '';

window.addEvent('domready', function() {
	desContentDiv = $('mainContainerWrapper');
	desInnotransOverlayDiv = new Element('div', {id: 'desInnotransOverlayDiv'}).injectBefore(desContentDiv);
	desInnotransTempDiv = new Element('div', {id: 'desInnotransTempDiv'}).injectBefore(desContentDiv);
	desInnotransTempDiv.setStyle('opacity', '0');
		
	function shrinkDivNow() {
		desContentDiv.remove();
		var showDiv = new Fx.Style(desInnotransTempDiv,'opacity', {duration: 500});
		$('desFlashBanner').remove();
		showDiv.start(1).chain(function() {
			var growDiv = new Fx.Style(desInnotransOverlayDiv,'height', {duration: 1000});
			growDiv.start(0).chain(function() {	
				window.location = '/'+desSwitchingUrl ;
			});
		});
	}
	

	if ($chk($('desInnotransSwitcher'))) {	
		desSwitchingUrl = $('desInnotransSwitcher').getProperty('href');
		$('desInnotransSwitcher').setProperty('onclick', 'return false;');
			
		$('desInnotransSwitcher').addEvent('click', function(){	
			scroll(0,0);
			
			var growDiv = new Fx.Style(desInnotransOverlayDiv,'height', {duration: 1000});		
			growDiv.start(window.size().height).chain(function() {
				var hideDiv = new Fx.Style(desContentDiv,'opacity', {duration: 500});
				hideDiv.start(0).chain(function() {
					//$('desInnoCssScreen').remove();
					//$('desInnoCssMenu').remove();
					
					new Ajax(desSwitchingUrl, {
						method: 'get',
						update: desInnotransTempDiv,
						onComplete: shrinkDivNow
					}).request();
				});
			});
		});
	}

});

function desInnotransSwitchingTo(path) {
	desSwitchingUrl = path;
	
	scroll(0,0);
	
	function shrinkDivNow() {
		desContentDiv.remove();
		var showDiv = new Fx.Style(desInnotransTempDiv,'opacity', {duration: 500});
		showDiv.start(1).chain(function() {
			var growDiv = new Fx.Style(desInnotransOverlayDiv,'height', {duration: 1000});
			growDiv.start(0).chain(function() {	
				window.location = '/'+desSwitchingUrl ;
			});
		});
	}
			
	var growDiv = new Fx.Style(desInnotransOverlayDiv,'height', {duration: 1000});
	$('desFlashBanner').remove();		
	growDiv.start(window.size().height).chain(function() {
		var hideDiv = new Fx.Style(desContentDiv,'opacity', {duration: 500});
		hideDiv.start(0).chain(function() {
			//$('desInnoCssScreen').remove();
			//$('desInnoCssMenu').remove();
			
			new Ajax(desSwitchingUrl, {
				method: 'get',
				update: desInnotransTempDiv,
				onComplete: shrinkDivNow
			}).request();
		});
	});
}
