$(document).ready(function() {

	jQuery('.float').keyup(function () {
		this.value = this.value.replace(/[^0-9\.]/g,'');
	});

	jQuery('.whole').keyup(function () {
		this.value = this.value.replace(/[^0-9]/g,'');
	});

	jQuery('.filename').keyup(function () {
		this.value = this.value.replace(/[^0-9a-zA-Z\-\_]/g,'');
	});


	$('p.expander').expander({
		slicePoint:       320,  // default is 100
		expandText:         '[Read More]', // default is 'read more...'
		collapseTimer:    0, // re-collapses after 5 seconds; default is 0, so no re-collapsing
		userCollapseText: '[Close]'  // default is '[collapse expanded text]'
	});
  
  
	//makeSublist('child','grandsun', true, '');
	makeSublist('parent','child', false, '1');
		
	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});


	$("#myController").jFlow({
		slides: "#slides",
		controller: ".jFlowControl", // must be class, use . sign
		slideWrapper : "#jFlowSlide", // must be id, use # sign
		selectedWrapper: "jFlowSelected",  // just pure text, no sign
		auto: true,		//auto change slide, default true
		width: "750px",
		height: "271px",
		duration: 400,
		prev: ".jFlowPrev", // must be class, use . sign
		next: ".jFlowNext" // must be class, use . sign
	});



	if(typeof document.body.style.maxHeight === "undefined") {
		// IE6
		if ($('#deals').length == 0) {

		} else {

			oTable = $('#deals').dataTable({
				"bFilter": false,
				"bInfo": false,
				"bJQueryUI": true,
				//"bStateSave": true,
				"sPaginationType": "full_numbers",
				"bPaginate": false, 
				"aaSorting": [[ 7, "asc" ]],
				"aoColumns": [
					{ "bSortable": false, "sWidth": "0px" },
					{ "bSortable": false, "sWidth": "0px" },
					{ "sWidth": "100%" },
					{ "sWidth": "0px" },
					null,
					null,
					null,
					null,
					{ "bSortable": false, "sWidth": "0px" }
				]
			});
		}
	} else {
		// OTHER
		if ($('#deals').length == 0) {

		} else {

			oTable = $('#deals').dataTable({
				"bJQueryUI": true,
				//"bStateSave": true,
				"sPaginationType": "full_numbers",
				"bPaginate": true, 
				"aaSorting": [[ 7, "asc" ]],
				"aoColumns": [
					{ "bSortable": false, "sWidth": "0px" },
					{ "bSortable": false, "sWidth": "0px" },
					{ "sWidth": "100%" },
					{ "sWidth": "0px" },
					null,
					null,
					null,
					null,
					{ "bSortable": false, "sWidth": "0px" }
				]
			});
		}
	}


	




	if ($('#similar').length == 0) {
	
	} else {
	
		oTable = $('#similar').dataTable({
			"bFilter": false,
			"bInfo": false,
			"bJQueryUI": true,
			//"bStateSave": true,
			"sPaginationType": "full_numbers",
			"bPaginate": false, 
			"aaSorting": [[ 4, "asc" ]],
			"aoColumns": [
				{ "sWidth": "100%" },
				{ "sWidth": "0px" },
				{ "sWidth": "0px" },
				{ "sWidth": "0px" },
				{ "sWidth": "0px" }
			]
		});
	}

	if ($('#linked').length == 0) {
	
	} else {
	
		oTable = $('#linked').dataTable({
			"bFilter": false,
			"bInfo": false,
			"bJQueryUI": true,
			//"bStateSave": true,
			"sPaginationType": "full_numbers",
			"bPaginate": false, 
			"aaSorting": [[ 2, "asc" ]],
			"aoColumns": [
				{ "sWidth": "100%" },
				{ "sWidth": "0px" },
				{ "sWidth": "0px" }
			]
		});
	}
	
	if ($('#basket').length == 0) {
	
	} else {
	
		oTable = $('#basket').dataTable({
			"bFilter": false,
			"bInfo": false,
			"bJQueryUI": true,
			//"bStateSave": true,
			"sPaginationType": "full_numbers",
			"bPaginate": false, 
			"aaSorting": [[ 5, "asc" ]],
			"aoColumns": [
				{ "bSortable": false, "sWidth": "0px" },
				{ "bSortable": false, "sWidth": "0px" },
				{ "sWidth": "300px" },
				{ "sWidth": "0px" },
				null,
				{ "sWidth": "175px" },
				{ "bSortable": false, "sWidth": "0px" }
			]
		});
	}
	
	if ($('#gallery').length == 0) {
	
	} else {
	
		$('#gallery ul li a').lightBox();
	
	}

	// TWEETS
	$jScroller.add("#tweet","#tweetline","left",1);
	$jScroller.config.refresh = 20;
	$jScroller.start();
  
});
