// Styles Creative Web Design
// Javascript sheet

$(document).ready(function(){
	// initialize Homepage scrollable
	$(".rotator").scrollable({speed:700}).autoscroll({autoplay: true,interval:5000,autopause:true});
	
	// initialise Testimonials fader
	$(".slidetabs").tabs(".testimonial > div", {effect: 'fade', fadeOutSpeed: 'slow', rotate: true })
	.slideshow({autoplay:true, interval: 6000, clickable: false});
	
	// initialise drop down 
	$(".tabs").tabs(".product-group > .product", {effect: 'fade', fadeOutSpeed: 'fast', rotate: false})
	.slideshow({clickable: false});
	
	$("ul.tabs li span").click(function() { //When trigger is clicked...
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find(".subnav").slideDown().show(); //Drop down the subnav on click
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find(".subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
	
	$("ul.tabs li ul li a").click(function() {
		$("ul.tabs li span").parent().find(".subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
	});
	
	$(".product-image a").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over'
	});
	
	$(".fancy").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over'
	});	
	
});


// Enquiry Form Subject Line
<!-- hide from old browsers
function getValue(varname)
{
  // First, we load the URL into a variable
  var url = window.location.href;

  // Next, split the url by the ?
  var qparts = url.split("?");
  // Check that there is a querystring, return "" if not
  if (qparts.length == 0)
  {
    return "";
  }
  // Then find the querystring, everything after the ?
  var query = qparts[1];
  // Split the query string into variables (separates by &s)
  var vars = query.split("&");
  // Initialize the value with "" as default
  var value = "";
  // Iterate through vars, checking each one for varname
  for (i=0;i<vars.length;i++)
  {
    // Split the variable by =, which splits name and value
    var parts = vars[i].split("=");
    
    // Check if the correct variable
    if (parts[0] == varname)
    {
      // Load value into variable
      value = parts[1];

      // End the loop
      break;
    }
  }
  
  // Convert escape code
  value = unescape(value);
  // Convert "+"s to " "s
  value.replace(/\+/g," ");
  // Return the value
  return value;
}
var name = getValue("subject");
// end hide -->

