/*********************************************/
/*           HEADER FUNCTIONS                */
/*********************************************/

function writeCircleButton(p){
	
	if(!p){
		alert("Button properties were not passed to PMG_writeButton()");
		return false;
	}
	
	if(!p.text){p.text = "Button Name"}
	if(!p.id){p.id = p.text.toLowerCase()}
	
	var lPage = false;
	switch(p.id){
		case "home":
			lPage = "personal.aspx";
			break;
		case "my_account":
			lPage = "myaccount.aspx";
			break;
		case "help":
			lPage = "faq.aspx";
			break;
		case "itk_arde":
			lPage = "ard_explained.aspx";
			break;
		case "itk_heal":
			lPage = "healing_purplepill.aspx";
			break;
		case "itk_faq":
			lPage = "itk_faqs.aspx";
			break;
		case "itk_news":
			lPage = "in_the_news.aspx";
			break;
	}
	
	var lStyle = false;
	
	if(lPage){
		if(escape(location.href).split("/").pop() == lPage){
			lStyle = 'style="color:#f9db83;"';
		}
	}
	
	var ws = '<div class="circle_button_container_pmg">';
	ws += '<table cellpadding="0" cellspacing="0" border="0">';
	ws += '<tr onfocus="this.blur();"' + ((!lStyle)? 'onmouseout="circle_buttonColor(this,0);"' : "") + 'onmouseover="circle_buttonColor(this,1);" onclick="circle_buttonClick(\'' + p.id + '\'); return false;" tabindex="0" id="pmg_button_' + p.id + '">';
	ws += '<td ' + lStyle + ' class="circle_button_text_pmg">' + p.text + '</td>';
	ws += '</tr>';
	ws += '</table>';
	ws += '</div>';
		
	if(p.inline){
		return ws;
	}else{
		document.write(ws);
	}

	return false;
}

function circle_buttonColor(p,p_roll){
	var lColor = "#ffffff";
	if(p_roll){
		//lColor = "#e0c087";
		lColor = "#f9db83";
	}
	p.childNodes[0].style.border = "0px solid #6a4397";
	p.childNodes[0].style.color = lColor;
	
}



function circle_buttonClick(p_name){
	
	var _location = false;

	switch(p_name){
		case "home":
			_location = "/purpleplus/personal.aspx";
			break;
		case "my_account":
			var sPage = window.location.href.replace('http://'+window.location.hostname,'');
			cookie_write({cookie:'pplusbc',value:sPage})
			_location = "/purpleplus/myaccount.aspx";
			break;
		case "help":
			_location = "/purpleplus/faq.aspx";
			break;
		case "tell":
			//_location = "/purpleplus/tell_friend.aspx";
			if(!gPanel.objects.friend.panel){alert('"Tell A Friend" has not been added to this page yet.'); return}
			//__ClearTellAFriendForm();
			gPanel.objects.friend.openPanel();
			break;
		case "purplepill":
			_location = "/index.aspx";
			break;
		case "itk_arde":
			_location = "ard_explained.aspx";
			break;
		case "itk_heal":
			_location = "healing_purplepill.aspx";
			break;
		case "itk_faq":
			_location = "itk_faqs.aspx";
			break;
		case "itk_news":
			_location = "in_the_news.aspx";
			break;

		default:
			alert(p_name);
			break;
	}
	
	if(_location){
		location.href = _location;
	}
	

}
