// layout javascript functions //

// ******************************************** //
// EXEC A BODY CONTENT LINK   
// _location = string
// can redirect or call openNewWindow();
// ******************************************** //
function PMG_clickLink(p_id){
	
	var pLoc = null;

	switch(p_id){
		case "home":
			pLoc = gPaths.base + "index.html";
			break;
		case "what_button":
			pLoc = gPaths.base + "what.html";
			break;
		case "who_button":
			pLoc = gPaths.base + "who.html";
			break;
		case "how_button":
			pLoc = gPaths.base + "how.html";
			break;
		case "news_button":
			pLoc = "news.html?news=newsletters";
			break;
		case "contact_button":
			pLoc = gPaths.base + "contact.html";
			break;
		case "flash_animation":
			pLoc = gPaths.base + "who.html";
			break;
		default:
			if(p_id.indexOf(".") != -1){
				if(p_id.indexOf("http") != -1){
					PMG_newWindow({loc:p_id})
				}else{
					pLoc = p_id;
				}
			}else{
			 	alert(p_id + " not assigned in PMG_clickLink() in functions_pmg.js");
			}
			break;
	}

	
	if(pLoc != null){
		location.href = pLoc;
	}
	
}

function writeLayout(p){

	var ws = '';
	switch(p.type){
		case "start":
			ws += '<div id="full_screen_container">';
			ws += '<div id="site_container">';
			
			ws += '<table id="content_table" cellpadding="0" cellspacing="0" border="0">';
			ws += '<tr><td colspan="3" id="frame_top"></td></tr>'
			// BLUE GRADIENT HEADER //           
		   	ws += '<tr>';
			ws += '<td id="frame_td_left"></td>';
			ws += '<td id="header_td"><div id="header_logo" onfocus="this.blur();" onclick="PMG_clickLink(\'home\'); return false;"></div></td>';
			ws += '<td id="frame_td_right"></td>';
			ws += '</tr>';
			
			// YELLOW NAVIGATION //           
			ws += '<tr>';
			ws += '<td id="frame_td_left"></td>';
			ws += '<td id="navigation_td"><div id="navigation">';
			
			// Add the home button to all pages except index.html //
			if(!gButtons.home){gButtons.header.unshift({id:"home",text:"Home"})};
			for(var i=0; i<gButtons.header.length; i++){
				var lB = gButtons.header[i];
				lB.inline = true;
				lB.clas = "arrow_links";
				ws += PMG_writeLink(lB);
			}
			
			ws += '</div></td>';
			ws += '<td id="frame_td_right"></td>';
			ws += '</tr>';

			// CONTENT //
			ws += '<tr>';
			ws += '<td id="frame_td_left"></td>';
            ws += '<td id="content_td">';
			
			break;
		case "end":
			ws += '</td>';
            ws += '<td id="frame_td_right"></td>';
            ws += '</tr>';
			ws += '<tr><td colspan="3" id="frame_bottom"></td></tr>'
            ws += '</table>';

			
			break;
		case "footer":
			
			//ws += '<div id="footer_line"></div>';
			ws += '<div id="footer">';
			ws += PMG_writeLink({text:"Contact us",inline:true,clas:"footer_link",id:"contact_button"});
			//ws += '|';
			//ws += PMG_writeLink({text:"Site map",inline:true,clas:"footer_link",id:"site_map"});
			ws += '&copy; Patient Marketing Group. All rights reserved.';
			ws += '</div>';
			ws += '</div>'; // END SITE CONTAINER //
			ws += '<div id="footer_space"></div>';
			ws += '</div>'; // END FULL SCREEN CONTAINER //
			break;
		case "left":
			ws += '<div id="content_left_div">';
				if(p.buttons){
					for(var i=0; i<gButtons[p.buttons].length; i++){
						ws += '<div class="buttons_left">';
						var lB = gButtons[p.buttons][i];
						lB.inline = true;
						lB.clas = "arrow_links";
						lB.script = "changeRightContent"
						ws += PMG_writeLink(lB)
						ws += '</div>';
					}
				}
				
			ws += '<br style="clear:both;" />'
			ws += '<div id="quote_content"></div>';
				
			ws += '</div>';
			break;
	}
	
	document.write(ws);
	
}

function MenuRoll(p,p_on){
	var lColor = "#113e89";
	if(p_on){
		lColor = "#0000ff";
	}
		
	p.style.color = lColor;
	//113e89
	//p.style.cursor = 'pointer';
	//document.body.style.cursor = 'pointer';
	
}

function MenuClick(p){

	alert(p.id + " has been clicked.");

}