var $jq = jQuery.noConflict(); 

var wrapperWidth=0;
var wfdbookIframeWidth=0;
var FBW=false;
var popPanel = null;
var rPopPanel = null;

var currentEBookHeight = 0;

var supportedFileTypes = new Array();
supportedFileTypes[".pdf"] = true;
supportedFileTypes[".doc"] = true;
supportedFileTypes[".odt"] = true;
supportedFileTypes[".txt"] = true;
supportedFileTypes[".odp"] = true;
supportedFileTypes[".ppt"] = true;

var hoverPanel = null;
var hoverTimeout;

var bPanels = new Array();
var brPanels = new Array();

(function () {
        var carousel;
                
        YAHOO.util.Event.onDOMReady(function (ev) {
            var carousel    = new YAHOO.widget.Carousel("clist1", {
                        isCircular: true, numVisible: 4, revealAmount: 0
                });

          
		    carousel.render(); // get ready for rendering the widget
            carousel.show();   // display the widget
			
			// TODO temp fix for IE problem. To be removed!!!
			// $jq('#clist1 .yui-carousel-nav').hide();
        });
})();


$jq(document).ready(
function ()
{
	$jq(".wfclose-panel").bind('click', function() 
	{
	  $jq(this).parent().hide();
	});
	
	$jq('.portlet-msg-error').bind('click', function(){
		$jq(this).hide();
   	 	return false;
	});
	
	$jq('.portlet-msg-success').bind('click', function(){
		$jq(this).hide();
   	 	return false;
	});
	
});

var WFTabs = {
	show : function (namespace, names, id) {
		var el = document.getElementById(namespace + id + "TabsId");

		if (el) {
			el.className = "current";
		}

		el = document.getElementById(namespace + id + "TabsSection");

		if (el) {
			el.style.display = "block";
		}

		for (var i = 0; (names.length > 1) && (i < names.length); i++) {
			if (id != names[i]) {
				el = document.getElementById(namespace + names[i] + "TabsId");

				if (el) {
					el.className = "none";
				}

				el = document.getElementById(namespace + names[i] + "TabsSection");

				if (el) {
					el.style.display = "none";
				}
			}
		}
	}
};

function iframeAutoHeight(id)
{
}

function refreshImage(id, url)
{
	$jq('#' + id).attr('src', url + '&' + new Date().getTime());
   
	return false;
}

function wfconsole(str)
{
	console.log(str);
}

function stringReplace(str, searchFor, replaceWith) {
	var tmpStr = str.split(searchFor);
	return tmpStr.join(replaceWith);
}
 
function stringReplaceRegex(str, regex, replaceWith) {
	var r = new RegExp(regex, 'g');
	return str.replace(r, replaceWith);
}

function setFullBrowserWidth() 
{
	if(!FBW)
	{
		wrapperWidth = $jq('#wrapper').width();
		$jq('#wrapper').width("100%");
		
		wfdbookIframeWidth = $jq('#wfdbookIframe').width();
		$jq('#wfdbookIframe').width("100%");
		
		FBW=true;
	}
	else
	{
		$jq('#wrapper').width(wrapperWidth);
		$jq('#wfdbookIframe').width(wfdbookIframeWidth);
		FBW=false;
	}
}

function getFileName(path) 
{
    var re = new RegExp(/([^\/\\]+)$/);
    var str = re.exec(path);

    if (str == null) 
	{
        return null;
    }
    else 
	{
        return str[0];
    }
}

function getExtention(fname)
{
	if( fname.length == 0 ) 
		return null; 
	
	var dot = fname.lastIndexOf("."); 
	if( dot == -1 ) 
		return null; 
	
	return fname.substr(dot,fname.length); 
}

function isSupportedFileType(path) 
{
    if ((path == null) || (path == undefined))
	{
        return false;
    }
    else 
	{
    	var fname = path;
		if((fname.indexOf("/") != -1) || (fname.indexOf("\\")))
		{
			fname = getFileName(fname);
		}
		
		var ext = getExtention(fname);
		if(ext == null)
		{
			return false;
		}
		else 
		{
			if(supportedFileTypes[ext] == undefined)
				return false
			else
				return true;
		}														
    }
}

function showElement(eid)
{
	var e = document.getElementById(eid);
	if(e != null)
	{
		e.style.display = "block";
	}
}

function hideElement(eid)
{
	var e = document.getElementById(eid);
	if(e != null)
	{
		e.style.display = "none";
	}
}

function controlDisplay(eid, control)
{
	var e = document.getElementById(eid);
	if(e != null)
	{
		e.style.display = control;
	}
}

function flexNavControl(prefix, isOpen)
{
	var openId = prefix + "Open";
	var closeId = prefix + "Close";
	var contentId = prefix + "Content";
	if(isOpen)
	{
		controlDisplay(openId, 'block');
		controlDisplay(closeId, 'none');
		controlDisplay(contentId, 'block');
	}
	else
	{
		controlDisplay(openId, 'none');
		controlDisplay(closeId, 'block');
		controlDisplay(contentId, 'none');
	}
}

function clearContent(id)
{
	var e = document.getElementById(id);
	e.innerHTML = "";
}

function clearMessages(id)
{
	var e = document.getElementById(id+"0");
	if(e != null)
		e.innerHTML = "";
	e = document.getElementById(id+"1");
	if(e != null)
		e.innerHTML = "";
}

function containsKey( key, checkArray )
{
   if(checkArray[key]==undefined)
		return false;	
	else
		return true;
}

function getFlashRef(movieName)
{
	return getFlashRef(movieName, null);
}

function getFlashRef(movieName, iframeName)
{
	if(iframeName == null)
	{
		if(document.embeds[movieName]) return document.embeds[movieName]; // FireFox
		if(window.document[movieName]) return window.document[movieName]; // IE 
		if(window[movieName]) return window[movieName]; 
		if(document[movieName]) return document[movieName]; 
		return null; 
	}
	else
	{
		var idoc = window.frames[iframeName].document;

		if(idoc.embeds[movieName]) 
			return idoc.embeds[movieName]; // FireFox
		if(idoc[movieName]) 
			return idoc[movieName]; // IE 
			
		return null; 
	}
}

function gotoPage(pageNumber, objID) 
{
	iframeName = "wfdbookIframe";
	
	if(objID == null)
		objID = "wfdbook";
		
	var flashRef=getFlashRef(objID, iframeName);
	
	//alert("Calling Callback_WFGotoPage ");
	flashRef.Callback_WFGotoPage(pageNumber);
}

function gotoPageTmp(pageNumber) 
{
	iframeName = "wfdbookIframe";
	objID = "wfdbook";
	var flashRef=getFlashRef(objID);
	//var flashRef=getFlashRef(objID);
	
	flashRef.Callback_WFGotoPage(pageNumber);
}

function switchToQuery(shortTitle)
{
	toggleTabs("Query", "Index");
	document._WFViewer_fm4._WFViewer_queryItem.value = shortTitle;
}

function switchToTellAFriend(shortTitle)
{
	toggleTabs("Tell-A-Friend", "Index");
	document._WFViewer_fm5._WFViewer_sendItemNumber.value = shortTitle;
}

function switchToSave(shortTitle)
{
	toggleTabs("Bookmark", "Index");
	document._WFViewer_fm3._WFViewer_saveItemNumber.value = shortTitle;
}


function startAtPage (pageNumber, ebookURL, viewerType) 
{
	iframeName = "wfdbookIframe";
		
	if(viewerType == "TYPE1")
	{
		objID = "wfdbook";
		var flashRef=getFlashRef(objID, iframeName);
		//toggleTabs("Content", "Index");
		document.getElementById(iframeName).src = ebookURL;
	}
	else if(viewerType == "TYPE2")
	{
		//var e = window.frames[iframeName].document;
		//toggleTabs("Content", "Index");
		window.frames[iframeName].gb.jumpToPage(pageNumber);
	}
	if(viewerType == "TYPE3")
	{
		objID = "wfdbook";		
		//toggleTabs("Content", "Index");
		gotoPage(pageNumber, null);
	}
}

function toggleTabs (on, off) 
{
   var offTab = "_WFViewer_tabs1" + off + "TabsId";
   var onTab = "_WFViewer_tabs1" + on + "TabsId";
   var offSection = "_WFViewer_tabs1" + off + "TabsSection";
   var onSection = "_WFViewer_tabs1" +  on  + "TabsSection";
   
   var el = document.getElementById(offTab);
   
   if (el) 
   {
		el.className = "none";
   }
   
   el = document.getElementById(offSection);
   
   if (el) 
   {
		el.style.display = "none";
   }
   
   el = document.getElementById(onTab);
   if (el) 
   {
		el.className = "current";
   }

   el = document.getElementById(onSection);
   if (el) 
   {
		el.style.display = "block";
   }
   
}

function toggleTwoElements(e1, e2)
{
	toggleElementDisplay(e1);
	toggleElementDisplay(e2);
}

function toggleElementDisplay(eid)
{
	if(eid == null)
		return;
	
	$jq("#" + eid).toggle();
	
}

/* ted : Toggle Element Display
* e = this (anchor element)
* tid = id to be toggled
* sClass : show class (icon)
* hClass : hide class (icon)
*/
function ted1(e, tid, sClass, hClass)
{
	if(tid == null)
		return;
	
	$jq("#" + tid).toggle();
	
	if((sClass != null) && (hClass != null))
	{		
		if($jq(e).hasClass(sClass))
		{
			$jq(e).removeClass(sClass);
			$jq(e).addClass(hClass);
		}
		else if($jq(e).hasClass(hClass))
		{
			$jq(e).removeClass(hClass);
			$jq(e).addClass(sClass);
		}
	}
	
	return false;
}

/* ted : Toggle Element Display
* e = this (anchor element)
* cClass = class name of the element to be toggled
* (must be child of e's parent node)
* sClass : show class (icon)
* hClass : hide class (icon)
*/
function ted2(e, cClass, sClass, hClass)
{
	if(e == null)
		return;
		
	var t = null;
	var	arr = getElementsByClassName(cClass, e.parentNode, null);
	if(arr != null)
	{
		t = arr[0];
	}
	
	$jq(t).toggle();
	
	if((sClass != null) && (hClass != null))
	{		
		if($jq(e).hasClass(sClass))
		{
			$jq(e).removeClass(sClass);
			$jq(e).addClass(hClass);
		}
		else if($jq(e).hasClass(hClass))
		{
			$jq(e).removeClass(hClass);
			$jq(e).addClass(sClass);
		}
	}
	
	return false;
}


function getConfirm(str, fullQuestion)
{
	var question = "Are you sure"
	
	if(str == null)
		str = "";
		
	if(fullQuestion)
	{
		question = str;
	}
	else
	{
		question = "Are you sure you want to " + str + " ?";
	}
	
	if(confirm(question))
	{
		return true;
	}
	else
	{
		return false;
	}
}

// ----- start collapsible panel

function ecPanel(e)
{		
	var arr = null;
	var img_location = "/wfs/util/images/icons/";
	
	var e_img = null;
	arr = getElementsByClassName("ecimg", e, "img");
	if(arr != null)
	{
		e_img = arr[0];
	}
	
	var e_panel = null;
	if(e.className == "cHead")
	{
		arr = getElementsByClassName("cPanel", e, "div");
	}
	else
	{
		arr = getElementsByClassName("ePanel", e, "div");
	}
		
	if(arr != null)
	{
		e_panel = arr[0];
	}
	else
	{
		e_panel = e.getElementsByTagName("div")[0];
	}
	
   if(e_panel.className == "cPanel")
   {
     e_panel.className = "ePanel";
	 e_img.src = img_location + "c.png";
	 e.className  = "eHead";
   }
   else
   {
     e_panel.className = "cPanel";
	 e_img.src = img_location + "e.png";
	 e.className  = "eHead";
   }
}

function getElementsByClassName(searchClass, node, tag)
{
      var classElements = new Array();
      if (node == null)
      {
      	node = document;
      }
      
	  if (tag == null)
      {
     	 tag = '*';
      }
     
	  var els = node.getElementsByTagName(tag);
      var elsLen = els.length;
      var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");

      for (var i = 0, j = 0; i < elsLen; i++)
      {
     	if (pattern.test(els[i].className))
      	{
      		classElements[j] = els[i];
      		j++;
      	}
      }
	  
	if(classElements.length > 0)
	    return classElements;
	else
		return null;
}

// ----- end collapsible panel

// ----- Start resizable pop-up

function showPopUpWithLoading(url, resizable, modal, heading, width, height) 
{
	//alert("In showPopUpWithLoading");
	var tmpMsg = "<div style='text-align:center;margin-top:20px;'>Loading, please wait...<br/><img src=\"/wfs/util/images/anim/bar1.gif\"/></div>";
	showPopUp(resizable, modal, tmpMsg, null, "Loading, please wait...", "250px", "150px");
	
	$jq.ajax({
		type: "GET",
		async:false,
	 	url: url,
	 	cache: false,
		success: function(html){		
			showPopUp(resizable, modal, html, null, heading, width, height);		
	 	},
		error: function(html){
			tmpMsg = "<div style='text-align:center;margin-top:20px;color:#E00;font-weight:bold;font-size:14px;'>Connection Failed!</div>";
			showPopUp(resizable, modal, tmpMsg, null, heading, "250px", "150px");			
	 	}	
	});	
}

function showPopUp(resizable, modal, content, contentId, heading, width, height) 
{
	
	if(width == null)
	{
		width = "400px";
	}
	
	if(height == null)
	{
		height = "200px";
	}
	
	if(content == null)
	{
		content = $jq("#" + contentId).html();
	}
	
	if(heading == null)
	{
		heading = "Info";
	}
	
	if(popPanel == null)
	{
		popPanel = createPopUp("popPanel");
	}

	popPanel.setHeader(heading);
	popPanel.setBody(content);
	popPanel.setFooter("");
	popPanel.render(document.body);
	$jq("#popPanel_c").addClass('yui-skin-sam');
	//$jq("#popPanel_mask").addClass('yui-skin-sam');
	
	if(resizable)
	{
		rPopPanel = enableResize(rPopPanel, popPanel, "popPanel");
	}
	else
	{
		if(rPopPanel != null)
		{
			rPopPanel.destroy();
			rPopPanel = null;
		}
	}

	popPanel.cfg.setProperty("width", width);
	popPanel.cfg.setProperty("height", height);
	
	if(modal)
	{
		popPanel.cfg.setProperty("modal",true);
	}
	else
	{
		popPanel.cfg.setProperty("modal",false);
	}

	popPanel.show();
}

function createPopUp(panelId, isDialog) 
{
	var panel = null;
		
	if(isDialog)
	{
		panel = new YAHOO.widget.Dialog(panelId, 
					{ 
						close:true,  
						visible:false,  
						fixedcenter: true,
						constraintoviewport: true, 
						width: "400px",
       					//height: "200px",
						underlay: "shadow",
						autofillheight : "body",
						draggable:true
					} 
				); 
	}
	else
	{
		panel = new YAHOO.widget.Panel(panelId, 
					{ 
						close:true,  
						visible:false,  
						fixedcenter: true,
						constraintoviewport: true, 
						width: "400px",
       					//height: "200px",
						underlay: "shadow",
						autofillheight : "body",
						draggable:true
					} 
				); 
	}
	
	return panel;
}

function enableResize(resizePanel, panel, panelId) 
{
	if(resizePanel == null)
	{
		resizePanel = new YAHOO.util.Resize(panelId, {
		handles: ["br"],
		autoRatio: false,
		minWidth: 300,
		minHeight: 150,
		status: false 
		});
	}
	
	resizePanel.on("startResize", function(args) 
	{
		if (this.cfg.getProperty("constraintoviewport")) 
		{
			var D = YAHOO.util.Dom;
	
			var clientRegion = D.getClientRegion();
			var elRegion = D.getRegion(this.element);
	
			resizePanel.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
			resizePanel.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
		} 
		else 
		{
			resizePanel.set("maxWidth", null);
			resizePanel.set("maxHeight", null);
		}

	}, panel, true);

	resizePanel.on("resize", function(args) 
	{
		var panelHeight = args.height;
		this.cfg.setProperty("height", panelHeight + "px");
	}, panel, true);
	
	return resizePanel;
}


function createBoundPopUp(show, resizable, modal, contentId, heading, width, height, isForm) 
{		
	var tPanel = bPanels[contentId];
	var trPanel = brPanels[contentId];
	
	//alert(tPanel);
	if(tPanel == null)
	{
		if(width == null)
		{
			width = "400px";
		}
		
		if(height == null)
		{
			height = "250px";
		}
	
		if(isForm == undefined)
			isForm = false;
	
		tPanel = createPopUp(contentId, isForm);
		tPanel.render(document.body);
		
		//$jq("#" + contentId + " .bd").height(height);
		tPanel.cfg.setProperty("width", width);
		tPanel.cfg.setProperty("height", height);
		
		if(heading != null)
		{
			tPanel.setHeader(heading);
		}
		
		if(modal)
		{
			tPanel.cfg.setProperty("modal",true);
		}
		else
		{
			tPanel.cfg.setProperty("modal",false);
		}		
		
		//tPanel.setFooter("");
		
		$jq("#" + contentId + "_c").addClass('yui-skin-sam');
		
		bPanels[contentId] = tPanel;
		
		if(resizable && (trPanel == null))
		{
			trPanel = enableResize(trPanel, tPanel, contentId);
			brPanels[contentId] = trPanel;
		}		
	}
	
	if(show)
	{
		//if(tPanel.cfg.getProperty("visible"))
		//var bVisible = tPanel.cfg.getProperty("visible");
		if(!tPanel.cfg.getProperty("visible"))
		{
			$jq("#" + contentId).show();
			tPanel.show();
		}
		else 
		{
			$jq("#" + contentId).hide();
			tPanel.hide();
		}		
	}
	else
	{
		$jq("#" + contentId).hide();
		tPanel.hide();
	}
	
}

function showActions(id)
{
	if(id == undefined)
		id = "docIDActions";
		
	cpv(id);
}

// cpv : controlPanelVisibility

function cpv(contentId, flag) 
{
	var tPanel = bPanels[contentId];

	if(tPanel != null)
	{
		if(flag == undefined)
		{	
			if(!tPanel.cfg.getProperty("visible"))
			{
				$jq("#" + contentId).show();
				tPanel.show();
			}
			else 
			{
				$jq("#" + contentId).hide();
				tPanel.hide();
			}	
		}
		else if(flag == 1)
		{
			$jq("#" + contentId).show();
			tPanel.show();
		}
		else if(flag == 0)
		{
			$jq("#" + contentId).hide();
			tPanel.hide();
		}
	}
}


// ----- End resizable pop-up

// --- start hover ------
function showHoverPopUp(ae, modal, content, contentId, heading, width, height) 
{
	delay = 250;
	var anchorId = ae.id;
	var eAnchor = ae;
	var panelId = "hoverPanel_c";
    var ePanel  = null;
	var init = false;
	
	if(width == null)
	{
		width = "400px";
	}
	
	if(height == null)
	{
		height = "200px";
	}
	
	if(content == null)
	{
		content = $jq("#" + contentId).html();
	}
	
	if(heading == null)
	{
		heading = "Info";
	}
	
	if(hoverPanel == null)
	{
		hoverPanel = new YAHOO.widget.Panel("hoverPanel", 
		{
            context: [anchorId, "tl", "bl"],
            width: "300px",
            draggable: false,
            visible: false,
            close: false,
            underlay: "shadow"
        });
		
		init = true;
	}
	
	ePanel  = document.getElementById(panelId);

	hoverPanel.setHeader(heading);
	hoverPanel.setBody(content);
	//hoverPanel.setFooter("");
	hoverPanel.render(document.body);
	
	$jq("#" + panelId).addClass('yui-skin-sam');
	
	//$jq("#popPanel_mask").addClass('yui-skin-sam');
	
	hoverPanel.cfg.setProperty("width", width);
	hoverPanel.cfg.setProperty("height", height);
	hoverPanel.cfg.setProperty("context", [anchorId, 'tl', 'bl']);
	
	if(modal)
	{
		hoverPanel.cfg.setProperty("modal",true);
	}
	else
	{
		hoverPanel.cfg.setProperty("modal",false);
	}
	
	var timeoutFunc = function() 
	{
		hoverPanel.hide();
	};
	
	$jq('#' + anchorId).mouseover(function() {
		hoverPanel.align("tl", "bl"); 
		hoverPanel.show();
		if (hoverTimeout) clearTimeout(hoverTimeout);
	});
	
	$jq('#' + panelId).mouseover(function() {
		if (hoverTimeout) clearTimeout(hoverTimeout);
	});
	
	
	$jq('#' + anchorId).mouseout(function() {
		if (hoverTimeout) clearTimeout(hoverTimeout);
		hoverTimeout = setTimeout(timeoutFunc, delay);
	});
	
	$jq('#' + panelId).mouseout(function() {
		if (hoverTimeout) clearTimeout(hoverTimeout);
		hoverTimeout = setTimeout(timeoutFunc, delay);
	});
	
	hoverPanel.show();
	
}

// ------ end hover ----------


function popWFIDInfo(anchorElement, WFID, viewURL, thumbURL, pname0, pvalue0)
{
		var content = "<table class='searchTable1' cellspacing='0' cellpadding='0' style='width:300px;'> "
		+ "	<tr> "
		+ "		<td colspan='2' align='center' class='bg2'><a href='$VIEW_URL$' target='_blank' ><img style='padding:8px;width:200px;height:auto;' src='$THUMB_URL$' /></a></td> "
		+ "	</tr> "
		+ "	<tr> "
		+ "		<td class='t-right'>DOC-ID</td> "
		+ "		<td class='value textColor8'><a href='$VIEW_URL$' target='_blank' ><b>$WFID$</b> "
		+ "			&nbsp;<img alt='Launch in new Window' title='Launch in new Window' src='/html/common/themes/images/newWindow.png' /></a></td> "
		+ "	</tr> "
		+ "	</table> ";
		
		content = stringReplace(content, "$WFID$", WFID);
		content = stringReplace(content, "$VIEW_URL$", viewURL);
		content = stringReplace(content, "$THUMB_URL$", thumbURL);
		content = stringReplace(content, "$PNAME0$", pname0);
		content = stringReplace(content, "$PVALUE0$", pvalue0);
		
		showHoverPopUp(anchorElement, 0, content, null, "DOC-ID : " + WFID, "auto", "auto");
}

function popWFIDInfo2(anchorElement, WFID, viewURL, thumbURL, 
					  publishDate, expirationDate, owner, alias, 
					  n0, v0, n1, v1, n2, v2, n3, v3, n4, v4, n5, v5, n6, v6)
{
	var content = "<table class='searchTable1' cellspacing='0' cellpadding='0' style='width:350px;'> \
		<tr> \
			<td colspan='2' align='center' class='bg2'><a href='" + viewURL + "' target='_blank' ><img \
			style='padding:8px;width:200px;height:auto;' src='" + thumbURL + "' /></a></td> \
		</tr> \
		<tr> \
			<td class='t-right'>DOC-ID</td> \
			<td class='value textColor8'><a href='" + viewURL + "' target='_blank' ><b>" + WFID + "</b> \
				&nbsp;<img alt='Launch in new Window' title='Launch in new Window' src='/html/common/themes/images/newWindow.png' /></a></td> \
		</tr> ";
	
	content += 
	"<tr> \
		<td class='param'>Direct Link</td> \
		<td class='value textColor8'><a href='" + viewURL + "' target='_self' ><b>" + viewURL + "</b> \
				&nbsp;<img alt='View' title='View' src='/html/common/themes/images/newWindow.png' /></a></td> \
	</tr> ";

	if((alias != null) && (alias.length > 0))
	{
		content += 
		"<tr> \
			<td class='param'>Alias Link</td> \
			<td class='value textColor8'><a href='" + alias + "' target='_self' ><b>" + alias + "</b> \
					&nbsp;<img alt='View' title='View' src='/html/common/themes/images/newWindow.png' /></a></td> \
		</tr> ";
	}

	content += 
	"<tr> \
		<td class='param'>Publish Date</td> \
		<td class='value textColor8'>" + publishDate + "</td> \
	</tr> ";
	
	content += 
	"<tr> \
		<td class='param'>Expiration Date</td> \
		<td class='value textColor8'>" + expirationDate + "</td> \
	</tr> ";	
	
	content += 
	"<tr> \
		<td class='param'>Owner</td> \
		<td class='value textColor8'>" + owner + "</td> \
	</tr> ";		
	

	
	
	if((n0 != null) && (v0 != null) && (v0.length > 0))
	{
		content += 
		"<tr> \
			<td class='param'>" + n0 + "</td> \
			<td class='value textColor8'>" + v0 + "</td> \
		</tr> ";
	}
	
	if((n1 != null) && (v1 != null) && (v1.length > 0))
	{
		content += 
		"<tr> \
			<td class='param'>" + n1 + "</td> \
			<td class='value textColor8'>" + v1 + "</td> \
		</tr> ";
	}
	
	if((n2 != null) && (v2 != null) && (v2.length > 0))
	{
		content += 
		"<tr> \
			<td class='param'>" + n2 + "</td> \
			<td class='value textColor8'>" + v2 + "</td> \
		</tr> ";
	}
	
	if((n3 != null) && (v3 != null) && (v3.length > 0))
	{
		content += 
		"<tr> \
			<td class='param'>" + n3 + "</td> \
			<td class='value textColor8'>" + v3 + "</td> \
		</tr> ";
	}
	
	if((n4 != null) && (v4 != null) && (v4.length > 0))
	{
		content += 
		"<tr> \
			<td class='param'>" + n4 + "</td> \
			<td class='value textColor8'>" + v4 + "</td> \
		</tr> ";
	}
	
	if((n5 != null) && (v5 != null) && (v5.length > 0))
	{
		content += 
		"<tr> \
			<td class='param'>" + n5 + "</td> \
			<td class='value textColor8'>" + v5 + "</td> \
		</tr> ";
	}
	
	if((n6 != null) && (v6 != null) && (v6.length > 0))
	{
		content += 
		"<tr> \
			<td class='param'>" + n6 + "</td> \
			<td class='value textColor8'>" + v6 + "</td> \
		</tr> ";
	}

	
	content += "</table/>";
	
	
	showHoverPopUp(anchorElement, 0, content, null, "DOC-ID : " + WFID, "auto", "auto");
}

function doesExists(e)
{
  return typeof(e) != 'undefined';
}

function countChars(tbox, cbox, max) 
{
	var max = max ? max : 256;

	var field = document.getElementById(tbox);
	var cField = document.getElementById(cbox);
	if((cField != null) && (field != null)) 
	{
		if (field && field.value.length >= max) 
		{
				field.value = field.value.substring(0, max);
		}
		
		cField.innerHTML = field.value.length;
	}
}

