var $j = jQuery.noConflict();

$j(document).ready(function(){


	$j("#find-rep-box").show();
	$j("#rep-state").change(function() {
		currentVal = $j('#rep-state option:selected').val();
		
		if (!$j("#branches").find("."+currentVal).hasClass("active")){
			$j("#branches").find(".active").hide().removeClass("active");
			$j("#branches").find("."+currentVal).fadeIn("slow").addClass("active");
		} 
	});
	
	$j("a[rel='country2']").click(function(e){
		e.preventDefault();
		$j(this).parent().find('ul.dim').slideToggle();
	})

	$j("table.rep-table tr:even").addClass("oddrow");
	$j( "#tabs" ).tabs();

	
	$j(".heading-hire").click(function(e){
		e.preventDefault();
		$j(this).next(".content-right-hire1").slideToggle();
	})
	
	$j(".faq-top").click(function(e){
		e.preventDefault();
		
		
		if (!$j(this).hasClass('open')){
			$j('.open').removeClass('open').next(".section").slideToggle();
			$j(this).addClass('open').next(".section").slideToggle();
		} else {
			$j('.open').removeClass('open').next(".section").slideToggle();
		}
		
	})
	
	$j('#abbr-jumplinks a').click(function(e){
		e.preventDefault();
			
		$letter = $j(this).html();
		
		$j('#common-abbr tr>td strong').each(function(){
			if ($j(this).html().substr(0,1) != $letter){
				$j(this).parent().parent().hide();
			} else {
				$j(this).parent().parent().show();
			}
		})
	})	
	
	$j('#terms-jumplinks a').click(function(e){
		e.preventDefault();
		
		$tletter = $j(this).html();
		
		$j('.terms .heading-hire h3').each(function(){
			if ($j(this).html().substr(0,1) != $tletter){
				$j(this).parent().parent().parent().hide().next().hide();
			} else {
				$j(this).parent().parent().parent().show();
			}	
		})
	})
	
	$j('#abbr-jumplinks a.show-all').click(function(e){
		$j('#common-abbr tr').show();
	})
	
	$j('#terms-jumplinks a.show-all').click(function(e){
		$j('.heading-hire').show();
	})
	
	//work the custom dropdown menu
	$j("#quick-subject").focus(function(){
		$j("#quick-subject-options").show("fast");
	})
	
	//control value changing of custom dropdown
	$j("#quick-subject-options div").click(function(){
		$j("#quick-subject").val($j(this).html());
		$j("#quick-subject-options").hide();
	})
	
/*
	$j(":not(#quick-subject-options div)").click(function(){
		$j("#quick-subject-options").hide();
	})
*/
	
	
	//image gallery stuff
	$j("ul.thumbs a img").css("padding-top", function(){
       return (100 - $j(this).height())/2;
	});
	
	$j("a[rel='gallery']").colorbox({width: '800px'});
	
	$j('#map').zoommap({
		// Width and Height of the Map
		width: '727px',
		height: '430px',
			
		//Misc Settings
		blankImage: 'images/blank.gif',
		fadeDuration: 500,
		zoomDuration: 300,
		
		//ids and classes
		zoomClass: 'zoomable',
		popupSelector: 'div.popup',
		popupCloseSelector: 'a.close',
		
		//Return to Parent Map Link
		showReturnLink: true,
		returnId: 'returnlink',
		returnText: 'return to world map',
		
		//Initial Region to be shown
		map: {
			id: 'campus',
			image: 'images/map-large.jpg',
			data: 'popups/main.html',
			maps: [
			{
				id: 'north-america',
				parent: 'campus',
				image: 'images/north-america.jpg',
				data: 'popups/north-america.html',
				width: '226px',
				height: '130px',
				top: '97px',
				left: '48px'
			},
			{
				id: 'europe-india-africa',
				parent: 'campus',
				image: 'images/eu-india-africa.jpg',
				data: 'popups/europe-india-africa.html',
				width: '380px',
				height: '218px',
				top: '126px',
				left: '299px'
			}
			]
		}
	}); 	


});


