if(document.all){
    if (!window.XMLHttpRequest  ) {
    	browser = 'ie6'; // ie6
    } else {
    	browser = 'ie'; // ie7, ie8
    }
} else {
    	browser = ''; // etc.
}

var princePrev = 'index';
var aniFirst = 'index';
var mapFirst = '';

$(document).ready(function() {
	$("a.photo_link[rel=gallery]").fancybox();
	$('div#header div.navigation ul li a').each(function(){
		$(this).click(function(){
			if(browser=='ie6') { navigaion($(this).attr('class'), $(this).attr('class')); $(this).html('<img src="images/ie6/t.gif" alt="" />') } else { navigaionAni($(this).attr('class'), $(this).attr('class')); }
		});
	});
	if(browser=='ie6') {
		$('em#curtain_left').animate( { left : '0' }, { duration: 500, easing : 'easeInQuad' } );
		$('em#curtain_right').animate( { right : '0' }, { duration: 500, easing : 'easeInQuad', complete: function(){
			$('span#postit').fadeIn( { duration: 1000, easing : 'easeOutBack' } );
			$('a#home').trigger('click');
		} } );
	} else {
		$('div#footer').slideUp(500,function(){
			$('div#footer').slideDown(500,function(){
			$('em#curtain_left').animate( { left : '0' }, { duration: 500, easing : 'easeInQuad' } );
			$('em#curtain_right').animate( { right : '0' }, { duration: 500, easing : 'easeInQuad', complete: function(){
				$('span#postit').fadeIn( { duration: 1000, easing : 'easeOutBack' } );
				$('em#index_bg').slideDown({ duration: 300, easing : 'easeOutBack' } ).delay(2000).show({ duration: 300, easing : 'easeOutBack', complete: function(){
					$('a#home').trigger('click');
				} } );
			} } );
			});
		});
	}
	$('a#map01').click(function(){
		$('a#home4').trigger('click');
	});
	$('a#map02').click(function(){
		$('a#home5').trigger('click');
	});
	$('a#mapPrint02').click(function(){
		$('a#home2').trigger('click');
	});
	$('a#mapGoogle01').click(function(){
		$('a#home2').trigger('click');
	});
	welcome();
});

// Google Map API Key
// ABQIAAAAWfsHmbzua2QSrKUZF_svCxSS7cyBYqC7HsufbjSdf4zQcx5c3xRSMgonwey0P4w5F_lefgs7relNlg

function navigaion(className, titleName){
	$('img#logo_prince').css( 'display', 'none' );
	if(className=='index') {			
		$('#header').css( 'top', '-470px');
		$('em#'+className+'_bg').css( 'top', '-470px');
		$('div#footer').css( 'top', '507px' );
	} else {	
		$('div#header').css( 'top', '0');
		$('em#'+className+'_bg').css( 'top', '0');
		$('div#footer').css( 'top', '547px' );
	}
	$('div#'+princePrev).css( 'display' , 'none' );
	$('div#'+className).css( 'display', 'block' );
	$('em#'+princePrev+'_bg').css( 'display', 'none' );
	$('em#'+className+'_bg').css( 'display', 'block' );
	
	if(className=='mapGoogle') {
		if(mapFirst!='map'){
			$('div#mapDiv').html($('div#map_display').html());
			$('div#map_display').html('');
			mapFirst = 'map';
		}
	alert('신촌역 8번 출구로부터 5분거리 하나로마트 건물지나서 Family mart 3층.');
	}
	
	princePrev = className;
	
	document.title = 'Prince - ' + titleName;
	window.scrollTo(0,0);
}


function navigaionAni(className, titleName){
	$('div#'+princePrev).slideUp( { duration: 0, easing : 'easeInOutBack', complete: function(){
		if(className=='index') {
			$('img#logo_prince').fadeOut( { duration: 500, easing : 'easeInOutBack' } );
			$('div#header').css( 'top', '-470px');
			$('em#'+princePrev+'_bg').animate( { top : '-470px' }, { duration: 500, easing : 'easeInOutBack', complete: function(){
				if(aniFirst!='index'){$(this).fadeOut( { duration: 300, easing : 'easeInOutBack' } );}
				$('em#'+princePrev+'_bg').fadeIn( { duration: 300, easing : 'easeInOutBack' } );
				if(!browser){$('div#'+className).fadeIn( { duration: 1000, easing : 'easeInOutBack' } );} else {$('div#'+className).slideDown( { duration: 1000, easing : 'easeInOutBack' } );}
			} } );
			$('div#footer').animate( { top : '507px' } );
			princePrev = className;
		} else {
			$('img#logo_prince').fadeIn( { duration: 300, easing : 'easeInOutBack' } );
			$('div#header').css( 'top', '0');
			if(princePrev=='index'){
				$('em#'+className+'_bg').css( 'top', '-470px');
				$('em#'+princePrev+'_bg').fadeOut( { duration: 300, easing : 'easeInOutBack' } );
				$('div#'+className).css( 'display' , 'block' );
				$('em#'+className+'_bg').fadeIn( { duration: 300, easing : 'easeInOutBack' } );
				$('em#'+className+'_bg').animate( { top : '0' }, { duration: 500, easing : 'easeInOutBack' } );
				$('div#footer').animate( { top : '547px' } );
			} else {
				if(className!=princePrev) {
				$('em#'+className+'_bg').css( 'top', '-470px');
				}
				$('em#'+princePrev+'_bg').animate( { top : '-470px' }, { duration: 500, easing : 'easeInOutBack', complete: function(){
					$(this).fadeOut( { duration: 300, easing : 'easeInOutBack' } );
					$('div#'+className).css( 'display' , 'block' );
					$('em#'+className+'_bg').fadeIn( { duration: 300, easing : 'easeInOutBack', complete: function(){if(className=='mapGoogle') { 
						if(mapFirst=='map'){
						$('div#mapDiv').animate({opacity:'0'},{duration: 100}).delay(500).animate({opacity:'0'},{duration: 100, complete:function(){
							$('div#mapDiv').html($('div#map_display').html());
							$(this).animate({opacity:'0'},{duration: 100}).delay(1000).animate({opacity:'1'},{duration: 1000});
						}});
						} else {
						$('div#mapDiv').animate({opacity:'0'},{duration: 100}).delay(1000).animate({opacity:'1'},{duration: 1000});
						}
					} else {
						$('div#mapDiv').animate({opacity:'0'},{duration: 100});
					} } } );
					$('em#'+className+'_bg').animate( { top : '0' }, { duration: 500, easing : 'easeInOutBack' } );
					
				} } );
				$('div#footer').animate( { top : '547px' } );
			}
			princePrev = className;
			aniFirst = '';
			mapFirst = 'map';
		}
		$('div.navigation').css( 'display' , 'block' );
		document.title = 'Prince - ' + titleName;
	} });
	window.scrollTo(0,0);
}


wel = 1;
function welcome() {
	/*for(i=0; i<3; i++) {
		if(i==wel) {
		$('span#welcome'+i).css('display','block');
		} else {
		$('span#welcome'+i).css('display','none');
		}
	}
	if(wel < 2) { wel++; } else { wel = 0; }
	setTimeout('welcome()', 1000);
	*/
}

function sketchMap() {
	window.open('sketch_map.html','','width=800,height=600,scrollbars=1');
}
