function mini_slider(){
	// #####  MINI SCROLLABLE FOR CURRENT SHOWS IN HEADER  #####
	var mini_horizontal = $(".mini_scrollable").scrollable({ circular: true, speed: 400 }).autoscroll({ interval: 5000}).navigator(".mini_navi");
	// when page loads setup keyboard focus on the first horzontal scrollable
	//mini_horizontal.eq(0).data("mini_scrollable").focus();
}


function feature_slider(){
	// #####  SCROLLABLE SLIDER FOR FEATURED CONTENT IN BODY  #####
	// horizontal scrollables. each one is circular and has its own navigator instance
	var horizontal = $(".scrollable").scrollable({ circular: true, speed: 400 }).autoscroll({ interval: 5000}).navigator(".navi");
	 
	// provide scrollable API for the action buttons
	//window.api = root.data("scrollable");
	 
	// when page loads setup keyboard focus on the first horzontal scrollable
	//horizontal.eq(0).data("scrollable").focus();
}

function promo_slider(){
	// main vertical scroll
	$("#promo_main").scrollable({

		// basic settings
		vertical: true,
		circular: true,
		speed: 300

	// main navigator (thumbnail images)
	}).autoscroll({ interval: 5000}).navigator("#promo_main_navi");


}

function promo_widget(){
$("ul.promotabs").tabs(".promo_widget > div", {

	// enable "cross-fading" effect
	effect: 'fade',
	fadeInSpeed: 500,

	// start from the beginning after the last tab
	rotate: true

// use the slideshow plugin. It accepts its own configuration
}).slideshow({ autoplay: true, interval: 4000});

}

function delete_overlay(){
	$(".remove_button").overlay({
		mask: {
		color: "#000",
		loadSpeed: 200,
		opacity: 0.5
		}
	});
	
	$(".remove_button").click(function() {
		var value = $(this).attr("value").replace("_t", "");
		$("#confirm_delete").val(value);
	});
}

function save_overlay_close(){
	//$("#visibleclose").click(function() {
	//	$(".visible").css("display","none");
	//});	
	
	$("#pagesaved").overlay({
	 	speed: "normal",
		mask: {
		 // you might also consider a "transparent" color for the mask
		 color: "#000",
		 
		 // load mask a little faster
		 loadSpeed: 200,
		
		 // very transparent
		 opacity: 0.5
		 },

		 api: true
		 // load it immediately after the construction
		 //load: true 
	}).load();
	
	
}


function category_refine_select(sortID, formID, containerID, refinepageURL, page){
	$('#'+containerID).animate({'opacity': '0'}, 500, function(){
		$(this).animate({'opacity': '1'}, 500).html("<div class='ajax-loader'></div>")
	});
	

	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
		  var response = xmlhttp.responseText;
		  $('#'+containerID).css({'opacity': '0'});
		  $('#'+containerID).html(response).load($('#'+containerID).animate({'opacity': '1'}, 500));
	    }
	  }
	//xmlhttp.open("GET","http://localhost/thehomechannel/wp-content/themes/SketchPad/scripts/ajax/category_refine.php?q="+catID,true);
	xmlhttp.open("GET", refinepageURL+"?srt="+sortID+"&con="+containerID+"&frm="+formID+"&pg="+page,true);
	xmlhttp.send();

}




function experts_refine_select(sortID, formID, containerID, refinepageURL, page){
	$('#'+containerID).animate({'opacity': '0'}, 500, function(){
		$(this).animate({'opacity': '1'}, 500).html("<div class='ajax-loader'></div>")
	});
	

	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
		  var response = xmlhttp.responseText;
		  $('#'+containerID).css({'opacity': '0'});
		  $('#'+containerID).html(response).load($('#'+containerID).animate({'opacity': '1'}, 500));
	    }
	  }
	//xmlhttp.open("GET","http://localhost/thehomechannel/wp-content/themes/SketchPad/scripts/ajax/category_refine.php?q="+catID,true);
	xmlhttp.open("GET", refinepageURL+"?srt="+sortID+"&con="+containerID+"&frm="+formID+"&pg="+page,true);
	xmlhttp.send();

}

function refine_weather_location(locationID, locationName, refinepageURL){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  
	xmlhttp.onreadystatechange=function()
	  {	
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
		  var response = xmlhttp.responseText;
		  $('#weather_widget').html(response);
	    }
	  }
	
	//xmlhttp.open("GET","http://localhost/thehomechannel/wp-content/themes/SketchPad/widget_weather.php?loc="+locationID,true);
	xmlhttp.open("GET", refinepageURL+"?locID="+locationID+"&locName="+locationName,true);
	xmlhttp.send();

}


function custom_dropdownbox(){	
	 $(".dropdownbox dt a").click(function() {
		 $(this).closest(".dropdownbox").find("ul").slideToggle(500); 
		  return false;
     });
                 
     $(".dropdownbox dd ul li a").click(function() {
    	 var text = $(this).html();
    	 $(this).closest(".dropdownbox").find("dt a span").html(text);
    	 $(this).closest(".dropdownbox").find("ul").slideUp(500); 
     });

    $(document).bind('click', function(e) {
    	var clicked = $(e.target);
    	if (! clicked.parents().hasClass("dropdownbox"))
    	 $('.dropdownbox').find("ul").slideUp(500); 
    });
}

function getSelectedValue(id){
    return $("#" + id).find("dt a span.value").html();
}

function dropdown_menuslide(){	
	$('.dropdown li').hover(
			function(){
				$(this).find('.sub-menu').slideDown('fast').css('visibility', 'visible');
			},
			function(){
				$(this).find('.sub-menu').slideUp('fast', 
						function(){
							$(this).css('visibility', 'hidden');
						});
				
			}
	);
	
}

function weather_location_dropdownbox(){
	$('#change_loc').click(function() {
		$('.location_list').toggle('slow');
    });

	$('#close_loc').click(function() {
		$('.location_list').hide('fast');
    });
	
	$('.location_list ul li').click(function() {
		$('.location_list').hide('slow');
    });
	
}

function tab_pagination(){
	$("ul.tabs").tabs("div.panes", {effect: 'fade', history: true}); 
	//$(".tab_pagination").tabs("div.panes"); 
	/*$("ul.tabs li a").click(function() {
		var currentID = $(this).attr("href").replace("_t", "");
		currentID = parseInt(currentID.substr(1));
		var prev = currentID-1;
		var next = currentID+1;
		
		var lastID = $(".last a").attr("href").replace("_t", "");
		lastID = parseInt(lastID.substr(1));

		if (currentID == 1){
			$(".backward").css("display", "none");
		}else{
			$(".backward").css("display", "block");
			$(".backward").attr("href", "#"+prev);
		}

		if (currentID == lastID){
			$(".forward").css("display", "none");
		}else{
			$(".forward").css("display", "block");
			$(".forward").attr("href", "#"+next);
		}
		
		$("#current_tab").html(currentID);
	});
	
	$(".first").click(function() {
		$(".backward").css("display", "none");
		$(".forward").attr("href", "#1");
		$(".forward").css("display", "block");
		$(".forward").attr("href", "#2");
		$(".current").removeClass("current");
		$("#n1").addClass("current");
		$("#current_tab").html("1");
	});
	
	$(".last").click(function() {
		var lastID = $(".last a").attr("href").replace("_t", "");
		lastID = parseInt(lastID.substr(1));
		var prev = lastID-1;
		
		$(".forward").css("display", "none");
		$(".backward").attr("href", "#"+lastID);
		$(".backward").css("display", "block");
		$(".backward").attr("href", "#"+prev);
		$(".current").removeClass("current");
		$("#n"+lastID).addClass("current");
		$("#current_tab").html(lastID);
	});
	
	$(".forward").click(function() {
		var lastID = $(".last a").attr("href").replace("_t", "");
		lastID = parseInt(lastID.substr(1));
		
		var currentID = $(".current").attr("href").replace("_t", "");
		currentID = parseInt(currentID.substr(1));
		var next = currentID+1;
		
		if (next == lastID){
			$(".forward").css("display", "none");
			$(".forward").attr("href", "#"+next);
		}else{
			$(".forward").css("display", "block");
			$(".forward").attr("href", "#"+next);
		}
		
		var prev = currentID-1;
		$(".backward").css("display", "block");
		$(".backward").attr("href", "#"+prev);
		
		$(".current").removeClass("current");
		$("#n"+next).addClass("current");
		$("#current_tab").html(next);
		
	});
	
	$(".backward").click(function() {
		var currentID = $(".current").attr("href").replace("_t", "");
		currentID = parseInt(currentID.substr(1));
		var prev = currentID-1;
		
		if (prev == 1){
			$(".backward").css("display", "none");
			$(".backward").attr("href", "#"+prev);
		}else{
			$(".backward").css("display", "block");
			$(".backward").attr("href", "#"+prev);
		}
		
		var next = currentID+1;
		$(".forward").css("display", "block");
		$(".forward").attr("href", "#"+next);
		
		$(".current").removeClass("current");
		$("#n"+prev).addClass("current");
		$("#current_tab").html(prev);
	});*/

}
