var _body=$('body'); var _header=$('.global-header'); var _nav=_header.find('nav'); var _m_nav_caller=_header.find('.nav-caller'); var _m_game_nav_caller=_header.find('.temp-nav-caller'); var global={ size : function(){ $(window).bind('load resize', function(){ var _width=(window.innerWidth || $(window).innerWidth()); if (_width < 980) { _body.addClass('mobile'); } else { _body.removeClass('mobile') } }) }, topbar : function(){ var _games=function(){ var toggle=false; var active=false; var caller=_header.find('.games').find('.caller'); var slider; var create=function(){ slider = $('.games-list').bxSlider({ adaptiveHeight: false, controls: false, infiniteLoop: false, randomStart: false }); return false; } var remove=function(){ slider.destroySlider(); var reset=setTimeout(function(){ $('.games-list').removeAttr('style'); $('.games-list').find('div').removeAttr('style'); }, 10); } caller.bind({ click : function(){ if (!toggle) { $(this).next().show(); $(this).addClass('selected'); if (!active) { create(); } toggle=true; } else { $(this).next().hide(); $(this).removeClass('selected'); remove(); toggle=false; } } }); $(document).bind('click', function(e) { var clicked = $(e.target); if (!clicked.parents().hasClass('games') && toggle) { $('.games-layer').hide(); caller.removeClass('selected'); toggle=false; remove(); } }); } var _menumore=function(){ var caller=_header.find('.menu-more').find('.caller'); _header.find('.menu-more').each(function(){ var $this=$(this); $(this).find('.caller').unbind('click').click(function(){ $(this).toggleClass('selected'); $this.find('.more-layer').toggle(); }) }) } var _nickname=function(){ var parent=$('.my'); var caller=parent.find('.nickname') var toggle=false; caller.bind({ click : function(){ if (!toggle) { $(this).next().show(); $(this).addClass('selected'); toggle=true; } else { $(this).next().hide(); $(this).removeClass('selected'); toggle=false; } } }); $(document).bind('click', function(e) { var clicked = $(e.target); if (!clicked.parents().hasClass('my')) { $(parent).find('.my-contents').hide(); caller.removeClass('selected'); toggle=false; } }); } var _m_nav=function(){ var _scroll=0; _m_nav_caller.bind({ click : function(){ if (_body.hasClass('mobile')) { _scroll=$('body').scrollTop(); $('html, body').css({ 'width' : '100%', 'position' : 'fixed', 'overflow' : 'hidden' }); _nav.css('left','0'); _nav.height($(window).height()); _nav.find('.nav-contents').height($(window).height()); global.shadow('show'); $('.global-header').append('close'); return false; } } }) $('._shadow, .global-header nav .m-nav-close').live('click', function(){ $('html, body').removeAttr('style'); _nav.removeAttr('style'); global.shadow('hide'); }); } var _my_layer=_header.find('.my-contents'); $(window).bind('load resize', function(){ var _width=(window.innerWidth || $(window).innerWidth()); if (_width < 980) { _nav.height($(window).height()); _nav.find('.nav-contents').height($(window).height()); _my_layer.css('width',_width); } else { $('html, body').removeAttr('style'); _nav.removeAttr('style'); _nav.find('.nav-contents').removeAttr('style'); _my_layer.removeAttr('style'); global.shadow('hide'); } }) _games(); _menumore(); _nickname(); _m_nav(); }, footer : function(){ var _language=function(){ var parent=$('.language'); var caller=parent.find('.selected') var toggle=false; caller.bind({ click : function(){ if (!toggle) { $(this).next().show(); $(this).addClass('hover'); toggle=true; } else { $(this).next().hide(); $(this).removeClass('hover'); toggle=false; } } }); $(document).bind('click', function(e) { var clicked = $(e.target); if (!clicked.parents().hasClass('language')) { $(parent).find('.list').hide(); caller.removeClass('hover'); toggle=false; } }); } _language(); }, common : function(){ global.topbar(); global.footer(); }, shadow : function(type){ var shadow='close'; if (type=='show') { $('body').append(shadow); } else { $('._shadow').remove(); } }, gamenav : function(){ var _scroll=0; var _game_nav=$('.temp-header-container'); _m_game_nav_caller.bind({ click : function(){ if (_body.hasClass('mobile')) { _scroll=$('body').scrollTop(); $('html, body').css({ 'width' : '100%', 'position' : 'fixed', 'overflow' : 'hidden' }); _game_nav.css({ 'right':'0', 'display' : 'block' }); _game_nav.height($(window).height()); _game_nav.find('.global-temp-header').height($(window).height()); global.shadow('show'); $('.global-header').append('close'); return false; } } }) var _close_nav=function(){ $('html, body').removeAttr('style'); _game_nav.removeAttr('style'); _game_nav.find('.global-temp-header').removeAttr('style'); global.shadow('hide'); } $('._shadow').live('click', function(){ _close_nav(); }); $(window).bind('load resize', function(){ var _width=(window.innerWidth || $(window).innerWidth()); if (_width > 979) { _close_nav(); } }) } } var ui={ selectbox : function(){ $('.selectbox').each(function(){ var selected=$(this).find('a'); $(this).find('select').change(function(){ selected.text($(this).find('option:selected').text()); }) }) }, checkbox : function(type){ var all=$('.all-check'); var checkbox=$('.checkbox'); var size=$('.checkbox').size()-$('.checkbox .disabled').size()-$('.checkbox.all-check').size(); checkbox.each(function(){ if ($(this).find('input[type=checkbox]').prop('checked')) { $(this).find('label').addClass('checked'); } $(this).find('input[type=checkbox]').change(function(){ if ($(this).prop('checked')) $(this).closest('label').addClass('checked'); else $(this).closest('label').removeClass('checked'); }); }) if (all.size() > 0) { all.find('input[type=checkbox]').change(function(){ if ($(this).prop('checked')) { $(this).find('label').addClass('checked'); $('.checkbox').each(function(){ if (!$(this).find('label').hasClass('disabled')) { $(this).find('label').addClass('checked'); $(this).find('input[type=checkbox]').prop('checked', 'checked'); } }) } else { $(this).find('label').removeClass('checked'); $('.checkbox').find('label').removeClass('checked'); $('.checkbox').find('input[type=checkbox]').removeProp('checked'); } }); } if (type=='clear') { $('.checkbox').find('label').removeClass('checked'); $('.checkbox').find('input[type=checkbox]').removeProp('checked'); } }, radio : function(){ $('input[type=radio]').each(function(){ if ($(this).prop('checked')) { $(this).closest('label').addClass('checked'); } }) /* $('input[type=radio]').bind('click',function(){ $('input[name='+$(this).attr('name')+']').parent().removeClass('checked'); $(this).parent().addClass('checked'); }); */ $('input[type=radio]').change(function(){ $('input[name='+$(this).attr('name')+']').closest('label').removeClass('checked'); $(this).closest('label').addClass('checked'); }); }, textbox : function(){ $("input[type=text]").each(function(){ $("input[type=text]").blur(function(){ if($(this).val() == ""){ $(this).closest(".textbox").find(".lbl").removeClass("focus"); }else{ $(this).closest(".textbox").find(".lbl").addClass("focus"); } }); $("input[type=text]").focus(function(){ $(this).closest(".textbox").find(".lbl").addClass("focus"); }); }); } } var redirect=function(a, b, c, d){ $('.global-header').append('background'); $('body').append('
'+b+''+c+'