/* jQuery.noConflict(); */
var basic = {
			removePlugins : 'resize, elementspath, toolbar',
			height : 30,
			skin : 'kama',
			uiColor : '#ababab'
		};

var full = {
	toolbar : [
				['Source'],
				['Cut','Copy','Paste','PasteText','PasteFromWord'],
				['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
				'/',
				['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
				['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
				['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
				['Link','Unlink','Anchor'],
				['Table','HorizontalRule','SpecialChar'],
				'/',
				['Format','Font','FontSize']
				['Maximize', 'ShowBlocks']
			],
	removePlugins : 'resize, elementspath',
	height : 200,
	skin : 'kama',
	uiColor : '#ababab'
};

  jQuery(document).ready(function($){
	// Place Functions Below this line

	// Form Validtion
	$('#subscriptionsForm').validate(
	{
		messages: {
			firstName: 'Please provide your first name',
			surname: 'Please provide your surname',
			message: 'Please provide details of your enquiry',
			street: 'Please complete this field',
			city: 'Please complete this field.',
			postcode: 'Please provide a valid postcode',
			country: 'Please provide your country of residence',
			tel: 'Please provide your full telephone number',
			mobile: 'Please provide your full mobile number',
			enquiry: 'Please specify the nature of your enquiry.',
			email: {
				required: 'Please provide a valid email address',
				email: 'Example: name@domain.com'
			}
		}
	});

	$('.company-logo p').center();


	// jLable
	$('input[type=text], input[type=password], textarea').jLabel();

	// rollover buttons
	$('button.rollover, .chartFeed li, table.default tr').hover(function(event)
	{
		$(this).addClass('over').css('cursor','pointer');
	},
	function(event)
	{
		$(this).removeClass('over').css('cursor','auto');
	});

	//HTML markup
	$('ul > li:last-child').addClass('lastItem');
	$('ul > li:first-child').addClass('firstItem');
	$('hr').replaceWith('<div class="ruledLine"></div>');
	$('#bradingContainer').append('<span class="shadowTop"></span><span class="shadowBottom"></span>');
	$('#breadCrumb li:not(:last-child)').append(' /');
	$('#latest-eJournals li, .commentEntry, #featureFeed li').append('<div class="clear"></div>');
	$('#footerNav li a').append('<em></em>');
	//$('.imageBasedFeed li h3 a').append('&hellip;');
	$('.pdfPackagesDownload li').prepend('<span></span>').append('<div class="clear"></div>');
	$('table.default tr td:last-child, table.default tr th:last-child').addClass('lastRowCell');
	$('table.entry-detail-contact tr > td:first-child').addClass('firstRowCell');
	$('.accordionCopy table.default tr:last-child').addClass('finalRow');
	$('.calendarContainer h2:not(":first-child")').prepend('<a href="#header" class="scrollPage">Top of Page <em>&uarr;</em></a>');

	//News Feed
	$('.newsFeed li:nth-child(even), table.default tr:nth-child(even)').addClass('alt');
	$('.tabContent .newsFeed li p.details').remove();


	//$('.newsFeed li p.details').append(' &hellip;');
	//$('.newsFeed li p.date').append('<a class="arrowLink" href="javascript:;">Read more <em></em></a>');
	$('.newsFeed li.skyscraperContainer').next('li').css('border-top', '1px solid #999');

	// $('#featureFeed li').append('<div class="clear"></div>');

	//Chart Feed
	$('.chartFeed li').append('<em></em>');

	//Hero Feature Animation
	//$('#heroFeatures li h1 a, #heroFeatures li p.details').append('&hellip;');
	$('#heroFeatures').cycle(
	{
		fx: 'scrollHorz',
		pause: 1,
		speed: 500,
		timeout: 5000,
		prev: '.prevFeature',
		next: '.nextFeature',
		pager:  '#featureNavIndicator'
	});

	$('#featureNavIndicator').each(function(){
		var box = $(this);
		var pw = box.parent().width();
		var bw = box.width();
		var pos = (pw/2)-(bw/2);
		box.css('margin-left' , pos+'px');
	});

	//Tabbed Navigation
	$('ul.tabNav li a').click(function()
	{
		var curChildIndex = $(this).parent().prevAll().length + 1;
		$(this).parent().parent().children('.active').removeClass('active');
		$(this).parent().addClass('active');
		$(this).parent().parent().next('.tabsContainer').children('.active').fadeOut('fast',function()
		{
			$(this).removeClass('active');
			$(this).parent().children('div:nth-child('+curChildIndex+')').fadeIn('normal',function()
			{
				$(this).addClass('active');
			});
		});
		return false;
	});

	// Accordion Menu
	$('.accordionCopy').append('<div class="clear"></div><a class="closer" href="javascript:;"><em></em>close this content</a>');
	$('.accordionContent h3 a').prepend('<span></span>');

	//Accordion Mechanics
	$('.accordionContent h3, .closer').click(function()
	{
		$('.accordionContent h3, .closer').removeClass('active');
		$('.accordionCopy').slideUp(500);
		if ($(this).next().is(':hidden') == true)
		{
			$(this).addClass('active');
			$(this).next().slideDown(500);
		}
	});
	$('.accordionContent h3, .closer').mouseover(function() { $(this).addClass('over');}).mouseout(function() {$(this).removeClass('over');});
	$('.accordionCopy').hide();

	$('.accordionCopy ul > li:even').addClass('clear');


	// Animated Page Scrolling
	$('.scrollPage').click(function() {
	   elementClicked = $(this).attr("href");
	   split=elementClicked.split("/");
	   elementClicked = split.pop();
	   destination = $(elementClicked).offset().top;
	   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-15}, 750 );
	   return false;
	});

	//ARTICLE GALLERY
	//$('.articleHero a').append('<span class="magnify">Click To Enlarge<em></em></span>');
	$('.articleGallery a:nth-child(4) img').addClass('lastItem');

	// Fancybox
	$('a.fancyBox').fancybox(
	{
		'padding'		: 5,
		'overlayColor'	: '#000',
		'overlayColor'	: '#000',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'speedIn'		: 400,
		'speedOut'		: 200,
		'cycle'			: true,
		'titlePosition'	: 'over'
	});

	$("a.iframe").fancybox();


	// Video Link
	$('a.videoLink').click(function()
	{
		$.fancybox(
		{
			'padding'		: 5,
			'overlayColor'	: '#000',
			'autoScale'		: false,
			'transitionIn'	: 'fadeIn',
			'transitionOut'	: 'fadeOut',
			'title'			: this.title,
			'titleShow'		: false,
			'width'			: 720,
			'height'		: 429,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',    // <--add a comma here
			'swf'			: {'allowfullscreen':'true'} // <-- flashvars here
		});
		return false;
	});

	//Calendar Definitions
	$('table.eventsCalendar tr td:first-child, table.eventsCalendar tr th:first-child').addClass('date');
	$('table.eventsCalendar tr td:last-child, table.eventsCalendar tr th:last-child').addClass('location');
	$('.eventDetails').hide();
	$('a.detailShower').click(function(){
		$(this).parent().next('div').slideToggle('slow');
	});

	// BUYER GUIDE

	$('#buyers-guide-listings li a').prepend('<span></span>');
	//$('#buyers-sub-cat li:nth-child(3n)').addClass('row-end');
	//$('#buyers-sub-cat li:nth-child(4n)').css('clear','both');

	$('.buyers-submenu a').addClass('arrowLink');
	$('#featureFeed.buyers-companies li').prepend('<span class="big-arrow">Full Details <em></em></span>').append('<div class="clear"></div>');
	$('#featureFeed.buyers-companies li:even').addClass('alt');

	//$('.company-product-categories-list li').append('<em> | </em>');


	$('div.columnise.four').columnize({width:195});



	// BUYER GUIDE REGISTRATION

	$('#buyers-orders tr td:nth-child(5)').addClass('details-col');
	$('#buyers-orders tr td:last-child, #buyers-orders tr th:last-child').addClass('view-order');


	$('#marketing-address-details, #enquiry-address-details').hide();


	$('#chkEnquiry').click(function(event)
	{
		if (this.checked)
		{
			$('#enquiry-address-details').show();
		}
		else
		{
			$('#enquiry-address-details').hide();
		}
	});

	$('#chkMarketing').click(function(event)
	{
		if (this.checked)
		{
			$('#marketing-address-details').show();
		}
		else
		{
			$('#marketing-address-details').hide();
		}
	});

	// Sub cat selection

	$('.cat-column.last').append('<div class="cat-arrow"></div>')

	$('#registration-category-selectors li a').prepend('<em></em>');
	//$('#registration-category-selectors li a:eq(0)').addClass('active');

	//$('div.reg-subcat').not('div.reg-subcat:eq(0)').hide();
	/*$('#registration-category-selectors li a').click(function()
	{
		var catShow = $(this).attr('title')

		$('#registration-category-selectors li a').removeClass('active');
		$('div.reg-subcat:visible').slideUp('slow');

		$('#'+catShow).slideDown('slow');
		$(this).addClass('active');
	});*/

	// Web listing Boxes
	$('#web-listings').masonry({
		itemSelector : '#web-listings > li',
	});

	//Enhancements
	$('#edit-assignment').prepend('<a class="close-enhance" href="javascript:;">Close</a>').hide();

	$('a.enhance-it').click(function()
	{
		$('#edit-assignment:visible').fadeOut();
		$('#edit-assignment').fadeIn();
	});

	$('a.close-enhance').click(function()
	{
		$('#edit-assignment').fadeOut();
	});

	//Add Category Listing
/*	$('#add-category').prepend('<a class="close-category" href="javascript:;">Close</a><div class="clear"></div').hide();
	$('a.create-category').click(function()
	{
		$('#add-category:visible').fadeOut();
		$('#add-category').fadeIn();
	});
	$('a.close-category').click(function()
	{
		$('#add-category').fadeOut();
	});
*/
/*	$('#add-sub-category').prepend('<a class="close-sub-category" href="javascript:;">Close</a><div class="clear"></div').hide();
	$('a.create-sub-category').click(function()
	{
		$('#add-sub-category:visible').fadeOut();
		$('#add-sub-category').fadeIn();
	});
	$('a.close-sub-category').click(function()
	{
		$('#add-sub-category').fadeOut();
	});*/


	//Profile
	/*$('div.logo-container p').hide();

	$('div.logo-container:not(:has(img))').each(function()
	{
		$('div.logo-container p').show();
	});*/


	//Order Entries

	$('div.status-box p strong').each(function() {
		 $(this).prependTo(this.parentNode);
		 $(this).parent().addClass('status-indicator');
	});



	//RSS Feeds
	$('.rssFeed li a').prepend('<em></em>');

	// Make Whole Element a Link
	$('#newsFeed li, .chartFeed li, #featureFeed.buyers-companies li, #buyers-orders tr:has(td)').click(function(event)
		{
			var href = $(this).find('a:first').attr('href');
			if (!href) { return ;}
			location.href = href;
	});



	//addThis
	$('.bookmarkIt').html('<div class="addthis_toolbox addthis_default_style "><a href="http://www.addthis.com/bookmark.php?v=250&amp;username=ilmpublications" class="addthis_button_compact">Share</a><span class="addthis_separator">|</span><a class="addthis_button_delicious"></a><a class="addthis_button_linkedin"></a><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a><a class="addthis_button_googlebuzz"></a></div><div class="addthis_toolbox addthis_default_style "><a class="addthis_button_tweet"></a><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a></div><script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=ilmpublications"></script>');

	// Google Maps
	$('div.googleMapContainer').html('<iframe width="482" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=International+Labmate+Ltd,+Oak+Court,+Sandridge+Park,+Saint+Albans&amp;aq=0&amp;sll=51.773166,-0.323685&amp;sspn=0.011339,0.027809&amp;vpsrc=6&amp;ie=UTF8&amp;hq=International+Labmate+Ltd,+Oak+Court,&amp;hnear=Sandridge+Park,+St+Albans,+Hertfordshire+AL3+6,+United+Kingdom&amp;ll=51.780161,-0.278778&amp;spn=0.127444,0.33165&amp;z=11&amp;output=embed"></iframe>');

	//$('p.getDirection').html('<a class="arrowLink" href="http://maps.google.co.uk/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=International+Labmate+Ltd,+Oak+Court,+Sandridge+Park,+Saint+Albans&amp;aq=0&amp;sll=51.773166,-0.323685&amp;sspn=0.011339,0.027809&amp;vpsrc=6&amp;ie=UTF8&amp;hq=International+Labmate+Ltd,+Oak+Court,&amp;hnear=Sandridge+Park,+St+Albans,+Hertfordshire+AL3+6,+United+Kingdom&amp;ll=51.780161,-0.278778&amp;spn=0.127444,0.33165&amp;z=11" rel="external">Get Directions<em></em></a>');


	// External Links
	$('a[rel=external]').click(function(){
		this.target = '_blank';
	});


// Place Functions Above this line
	}
);

