// -------------
//--- JQUERY ---
// -------------
$(document).ready(function () { //HTML DOM document is ready

	//image rollover
	$("a.roll").bind('mouseover focus', function(event) {
		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f1').join('_f2'))
	}).bind('mouseout blur', function(event) {/*mouseout*/
		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f2').join('_f1'))
	});

	//image lit
//	$("a.lit").bind,  function(event) {
//		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f1').join('_f2'))
//	};
	
	//table row rollover
	$("table.financial tbody tr").mouseover(function() {
		$(this).addClass("hover");
	}).mouseout(function() {
		$(this).removeClass("hover");
	});
	//table row rollover
	$("table.broker tbody tr").mouseover(function() {
		$(this).addClass("hover");
	}).mouseout(function() {
		$(this).removeClass("hover");
	});
	// Check All boxes
	$("#category_all").click(function() {
		var checked_status = this.checked;
		$("input[@name=category]").each(function()
		{
			this.checked = checked_status;
		});
	});	

	//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.';
	});

	// add print link to tools
	//$("ul#tools li:last").before("<li><a class=\"printpage\" href=\"javascript:window.print()\">Print this page<\/a></li>");
	
	//rns popup
	//$("td .rnspopup").attr("title","Opens in a new browser window.").click(function() {
	//	window.open($(this).attr('href'),"rnspopup","scrollbars=1,statusbar=1,resizable=1,width=950,height=500'");return false;
	//});

	//form button rollovers
	$("form input.button").hover(highlight_btn,restore_btn);
	function highlight_btn(event) {$(this).addClass('button_f2');}
	function restore_btn(event) {$(this).removeClass('button_f2');}
	
	$("form input.submit").hover(highlight_btn2,restore_btn2);
	function highlight_btn2(event) {$(this).addClass('button_f2');}
	function restore_btn2(event) {$(this).removeClass('button_f2');}

	$("form input.submit").focus(highlight_btn2);
	$("form input.submit").blur(restore_btn2);
	function restore_btn2(event) {$(this).removeClass('button_f2');}

	//Share price module tabs
//	$("ul#sharepricetabs li a").livequery('click', function(event) {
//		var urlData = $(this).attr('href').split("=");
//		var strPageId = urlData[1].split("&");
//		var strStockExchange = urlData[2].split("#");
//		$.get('managed_content/library/feature_panels/shareprice.asp', {'pageid' : strPageId[0], 'se' : strStockExchange[0]}, function(html){
//			$('div#sharepricemodule').html(html);
//		}); return false;
//	});


	//News module tabs
//	$("ul#newstabs li a").livequery('click', function(event) {
//		var urlData = $(this).attr('href').split("=");
//		var strPageId = urlData[1].split("&");
//		var strNewsType = urlData[2].split("#");
//		$.get('managed_content/modules/newslide.asp', {'pageid' : strPageId[0], 'news' : strNewsType[0], 'ajax' : 'true'}, function(html){
//			$('div#newsmodule').html(html);
//		}); return false;
//	});
	
	
	//show/hide graph details - regional profiles: financial
//	$("div.graphdetails").hide().before("<p class=\"clearboth bold\"><a href=\"#\" class=\"showdetails\">View chart figures</a></p>");
//	$("p .showdetails").click(function() {
//		if ($(this).parent().next().is(':hidden')) {
//			$(this).parent().next().slideDown("normal");$(this).text("Hide chart figures")
//		} else {
//			$(this).parent().next().slideUp("normal");$(this).text("View chart figures")
//		} return false;
//	});

});

// --------------------------------------
// --- DOWNLOAD KIT SELECT ALL BUTTON ---
// --------------------------------------
function selectDownload(){
	var intDownloads=document.getElementById('assetlist').elements.length;
	for(var i=3;i<intDownloads;i++){
		if(document.getElementById('assetlist').checkall.checked==true){
			document.getElementById('assetlist').elements[i].checked=true;
		}else{
			document.getElementById('assetlist').elements[i].checked=false;
		}
	}
}

// --------------------------------------
// --- PRESENTATIONS POPUP ---
// --------------------------------------
var _POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,width=773,height=600';

function raw_popup(url, target, features) {
if (features ==""){
	theFeatures = _POPUP_FEATURES;
}else{
	theFeatures = features
}
var theWindow = window.open(url, target, theFeatures);
theWindow.focus();
return theWindow;
}

function link_popup(src, target, features) {
	return raw_popup(src, target, features);
}