/*
 *        Scripts used by Dhamma Kunja web pages
 */
	 
/* Opens a linked page in one of 3 ways:
		modal: As modal dialog in "graybox" (background grayed out)
		inSite: New page replaces current page (back-link to current page)
		externalSite: New page opens in new window/tab
*/
function DK_OpenSubPage( displayType, pageURL, pageTitle, w, h, sb )  {
	if (displayType == 'modal'){
		GB_showCenter(pageTitle, pageURL, 560, 700);
	}
	else if (displayType == 'inSite'){
		window.location=pageURL;
	}
	else {	// openType= 'externalSite'
		window.open(pageURL);
	}
}

var allowEmbed = 0;
function DK_OpenEmbeddedObject( displayType, objURL, pageTitle, embedPageURL )	{
	// we will add this back when PDF embedding works better
	if (allowEmbed && embedPageURL != null)	{
		DK_OpenSubPage( 'inSite', embedPageURL );
	}
	else	{
		DK_OpenSubPage(displayType, objURL, pageTitle);
	}		
}

function DK_ToggleEmbed()	{
	if (allowEmbed > 0)
		allowEmbed = 0;
	else
		allowEmbed = 1;
}

// for embedded PDF's - this function allows for switching documents in the PDF viewer of the HTML page
// inBlockID = div/block "id" of the element containing the PDF viewer
// inPDFDocURL = complete URL for the PDF to view
function SwitchPDFDoc(inBlockID, inPDFDocURL)
{
	if (allowEmbed > 0)	{
		var obj = document.getElementById(inBlockID);
		var pdfTag = "<object type='application/pdf' width='700' height='500' data='" + inPDFDocURL + "' /> alt:<p>It appears you don't have a PDF plugin for this browser. <a href='"+ inPDFDocURL + "'>Click here to download the PDF file.</a></p> <embed src='" + inPDFDocURL + "' type='application/pdf' />";
		obj.innerHTML = pdfTag;
	}
	else	{
		DK_OpenSubPage('externalSite', inPDFDocURL);
	}
}



function DK_GotoPageRef( refName )  {
	document.location= '#' + refName;
}  

/* mbMenu Definitions for Dhamma Kunja top menu and side menus */

/*
* DEFAULT OPTIONS
*
	options: {
	template:"yourMenuVoiceTemplate", --> the url that returns the menu voices via ajax. the data passed in the request is the "menu" attribute value as "menuId"
	additionalData:"",								--> if you need additional data to pass to the ajax call
	menuSelector:".menuContainer",		--> the css class for the menu container
	menuWidth:150,										--> min menu width
	openOnRight:false,								--> if the menu has to open on the right insted of bottom
	iconPath:"ico/",									--> the path for the icons on the left of the menu voice
	hasImages:true,										--> if the menuvoices have an icon (a space on the left is added for the icon)
	fadeInTime:100,										--> time in milliseconds to fade in the menu once you roll over the root voice
	fadeOutTime:200,									--> time in milliseconds to fade out the menu once you close the menu
	menuTop:0,												--> top space from the menu voice caller
	menuLeft:0,												--> left space from the menu voice caller
	submenuTop:0,											--> top space from the submenu voice caller
	submenuLeft:4,										--> left space from the submenu voice caller
	opacity:1,												--> opacity of the menu
	shadow:false,											--> if the menu has a shadow
	shadowColor:"black",							--> the color of the shadow
	shadowOpacity:.2,									--> the opacity of the shadow
	openOnClick:true,									--> if the menu has to be opened by a click event (otherwise is opened by a hover event)
	closeOnMouseOut:false,						--> if the menu has to be cloesed on mouse out
	closeAfter:500,										--> time in millisecond to whait befor closing menu once you mouse out
	minZindex:"auto", 								--> if set to "auto" the zIndex is automatically evaluate, otherwise it start from your settings ("auto" or int)
	hoverInted:0, 										--> if you use jquery.hoverinted.js set this to time in milliseconds to delay the hover event (0= false)
	onContextualMenu:function(o,e){} 	--> a function invoked once you call a contextual menu; it pass o (the menu you clicked on) and e (the event)
},
*/

$(function(){
	$(".DKTopMenu").buildMenu(
	{
		template:"",
		additionalData:"",
		menuWidth:124,
		openOnRight:false,
		menuSelector: ".menuContainer",
		iconPath:"ico/",
		hasImages:false,
		fadeInTime:100,
		fadeOutTime:200,
		menuLeft:5,	
		minZindex:"auto",
		adjustTop:10,
		opacity:.95,
		shadow:true,
		shadowColor:"black",							
		shadowOpacity:.2,									
		closeOnMouseOut:false,
		closeAfter:1000,
     	 minZindex:200
	});

	$(".DKVerticalMenu").buildMenu(
	  {
		template:"",
		menuWidth:170,
		openOnRight:true,
		openOnClick:false,
		menuSelector: ".menuContainer",
		iconPath:"ico/",
		hasImages:false,
		fadeInTime:200,
		fadeOutTime:200,
		adjustLeft:0,
		adjustTop:0,
		opacity:.95,
		openOnClick:false,
		minZindex:200,
		shadow:false,
		closeOnMouseOut:true
	  });
});


