$(document).ready(function(){
	
	if($('body').hasClass('page') || $('body').hasClass('error404')) {
		if($('body').hasClass('page-work') || $('body').hasClass('home')) {
				$.backstretch('/wp-content/themes/seve7ndesign/img/bck-home.jpg', {minW: 960,centeredY:false});
		} else if($('body').hasClass('page-clients')) {
				$.backstretch('/wp-content/themes/seve7ndesign/img/bck-clients.jpg', {minW: 960,centeredY:false});
		} else {
			$.backstretch('/wp-content/themes/seve7ndesign/img/bck-about.jpg', {minW: 960,centeredY:false});
		}
	}
	

	
	
	$('#work-gallery li:nth-child(4n+1)').addClass('first');
	
		$('.single-project #info img').appendTo('#slides');
		
		$('#page-content img, .billboard-text > p > img').appendTo('h1');

	
	$('#slides').cycle({
		speed:	 300,
        timeout:  0,
		nowrap:  0,
	    prev:    '#prev',
        next:    '#next, #slides img',
		after: onAfter
    });
	var current;
	if(paramExists('expertise')){
		current=getParameterByName( 'expertise' );
	}
	if(paramExists('industry')){
		current=getParameterByName( 'industry' );
	}
	
	$('#header li').each(function(){
		if($(this).attr('class').indexOf(current) > -1) {
			$(this).addClass('current');	
		}
  });
  
  $('a[rel=prev]').attr('href', $('a[rel=prev]').attr('href') + '?' + window.location.search.substring(1));
  $('a[rel=next]').attr('href', $('a[rel=next]').attr('href') + '?' + window.location.search.substring(1));
  $('a#main-link').attr('href', $('a#main-link').attr('href') + '?' + window.location.search.substring(1));
	

});

	function onAfter(curr,next,opts) {
		var caption = (opts.currSlide + 1) + ' / ' + opts.slideCount;
		$('.numbering').html(caption);
	}
	
	
	function getParameterByName( name )
	{
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null )
		return "";
	  else
		return decodeURIComponent(results[1].replace(/\+/g, " "));
	}

	function paramExists(param){
		var url = window.location.href;
		if(url.indexOf('?' + param + '=') != -1)
			return true;
		else if(url.indexOf('&' + param + '=') != -1)
			return true;
		return false;
	}

