$(document).ready(function() 
{
	$("#nav_1").hover(function() { //When trigger is clicked...
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).find("ul.subnav").show(); //Drop down the subnav on click

		$(this).hover(function() 
		{
		}, function(){
			$(this).find("ul.subnav").hide(); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
}
);

function toggleDiv(id)
{
	var div = $("#"+id+"_content");
	if(div.css('display') == "none")
	{
		div.show();
		var img = $("#"+id+"_a");
		img.attr("src", "/imgs/minus.png");	
		$("#"+id+"_prs h3 span").css('font-weight', 'bold');
	}
	else
	{
		div.hide();
		var img = $("#"+id+"_a");
		img.attr("src", "/imgs/plus.png");
		$("#"+id+"_prs h3 span").css('font-weight', 'normal');		
	}
}

function MoveOption(objSourceElement, objTargetElement)
{
	objTargetElement.append(objSourceElement.children(":selected"));
	objTargetElement.html(objTargetElement.children('option').sort(function (a, b) { return a.text == b.text ? 0 : a.text < b.text ? -1 : 1; }));
	objSourceElement.html(objSourceElement.children('option').sort(function (a, b) { return a.text == b.text ? 0 : a.text < b.text ? -1 : 1; }));
}

function toHiddenInput(source, dest)
{
	var length = $(source + " option").length - 1;
	var options = $(source + " option");
	var icount = 1;
	
	for(length; length > -1; length--)
	{
		
		if(icount == 1)
			$(dest).attr('value', options[length].value);
		else
			$(dest).attr('value', options[length].value + "," + $(dest).attr('value')); 
		icount++;
		
	}		
}

function SubmitForm(form)
{
	toHiddenInput("#newRelatedItems", "#hRelated");
	toHiddenInput("#relatedPress", "#hRelatedPress");
	toHiddenInput("#relatedNews", "#hRelatedNews");

	form.submit();
}

