
if (typeof $j === "undefined"){
    $j = jQuery;
}
	
	$j(document).ready(function()
	{		
		// Clear some non js fixes in css
		$j('.staticpage-home #imagenav').css('overflow', 'visible')

		
		$j('.overlay').css(
		{
			position:'relative',
			zIndex:'9999999'
		});
		
 		$j(".jqzoom").jqueryzoom({xzoom: 458, yzoom: 622,	offset: 20,	position: "right",	preload:1,	lens:1,	fadeIn: 600,fadeOut: 600});	

		var lis = jQuery('#feature-total li');

		lis.mouseover(function(){
		    $j('#article #slide ul').cycle(lis.index(this));
		});
		
		
		
	$j('.dropdown-handle').hover(function(){
		$j(this).parent().find('.dropdown').addClass('sfhover');
	}, function(){
		$j(this).parent().find('.dropdown').removeClass('sfhover');
	});

	$j('.dropdown').hover(function(){
		$j(this).addClass('sfhover');
	}, function(){
		$j(this).removeClass('sfhover');
	});

	$j('#navigation #siteNav li').hover(
		function () {
			$j(this).addClass('sfhover');
		}, 
		function () {
			$j(this).removeClass('sfhover');
		}
    );
    
	$j('.staticpage-home  #imagenav li').hover(
		function () {
			$j(this).addClass('sfhover');
		}, 
		function () {
			$j(this).removeClass('sfhover');
		}
    );

	$j('#feature-mask .auth-button').hover(
		function () {
			$j(this).addClass('sfhover');
		},
		function () {
			$j(this).removeClass('sfhover');
		}
    ).click(function(){
		window.location = $j(this).find('a').attr('href');
	})

	$j('#feature-mask .laurel-button').hover(
		function () {
			$j(this).addClass('sfhover');
		},
		function () {
			$j(this).removeClass('sfhover');
		}
    ).click(function(){
		window.location = $j(this).find('a').attr('href');
	})

	$j('.cfeature-outer').hover(function(){
		$j(this).find('.slide-block').stop(true,false).animate({top:95},{
			duration: 250,
			easing: 'easeInOutQuad'
		} );

	}, function(){
		$j(this).find('.slide-block').stop(true,false).animate({top:160}, 400);
	}).click(function(){
		window.location = $j(this).find('a').attr('href');
	});

// 	$j('#logo').bind('click', function()
// 	{
// 		window.location = '/';
// 	});

		$j('.women_hover').hover
		(
			function () {
				$j('.lim_women').addClass('showblock');
			}, 
			function () {
				$j('.lim_women').removeClass('showblock');
		});
		
		$j('.men_hover').hover
		(
		
			function () {
				$j('.lim_men').addClass('showblock');
			}, 
			function () {
				$j('.lim_men').removeClass('showblock');				
		});
		
		
		
		$j('.lim_men, .lim_women, .access_men, .access_women').hover
		(
			function () {
				$j(this).addClass('showblock');
			}, 
			function () {
				$j(this).removeClass('showblock');				
		});

		$j('.access_men_hover').hover
		(
			function () {
				$j('.access_men').addClass('showblock');
			},
			function () {
				$j('.access_men').removeClass('showblock');
		});
		$j('.access_women_hover').hover
		(
			function () {
				$j('.access_women').addClass('showblock');
			},
			function () {
				$j('.access_women').removeClass('showblock');
		});
		
		$j('.internallink').click(function(){
			var toopen = $j(this).attr('href');
			var elementToMove = $j('.faqquestion[name='+toopen.replace('#', '')+']').next('dl');
			elementToMove.slideToggle();
   			elementToMove.parent('li').toggleClass('light');
   			$j('.faqquestion[name='+toopen.replace('#', '')+']').toggleClass('selected');
			

		});

		if (window.location.hash == "#howdoIcontactcustomer") {
			$j(".faqquestion[name=howdoIcontactcustomer]").next('dl').slideToggle();
		}
		
		$j(".faqquestion").click(function () {
   			 $j(this).next('dl').slideToggle();
   			 $j(this).parent('li').toggleClass('light');
   			 $j(this).toggleClass('selected');
   			 return false;
		});

		$j('.tiparea').hover(function(){
			$j(this).addClass('fakehover');
			$j(this).find('.tooltip-outer').stop(true,false).fadeIn('fast');
		}, function(){
			$j(this).removeClass('fakehover');
			$j(this).find('.tooltip-outer').stop(true,false).fadeOut('fast');
		})



		$j('#feature-total #preview').hover(function(){
			$j('#article #slide ul').cycle('pause');
		    $j(this).parent().find('#feature-dropdown').fadeIn('slow');
		    $j(this).fadeOut('fast', 0);
		}, function(){
		    
		});

		 $j('#feature-total #feature-dropdown').hover
		(
		    function(){
		    },
		    function(){
			$j('#article #slide ul').cycle('resume');
			$j(this).parent().find('#preview').fadeIn('slow');
			$j(this).fadeOut('fast', 0);
		    }
		);


		/** fading maxiscreen */
		if ($j('.cms-home #feature-mask').length) {
			$j('body, html').css('overflow-x', 'hidden');
		}		

		var feature = $j('#feature-mask'),
		img         = $j('img', feature);

		var px = ''+((($j('body').width() - 1452 )/ 2)) + 'px';
		feature.css({
			position: 'absolute',
			width: $j('body').width() + 1000,
			height: $j(document).height() +1000
		});

		img.css({
			position: 'absolute',
			left: px,
			top: 0
		});
		
		var locked = false, fired = false;

		$j(document).mousemove(function(){
			// let the mousemove fire once before we do anything
			if ( ! fired) {
				fired = true;
				return false;
			}

			setTimeout(function(){
				if (locked){
					return;
				}

				locked = true;

				$j(this).unbind('mousemove');

				hideHomepageMask();
			}, 1);
		});
		if($j('.outer-site-notice')){
			function centerDialog() {
				var container = $j('.inner-site-notice');
				var top = Math.max(($j(window).height() - container
						.height()) / 2, 0);
				var left = Math.max(($j(window).width() - container
						.width()) / 2, 0);

				if (container.height() < $j(window).height()) {
					top += $j(document).scrollTop();
				}

				container.css("top", top + "px");
				container.css("left", left + "px");
			}

			var outerContainer = $j('.outer-site-notice');
			var closeButton = $j('.site-notice-close a');
			closeButton.click(function(){
				$j('.outer-site-notice, .inner-site-notice').hide();
				// set the location cookie after clicking only
				document.cookie = "LocationDetected = true;";
				return false;
			});

			var height_modifier = $j('div.wrapper > div.container_16').height() || 0;
			var page_height = ($j('div.page').height() || 0) + height_modifier;
			var window_height = $j(window).height();

			var new_height = Math.max(parseInt(page_height), parseInt(window_height));

			$j(window).resize(centerDialog);
			$j(document).scroll(centerDialog);

			outerContainer.css({height:new_height});
			outerContainer.show();
			if(/msie|MSIE 6/.test(navigator.userAgent)){
				outerContainer.css({height:new_height, width:parseInt($j(window).width())}).show();
			}
			centerDialog();
		}
});

function hideHomepageMask() {

	
     $j('.cms-home #feature-mask').fadeOut(1000, function() {

			$j('#slide-fake').fadeOut('fast');
			
            $j('#article #slide ul').cycle
            ({
                fx:         'fade',
                timeout:     6000,
                delay:     0,
                speed:       250,
                pause:  1,
                manualTrump: true
            })
			
		$j('body, html').css('overflow-x', 'auto');
	});
}



//----------------------------------
// ALL BELOW FOR MUSIC PLAYER POPUP
//----------------------------------

function launch_fp() {
  if (Macintosh_fp == true && browserName_fp == "IE") {
		playerWindow_fp = newWin_fp('http://www.fredperrysubculture.com/musicplayer_mainsite.asp?list=cat&id=1','player',600,88,false,'no','no','no','no','no','no',false,0,0);
	} else {
		playerWindow_fp = newWin_fp('http://www.fredperrysubculture.com/musicplayer_mainsite.asp?list=cat&id=1','player',600,58,false,'no','no','no','no','no','no',false,0,0);
	}
}

var its_fp;
var browserName_fp;
var browserName_fpLong;
var browserNew_fp;
var preloadFlag_fp = false;
var Macintosh_fp = navigator.userAgent.indexOf('Mac')>0;

function its_fp() {
	var n = navigator;
	var ua = ' ' + n.userAgent.toLowerCase();
	var pl = n.platform.toLowerCase();
	var an = n.appName.toLowerCase();

	// browser version
	this.version = n.appVersion;
	this.nn = ua.indexOf('mozilla') > 0;

	// 'compatible' versions of mozilla aren't navigator
	if(ua.indexOf('compatible') > 0) {
		this.nn = false;
	}
	
	this.opera = ua.indexOf('opera') > 0;
	this.ie = ua.indexOf('msie') > 0;
	this.major = parseInt( this.version );
	this.minor = parseFloat( this.version );

	// platform
	this.mac = ua.indexOf('mac') > 0;
	this.win = ua.indexOf('win') > 0;

	// workaround for IE5 which reports its_fpelf as version 4.0
	if(this.ie) {
		if(ua.indexOf("msie 5") > 1) {
		var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
		this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));
		}
	}

	return this;
}

function browserNaming_fp() {
	its_fp = new its_fp();
	
	// is it a DOM-enabled browser?
	if (!document.getElementById) {
		browserNew_fp = false;
	}
	else {
		browserNew_fp = true;
	}

	// need the name, too
	if (its_fp.opera) {
		browserName_fp = "Opera";
	}
	else if (its_fp.ie) {
		browserName_fp = "IE";
	}
	else {
		browserName_fp = "NS";
	}

	// and the number
	browserName_fpLong = browserName_fp + its_fp.major;

}
//initialise browser checking
browserNaming_fp();


function newWin_fp(theurl,winName,windowWidth,windowHeight,center,status,menubar,toolbar,resizable,scroll,location,offset,xPos,yPos) {
	//check if browser is version 4 or above, and if centering is desired
	if (its_fp.major >= 4 && center == true) {
		wX = (screen.width/2)-(windowWidth/2+10);
		wY = (screen.height/2)-(windowHeight/2+20);
	}else if (offset == true) {
		wX = xPos;
		wY = yPos; // offset window
	}else {
		wX = 0;
		wY = 0; // set window pos to 0,0 if browser is not ver 4 or center == false && offset == false
	}
	theurl = theurl;
	var popped = window.open(theurl,winName,'width='+windowWidth+',height='+windowHeight+',status='+status+',menubar='+menubar+',toolbar='+toolbar+',scrollbars='+scroll+',resizable='+resizable+',location='+location+',screenX='+wX+',screenY='+wY+',left='+wX+',top='+wY);
	if (browserName_fp == "NS" || document.all) {
	popped.focus();
	}
}


function launch(list, trackid) {
	if (Macintosh_fp == true && browserName_fp == "IE") {
		playerWindow_fp = newWin_fp('http://www.fredperrysubculture.com/musicplayer_mainsite.asp?list='+list+'&id='+trackid,'player',600,88,false,'no','no','no','no','no','no',false,0,0);
	} else {
		playerWindow_fp = newWin_fp('http://www.fredperrysubculture.com/musicplayer_mainsite.asp?list='+list+'&id='+trackid,'player',600,58,false,'no','no','no','no','no','no',false,0,0);
	}
}

jQuery.extend( jQuery.easing,
{
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	}
});


