
// Use jQuery via $j(...)
var $j = jQuery.noConflict();
    $j(function() {
        $j('#lightbox-gallery a').lightBox({fixedNavigation:true});
    });

// Function for Homepage Slider
        
	function formatText(index, panel) {
	  return index + "";
	}

	$j(function () {
	
		$j('.anythingSlider').anythingSlider({
			easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
			autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
			delay: 9000,                    // How long between slide transitions in AutoPlay mode
			startStopped: false,            // If autoPlay is on, this can force it to start stopped
			animationTime: 900,             // How long the slide transition takes
			hashTags: true,                 // Should links change the hashtag in the URL?
			buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
			pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
			startText: "Start",             // Start text
			stopText: "Pause",               // Stop text
			navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
		});
		
	});

// Function for Equal Height Fix for Catalogue
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $j(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
$j(document).ready(function() {
	equalHeight($j(".equal"));
});
$j(document).ready(function() {
	equalHeight($j(".equal-1"));
});
$j(document).ready(function() {
	equalHeight($j(".equal-2"));
});
$j(document).ready(function() {
	equalHeight($j(".products-grid li"));
});
$j(document).ready(function() {
	equalHeight($j("#cross-sell-list li"));
});

// Function for Top Cart Concealer
var $j = jQuery.noConflict();
$j(document).ready(function(){
	$j(".btn-slide").click(function(){
	  $j("#cart_concealer").slideToggle("fast");
	  $j(this).toggleClass("active"); return false;
	});

});


var currentlocation = window.location;

$j(function(){
  $j("select#type").change(function(){
	var typeValue = $j("#type option:selected").val(); 
    $j.getJSON("ajax-block-feed.php?id=" + typeValue,function(data){fillmanufacturervalues(data);}); 
  })
  $j("select#manufacturer").change(function(){
		var manufacturerValue = $j("#manufacturer option:selected").val(); 
	    $j.getJSON("/ajax-block-feed.php?id=" + manufacturerValue,function(data){fillrangevalues(data);}); 
	  })
  $j("select#range").change(function(){
		var rangeValue = $j("#range option:selected").val(); 
		$j.getJSON("/ajax-block-feed.php?id=" + rangeValue,function(data){fillmodelvalues(data);}); 
	  })
  $j("select#model").change(function(){
    	var modelValue = $j("#model option:selected").val();
		$j.getJSON("/ajax-block-feed.php?cat2url=" + modelValue,function(data){displayURL(data);}); 
      })
})

function displayURL(j){
     //alert(j);
     currentlocation = j;
    // window.location = currentlocation;
}


function fillmanufacturervalues(j){
	var manufacturer = document.getElementById('manufacturer'); 
	manufacturer.disabled = false; 
      var options = '';
      $j("#manufacturer>option").remove();
      for (type in j) {
    	  options += '<option value="' + type + '">' + j[type] + '</option>';
          //$j("select#manufacturer").append(new Option(j[type],type));
      }
	  $j("select#manufacturer").append(options);
}
function fillrangevalues(j){
	var range = document.getElementById('range'); 
	range.disabled = false; 
    var options = '';
    $j("#range>option").remove();
    for (type in j) {
  	  options += '<option value="' + type + '">' + j[type] + '</option>';
        //$j("select#range").append(new Option(j[type],type));
    }
	$j("select#range").append(options);
}
function fillmodelvalues(j){
	var model = document.getElementById('model'); 
	model.disabled = false; 
    var options = '';
    $j("#model>option").remove();
    for (type in j) {
    	  options += '<option value="' + type + '">' + j[type] + '</option>';
          //$j("select#model").append(new Option(j[type],type));
    }
  	$j("select#model").append(options);
}



