$(document).ready(function() {
	//$('#loginbox').hide();
	$('.error').hide();
	$("#horizontalForm").validate();

	$('a#login-show').click(function() {
		$('#loginbox').toggle('slow');
			return false;
	}); 
	
	$('a.gotologin').click(function() {
		$('#loginbox').show('slow');
		return false;
	}); 
	
	// Get the text for the username field
	var labelTxtUsername = 'Username';
	
	// Put the text from the variable above into the username field value below
	$('#username').attr('value',labelTxtUsername);
	
	// Focus & blur effects
	$('#username').focus(function(){
		if ((this.value == '') || (this.value == labelTxtUsername)) {
			$(this).val('');
		}
	});
	
	$('#username').blur(function(){
		if (this.value == '') {
			$(this).val(labelTxtUsername);
		}
	});
	
	// Get the text for the search field
	var labelTxtSearch = 'Enter search terms...';
	
	// Put the text from the variable above into the username field value below
	$('#s_search').attr('value',labelTxtSearch);
	
	// Focus & blur effects
	$('#s_search').focus(function(){
		if ((this.value == '') || (this.value == labelTxtSearch)) {
			$(this).val('');
		}
	});
	
	$('#s_search').blur(function(){
		if (this.value == '') {
			$(this).val(labelTxtSearch);
		}
	});	
	
	// initialize the Table Sorter Plugin for our tables.
    // define a custom text extraction function
	var myTextExtraction = function(node)  
	{  
        // if there is a link, return the content of the link
	    if (node.getElementsByTagName('a')[1]){
				return node.getElementsByTagName('a')[1].innerHTML;
    	}
        return node.innerHTML;
	} 
    
	$("table")
	//.tablesorter({sortList: [[0,0]], widgets: ['zebra'], textExtraction: "simple" })
	.tablesorter({sortList: [[0,0]], widgets: ['zebra'], textExtraction: myTextExtraction })
	//.tablesorterPager({container: $("#pager"), positionFixed: false});
	
	//Comment Code
     var options = { 
        target:        '#commentArea',
        //beforeSubmit:  preSubmit,
        success:       postSubmit
    }; 
 
	$('#commentForm').submit(function() { 
		$(this).ajaxSubmit(options);
        return false; 
	}); 
	
	function preSubmit() { 
	    //return true; 
	} 
	 
	function postSubmit()  { 
	//	    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
	//        '\n\nThe output div should have already been updated with the responseText.');
		$('#commentArea').fadeIn("slow");
	}

	// Favorite Link //
	favLink();
	
	function favLink() {
		$("a.arfavorite").click(function() {
			$(this).fadeTo("fast", .0).parent().load($(this).attr("href"), function(data) {
				favLink(data);
			});
			return false;
		});
	}
		
	// JCarousel //
	jQuery('#mycarousel').jcarousel({
		//Config goes here.
	});
	
	// JCarousel //
	
	//$('ul#generalFaqs').hide();
	$('ul#downloadFaqs').hide();
	$('ul#pointsFaqs').hide();

	$('a#generalFaqsClick').click(function() {
		$('ul#generalFaqs').fadeIn('normal')
		.siblings('ul:visible').fadeOut('fast');
			return false;
	});
	
	$('a#downloadFaqsClick').click(function() {
		$('ul#downloadFaqs').fadeIn('normal')
		.siblings('ul:visible').fadeOut('fast');
			return false;
	});
	
	$('a#pointsFaqsClick').click(function() {
		$('ul#pointsFaqs').fadeIn('normal')
		.siblings('ul:visible').fadeOut('fast');
			return false;
	});

// End of the Line //

});

