//////////////////////
// jquery-ui.config //
//////////////////////

$(function(){
	// Tabs
	$('#tabs').tabs();	
	var $tabs = $('#tabs').tabs();
	$('#buy-now-options').click(function() { // bind click event to link
    $tabs.tabs('select', 0); // switch to third tab
    return false;
	});
});

//////////////////////////////
// jquery.thumbhover.config //
//////////////////////////////

$(function(){
	$("#buyTable img[src*='_th.jpg']").thumbPopup({imgSmallFlag: "_th", imgLargeFlag: "_th", popupCSS:{'border': '1px solid #cccccc', 'background': '#ffffff'}});
});

///////////////////////////////
// jquery.tablesorter.config //
///////////////////////////////

$(function(){
	// extend the default setting to always include the zebra widget.
	$.tablesorter.defaults.widgets = ['zebra'];
	// call the tablesorter plugin
	$("#specTable").tablesorter({
		// pass the headers argument and assing a object
		headers: {
		// define a custom text extraction function
		textExtraction: function(node) {
				// extract data from markup and return it
				return node.childNodes[0].childNodes[0].innerHTML;
			}
		}
	});
	$("#buyTable").tablesorter({
		// pass the headers argument and assing a object
		headers: {
			// assign the first column (we start counting zero)
			0: {
				// disable it by setting the property sorter to false
				sorter: false
				},
			// assign the third column (we start counting zero)
			3: {
				// disable it by setting the property sorter to false
				sorter: false
				},
		// define a custom text extraction function
		textExtraction: function(node) {
				// extract data from markup and return it
				return node.childNodes[0].childNodes[0].innerHTML;
			}
		}
	});
	$("#relatedTable").tablesorter({
		// pass the headers argument and assing a object
		headers: {
			// assign the first column (we start counting zero)
			0: {
				// disable it by setting the property sorter to false
				sorter: false
				},
			// assign the third column (we start counting zero)
			3: {
				// disable it by setting the property sorter to false
				sorter: false
				},
		// define a custom text extraction function
		textExtraction: function(node) {
				// extract data from markup and return it
				return node.childNodes[0].childNodes[0].innerHTML;
			}
		}
	});
	$("#faqTable").tablesorter({
		// pass the headers argument and assing a object
		headers: {
			// assign the first column (we start counting zero)
			0: {
				// disable it by setting the property sorter to false
				sorter: false
				},
			// assign the second column (we start counting zero)
			1: {
				// disable it by setting the property sorter to false
				sorter: false
				},
			// assign the second column (we start counting zero)
			2: {
				// disable it by setting the property sorter to false
				sorter: false
				},
		// define a custom text extraction function
		textExtraction: function(node) {
				// extract data from markup and return it
				return node.childNodes[0].childNodes[0].innerHTML;
			}
		}
	});
}); 
// $(function(){
// 	$("#specTable").tablesorterPager({
// 		container: $("#pager")
// 	}); 
// 	$("#buyTable").tablesorterPager({
// 		container: $("#pager")
// 	});
// 	$("#relatedTable").tablesorterPager({
// 		container: $("#pager")
// 	});
// }); 

///////////////////////////
// jquery.shuffle.config //
///////////////////////////

$(function() {
		$('#banner_offer').shuffle();
		$('#banner_delivery').shuffle();
		$('#product_header').shuffle();
});

////////////////////////////
// jquery.lightbox.config //
////////////////////////////

$(function() {
        $('#gallery a').lightBox();
});

///////////////////////////
// jquery.fortune.config //
///////////////////////////

$(function() {
                $(".waterwise").fortune({file: "/sites/assets/json/tips.json", cookieNode: "waterwise", metaNodes: {theTitle: "title", theContent: "content"}, animate: false});
});

/////////////////////////////
// jquery.formclear.config //
/////////////////////////////

$(function() { 
   $('.cleardefault').formclear({
   inactivecolor:'', // Defaults to #777 (dark grey)
   activecolor:'',  // defaults to #000 (black)
   emptyval:'' // defaults to '' (nothing, as in cleared)
	}); 
});

///////////////////////////////
// jquery.fancyButton.config //
///////////////////////////////

$(function() {
 $(document).fancyButton();
});

/////////////////////////////
// jquery.linkIcons.config //
/////////////////////////////

$(document).ready(function() {

	// Add pdf icons to pdf links
	$("a[href$='.pdf']").addClass("pdf");
	 
	// Add txt icons to document links (doc, rtf, txt)
	$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft']").addClass("txt");

	// Add zip icons to Zip file links (zip, rar)
	$("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 
	
	// Add email icons to email links
	$("a[href^='mailto:']").addClass("email");

	//Add external link icon to external links - 
	//$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	//    return this.hostname && this.hostname !== location.hostname;
	//  }).addClass("external");

});

/////////////////////////
// jquery.pngie.config //
/////////////////////////
$(document).pngie();