/*
 ## 
 ## *Author:Jose V.G.
 ## 
*/

$(function(){
	$('.topnav ul').superfish({ delay: 200, animation: {height:'show'}, speed: 'fast' });
	
	var hostname = window.location;
	hostname = hostname.toString();
	if(hostname.indexOf("pageid=11")!=-1) {
		$('#left-bar').remove();
		$('#page-container').addClass('company');
	}

	//PRODUCT DETAILS
	if ($('.product-details').length) {
		$('#center-main h1:first').insertBefore($('.product-details .details'))
	}
	if ($('.dialog-category-products-list').length) {
		$('#center-main h1:first').insertBefore($('.dialog-category-products-list .title'))
	}
	$('#footer .menu-help li:first').addClass('first-item');
	
	/*TAKE LINK VALUE AND ADD CLASS*/
	$('.menu-fancy-categories-list a').each(function(){
		var str = $(this).text().toLowerCase();
		str = str.replace(/ /g, "");
		str = str.replace(/12/g,"twelve");
		$(this).addClass(str).parent().addClass(str);
	});
	
	/*digg breadcrumbs - MOVE CURRENT SECTION CATEGORY TO TOP*/
	var crumbtx = $('#location .bread-crumb').text();
	if(crumbtx.match('Men'))
		$('#left-bar li.men').addClass('activeSection').insertBefore('#left-bar li.collections');
	if(crumbtx.match('Collections'))
		$('#left-bar li.men').addClass('activeSection').insertBefore('#left-bar li.collections');
	if(crumbtx.match('Women'))
		$('#left-bar li.women').addClass('activeSection').insertBefore('#left-bar li.collections');
	if(crumbtx.match('Kids'))
		$('#left-bar li.kids').addClass('activeSection').insertBefore('#left-bar li.collections');
	
	/*PRODUCT LIST*/
	if($('.products-list').length) {
		$('#page-container').addClass('productlist');
		$('.products-list .item').each(function(){
			$(this).find('.descr img').addClass('product_image2').appendTo($(this).find('.image .image-border a'));
		});
		$('.products-list .item:odd').addClass('odd');
	}
	
	/*REDIRECTS*/
	
	if($("#center h1:contains('Coming Soon!')").length) {
			var url = $('#location a.bread-crumb:last').attr('href');
			$(location).attr('href',url);
	}
	
	
	
	/*WELCOME PAGE*/
	if($('.welcome-page').length) {
			$('.i-main').bind('mouseover',function(){
				//temporary off rock_your_style accordion
				if ($(this).find('img').attr('src')=='images/rockurstyle.jpg') return false;
				if(this.parentNode.className == 'isopen'){
					alert('isopen');	
				}
				$(this).parent().animate({'width':'523px'},'slow').addClass('isopen');
				
				if($(this).parent().hasClass('t12gaitem')) {
					$('.fmitem').animate({'width':'723px'},'slow');
					$('.fmitem').find('p').show('slow');		
				}
			});
			$('.slideitem').bind('mouseleave',function(){
				if($(this).hasClass('welcomeitem')) 
					$(this).animate({'width':'312px'},'slow');
				else if($(this).hasClass('t12gaitem')) {
					//do nothing		
				}
				else
					$(this).animate({'width':'176px'},'slow').removeClass('isopen');
			});
			$('.fmitem').bind('mouseover',function(){
				$(this).animate({'width':'723px'},'slow');
				$(this).find('p').show('slow');
				$('.t12gaitem').animate({'width':'523px'},'slow'); 
			})
			$('.fmparent').bind('mouseleave',function(){
				$('.fmitem').animate({'width':'150px'},'slow');
				$('.fmitem').find('p').hide('slow');
				$('.t12gaitem').animate({'width':'176px'},'slow');
			});
	}
	
	/*deattach FMCC*/
	$("a[href='http://frontmann.com/FMCC/']").removeAttr('href');
	
	$('.topnav a').map(function(){
		if ($(this).attr('href') == '#') { 
			$(this).removeAttr('href').css('cursor', 'pointer');
		}
		if($(this).text() == 'FAQ/Help') $(this).remove();
	});
	
	$('.specialoffers, .featureditems').removeClass('empty-link').attr('href', 'http://frontmann.com/Ebmas-Trilogy.html');
	
});
