jQuery.noConflict();	

function assignClass(){
		// Snippets to get pagename
		p = window.location.pathname;
		//alert( p = p.substring(p.indexOf('http:'), p.lastIndexOf('/')) );
		while( p.indexOf('/')+1 ) p = p.replace(/\//,'-');
		while( p.indexOf('-' )+1) p = p.replace(/-/,'');
		return p;	
};

jQuery(function($){
		
		// body class based on path
		var thisClass = assignClass();
		$('body').attr('class', thisClass);
		// Add slider division. Next to append dynamic slider for header		
		var current = $('body').attr('class');
		var txt = $('#slider div img').attr('alt');
		
		$('img[alt="SpringCube Location"]').slideUp();
		/*
				
		$('#slider div').innerfade({ 
			speed: 'slow', 
			timeout: 4000, 
			type: 'sequence'
		});			
		*/	
		$('#slider div').cycle('fade');
		$('#slider')
			.append('<h2 class="title"/>');
		$('h2.title')
			.text(txt);
			
		$('h4:contains("Latest Post")').addClass('latest-post');

			
		if ( current === 'about' || current === 'aboutmanagement') {
			$('h2.title')
				.text('As a boutique executive search firm, we offer our clients '+ 
						'focused and customized recruitment strategies.');
						$('#contentleft h1').addClass('title-'+current);
		}
		else if (current === 'clients') {
			$('h2.title')
				.text('We are committed to understanding our clients’ business ' +
				 	'and social objectives, ensuring that they attract the right individuals.');
					$('#contentleft h1').addClass('title-'+current);
		}
		else if ( current === 'candidates') {
			$('h2.title').text('We provide an objective view of each opportunity '+
					'presented to our candidates, seeking only to recommend roles '+
					'that best maximize their worth and career aspirations.');
					$('#contentleft h1').addClass('title-'+current);
		}
		else if ( current === 'jobs' ) {
			$('#slider').hide('fast');
			$('#contentleft h1').addClass('title-'+current);
		}
		else {
			$('h2.title').text('Our aim is to help secure high caliber and noteworthy individuals '+
					'to be part of our clients team of professionals.');
					$('#contentleft h1').addClass('title-default');
		}
		
		// Table Interaction
		$('table').find('tr:odd').addClass('odd');
		$('table').find('tr:even').addClass('even');
				
		// wrapping image
		$('.textwidget')
			.find('img')
			.wrap('<div class="img-wrapper"/>');
		
		// Sidebar Height, make it equal with left content height
		var $sliderHeight = $('#slider').height();
		var $sidebarHeight = $('#wrap').innerHeight() - $sliderHeight;
		
		//console.log( $sliderHeight.toString() );
		
		$('#sidebar').animate({ 
			'height' : $sidebarHeight+'px' 
		},{queue:false, duration:1000});

		// last child
		$('#sidebar ul li:first-child')
			.addClass('first');
		$('#sidebar ul li:last, #sidebarwidgeted li:last')
			.addClass('last');
		
		$('.postarea a[rel="bookmark"]').css({ 
			'text-decoration':'none', 
			'font-weight': 'bold'})
			.parent().css({
				'padding': 0
			});

	
});

