var _blink = "";
var _smenu_vis = 0;

function showIntro() {
	jQuery.blockUI({ 
		message: jQuery('#intro'),
		css : {
			width:'100%',
			height:'100%',
	    	left: '0',
	    	top : '0'
	    },
	    onBlock:function(){
	    	jQuery("html").css("overflow", "hidden");
	    }
	});
}
function viewFuckIE() {
	//alert('해당 브라우저에선 코디북을 정상적으로 사용하실수 없습니다.\n최신브라우저를 이용해주세요 ^^');
}

function blink() {
	var delay = 250;
	var blink = jQuery('#logo div.blink1').show().animate({width:37,height:67,left: '-=18',top:'-=33'},delay,function() {
		jQuery('#logo div.blink1').animate({width:0,height:0,left: '+=18',top:'+=33'},delay-100,function(){
			jQuery('#logo div.blink1').hide();
		});
		var blink2 = jQuery('#logo div.blink2').show().animate({width:37,height:67,left: '-=18',top:'-=33'},delay,function(){
			jQuery('#logo div.blink2').animate({width:0,height:0,left: '+=18',top:'+=33'},delay-100,function(){
				jQuery('#logo div.blink2').hide();
			});
			var blink3 = jQuery('#logo div.blink3').show().animate({width:37,height:67,left: '-=18',top:'-=33'},delay,function(){
				jQuery('#logo div.blink3').animate({width:0,height:0,left: '+=18',top:'+=33'},delay-100,function(){
					jQuery('#logo div.blink3').hide();
				});
			});	
		});	
	});
}

function viewPolicy() {
	jQuery.blockUI({ 
		message: jQuery('#policyLayer'),
		css : {
			width:'100%',
			height:'100%',
	    	left: '0',
	    	top : '0'
	    },onBlock:function(){
	    	jQuery("html").css("overflow", "hidden");
	    }
	});
	jQuery('#policy_textarea').load('/policy.html');
}

function viewTerm() {
	jQuery.blockUI({ 
		message: jQuery('#termLayer'),
		css : {
			width:'100%',
			height:'100%',
	    	left: '0',
	    	top : '0'
	    },
	    onBlock:function(){
	    	jQuery("html").css("overflow", "hidden");
	    }
	});
	jQuery('#term_textarea').load('/term.html');
}

var search_sample = new Array("아이유","봄","파티","레드","데이트");

jQuery(document).ready(function(){
	jQuery('#menu_bar div').mouseover(function(){
		jQuery(this).addClass('on');
	}).mouseout(function(){
		jQuery(this).removeClass('on');
	});
	//jQuery('#category_tab').selectable();
	var menu_string = document.URL.split('/')[3];
	if(menu_string)
		if(menu_string == 'make' || menu_string == 'set' || menu_string == 'item')
			jQuery('.menu_bar .' + menu_string).addClass('ui-selected');

	//if(document.URL == 'http://codibook.net')
	
	jQuery('.search_text').focus(function(){
		jQuery(this).val('');
	});
	
	if(jQuery('.search_text').val() == "")
		jQuery('.search_text').val(search_sample[Math.floor(Math.random()*(search_sample.length))]);

	
	jQuery('#help').mouseover(function(){
		jQuery('#help .bg').show('normal');
		jQuery(this).addClass('on');
	}).mouseout(function(){
		jQuery('#help .bg').hide();
		jQuery(this).removeClass('on');
	});

	jQuery('#withus').mouseover(function(){
		jQuery('#withus .bg').show('normal');
		jQuery(this).addClass('on');
	}).mouseleave(function(e){
		jQuery('#withus .bg').hide();
		jQuery(this).removeClass('on');
	});
	/*
	for (var i=1;i<=3;i++)
		jQuery('<div class="blink' + i + '"><img src="/img/blink.png" width="100%"></div>').appendTo('#logo');
	
	jQuery('#logo').mouseenter(function(e){
		if(e.target.className == 'logo') {
			//blink();
			//_blink = setTimeout('blink()',1000);
			jQuery(this).animate({width:193,bottom:8,left:-5},50,function() {});
		}
	}).mouseleave(function(e){
		if(e.target.className == 'logo') {
			jQuery(this).animate({width:174,bottom:8,left:0},50);
		}
	});
	*/
	if(document.referrer.indexOf('cyworld') != -1) {
		jQuery.cookie('cyworld', 'Y');
	}
	
	if(jQuery.cookie('cyworld') == 'Y' && m_srl == '') {
		var cy_login = jQuery('<li id="cy_login" title="싸이월드 앱스와 연동!"><a href="#" onclick="window.open(\'/portal/step1.php\')"><img src="/img/nate_login.gif" border="0"/></a></li>').tooltip({ offset: [-12,0],position: "bottom left",effect: 'fade'}).appendTo('#lnb');
		
		setTimeout("jQuery('#cy_login').data('tooltip').show()",500);
	}

	if(jQuery.cookie('first') != 'N') {
		jQuery("#guide_note").animate({
		    height: 'toggle'
		  }, 800, function() {
		});
	}
	
	//sst = setTimeout("roll_slide()",1000)‎;
});

jQuery(window).scroll(function(e){
	var top = jQuery(this).scrollTop();
	//console.log(top);
	if(top>100) {
		if(!_smenu_vis)
			jQuery('#hidden_menu_cotainer_wrapper').show()
				
		_smenu_vis = 1;
	} else {
		jQuery('#hidden_menu_cotainer_wrapper').hide();
		_smenu_vis = 0;
	}
});
