// Form Controller
var formController = {
    init : function(){
        this.run();
    },
    run : function(){
        $('input[type=text]').focus(function(){
            if($(this).attr('value') == $(this).attr('defaultValue'))
                $(this).attr('value','');
        });
        $('input[type=text]').blur(function(){
            if($(this).attr('value') == '')
                $(this).attr('value', $(this).attr('defaultValue'));
        });
    }
}


// Categories Fixer
var categoryController = {
	init : function(){
		this.run()
	},
	run : function(){
		$('#prodListing li:nth-child(3n)').addClass('last')
		$('#prodListing li').hover(function(){
			$(this).addClass('hovering');
		}, function(){
			$(this).removeClass('hovering');
		});
	}
	
}

// Column Height Fixer
var columnFix = {
	init : function(){
		this.run();
	},
	run : function(){
		var lColHeight = $('#lCol').height();
		var rColHeight = $('#rCol').height();
		
		if(lColHeight < rColHeight){
			$('#lCol').height(rColHeight - 16);
		}else{
			if($('#pageTitle').length > 0)
				$('#contentBuffer').height(lColHeight - 144);
			else
				$('#contentBuffer').height(lColHeight - 16);
		}
		
	}
	
}


// Page Initialization
function initialize(){
    formController.init();
	categoryController.init();
	columnFix.init();
}


// Start
$(document).ready(function(){
    initialize();
});
