/**
 * Random site utility methods
 * 
 */
function verify(sMsg) {
    if (confirm(sMsg)) {
        return true;
    } else {
        return false;
    }
}


/**
 * Surfstation Javascript methods
 * 
 * @author Jessey White-Cinis <j@stolen.la>
 * @package surfstation.com
 */

var srfstn = {
	
	init: function() {
        this.blurLinks();        
	},
    
    blurLinks: function() {
        $("a").focus(function() {
            $(this).blur();
        });
    },
    
	test: function() {
		this.inputError('username','bad username fool!');
		this.inputError('password','Your password sucks!');
	},
	
	pageError: function(sText) {
		alert(sText);
	},
	
	inputError: function(sLabel, sText) {
		//$('#'+sLabel).animate({'backgroundColor':'#FACEC2','borderColor':'#ED5933'},500,'linear').animate({opacity: 1.0}, 2000).animate({'backgroundColor':'#F0EEE7','borderColor':'#D6D1BF'},1000);
		if(sText != '') $('#'+sLabel+'-error').text(sText).show('fast');
	},
	
	clearInputError: function(sLabel) {
        $('#'+sLabel+'-error').hide('fast');
	},
	
	clearInputErrors: function() {
        $('.input-error').hide('fast');
	},
	
	forms: {
        topic: {
            selected: '',
            set: function(topic) {
                this.selected = topic;
                $('form #topics .selected').removeClass('selected');
                $('form #topics #topic-'+topic).addClass('selected');
                $('form #topic').val(topic);
            },
            get: function() {
                return $('form #topics .selected').val();
            }
        }
	},	
    
	// PAGE SPECIFIC ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	
	posts: {
        
        init: function() {
            this.targetLinks();
        },
        
        targetLinks: function() {
            $('.post .body a').attr('target','_blank');
        }
	},
	
	press: {
        
        checkForm: function() {
            
            srfstn.clearInputErrors();
            
            var rtn = true;
            if($('input[name=topic]').val() == '') { srfstn.inputError('topic','You must select a topic'); rtn = false; }
            if($('input[name=title]').val() == '') { srfstn.inputError('title','You must enter a title'); rtn = false; }
            if($('textarea[name=body]').val() == '') { srfstn.inputError('body','You must enter some text'); rtn = false; }
            if($('input[name=submitted_name]').val() == '') { srfstn.inputError('submitted_name','You must enter your name'); rtn = false; }
            
            return rtn;
        }
	},
	
	
	// MODULES ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	
	modules: {
	   quotes: {
	       init: function() {
                $.getJSON("/services/quote",
                    function(data){
                        $('#wordsofwisdom .quote-txt').text(data.quote);                        
                        $('#wordsofwisdom .quote-author').text('- '+data.author);                        
                        $('#wordsofwisdom').slideDown('fast');
                        $('#wordsofwisdom .quote-txt').click(srfstn.modules.quotes.init);
                        $('#wordsofwisdom .quote-txt').css({'cursor':'pointer'});
                        
                    }
                );
	       }
	   }
	   
	},
	
	// ADMIN SPECIFIC ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	
	admin: {
	   
	   press: {
	       
	       allow: function(id) {
	           $('#press-form-'+id+'-action').val('allow');
	           $('#press-form-'+id).submit();
	       },
	       
	       deny: function(id) {
	           $('#press-form-'+id+'-action').val('deny');
	           $('#press-form-'+id).submit();
	       }
	   }
	   
	   
	},
	
	
    // NO COMMA ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    	
	nocomma: function() {}
};