$(document).ready(function () { //HTML DOM document is ready
//currently only being used in the new  CR section/report / Homepage / Guestcentre homepage

	//image rollover
	$("a.roll").livequery('mouseover focus', function(event) {
		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f1').join('_f2'))
	}).livequery('mouseout blur', function(event) {/*mouseout*/
		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f2').join('_f1'))
	});





	//open links in a new window - rel=external
	$("a[rel=external]").attr("target","_blank").each(function(n) {
		$(this).attr("title") !='' ? this.title=$(this).attr("title")+'. Opens in a new browser window.' : this.title='Opens in a new browser window.';
	});




	//photoplayer / videoplayer - open in sized browser
	
	$('a[rel="photoplayer"]').click( function() {
		window.open($(this).attr('href'), 'player_window', 'width=810,height=780,location=0').focus();
        return false;
    });
	$("a[rel=photoplayer]").each(function(n) {
		this.title='Opens in a new browser window.';
	});


	var width = screen.width;
	var height = screen.height;

	if ((width<=1024) && (height<=768))
	{
		$('a[rel="videoplayer"]').click( function() {
			window.open($(this).attr('href'), 'player_window', 'width=790,height=810,location=0,scrollbars=1').focus();
			return false;
		});
	}
	else
	{
		$('a[rel="videoplayer"]').click( function() {
			window.open($(this).attr('href'), 'player_window', 'width=790,height=810,location=0').focus();
			return false;
		});
	}
	
	$("a[rel=videoplayer]").each(function(n) {
		this.title='Opens in a new browser window.';
	});





	//form button rollovers
	
	$("form input.form_button").livequery('mouseover focus', function(event) {
		$(this).addClass('form_button_f2');
	}).livequery('mouseout blur', function(event) {
		$(this).removeClass('form_button_f2');
	});

	// crisis alternative homepage button
	$("form input.crisis_button").livequery('mouseover focus', function(event) {
		$(this).addClass('crisis_button_f2');
	}).livequery('mouseout blur', function(event) {
		$(this).removeClass('crisis_button_f2');
	});

	// CR section tools - shortcut to add page
	$("form.savepageform input.button_save").bind('mouseover focus', function(event) {
		$(this).addClass('button_save_f2');
	}).bind('mouseout blur', function(event) {
		$(this).removeClass('button_save_f2');
	});

	// main pages for tools: folder / notes page 
	$("form input.tools_button").bind('mouseover focus', function(event) {
		$(this).addClass('tools_button_f2');
	}).bind('mouseout blur', function(event) {
		$(this).removeClass('tools_button_f2');
	});


});


