$(document).ready(function(){






 
                $(document).ready(function(){
$ (".single-content table tr:even").addClass ('even');
        $ (".single-content table tr:odd").addClass ('odd');
        $ (".single-content table").addClass ('tborder')
		 });
                
// Mobile device detection
	
/*$(function() { 
          
        mobileResize();
         
        $(window).resize(function() {
            mobileResize();         
        });
       
    });

function mobileResize(){
     if ($("h2.mobileblue").css("text-transform") == "capitalize")
        {
            $("body").addClass("mobile"); 
            $(".wrapper").insertAfter(".left");
$(".site-area-1 .left").insertAfter(".site-area-1 .wrapper"); 
 
    }
   }*/

	
	// For aligned images
	$('img[align=right]').addClass('float-right');
	$('img[align=left]').addClass('float-left');	

	// Property module tabs
	$("#tabs").tabs();

	// Adds an icon and title for links that open in a new window
	$('p a[target=_blank]').attr('title', 'Opens in a new window').addClass('newindow');
	
	// Gallery Plugin
	/*$("a[rel=image_gallery]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'inside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});*/
	
	
	
	$('#search').live('focus', function() {
  		$(this).val('');
	});	
	
	/*$("a.lightbox").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic' 
	});*/
	
	//Rounded corners for IE
    $('#tabs a.submenu-item-1').corner("round 9px");
    $('#tabs a.submenu-item-2').corner("round 9px");
    $('#tabs a.submenu-item-3').corner("round 9px");
   



	// Quicklinks
	quicklinkgo();
	
	// Default slideshow - for opts see http://jquery.malsup.com/cycle/options.html
	$(".slider").v1Slider();
	
	
	

	

	
	
	///////////////// CMS specific code below /////////////////////
	
	//media file transcripts
	$(".mediaFileTranscript").hide();
	$(".toggleTranscriptView").click(function (ev) {
		ev.preventDefault();
		$(this).parent().next(".mediaFileTranscript").slideToggle(300);
	});
	
	//for personalisation
	//Personalise = new personalise();
	//Personalise.initfrontend("#perstodofrontph","#persfavfrontph","framework/personalise/personalisehandlerforfront.cfm");
	
	//Staff directory initialisation
	if (typeof StaffDirectory !== "undefined") {
		StaffDirectory = new StaffDirectory("<cfoutput>#variables.openTreeImage#</cfoutput>", "<cfoutput>#variables.closedTreeImage#</cfoutput>");
		StaffDirectory.init();
		
		//switcher for locations drop down
		$('.showLoc').click(function(){
			$('#location_div').toggle();
		});
	}
	
	//IPM initialisation
	if (typeof IPMController !== "undefined") {
		try {
			FieldManager = new fieldManager({
				handler: 'fieldManagerHandler.cfm',
				frontEndMode: true
			});
			IPM = new IPMController({
				handler: 'IPMHandler.cfm',
				parentDivId: '#IPMTemplate',
				frontEndMode: true
			});
			IPM.init();
		} catch (e) {
			alert(e.message);
		}
	}
	
	
	
	//Targets the HTML5 Placeholder element in form inputs and provides a fallback for crippled browsers
	//Taken from http://www.cssnewbie.com/cross-browser-support-for-html5-placeholder-text-in-forms/
	if(!$.support.placeholder) { 
		var active = document.activeElement;
		$(':text').focus(function () {
			if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
				$(this).val('').removeClass('hasPlaceholder');
			}
		}).blur(function () {
			if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
				/*commented out because its breaking at the moment.
				$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');*/
			}
		});
		$(':text').blur();
		$(active).focus();
		$('form').submit(function () {
			$(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
		});
	}
	
	
	/*
	
	//Rounded corners for crippled browsers
	if($.browser.msie) {
		
		$('.detachedmenu_blue').corner("round 10px");
		$('#detached-menu-quicklinks ol.menu li a').corner("round 10px");
		$('#footer-links').corner("round 10px");
		$('ol#top_nav li a').corner("round top 10px");
		$('.placeholder h2').corner("round top 10px");
		$('.placeholder').corner("round top 10px");
		$('.ph-inner').corner("round 10px");
		$('.sidemenu').corner("round 10px");
		$('.banner .placeholder').corner("round 10px");
		$('.detachedmenu_blue .ph-inner').corner("round 10px");
		$('#search_bar').corner("round 10px");
		
		
	
	}*/
	
	
});	

function quicklinkgo(){
	var btn = document.getElementById('quicklinks_go');
	if(!btn)
		return false;
	btn.style.display='none';//hide the button

	btn = document.getElementById('quicklinks_select');
	if(btn)btn.onchange=function(){this.parentNode.submit();}
}


//Add span around an breadcrumb text

$("#breadcrumbs2 li ").each(function() {
		var $this = $(this);
		var text = $this.text();
		text = "<span></span>";
		$this.html(text);
	});

