//---------------------------------------------------------------------------------------'
//toggle tab visibility
function MyPanel_Refresh() {
	//hide other divs
	for (var tv=1; tv<4; tv++) {
		fnc_FormElm('tab_div_' + tv).style.display = "none";
	}
		
	//display the selected div
	fnc_FormElm('tab_div_' + new cookie("tab_div_").read()).style.display = "block";
}
//---------------------------------------------------------------------------------------'
//toggle tab visibility
function MyPanel_Tab(int_Toggle) {

	//Display Tasklist Image
	if (int_Toggle == 1) {fnc_FormElm('myArea_TabImg').src = "../../img/generic/myArea_Tasklist.gif";}
	
	//Display Personal Image
	if (int_Toggle == 2) {fnc_FormElm('myArea_TabImg').src = "../../img/generic/myArea_Personal.gif";}
	
	//Display Favourites Image
	if (int_Toggle == 3) {
		fnc_FormElm('myArea_TabImg').src = "../../img/generic/myArea_Favourite.gif";
		MyPanel_DisplayFavourites();
	}

	//store the selected div
	new cookie("tab_div_", int_Toggle, 7, '/').set();
		
	//Refresh the display
	MyPanel_Refresh();
}//---------------------------------------------------------------------------------------'
//Display favourties
function MyPanel_DisplayFavourites_Toggle() {
	new cookie("MyPanel_DisplayFavourites", fnc_FormElm('Favourites_Det').style.display, 7, '/').set();
	MyPanel_DisplayFavourites();
}
//---------------------------------------------------------------------------------------'
//Display favourties
function MyPanel_DisplayFavourites() {


	//Current status
	var strCState = new cookie("MyPanel_DisplayFavourites").read();

	//Create the cookie if it is absent
	if (strCState == null) {
		strCState = "none";
		new cookie("MyPanel_DisplayFavourites", strCState, 7, '/').set();
	}

	//open personal details
	if (strCState == "none") {
		fnc_FormElm('Favourites_WArrow').src = "../../img/generic/warrow_up.gif";
		fnc_FormElm('Favourites_Det').style.display = "block";
		fnc_FormElm('Fav_Button_Div_1').style.display = "block";
	}
	//Close task
	else {
		fnc_FormElm('Favourites_WArrow').src = "../../img/generic/warrow_down.gif";
		fnc_FormElm('Favourites_Det').style.display = "none";
		fnc_FormElm('Fav_Button_Div_1').style.display = "none";
	}
	//Refresh the display
	MyPanel_Refresh();	
}
//---------------------------------------------------------------------------------------'
//toggle'my panel' visibillity
function MyPanel_Vis(int_Toggle) {
	
	//hide + increase width of tables
	if (int_Toggle == 0) {

		//get the screen width minus the my area tab and the navigation
		var docWidth = document.body.clientWidth;
		if (docWidth >= 770) {
			var navWidth = 164;
			var myAWidth = 20;
		}
		else {
			var navWidth = 0;
			var myAWidth = 0;
			var docWidth = 600;
		}		
		var jsClientWidth = (docWidth - navWidth - myAWidth);
		
		//set the width of the content area
		fnc_FormElm('MContent_Div').style.width = jsClientWidth;
		fnc_FormElm('MyArea_Anchor').style.width = "20";
		fnc_FormElm('myArea_closed').style.display = "block";
		
		
		//hide the myarea + close the cookie		
		fnc_FormElm('vis_control_row').style.display = "none"
		//Setup the cookie
		new cookie('myPanel', 'closed', 7, '/').set();
	}
	
	//show + decrease width of tables
	if (int_Toggle == 1) {
				
		//get the screen width minus the my area tab and the navigation
		//783 is the magic number
		//alert(document.body.clientWidth);
		var docWidth = document.body.clientWidth;
		
		if (docWidth >= 770) {
			var navWidth = 159;
			var myAWidth = 198;
		}
		else {
			var navWidth = 0;
			var myAWidth = 0;
			var docWidth = 425;
		}
		
		var jsClientWidth = (docWidth - navWidth - myAWidth);
		
		//set the width of the content area
		fnc_FormElm('MContent_Div').style.width = jsClientWidth;
		fnc_FormElm('MyArea_Anchor').style.width = "198";
		fnc_FormElm('myArea_closed').style.display = "none";
		
		//show the myarea + open the cookie
		fnc_FormElm('vis_control_row').style.display = "block"
				
		new cookie('myPanel', 'open', 7, '/').set();
		
		//collect the tab cookie
		var check_snav = new cookie("tab_div_").read();
				
		if (check_snav != null) {
			MyPanel_Tab(check_snav)
		}
		//open the tasks by default
		else {
			MyPanel_Tab(1)
		}
	}
}
//---------------------------------------------------------------------------------------'
//display incomplete tasks in myArea
function MyPanel_DisplayIncTask(int_TCount, Id_Task) {
	
	//Current status
	var strCState = fnc_FormElm('IncDesc_' + int_TCount).style.display

	//Open task
	if (strCState == "none") {
		fnc_FormElm('IncWArrow_' + int_TCount).src = "../../img/generic/warrow_up.gif";
		fnc_FormElm('IncDesc_' + int_TCount).style.display = "block";
		fnc_FormElm('Id_Task').value = Id_Task;
	}	
	//Close task
	else {
		fnc_FormElm('IncWArrow_' + int_TCount).src = "../../img/generic/warrow_down.gif";
		fnc_FormElm('IncDesc_' + int_TCount).style.display = "none";
		fnc_FormElm('Id_Task').value = "0";
	}
	//Refresh the display
	MyPanel_Refresh();
	
}
//---------------------------------------------------------------------------------------'
//display personal information in myArea
function MyPanel_DisplayPersonal(int_Toggle) {

	//Current status
	var strCState = fnc_FormElm('Personal_Det_' + int_Toggle).style.display

	//open personal details
	if (strCState == "none") {

		fnc_FormElm('Personal_WArrow_' + int_Toggle).src = "../../img/generic/warrow_up.gif";
		fnc_FormElm('Personal_Det_' + int_Toggle).style.display = "block";
		fnc_FormElm('Personal_Button_Div_1').style.display = "block";
		fnc_FormElm('Personal_Button_Div_2').style.display = "none";

		//Force the other div shut
		if (int_Toggle == 1) {
			fnc_FormElm('Personal_WArrow_2').src = "../../img/generic/warrow_down.gif";
			fnc_FormElm('Personal_Det_2').style.display = "none";
			fnc_FormElm('mA_PToggle').value = "0"
		}
		if (int_Toggle == 2) {
			fnc_FormElm('Personal_WArrow_1').src = "../../img/generic/warrow_down.gif";
			fnc_FormElm('Personal_Det_1').style.display = "none";
			fnc_FormElm('mA_PToggle').value = "1"
		}
	}

	//Close task
	else {
		fnc_FormElm('Personal_WArrow_' + int_Toggle).src = "../../img/generic/warrow_down.gif";
		fnc_FormElm('Personal_Det_' + int_Toggle).style.display = "none";
		fnc_FormElm('Personal_Button_Div_1').style.display = "none";
		fnc_FormElm('Personal_Button_Div_2').style.display = "block";
	}	
	//Refresh the display
	MyPanel_Refresh();
}
//---------------------------------------------------------------------------------------'
//Select link 
function myPanel_SelectLink(int_Id, int_Toggle) {
	
	//close any others that are open
	var intFavCount = fnc_FormElm('fav_Counter').value;
	
	for (var fcnt=1; fcnt<intFavCount; fcnt++) {
		myPanel_HighlightFavourite(fcnt, 1);
	}
	
	//determine link status
	//currently open
	if (fnc_FormElm('fav_row_title_' + int_Toggle).className == "news_prv") {
		myPanel_HighlightFavourite(int_Toggle, 1);
		fnc_FormElm('fav_linkToDelete').value = "0";
	}
	//currently closed
	else {
		myPanel_HighlightFavourite(int_Toggle, 0);
		fnc_FormElm('fav_linkToDelete').value = int_Id;
	}
	
}
//---------------------------------------------------------------------------------------'
//highlight - un-highlight selected link
function myPanel_HighlightFavourite(int_Toggle, int_Status) {
	if (int_Status == 0) {
		fnc_FormElm('fav_row_title_' + int_Toggle).className = "news_prv";
		fnc_FormElm('fav_row_desc_' + int_Toggle).className = "news_prv";
	}
	if (int_Status == 1) {
		fnc_FormElm('fav_row_title_' + int_Toggle).className = "news_noprv";
		fnc_FormElm('fav_row_desc_' + int_Toggle).className = "news_noprv";
	}
}
//---------------------------------------------------------------------------------------'
//jump to relevant mypanel favourite
function myPanel_JumptoFavourite(strURL, int_Toggle) {

	//remove highlighting
	myPanel_HighlightFavourite(int_Toggle, 1)
	document.location.href = strURL;
	
}
//---------------------------------------------------------------------------------------'
