// JavaScript Document
// Copyright 2008 Harry Botha (harry@dumel.co.za)
// May not be copied without permission

var tinymce_enabled = true;
var debug_log_enabled = false;
var hashEnabled = true;
var mainContainerId = "container";
var mainContainerLoadingImage = "container_loading_image";
var currentLanguage = "";
var oldLanguage = "";
var cacheImages = false;
var languageCount = 0;
var lightbox_enabled = true;
var multibox_enabled = true;


var ajax_url;
var global_site_url = globalSiteBaseUrl.substring(0, globalSiteBaseUrl.length - 1);
var tmpUrl = window.location.href;



var a2a_config = a2a_config || {};

//if (global_site_url.indexOf("#") >= 0)
//	global_site_url = global_site_url.substring(0, global_site_url.indexOf("#"));	
//if (global_site_url.indexOf(".asp") >= 0)
//	global_site_url = global_site_url.substring(0, global_site_url.lastIndexOf("/")+0);
	



/*

ajax code here


if (tmpUrl.substring(tmpUrl.indexOf("#")+1, tmpUrl.length) == "")
	tmpUrl = tmpUrl.replace("#", "");

var tmpLoadingUrl = tmpUrl;

if (tmpLoadingUrl.indexOf("#") >= 0)
	tmpLoadingUrl = tmpLoadingUrl.substring(0, tmpLoadingUrl.indexOf("#"));	


if (tmpLoadingUrl.indexOf(".asp") > -1 && tmpLoadingUrl.indexOf("search-results.asp") == -1)
{
	if (window.location.href.indexOf("preview=true") == -1)
	{
		tmpLoadingUrl = tmpLoadingUrl.replace(global_site_url, "");
	 	window.location.href = global_site_url + "#" + tmpLoadingUrl;
	}
}
*/


if (lightbox_enabled)
{
//	dhtmlLoadStyle("inc/cmsdash/plugins/multibox/multibox.css");
//	dhtmlLoadScript("inc/cmsdash/plugins/multibox/overlay.js");
//	dhtmlLoadScript("inc/cmsdash/plugins/multibox/multibox.js");
}



var cachedTemplates = "";
var alreadyCached = false;

function cacheImagesLoad()
{
	if (cacheImages && !alreadyCached)
	{
		var imgStrTmp = ""

		for (i = 0; i < imgCacheArray.length; i++)
		{
			imgStrTmp += "<img src=\"" + imgCacheArray[i] + "\" style=\"display: none;\">";
		}
		//alert(imgStrTmp);
		document.getElementById("body_obj").innerHTML += imgStrTmp;
		alreadyCached = true;
		
	}
}

function showDocumentInfo(document_id)
{
	//showDocumentInfo
	// var tableObj = document.getElementById("table_info_" + document_id);
	


	
	// tbl_folder_icon_
	
	
	  jQuery("#table_info_" + document_id).slideToggle('slow', function() {
		// Animation complete.
			var fldobj = jQuery("#tbl_folder_icon_" + document_id);
			
			if (fldobj.length > 0) {
			
				if (fldobj.attr("src").indexOf("_plus") > -1 ) {
					
					fldobj.attr("src", fldobj.attr("src").replace("_plus", "_minus"));
	
				}
				else {
					
					fldobj.attr("src", fldobj.attr("src").replace("_minus", "_plus"));
				}
				
			}
		
		});

	
	
	//if (tableObj.style.display == "none")
	//	tableObj.style.display = "";
	//else
//		tableObj.style.display = "none";
	
}

window.onload = function() {
	
	

	if (document.getElementById(mainContainerId))
		document.getElementById(mainContainerId).style.display = "";
		
	if (document.getElementById(mainContainerLoadingImage))
		document.getElementById(mainContainerLoadingImage).style.visibility = "hidden";	
	
	ajaxReloaded();

	
	//if (document.getElementById("MainLinkId").value + "" != "18") {
		
		
		/* 
		if (hashEnabled)
		{
			debugLog("Loading...");
			
			if (tmpUrl.indexOf("#") > -1 && tmpLoadingUrl.indexOf("search-results.asp") == -1)
			{
				tmpUrl = tmpUrl.substring(tmpUrl.indexOf("#"), tmpUrl.length);
				tmpUrl = tmpUrl.replace("#", "");	
				
				ajaxReload(tmpUrl, mainContainerId, mainContainerLoadingImage);
			}
			else
			{
				if (document.getElementById(mainContainerId))
					document.getElementById(mainContainerId).style.display = "";
					
				if (document.getElementById(mainContainerLoadingImage))
					document.getElementById(mainContainerLoadingImage).style.visibility = "hidden";	
					
				cacheImagesLoad();

			}
	
			debugLog("Init done...");
		}
		*/

}

function checkLanguage()
{
	currentLanguage = document.getElementById("LangCurrentAbbr").value;
	
	if (currentLanguage != oldLanguage && oldLanguage != "")
	{		
		ajaxReload(window.location.hash.replace("#", ""), "container", "container_loading_image");

		switchLanguageMenus(currentLanguage);
	}
	else
	{
		if (oldLanguage == "")
			switchLanguageMenus(currentLanguage);
	}
	
	oldLanguage = currentLanguage;
}

function switchLanguageMenus(argLang)
{
	if (argLang == "afr")
	{
		//awmHideMenu("manillatabs-eng");
		//awmShowMenu("manillatabs");
	}
	else
	{
		//awmHideMenu("manillatabs");
		//awmShowMenu("manillatabs-eng");
	}
}

function ajaxReload(argURL, argObjectId, argLoadingId)
{
	location.href = argURL;

	return false;
	
	var newArgUrl = argURL;
	newArgUrl = newArgUrl.replace(global_site_url, "");

	//if (document.getElementById("MainLinkId").value + "" == "18") {
		
	//	location.href = newArgUrl;	
	//	return false;
	//}


	var httpRequest;
	var loadingImg = document.getElementById(argLoadingId);
	ajax_url = argURL;
	
	if (newArgUrl.indexOf("?") >= 0)
		newArgUrl += "&";
	else
		newArgUrl += "?";
	
	newArgUrl += "ajax_" + argObjectId + "=true&rnd=" + Math.random();
	
	if (window.XMLHttpRequest)     // Object of the current windows
		httpRequest = new XMLHttpRequest();     // Firefox, Safari, ...
	else 
	{
		if (window.ActiveXObject)   // ActiveX version
			httpRequest = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	}
	
	var bodyObj = document.getElementById(argObjectId);
	
	
	httpRequest.onreadystatechange = function() {
		
		if(httpRequest.readyState == 4)
		{
			if(httpRequest.status == 200)
			{
				if (bodyObj != null)
				{
					var responseText = httpRequest.responseText;
					
					//alert();
					
					if (responseText.substring(0, 7) == "<title>")
					{
						var strTmpTitle = responseText.substring(0, responseText.indexOf("</title>")+8);
						strTmpTitle = strTmpTitle.replace("<title>", "").replace("</title>", "");
						document.title = strTmpTitle;
						responseText = responseText.substring(responseText.indexOf("</title>")+8, responseText.length);
					}
					
					if (responseText.substring(0, 9) == "redirect=") 
					{
						if (argObjectId == "top")
							ajaxReload(responseText.substring(9, responseText.length), argObjectId, mainContainerLoadingImage);
						else
							ajaxReload(responseText.substring(9, responseText.length), mainContainerId, mainContainerLoadingImage);
					}
					else
					{

						bodyObj.innerHTML = responseText;
						bodyObj.style.display = "";
											
						var newHash = ajax_url;
						
						newHash = newHash.replace(global_site_url, "");
						
						if (hashEnabled)
						{
							if (newHash.substring(newHash.length-1, newHash.length) == "/")
								newHash = newHash.substring(0, newHash.length-1);
							
							if (newHash.indexOf("action=") > -1)
								newHash = newHash.substring(0, newHash.indexOf("action=")-1);
								
							debugLog("Setting hashy to #" + newHash);
							window.location.hash = newHash;					
						}
						
						
						if (loadingImg != null)
							loadingImg.style.visibility = "hidden";
	
						ajaxReloaded(argObjectId);
						
					}
					
				}
				
			}
			else
			{
				if (loadingImg != null)
					loadingImg.style.visibility = "hidden";
					
				debugLog("<strong><font color=red>Error " + httpRequest.status + " while requesting " + newArgUrl + "</font></strong>");
				
				if(confirm("Error " + httpRequest.status + ".\nURL: " + newArgUrl + "\n\nDo you want to see the response?")) 
				{
					document.write(httpRequest.responseText);
				}
				return false;
			}
		}
	};
		

	
	if (loadingImg != null)
		loadingImg.style.visibility = "visible";
	
	ajaxBeforeUnload(argObjectId);
	
	httpRequest.open("GET", newArgUrl,  true); 
	httpRequest.send(null);
	
	return false;

}



function ajaxSubmitForm(argFormName, argObjId, argUrl, argImgId)
{
	document.getElementById(argFormName).submit();
	
	return false;

	ajax_url = argUrl;
	var ajaxsForm = document.getElementById(argFormName);
	var ajaxUpdateObj = document.getElementById(argObjId);
	var ajaxsfLoadingImg = document.getElementById(argImgId);

	if (ajaxsForm == null)
	{
		alert("Form with ID " + argFormName + " does not exist.");	
		return false;
	}
	
	if(ajaxUpdateObj == null)
	{
		alert("Object with ID " + argObjId + " does not exist.");
		return false;
	}
	
	ajaxDoBeforeSubmit();
	
	var ajaxsUrl = "";
	
	if (argUrl == "") ajaxsUrl = ajaxsForm.action;
	else ajaxsUrl = argUrl;
	
	if (ajaxsUrl.indexOf("ajax_" + argObjId + "=true") < 0)
	{
		if (ajaxsUrl.indexOf("?") == -1) ajaxsUrl += "?ajax_" + argObjId + "=true";
		else ajaxsUrl += "&ajax_" + argObjId + "=true";	
	}
	
	ajaxsUrl = ajaxsUrl.replace(global_site_url, "");
	
	debugLog("Received ajax form submit request: " + ajaxsUrl);

	var ajaxsdata = "";
	
	for(i=0; i < ajaxsForm.elements.length; i++)
	{
		var elmObj = ajaxsForm.elements[i];
		if (elmObj.type == "textarea")
		{ 
			if (tinymce_enabled)
				ajaxsdata = ajaxsdata + elmObj.name + "=" + escape(stripSpanFonts(tinyMCE.get(elmObj.name).getContent())) + "&";
			else
				ajaxsdata = ajaxsdata + elmObj.name + "=" + escape(elmObj.value) + "&";
		}
		else
			ajaxsdata = ajaxsdata + elmObj.name + "=" + escape(elmObj.value) + "&";
	}
	
	
	var httpRequest;
	
	if (window.XMLHttpRequest)     // Object of the current windows
	{
		httpRequest = new XMLHttpRequest();     // Firefox, Safari, ...
	}
	else 
	{
		if (window.ActiveXObject)   // ActiveX version
		{
			httpRequest = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
		}
	}
	
	
	
	httpRequest.onreadystatechange = function() {
		
		if(httpRequest.readyState == 4)
		{

			if(httpRequest.status == 200)
			{
				strTmpResp = httpRequest.responseText;
				
				if (strTmpResp.substring(0, 9) == "redirect=")
					ajaxReload(strTmpResp.substring(9, strTmpResp.length), mainContainerId, mainContainerLoadingImage);
				else
				{
					ajaxUpdateObj.innerHTML = httpRequest.responseText;
					ajaxUpdateObj.style.display = "";
					
					if (ajaxsfLoadingImg != null) ajaxsfLoadingImg.style.visibility = "hidden";	
					
					ajaxReloaded(argObjId);
				}
			}
			else
			{
				debugLog("<font color=red>Error " + httpRequest.status + " while requesting " + ajaxsUrl + "</font>");
				if (ajaxsfLoadingImg != null)
					ajaxsfLoadingImg.style.visibility = "hidden";

				
				if(confirm("Error " + httpRequest.status + " while submitting form.\nURL: " + ajaxsUrl + "\n\nDo you want to see the response?")) 
					document.write(httpRequest.responseText);				
				
				return false;
			}
				
			
		}
	};
	
		
	
	
	if (ajaxsfLoadingImg != null) ajaxsfLoadingImg.style.visibility = "visible";
	
	ajaxBeforeUnload(argObjId);
	
	httpRequest.open("POST", ajaxsUrl, true); 
	httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	httpRequest.send(ajaxsdata);
	
	return false;
}

function debugLog(str)
{
	if (debug_log_enabled)
	{
		var debugLogObby = document.getElementById("log");
		
		debugLogObby.innerHTML = "(" + new Date().toGMTString()  + ") " + str + "<br>\n" + debugLogObby.innerHTML;
	}
}


 function tinyBrowser (field_name, url, type, win) {

    /* If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
       the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
       These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */

    var cmsURL = "/tiny_mce/plugins/tinybrowser/tinybrowser.php";    // script URL - use an absolute path!
    if (cmsURL.indexOf("?") < 0) {
        //add the type as the only query parameter
        cmsURL = cmsURL + "?type=" + type;
    }
    else {
        //add the type as an additional query parameter
        // (PHP session ID is now included if there is one at all)
        cmsURL = cmsURL + "&type=" + type;
    }

    tinyMCE.activeEditor.windowManager.open({
        file : cmsURL,
        title : 'Tiny Browser',
        width : 770, 
        height : 480,
        resizable : "yes",
		  scrollbars : "yes",
        inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous : "no"
    }, {
        window : win,
        input : field_name
    });
    return false;
  }

// this function is run every time ajax has finished loading (kind of like a <body onload="">
function ajaxReloaded(argObjId)
{
	
	// cacheImagesLoad();
	
	languageCount = parseInt(document.getElementById("LangCount").value);
		
	if (lightbox_enabled)
	{

		initLightbox();
	}
	
	if (multibox_enabled)
	{
		new MultiBox('mb', {
			descClassName:'multiBoxDesc', useOverlay: true
			
		});

	}

	
	if (tinymce_enabled)
	{
		tinyMCE.init({
			mode : "textareas",
			theme : "advanced",
			plugins : "inlinepopups,advimage,advlink,contextmenu,table,media",
			content_css : "/inc/cmsdash/plugins/tinymce/tinymce.css",
			editor_deselector : "mceNoEditor",
			file_browser_callback : "tinyBrowser",
			relative_urls : false,

			
			valid_elements : "a[name|href|target|title|script|rel],strong/b,em/i,strike,u,#p[style|align],-ol,-ul,-li,br,img[id|src|border|alt|title|hspace|vspace|width|height|align|rel],-sub,-sup,-blockquote,-table[id|title|style|border|cellspacing|cellpadding|width|height|align|bgcolor|background|bordercolor],-tr[id|style|rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[id|style|colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[style|colspan|rowspan|width|height|align|valign],-div,span[!style],-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],label[for],legend,small,object[width|height|data|type],param[name|value],embed[src|type|allowscriptaccess|allowfullscreen|width|height]",
			
			//file_browser_callback : "tinyBrowser",

			
			theme_advanced_path : true,
			theme_advanced_toolbar_location : 'top',
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor,|,formatselect",
			theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,media,cleanup,help,code,tinybrowser",
			theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap,|,tablecontrols",
			theme_advanced_toolbar_align : "center",
			theme_advanced_statusbar_location : "bottom"

			
		});
		
		
	}
	checkLanguage();
	validateLinkFormDateUpdate();
	validateMediaFormDateUpdate();

	//if (argObjId == "container")
	//	scroll(0,0);


	a2a_config.linkurl = location.href.replace("/#/", "/");


	(function(){
		var a = document.createElement('script');
		a.type = 'text/javascript';
		a.async = true;
		a.src = 'http://static.addtoany.com/menu/page.js';
		var s = document.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(a, s);
	})();				

}


function ajaxBeforeUnload(argObjId)
{
	if (tinymce_enabled)
	{
		if (argObjId != "associated_links_div")
		{
			var textboxIds = document.getElementsByTagName("textarea");
			for(i = 0; i < textboxIds.length; i++)
			{
				tinyMCE.execCommand('mceRemoveControl', false, textboxIds[i].id);
				
			}
		}
	}
}

function ajaxDoBeforeSubmit()
{
	// this is just a fix so that textarea content will be updated off tinymce when form is submitted
}

function stripSpanFonts(strContents) 
{
    return convertWord(strContents.replace(/style="font-[^\"]*"/gi,""));
}

//function convertWord(type, content) {
function convertWord(content) {
//	switch (type) {
//		// Gets executed before the built in logic performes it's cleanups
//		case "before":
//			// do nothing
//			break;
//
//		// Gets executed after the built in logic performes it's cleanups
//		case "after":
			content = content.replace(/<(!--)([\s\S]*)(--)>/gi, "");
//			break;
//	}
	return content;
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function switchLanguage(argLang)
{
	
	ajaxReload(document.getElementById("LinkTemplate").value + "?LinkId=" + document.getElementById("MainLinkId").value + "&LANGUAGE=" + argLang, "container", "container_loading_image");
}

function ajaxNavigate(argLinkId)
{
	ajaxReload(document.getElementById("LinkTemplate").value + "?go=true&LinkId=" + argLinkId, "container", "container_loading_image");
}

function validateMediaFormDateUpdate()
{
	//  
	
	var divObj = $o("validation_newsletter_update_date");
	
	if (divObj)
	{
		var goliveDateObj = $o("MediaDateGolive");
		var expiryDateObj = $o("MediaDateExpire");
		// BcDateGolive BcDateExpire
		
		if (goliveDateObj.value == "" && expiryDateObj.value == "")
			divObj.innerHTML = "*&nbsp;&nbsp; This Media Item will always be displayed when published";		
		else if (goliveDateObj.value != "" && expiryDateObj.value == "")
			divObj.innerHTML = "*&nbsp;&nbsp; This Media Item will be displayed from <b>" + goliveDateObj.value + "</b> when published";
		else if (goliveDateObj.value != "" && expiryDateObj.value != "")
			divObj.innerHTML = "*&nbsp;&nbsp; This Media Item will be displayed between <b>" + goliveDateObj.value + "</b> and <b>" + expiryDateObj.value + "</b> when published";
		else divObj.innerHTML = "*&nbsp;&nbsp; This Media Item will be displayed untill <b>" + expiryDateObj.value + "</b> when published";
		

	}

}

function validateLinkFormDateUpdate()
{
	var divObj = document.getElementById("validation_update_date");
	
	if (divObj)
	{
		var artTypeStr = "";
		var artTypeID = document.getElementById("BcType");

		if (artTypeID)
		{
			if (artTypeID.value == "1") artTypeStr = "Article";
			else if (artTypeID.value == "2") artTypeStr = "Event";
			else if (artTypeID.value == "3") artTypeStr = "News";
			else if (artTypeID.value == "4") artTypeStr = "Advertisement";
			else artTypeStr = "Unknown";
			
			
			
			var goliveDateObj = document.getElementById("BcDateGolive");
			var expiryDateObj = document.getElementById("BcDateExpire");
			// BcDateGolive BcDateExpire
			
			if (goliveDateObj.value == "" && expiryDateObj.value == "")
				divObj.innerHTML = "*&nbsp;&nbsp; This " + artTypeStr + " will always be displayed when published";		
			else if (goliveDateObj.value != "" && expiryDateObj.value == "")
				divObj.innerHTML = "*&nbsp;&nbsp; This " + artTypeStr + " will be displayed from <b>" + goliveDateObj.value + "</b> when published";
			else if (goliveDateObj.value != "" && expiryDateObj.value != "")
				divObj.innerHTML = "*&nbsp;&nbsp; This " + artTypeStr + " will be displayed between <b>" + goliveDateObj.value + "</b> and <b>" + expiryDateObj.value + "</b> when published";
			else divObj.innerHTML = "*&nbsp;&nbsp; This " + artTypeStr + " will be displayed untill <b>" + expiryDateObj.value + "</b> when published";
		
		}
	}
}

function validateLinkForm(argForm)
{
	ajaxDoBeforeSubmit();
	
	var objLanguages = document.getElementById("BcLanguages");
	var languageArr = objLanguages.value.split(",");
	
	if (document.getElementById("BCLinkId").value.replace(",", "") == "")
	{
		alert("Please select atleast one associated link.");
		document.getElementById("SELECT_LINKS").focus();
		return false;
	}
	
	for (i = 0; i < languageArr.length; i++)
	{
		var strLanguage = languageArr[i];
		
		if (tinyMCE.get(strLanguage + "_BCTitle").getContent() == "")
		{
			alert("Please make sure all Titles are filled in.");
			return false;
		}
		
		if (tinyMCE.get(strLanguage + "_BCContent").getContent() == "")
		{
			//alert("Please make sure all Contents are filled in.");
			//return false;
		}
		
	}


	
	ajaxSubmitForm("updateLinkForm", "container", argForm.action, "container_loading_image");
	return false;
}


function openWindow(argName, argWidth, argHeight, argUrl)
{
    var owtop = ((window.screen.availHeight - argHeight) / 2);
    var owleft = ((window.screen.availWidth - argWidth) / 2);
	
    window.open(argUrl, argName, "width=" + argWidth + ",height=" + argHeight + ",left=" + owleft + ",top=" + owtop + ",scrollbars=yes,resizable=yes");
}


function toggleEditOptions(argOptionStr, argShow)
{
	var dispObj = document.getElementById(argOptionStr);
	
	if (dispObj != null)
	{
		if (argShow)
			dispObj.style.display = "";
		else
			dispObj.style.display = "none";
	}
}

function assocLinkAdd()
{
	var ddObj = document.getElementById("SELECT_LINKS");
	
	if (ddObj != null)
	{
		if (ddObj.value != "")
		{
			if (ddObj.value == "-50")
			{
				if(confirm("Adding this associated link will remove all other associated links.\nAre you sure you want to do this?"))
					ajaxReload(window.location.href.replace("#", "") + "&action=modifybclinks&BCLinkId=" + ddObj.value, "associated_links_div", "");
			}
			else
			{
				if (document.getElementById("BCLinkId").value == "-50")
				{
					if(confirm("Adding this associated link will remove the \"All links\" associated link.\nDo you want to continue?"))
						ajaxReload(window.location.href.replace("#", "") + "&action=modifybclinks&BCLinkId=" + ddObj.value, "associated_links_div", "");
				}
				else
				{
					if(confirm("Are you sure you want to add \"" + ddObj.options[ddObj.selectedIndex].text + "\"?"))
						ajaxReload(window.location.href.replace("#", "") + "&action=modifybclinks&BCLinkId=" + document.getElementById("BCLinkId").value + "," + ddObj.value, "associated_links_div", "");
				}
			}
			
		}
		else
		{
			alert("Please select an associated link");
		}
	}
	else
	{
		alert("Error occurred.");
	}
}
					  
					  
function assocLinkDelete(argBCLinkId, argDesc)
{
	if(confirm("Are you sure you want to delete \"" + argDesc + "\"?"))
	{		
		ajaxReload(window.location.href.replace("#", "") + "&action=modifybclinks&BCLinkId=" + argBCLinkId, "associated_links_div", "ajax_loading_image");
	}
}

function dashboardChecked(argBcId, argCheckObj)
{
	//  chk_
	var rowObj = document.getElementById("row_" + argBcId);
	
	if (argCheckObj.checked)
	{
		rowObj.style.backgroundColor = "#D1E2E7";
	}
	else
	{
		rowObj.style.backgroundColor = "";
	}

}

function dashboardAction(argAction)
{
	var dashCheckObjs = document.getElementsByTagName("INPUT");
	var strCheckedIds = "";
	var linkidObj = document.getElementById("LinkId");
	var bctypeidObj = document.getElementById("BcType");
	
	for (i = 0; i < dashCheckObjs.length; i++)
	{
		dashCheckObj = dashCheckObjs[i];
		
		if (dashCheckObj.type == "checkbox" && dashCheckObj.id.substring(0, 4) == "chk_")
		{
			if (dashCheckObj.checked)
				strCheckedIds += dashCheckObj.value + ",";
		}
	}
	
	if (strCheckedIds != "")
		strCheckedIds = strCheckedIds.substring(0, strCheckedIds.length-1);	
	
	var strActionUrl = "/dashboard.asp?";
	
	if (linkidObj.value != "")
		strActionUrl += "LinkId=" + linkidObj.value + "&";
		
	if (bctypeidObj.value != "")
		strActionUrl += "BcType=" + bctypeidObj.value + "&";
	
	strActionUrl += "action=" + argAction + "&BcId=" + strCheckedIds;
	
	if (strCheckedIds != "")
	{
		if (argAction == "delete")
		{
			if (confirm("Are you sure you want to delete the selected items?"))
			{
				if (languageCount > 1) {
					if (confirm("Do you want to delete the selected items for all languages?"))
						ajaxReload(strActionUrl + "&assoc=true", "container", "container_loading_image"); 
					else
						ajaxReload(strActionUrl, "container", "container_loading_image");
				}
				else
					ajaxReload(strActionUrl, "container", "container_loading_image");
				
			}
		}
		
		if (argAction == "preview")
		{
			if (confirm("Are you sure you want to preview  the selected items?"))
			{
				MM_openBrWindow('index.asp?LinkId=' + linkidObj.value + '&preview=true&previewbcid=' + strCheckedIds + '','oranjepreview','scrollbars=yes,resizable=yes,width=980,height=600');
			}
		}
		
		if (argAction == "unpublish")
		{
			if (confirm("Are you sure you want to unpublish the selected items?"))
			{
				if (languageCount > 1) {
					if (confirm("Do you want to unpublish the selected items for all languages?"))
						ajaxReload(strActionUrl + "&assoc=true", "container", "container_loading_image"); 
					else
						ajaxReload(strActionUrl, "container", "container_loading_image");
				}
				else
					ajaxReload(strActionUrl, "container", "container_loading_image");
			}
		}
		
		if (argAction == "publish")
		{
			if (confirm("Are you sure you want to publish the selected items?"))
			{
				if (languageCount > 1) {
					if (confirm("Do you want to publish the selected items for all languages?"))
						ajaxReload(strActionUrl + "&assoc=true", "container", "container_loading_image"); 
					else
						ajaxReload(strActionUrl, "container", "container_loading_image");
				}
				else
					ajaxReload(strActionUrl, "container", "container_loading_image");
			}
		}
		
		if (argAction == "edit")
		{
			if (strCheckedIds.indexOf(",") > -1)
			{
				alert("Please select only one item to edit.");
			}
			else
			{	
				// linkidObj bctypeidObj
				strUrl = document.getElementById("LinkTemplate").value + "?dash=true&BCId=" + strCheckedIds;
				
				if (linkidObj.value != "")
					strUrl += "&LinkId=" + linkidObj.value;
					
				if (bctypeidObj.value != "")
					strUrl += "&BcType=" + bctypeidObj.value;
				
				ajaxReload(strUrl, mainContainerId, mainContainerLoadingImage);
			}
		}
		
	}
	else
		alert("Please select at least one item first.");

}

/**
This is a JavaScript library that will allow you to easily add some basic DHTML
drop-down datepicker functionality to your Notes forms. This script is not as
full-featured as others you may find on the Internet, but it's free, it's easy to
understand, and it's easy to change.

You'll also want to include a stylesheet that makes the datepicker elements
look nice. An example one can be found in the database that this script was
originally released with, at:

http://www.nsftools.com/tips/NotesTips.htm#datepicker

I've tested this lightly with Internet Explorer 6 and Mozilla Firefox. I have no idea
how compatible it is with other browsers.

version 1.5
December 4, 2005
Julian Robichaux -- http://www.nsftools.com

HISTORY
--  version 1.0 (Sept. 4, 2004):
Initial release.

--  version 1.1 (Sept. 5, 2004):
Added capability to define the date format to be used, either globally (using the
defaultDateSeparator and defaultDateFormat variables) or when the displayDatePicker
function is called.

--  version 1.2 (Sept. 7, 2004):
Fixed problem where datepicker x-y coordinates weren't right inside of a table.
Fixed problem where datepicker wouldn't display over selection lists on a page.
Added a call to the datePickerClosed function (if one exists) after the datepicker
is closed, to allow the developer to add their own custom validation after a date
has been chosen. For this to work, you must have a function called datePickerClosed
somewhere on the page, that accepts a field object as a parameter. See the
example in the comments of the updateDateField function for more details.

--  version 1.3 (Sept. 9, 2004)
Fixed problem where adding the <div> and <iFrame> used for displaying the datepicker
was causing problems on IE 6 with global variables that had handles to objects on
the page (I fixed the problem by adding the elements using document.createElement()
and document.body.appendChild() instead of document.body.innerHTML += ...).

--  version 1.4 (Dec. 20, 2004)
Added "targetDateField.focus();" to the updateDateField function (as suggested
by Alan Lepofsky) to avoid a situation where the cursor focus is at the top of the
form after a date has been picked. Added "padding: 0px;" to the dpButton CSS
style, to keep the table from being so wide when displayed in Firefox.

-- version 1.5 (Dec 4, 2005)
Added display=none when datepicker is hidden, to fix problem where cursor is
not visible on input fields that are beneath the date picker. Added additional null
date handling for date errors in Safari when the date is empty. Added additional
error handling for iFrame creation, to avoid reported errors in Opera. Added
onMouseOver event for day cells, to allow color changes when the mouse hovers
over a cell (to make it easier to determine what cell you're over). Added comments
in the style sheet, to make it more clear what the different style elements are for.
*/

var datePickerDivID = "datepicker";
var iFrameDivID = "datepickeriframe";

var dayArrayShort = new Array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
var dayArrayMed = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
var dayArrayLong = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
var monthArrayShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var monthArrayMed = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
var monthArrayLong = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
 
// these variables define the date formatting we're expecting and outputting.
// If you want to use a different format by default, change the defaultDateSeparator
// and defaultDateFormat variables either here or on your HTML page.
var defaultDateSeparator = "/";        // common values would be "/" or "."
var defaultDateFormat = "ymd"    // valid values are "mdy", "dmy", and "ymd"
var dateSeparator = defaultDateSeparator;
var dateFormat = defaultDateFormat;

/**
This is the main function you'll call from the onClick event of a button.
Normally, you'll have something like this on your HTML page:

Start Date: <input name="StartDate">
<input type=button value="select" onclick="displayDatePicker('StartDate');">

That will cause the datepicker to be displayed beneath the StartDate field and
any date that is chosen will update the value of that field. If you'd rather have the
datepicker display beneath the button that was clicked, you can code the button
like this:

<input type=button value="select" onclick="displayDatePicker('StartDate', this);">

So, pretty much, the first argument (dateFieldName) is a string representing the
name of the field that will be modified if the user picks a date, and the second
argument (displayBelowThisObject) is optional and represents an actual node
on the HTML document that the datepicker should be displayed below.

In version 1.1 of this code, the dtFormat and dtSep variables were added, allowing
you to use a specific date format or date separator for a given call to this function.
Normally, you'll just want to set these defaults globally with the defaultDateSeparator
and defaultDateFormat variables, but it doesn't hurt anything to add them as optional
parameters here. An example of use is:

<input type=button value="select" onclick="displayDatePicker('StartDate', false, 'dmy', '.');">

This would display the datepicker beneath the StartDate field (because the
displayBelowThisObject parameter was false), and update the StartDate field with
the chosen value of the datepicker using a date format of dd.mm.yyyy
*/
function displayDatePicker(dateFieldName, displayBelowThisObject, dtFormat, dtSep)
{
  var targetDateField = document.getElementsByName (dateFieldName).item(0);
 
  // if we weren't told what node to display the datepicker beneath, just display it
  // beneath the date field we're updating
  if (!displayBelowThisObject)
    displayBelowThisObject = targetDateField;
 
  // if a date separator character was given, update the dateSeparator variable
  if (dtSep)
    dateSeparator = dtSep;
  else
    dateSeparator = defaultDateSeparator;
 
  // if a date format was given, update the dateFormat variable
  if (dtFormat)
    dateFormat = dtFormat;
  else
    dateFormat = defaultDateFormat;
 
  var x = displayBelowThisObject.offsetLeft;
  var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight ;
 
  // deal with elements inside tables and such
  var parent = displayBelowThisObject;
  while (parent.offsetParent) {
    parent = parent.offsetParent;
    x += parent.offsetLeft;
    y += parent.offsetTop ;
  }
 
  drawDatePicker(targetDateField, x, y);
}

function clearDatePicker(dateFieldName)
{
	var targetDateField = document.getElementsByName (dateFieldName).item(0);
	
	targetDateField.value = "";
}

/**
Draw the datepicker object (which is just a table with calendar elements) at the
specified x and y coordinates, using the targetDateField object as the input tag
that will ultimately be populated with a date.

This function will normally be called by the displayDatePicker function.
*/
function drawDatePicker(targetDateField, x, y)
{
  var dt = getFieldDate(targetDateField.value );
 
  // the datepicker table will be drawn inside of a <div> with an ID defined by the
  // global datePickerDivID variable. If such a div doesn't yet exist on the HTML
  // document we're working with, add one.
  if (!document.getElementById(datePickerDivID)) {
	  
    // don't use innerHTML to update the body, because it can cause global variables
    // that are currently pointing to objects on the page to have bad references
    //document.body.innerHTML += "<div id='" + datePickerDivID + "' class='dpDiv'></div>";
    var newNode = document.createElement("div");
    newNode.setAttribute("id", datePickerDivID);
    newNode.setAttribute("class", "dpDiv");
    newNode.setAttribute("style", "visibility: hidden;");
    document.body.appendChild(newNode);
  }
 
  // move the datepicker div to the proper x,y coordinate and toggle the visiblity
  var pickerDiv = document.getElementById(datePickerDivID);
  pickerDiv.style.position = "absolute";
  pickerDiv.style.left = x + "px";
  pickerDiv.style.top = y + "px";
  pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
  pickerDiv.style.display = (pickerDiv.style.display == "block" ? "none" : "block");
  pickerDiv.style.zIndex = 10000;
 
  // draw the datepicker table
  refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
}


function getYearDDString(argdfname, argdyear, argdmonth, argdday)
{
	
	var ddstr = "";
	
	ddstr += "<select onchange=\" refreshDatePicker(\'" + argdfname + "\', parseInt(this.value), " + argdmonth + ", " + argdday + "); \" class=\"dpDD\">";
	
	for (i = argdyear - 6; i <= argdyear + 6; i++)
	{
		ddstr += "<option ";
		
		if (i == argdyear)
			ddstr += " class=\"dpCurrentDD\" selected ";
		
		ddstr += " value=\"" + i + "\">" + i + "</option>";		
	}

	ddstr += "</select>";

	
	return ddstr;
}
function getMonthDDString(argdfname, argdyear, argdmonth, argdday)
{
	
	var ddstr = "";
	
	ddstr += "<select onchange=\"refreshDatePicker(\'" + argdfname + "\', " + argdyear + ", parseInt(this.value), " + argdday + "); \" class=\"dpDD\">";
	
	for (i = 0; i < monthArrayLong.length; i++)
	{
		var mName = monthArrayLong[i];
		
		ddstr += "<option ";
		
		if (i == argdmonth)
			ddstr += " class=\"dpCurrentDD\" selected ";
		
		ddstr += " value=\"" + i + "\">" + mName + "</option>";		
	}

	ddstr += "</select>";

	
	return ddstr;
}




// monthArrayLong


/**
This is the function that actually draws the datepicker calendar.
*/
function refreshDatePicker(dateFieldName, year, month, day)
{
	
  // if no arguments are passed, use today's date; otherwise, month and year
  // are required (if a day is passed, it will be highlighted later)
  var thisDay = new Date();
 
  if ((month >= 0) && (year > 0)) {
    thisDay = new Date(year, month, 1);
  } else {
    day = thisDay.getDate();
    thisDay.setDate(1);
  }
 
  // the calendar will be drawn as a table
  // you can customize the table elements with a global CSS style sheet,
  // or by hardcoding style and formatting elements below
  var crlf = "\r\n";
  var TABLE = "<table cols=7 class='dpTable'>" + crlf;
  var xTABLE = "</table>" + crlf;
  var TR = "<tr class='dpTR'>";
  var TR_title = "<tr class='dpTitleTR'>";
  var TR_days = "<tr class='dpDayTR'>";
  var TR_todaybutton = "<tr class='dpTodayButtonTR'>";
  var xTR = "</tr>" + crlf;
  var TD = "<td class='dpTD' onMouseOut='this.className=\"dpTD\";' onMouseOver=' this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
 // var TD_title = "<td colspan=5 class='dpTitleTD'>";
  var TD_title = "<td colspan=7 class='dpTitleTD'>";
  var TD_buttons = "<td class='dpButtonTD'>";
  var TD_todaybutton = "<td colspan=7 class='dpTodayButtonTD'>";
  var TD_days = "<td class='dpDayTD'>";
  var TD_selected = "<td class='dpDayHighlightTD' onMouseOut='this.className=\"dpDayHighlightTD\";' onMouseOver='this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  var xTD = "</td>" + crlf;
  var DIV_title = "<div class='dpTitleText'>";
  var DIV_selected = "<div class='dpDayHighlight'>";
  var xDIV = "</div>";
 
  // start generating the code for the calendar table
  var html = TABLE;
 
  // this is the title bar, which displays the month and the buttons to
  // go back to a previous month or forward to the next month
  
  
  
  
  html += TR_title;
  //html += TD_buttons + getButtonCode(dateFieldName, thisDay, -1, "&lt;") + xTD;
  //html += TD_buttons + "&nbsp;" + xTD;
  html += TD_title + DIV_title + getMonthDDString(dateFieldName, thisDay.getFullYear(), month, day) + "&nbsp;" + getYearDDString(dateFieldName, thisDay.getFullYear(), month, day) + xDIV + xTD;
  //html += TD_buttons + "&nbsp;" + xTD;
  //html += TD_buttons + getButtonCode(dateFieldName, thisDay, 1, "&gt;") + xTD;
  html += xTR;
 
  // this is the row that indicates which day of the week we're on
  html += TR_days;
  for(i = 0; i < dayArrayShort.length; i++)
    html += TD_days + dayArrayShort[i] + xTD;
  html += xTR;
 
  // now we'll start populating the table with days of the month
  html += TR;
 
  // first, the leading blanks
  for (i = 0; i < thisDay.getDay(); i++)
    html += TD + "&nbsp;" + xTD;
 
  // now, the days of the month
  do {
    dayNum = thisDay.getDate();
    TD_onclick = " onclick=\"updateDateField('" + dateFieldName + "', '" + getDateString(thisDay) + "');\">";
    
    if (dayNum == day)
      html += TD_selected + TD_onclick + DIV_selected + dayNum + xDIV + xTD;
    else
      html += TD + TD_onclick + dayNum + xTD;
    
    // if this is a Saturday, start a new row
    if (thisDay.getDay() == 6)
      html += xTR + TR;
    
    // increment the day
    thisDay.setDate(thisDay.getDate() + 1);
  } while (thisDay.getDate() > 1)
 
  // fill in any trailing blanks
  if (thisDay.getDay() > 0) {
    for (i = 6; i > thisDay.getDay(); i--)
      html += TD + "&nbsp;" + xTD;
  }
  html += xTR;
 
  // add a button to allow the user to easily return to today, or close the calendar
  var today = new Date();
  var todayString = "Today is " + dayArrayMed[today.getDay()] + ", " + monthArrayMed[ today.getMonth()] + " " + today.getDate();
  html += TR_todaybutton + TD_todaybutton;
  // clearDatePicker(dateFieldName)
  
  
  html += "<button class='dpTodayButton' onClick='clearDatePicker(\"" + dateFieldName + "\"); updateDateField(\"" + dateFieldName + "\");'>clear</button> ";
  html += "<button class='dpTodayButton' onClick='updateDateField(\"" + dateFieldName + "\");'>close</button>";
  html += xTD + xTR;
 
  // and finally, close the table
  html += xTABLE;
 
  var tmpddpcobj = document.getElementById(datePickerDivID);
  
  tmpddpcobj.innerHTML = html;
  
  // getViewportSize("w")
  
//  if (tmpddpcobj.clientWidth + 
	
	dTmpRight = tmpddpcobj.style.left.replace("px", "");
	dTmpRight = tmpddpcobj.clientWidth + parseInt(dTmpRight);
	
	if (dTmpRight > getViewportSize("w")) {
		tmpddpcobj.style.left = parseInt(tmpddpcobj.style.left.replace("px", "")) - ( dTmpRight - getViewportSize("w") ) + "px";
	}

  
  
  
  
  
  // add an "iFrame shim" to allow the datepicker to display above selection lists
  adjustiFrame();
}


/**
Convenience function for writing the code for the buttons that bring us back or forward
a month.
*/
function getButtonCode(dateFieldName, dateVal, adjust, label)
{
  var newMonth = (dateVal.getMonth () + adjust) % 12;
  var newYear = dateVal.getFullYear() + parseInt((dateVal.getMonth() + adjust) / 12);
  if (newMonth < 0) {
    newMonth += 12;
    newYear += -1;
  }
 
  return "<button class='dpButton' onClick='refreshDatePicker(\"" + dateFieldName + "\", " + newYear + ", " + newMonth + ");'>" + label + "</button>";
}


/**
Convert a JavaScript Date object to a string, based on the dateFormat and dateSeparator
variables at the beginning of this script library.
*/
function getDateString(dateVal)
{
  var dayString = "00" + dateVal.getDate();
  var monthString = "00" + (dateVal.getMonth()+1);
  dayString = dayString.substring(dayString.length - 2);
  monthString = monthString.substring(monthString.length - 2);
 
  switch (dateFormat) {
    case "dmy" :
      return dayString + dateSeparator + monthString + dateSeparator + dateVal.getFullYear();
    case "ymd" :
      return dateVal.getFullYear() + dateSeparator + monthString + dateSeparator + dayString;
    case "mdy" :
    default :
      return monthString + dateSeparator + dayString + dateSeparator + dateVal.getFullYear();
  }
}


/**
Convert a string to a JavaScript Date object.
*/
function getFieldDate(dateString)
{
  var dateVal;
  var dArray;
  var d, m, y;
 
  try {
    dArray = splitDateString(dateString);
    if (dArray) {
      switch (dateFormat) {
        case "dmy" :
          d = parseInt(dArray[0], 10);
          m = parseInt(dArray[1], 10) - 1;
          y = parseInt(dArray[2], 10);
          break;
        case "ymd" :
          d = parseInt(dArray[2], 10);
          m = parseInt(dArray[1], 10) - 1;
          y = parseInt(dArray[0], 10);
          break;
        case "mdy" :
        default :
          d = parseInt(dArray[1], 10);
          m = parseInt(dArray[0], 10) - 1;
          y = parseInt(dArray[2], 10);
          break;
      }
      dateVal = new Date(y, m, d);
    } else if (dateString) {
      dateVal = new Date(dateString);
    } else {
      dateVal = new Date();
    }
  } catch(e) {
    dateVal = new Date();
  }
 
  return dateVal;
}


/**
Try to split a date string into an array of elements, using common date separators.
If the date is split, an array is returned; otherwise, we just return false.
*/
function splitDateString(dateString)
{
  var dArray;
  if (dateString.indexOf("/") >= 0)
    dArray = dateString.split("/");
  else if (dateString.indexOf(".") >= 0)
    dArray = dateString.split(".");
  else if (dateString.indexOf("-") >= 0)
    dArray = dateString.split("-");
  else if (dateString.indexOf("\\") >= 0)
    dArray = dateString.split("\\");
  else
    dArray = false;
 
  return dArray;
}

/**
Update the field with the given dateFieldName with the dateString that has been passed,
and hide the datepicker. If no dateString is passed, just close the datepicker without
changing the field value.

Also, if the page developer has defined a function called datePickerClosed anywhere on
the page or in an imported library, we will attempt to run that function with the updated
field as a parameter. This can be used for such things as date validation, setting default
values for related fields, etc. For example, you might have a function like this to validate
a start date field:

function datePickerClosed(dateField)
{
  var dateObj = getFieldDate(dateField.value);
  var today = new Date();
  today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
 
  if (dateField.name == "StartDate") {
    if (dateObj < today) {
      // if the date is before today, alert the user and display the datepicker again
      alert("Please enter a date that is today or later");
      dateField.value = "";
      document.getElementById(datePickerDivID).style.visibility = "visible";
      adjustiFrame();
    } else {
      // if the date is okay, set the EndDate field to 7 days after the StartDate
      dateObj.setTime(dateObj.getTime() + (7 * 24 * 60 * 60 * 1000));
      var endDateField = document.getElementsByName ("EndDate").item(0);
      endDateField.value = getDateString(dateObj);
    }
  }
}

*/
function updateDateField(dateFieldName, dateString)
{
  var targetDateField = document.getElementsByName (dateFieldName).item(0);
  if (dateString)
    targetDateField.value = dateString;
 
  var pickerDiv = document.getElementById(datePickerDivID);
  pickerDiv.style.visibility = "hidden";
  pickerDiv.style.display = "none";
 
  adjustiFrame();
  targetDateField.focus();
 
  // after the datepicker has closed, optionally run a user-defined function called
  // datePickerClosed, passing the field that was just updated as a parameter
  // (note that this will only run if the user actually selected a date from the datepicker)
  if ((dateString) && (typeof(datePickerClosed) == "function"))
    datePickerClosed(targetDateField);
}


/**
Use an "iFrame shim" to deal with problems where the datepicker shows up behind
selection list elements, if they're below the datepicker. The problem and solution are
described at:

http://dotnetjunkies.com/WebLog/jking/archive/2003/07/21/488.aspx
http://dotnetjunkies.com/WebLog/jking/archive/2003/10/30/2975.aspx
*/
function adjustiFrame(pickerDiv, iFrameDiv)
{
  // we know that Opera doesn't like something about this, so if we
  // think we're using Opera, don't even try
  var is_opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
  if (is_opera)
    return;
  
  // put a try/catch block around the whole thing, just in case
  try {
    if (!document.getElementById(iFrameDivID)) {
      // don't use innerHTML to update the body, because it can cause global variables
      // that are currently pointing to objects on the page to have bad references
      //document.body.innerHTML += "<iframe id='" + iFrameDivID + "' src='javascript:false;' scrolling='no' frameborder='0'>";
      var newNode = document.createElement("iFrame");
      newNode.setAttribute("id", iFrameDivID);
      newNode.setAttribute("src", "javascript:false;");
      newNode.setAttribute("scrolling", "no");
      newNode.setAttribute ("frameborder", "0");
      document.body.appendChild(newNode);
    }
    
    if (!pickerDiv)
      pickerDiv = document.getElementById(datePickerDivID);
    if (!iFrameDiv)
      iFrameDiv = document.getElementById(iFrameDivID);
    
    try {
      iFrameDiv.style.position = "absolute";
      iFrameDiv.style.width = pickerDiv.offsetWidth;
      iFrameDiv.style.height = pickerDiv.offsetHeight ;
      iFrameDiv.style.top = pickerDiv.style.top;
      iFrameDiv.style.left = pickerDiv.style.left;
      iFrameDiv.style.zIndex = pickerDiv.style.zIndex - 1;
      iFrameDiv.style.visibility = pickerDiv.style.visibility ;
      iFrameDiv.style.display = pickerDiv.style.display;
    } catch(e) {
    }
 
  } catch (ee) {
  }
 
}



function getViewportSize(argUnit)
{
	 var viewportwidth;
	 var viewportheight;
	 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
		  viewportwidth = window.innerWidth,
		  viewportheight = window.innerHeight
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	 else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	 {
		   viewportwidth = document.documentElement.clientWidth,
		   viewportheight = document.documentElement.clientHeight
	 }
	 else
	 {
		   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
	 if ( argUnit == "h" )
	 {
		 return viewportheight;
	 }
	 else
	 {
		 return viewportwidth;
	 }
 
}


function dhtmlLoadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}

function dhtmlLoadStyle(url)
{
	var cssNode = document.createElement("link");
	cssNode.type = "text/css";
	cssNode.rel = "stylesheet";
	cssNode.href = url;
	document.getElementsByTagName("head")[0].appendChild(cssNode);
	
}

function $o(argId) {
	return document.getElementById(argId);
}

function linkLeftClick(argLinkId) {

	$o("linkleft_" + argLinkId.substring(argLinkId.indexOf("=")+1)).style.visibility = "visible";
	
	
}

function opnWindow(argSrc, argName, argWidth, argHeight) {
	

    var top = ((window.screen.availHeight - argHeight) / 2);
    var left = ((window.screen.availWidth - argWidth) / 2);

    window.open(argSrc, argName, "width=" + argWidth + ",height=" + argHeight + ",left=" + left + ",top=" + top + "");
	
}


