var _csizes = false; var _timer = null; var _tempElement = 6; $(document).ready(function(){ clearInputs(); ieHover('#navigation .main_nav li'); $('select').customSelect(); $('input').customRadio(); $('input').customCheckbox(); }); function checkSizes( _static ) { clearTimeout(_timer); if (_csizes) { var _sh = $("#sidebar").height(); var _ch = $("#content").height(); if(_sh < _ch) { if (!_static) { $("#sidebar").stop().animate({'marginTop': _ch-_sh}); } else { $("#sidebar").css({'marginTop': _ch-_sh}); } } _timer = setTimeout('checkSizes()', 1000); } } /*---- IE6 hover function ---*/ function ieHover(h_list) { if ($.browser.msie && $.browser.version < 7) { $(h_list).hover(function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); }); } } /*---- clear inputs function ---*/ function clearInputs(){ $('input:text, input:password, textarea').each(function(){ if(!this.val) this.val = this.value; this.onfocus = function(){ if(this.value == this.val) this.value = ''; } this.onblur = function(){ if(this.value == '') this.value = this.val; } }); } /*--- custom select function ---*/ jQuery.fn.customSelect = function(_options){ var _options = jQuery.extend({ selectStructure: '
 
', selectText: '.center', selectBtn: '.selectButton', selectDisabled: '.disabled', optStructure: '
', optList: 'ul' }, _options); return this.each(function(){ var select = jQuery(this); if(!select.hasClass('outtaHere')){ if(select.is(':visible')){ var replaced = jQuery(_options.selectStructure); var selectText = replaced.find(_options.selectText); var selectBtn = replaced.find(_options.selectBtn); var selectDisabled = replaced.find(_options.selectDisabled).hide(); var optHolder = jQuery(_options.optStructure); var optList = optHolder.find(_options.optList); if(select.attr('disabled')) selectDisabled.show(); select.find('option').each(function(){ var selOpt = $(this); var _opt = jQuery('
  • ' + selOpt.html() + '
  • '); if(selOpt.attr('selected')){ selectText.html(selOpt.html()); _opt.addClass('selected'); } _opt.children('a').click(function(){ optList.find('li').removeClass('selected'); select.find('option').removeAttr('selected'); $(this).parent().addClass('selected'); selOpt.attr('selected', 'selected'); selectText.html(selOpt.html()); select.change(); optHolder.hide(); return false; }); optList.append(_opt); }); //replaced.width(select.outerWidth()); replaced.insertBefore(select); jQuery(document.body).append(optHolder); _tmp = optHolder.outerHeight(); if (_tmp > (_tempElement*18+5)) optHolder.css({ height: (_tempElement*18+5) + 'px', width: select.outerWidth(), display: 'none', position: 'absolute', overflow: 'auto' }); else optHolder.css({ width: select.outerWidth(), display: 'none', position: 'absolute' }); var optTimer; replaced.hover(function(){ if(optTimer) clearTimeout(optTimer); }, function(){ optTimer = setTimeout(function(){ optHolder.hide(); }, 200); }); optHolder.hover(function(){ if(optTimer) clearTimeout(optTimer); }, function(){ optTimer = setTimeout(function(){ optHolder.hide(); }, 200); }); selectBtn.click(function(){ if(optHolder.is(':visible')){ optHolder.hide(); } else{ optHolder.css({ top: replaced.offset().top + replaced.outerHeight(), left: replaced.offset().left, display: 'block' }); } return false; }); select.addClass('outtaHere'); } } }); } /*--- custom radio function ---*/ jQuery.fn.customRadio = function(_options){ var _options = jQuery.extend({ radioStructure: '
    ', radioDisabled: 'disabled', radioDefault: 'radioArea', radioChecked: 'radioAreaChecked' }, _options); return this.each(function(){ var radio = jQuery(this); if(!radio.hasClass('outtaHere') && radio.is(':radio')){ var replaced = jQuery(_options.radioStructure); this._replaced = replaced; if(radio.is(':disabled')) replaced.addClass(_options.radioDisabled); else if(radio.is(':checked')) replaced.addClass(_options.radioChecked); else replaced.addClass(_options.radioDefault); replaced.click(function(){ if($(this).hasClass(_options.radioDefault)){ radio.attr('checked', 'checked'); changeRadio(radio.get(0)); } }); radio.click(function(){ changeRadio(this); }); replaced.insertBefore(radio); radio.addClass('outtaHere'); } }); function changeRadio(_this){ $('input:radio[name='+$(_this).attr("name")+']').not(_this).each(function(){ if(this._replaced && !$(this).is(':disabled')) this._replaced.removeClass().addClass(_options.radioDefault); }); _this._replaced.removeClass().addClass(_options.radioChecked); } } /*--- custom checkbox function ---*/ jQuery.fn.customCheckbox = function(_options){ var _options = jQuery.extend({ checkboxStructure: '
    ', checkboxDisabled: 'disabled', checkboxDefault: 'checkboxArea', checkboxChecked: 'checkboxAreaChecked' }, _options); return this.each(function(){ var checkbox = jQuery(this); if(!checkbox.hasClass('outtaHere') && checkbox.is(':checkbox')){ var replaced = jQuery(_options.checkboxStructure); this._replaced = replaced; if(checkbox.is(':disabled')) replaced.addClass(_options.checkboxDisabled); else if(checkbox.is(':checked')) replaced.addClass(_options.checkboxChecked); else replaced.addClass(_options.checkboxDefault); replaced.click(function(){ if(checkbox.is(':checked')) checkbox.removeAttr('checked'); else checkbox.attr('checked', 'checked'); changeCheckbox(checkbox); }); checkbox.click(function(){ changeCheckbox(checkbox); }); replaced.insertBefore(checkbox); checkbox.addClass('outtaHere'); } }); function changeCheckbox(_this){ if(_this.is(':checked')) _this.get(0)._replaced.removeClass().addClass(_options.checkboxChecked); else _this.get(0)._replaced.removeClass().addClass(_options.checkboxDefault); } } // return small youtube image function getScreen( url ) { if ( url === null ){ return ""; } var vid; var results; var results = url.match('http://www\.youtube\.com/v/([a-zA-Z0-9_]+)&.*'); if ( results === null) var results = url.match("[\\?&]v=([^&#]*)"); vid = ( results === null ) ? "" : results[1]; if (vid != "") return "http://img.youtube.com/vi/"+vid+"/default.jpg"; else return ""; } // Select menu item function selectMenuItem( item ){ var obj = $('#navigation .main_nav li:eq(2)'); obj.addClass('active hover'); switch ( item ) { case 'prizes': obj.find('a.prizes' ).css('background-position','0px -11px'); break; case 'rules': obj.find('a.rules' ).css('background-position','-42px -11px'); break; case 'submission_guidelines': obj.find('a.submission_guidelines' ).css('background-position','-85px -11px'); break; case 'live_events': obj.find('a.live_events' ).css('background-position','-218px -11px'); break; case 'faqs': obj.find('a.faqs' ).css('background-position','-288px -11px'); break; } }