if ($.browser.msie) { var speed = 230; } else {var speed = 330;}
var ac = '/ajax.php';


$(window).ready(
	function(){
		
		
		// links activation
		$('.sq a, .copy a.ajaxlink, #qlinkz a').not('.everest').click(
			function(){ 
				setTimeout(function(){	
					ajaxtransfer(getAnchor());	
				}
		);});	 
		
		// onload activation
		var department = getAnchor(); 
		if (department != undefined){	
			ajaxtransfer(department);	
		}
	
	
		$('.btn a').mouseover(function(){
			var id = $(this).parent().attr('id');
			if 	($('#'+ id + 'menu .sq').length > 1){
						showmenu(id);
			}
			
			$(this).parent().parent().parent().hover(
			function(){
			},										 
			function(){
				//$('.innermenu', this).not('.active').find('.sq').SlideOutLeft(speed, function(){
					//$('.innermenu').not('#'+ id + 'menu').not('.active').find('.sq').filter(':visible').SlideOutLeft(speed, null, 'easeout'); 
				//}, 'easein');
			});
			
		});
	
});





function showmenu(id){

	if(	$('#'+ id + 'menu').css('display') == 'none' ){
				$('#'+ id + 'menu .sq').css('display', 'none');
				$('#'+ id + 'menu').css('display', 'block');

		$('#'+ id + 'menu .sq').SlideInLeft(speed, function(){
				if ( $('#'+ id + 'menu').css('display') == 'none' ){
					$('#'+ id + 'menu .sq').SlideInLeft(speed, null, 'easeout');		
				}
		}, 'easeout');		
	} 
	
	
	if ($('.innermenu').not('.active').filter(':visible').find('.sq').length > 0)	{
		$('.innermenu').not('#'+ id + 'menu').not('.active').filter(':visible').find('.sq').SlideOutLeft(speed, function(){
			$('.innermenu').not('#'+ id + 'menu').not('.active').filter(':visible').css('display', 'none');							
		}, 'easein');
	} else {
		$('.innermenu').not('#'+ id + 'menu').not('.active').filter(':visible').css('display', 'none');	
	}
	
}

function ajaxtransfer(dep){
	if (typeof dep == 'undefined') { 	return false; 	}
	// alpha for loading
	//$('#page').addClass('alpha');
//	window.scrollTo(0,0);
	$('#rtop').ScrollTo(400, 'easeout');
	
	$('#page').html('<div>&nbsp;</div>');
	$('#page div').addClass('ajax');
	
	$('#qlinkz').html('<div class="qlink"></div>');

	// global department
	var dep = dep;
		
	// spliting a dep query
	menu = dep.split("@");
	$('div.active').removeClass('active');
	$('#'+menu[0]+'menu').addClass('active');
		
	// gray bg for menu block
	if ($('.innermenu').not('.active').filter(':visible').length > 0 ){
		$('.innermenu').not('.active').filter(':visible').find('.sq').SlideOutLeft(speed, function(){
			$('.innermenu').not('.active').filter(':visible').css('display', 'none');							
		}, 'easein');
	}
	
	
	
	// showing menu if hided
	if ($('#'+menu).length == 1 && $('#'+ menu[0] + 'menu').css('display') == 'none'){ 
		showmenu(menu[0]); 
	}
		
		$('a.super').removeClass('super');	
	if (typeof menu[1] != 'undefined'){
		para = menu[1].split("-");
		hightlightmenu(para[0]);
		
		
		$('#'+menu[0]+'lnk').addClass('super');
	} else {
		
		hightlightmenu(menu[0]+'lnk');
	}
		
	func = menu[0] + ((typeof menu[1] != 'undefined') ? menu[1] : '') ;
	if (menu[0] == 'company_info') {
		func = 'company_info';
	}
		
		

	if (typeof para != 'undefined'){
		if ((menu[0] + para[0] + para[1]) == 'whoceohideki') {
			func = 'whoceohideki';
		}
	}

	switch(func){
		case 'whyshowcase':  
			whyshowcase(); 
		break;
		case 'contact':
			contactform();

		break;
		case 'whoceohideki':
			func = menu[0] + ((typeof menu[1] != 'undefined') ? menu[1] : '') ;
			hideki(func);
		break;
		case 'company_info':
			func = menu[0] + ((typeof menu[1] != 'undefined') ? menu[1] : '') ;
			press(func);
		break;
		default:
			getnode(func);
		break;
	}
	qlink((menu[0] + ((typeof menu[1] != 'undefined') ? menu[1] : '')));	
	para = false;
	//$('#page').removeClass('alpha');	
}





function hightlightmenu(para){	
	if ($('#'+para).length == 1){	
		$('.sq a').removeClass('show');
		$('#'+para).addClass('show'); 
		return true; 
	} 
}

function getAnchor(){ 
	if(typeof location.hash != undefined) {
		var name = location.hash.split("#"); 
		return name[1];	
	} 
	return false; 
}

