function initView(){//	try {		$('query').value = LANG_GEN_SEARCH;		$('query').onkeypress = handleSearchReturn;		checkFavoriteLinks();		if (window.location.href.indexOf("searchview") == -1 && window.location.href.indexOf("profile?openform") == -1)			initViewNav(5, 20, "viewnav1", "viewnav2");		CheckNoDocuments();		if (openinnewwindow){			var mainlinks = $$(".mainlink");			for (var i=0; i<mainlinks.length; i++){				mainlinks[i].target = "newwindow";			}		}		initMaintenance();		initSlider();//	}catch (e){}}function initMaintenance(){	if (username!="Anonymous"){		var links = $('linkview').getElements('span[id=maintain]');		for (var i=0; i<links.length; i++){			var unid = links[i].getAttribute("unid");			if (links[i].getAttribute("owner") == username){				var html = " (<a href=\"" + dbPath + "/0/" + unid + "?editdocument\">edit</a> | ";				html += "<a href=\"#" + unid + "\" onClick=\"deleteLink('" + unid + "', " + i + ")\">" + LANG_VIEW_REMOVE + "</a>)";				links[i].innerHTML = html;			}else{				var html = " (<a href=\"" + dbPath + "/link?openform&parentunid=" + unid + "\">" + LANG_VIEW_COPY + "</a> | ";				if (admin)					html += "<a href=\"" + dbPath + "/0/" + unid + "?editdocument\">" + LANG_VIEW_EDIT + "</a> | ";				html += "<a href=\"#" + unid + "\" onClick=\"reportDeadLink('" + unid + "', " + i + ")\">" + LANG_VIEW_REPORTBROKENLINK + "</a>)";				links[i].innerHTML = html;			}		}	}}function deleteLink(unid, index){	var url = dbPath + "/deleteLink?openagent&unid=" + unid + "&rnd=" + Math.floor(Math.random()*1001);;	new Ajax(url, {			method: 'get',	          onComplete: function (response){	          	if (response == "OK\n"){	          		//Delete the div containing the link	          		var divs = $$(".linkdetail");					var myFx = new Fx.Style(divs[index], 'opacity', {						transition: Fx.Transitions.Back.easeInOut,						duration: 1500					}).start(1, 0);					var mySlide = new Fx.Slide(divs[index], {						duration: 1500					}); 					mySlide.slideOut();	          	}else{	          		alert(response);	          	}	          }          }).request();}function reportDeadLink(unid, index) {	var url = dbPath + "/reportDeadLink?openagent&unid=" + unid + "&rnd=" + Math.floor(Math.random()*1001);;	new Ajax(url, {			method: 'get',	          onComplete: function (response){	          	if (response == "OK\n"){	          		//Add the dead link html to the view	          		var divs = $$(".div_link_tags");					divs[index].innerHTML += " <img src=\"" + dbPath + "/link_error.png\" alt=\"" + LANG_VIEW_REPORTED + "\" title=\"" + LANG_VIEW_REPORTED + "\"/> " + LANG_VIEW_BROKEN;	          	}else{	          		alert(response);	          	}	          }          }).request();}function handleSearchReturn(event){	var event = new Event(event);	if (event.key == "enter"){		event.stopPropagation();		doSearch();		return false;	}else{		return true;	}}function doSearch(){	if ($("query").value != "" && $("query").value != LANG_GEN_SEARCH){		var url = dbPath + "/links?searchview&query=" + escape($("query").value) + "&start=0&count=40";		window.location.href = url;	}}function CheckNoDocuments() { // function to replace the 'No documents found' message	var theview = $("linkview");	var rows = theview.getElementsByTagName("div");	if (rows.length == 0){		var url = window.location.href.toLowerCase();		document.getElementById("linkview").innerHTML = "<span style=margin-left:10px;>" + LANG_VIEW_NOLINKS + "	</a></span></h2>"		try {			$("viewnav1").style.display = "none";			$("viewnav2").style.display = "none";		}catch (e){}	} // end if} // end function/*VIEW NAVIGATIONOriginal code taken from http://quintessens.wordpress.com/2007/03/29/bobs-ultimate-view-navigator-categorized-view/and then adapated to Idea Jam requirements.*/// initViewNav function, loaded at onLoad event of form/************************************************/function initViewNav(range, cache, div1, div2) {	navRange = range;	navCache = cache;	navDiv1 = div1;	navDiv2 = div2;	startDoc = queryString('start');	startDoc = (startDoc == "") ? 1 : parseInt(startDoc);	docsPerPage = queryString('count');	docsPerPage = (docsPerPage == "") ? 20 : parseInt(docsPerPage);	waitForDocCount()}// QueryString function/****************************************************/function queryString(key){	var page = new PageQuery(window.location.search);	return unescape(page.getValue(key.toLowerCase()));}function PageQuery(q) {	try {		if(q.length > 1)			this.q = q.substring(1, q.length);		else			this.q = null;		this.keyValuePairs = new Array();		if(q) {			for(var i=0; i < this.q.split("&").length; i++) {				this.keyValuePairs[i] = this.q.split("&")[i].toLowerCase();			}		}		this.getKeyValuePairs = function() { return this.keyValuePairs; }		this.getValue = function(s) {			for(var j=0; j < this.keyValuePairs.length; j++) {				if(this.keyValuePairs[j].split("=")[0] == s)					return this.keyValuePairs[j].split("=")[1];			}			return "";		}		this.getParameters = function() {			var a = new Array(this.getLength());			for(var j=0; j < this.keyValuePairs.length; j++) {				a[j] = this.keyValuePairs[j].split("=")[0];			}			return a;		}		this.getLength = function() { return this.keyValuePairs.length; }	}catch (e){}}function getExpiryDate(minutes){	var UTCstring;	Today = new Date();	nomilli = Date.parse(Today);	Today.setTime(nomilli + (minutes * 0));	UTCstring = Today.toUTCString();	return UTCstring;}function setCookie(name, value, duration){	cookiestring = name + "=" + escape(value) + "; EXPIRES=" + getExpiryDate(duration);	document.cookie = cookiestring;}function getCookie(cookiename) {	var cookiestring = "" + document.cookie;	var index1 = cookiestring.indexOf(cookiename);	if (index1 == -1 || cookiename == "") return "";		var index2 = cookiestring.indexOf(';', index1);	if (index2 == -1) index2 = cookiestring.length;		return unescape(cookiestring.substring(index1 + cookiename.length + 1, index2));}var startDoc = 0;var docsPerPage = 0;var totalPages = 0;var navRange = 0;var navCache = 0;var navDiv1 = "";var navDiv2 = "";var checkCookie = false;var totalDocs = "";function waitForDocCount() {	if (checkCookie) {		totalDocs = getCookie('totaldocs');		checkCookie = false;	}	if (totalDocs == "") {		getDocCount();	} else {	}}function getDocCount () {	var xmlHttp = getXMLHTTP();	var strURL = dbPath + "/" + viewAlias + "?ReadViewEntries&count=1&rnd=" + Math.floor(Math.random()*1001);	if (Categories != "")		strURL += "&RestrictToCategory="+ Categories;	xmlHttp.open("GET", strURL );	xmlHttp.onreadystatechange = function() {		if (xmlHttp.readyState == 4 && xmlHttp.responseText) {			var resp = xmlHttp.responseText;			var countTag = resp.toLowerCase().indexOf('toplevelentries');			if (countTag > 0) {				resp = resp.substr(resp.indexOf('"', countTag) + 1);				totalDocs = resp.substring(0, resp.indexOf('"'));				setCookie('totaldocs', totalDocs, navCache)			}else{				setCookie('totaldocs', 0, navCache)			}			drawViewNav();		}	};	xmlHttp.send(null);}function getXMLHTTP() {	var xmlHttp = null	try {		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")	} catch(e) {		try {			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")		} catch(oc) {			xmlHttp = null		}	}	if(!xmlHttp && typeof XMLHttpRequest != "undefined") {		xmlHttp = new XMLHttpRequest()	}	return xmlHttp}function drawViewNav() {	//try {		partialPages = totalDocs / docsPerPage;		extraPage = (partialPages == Math.floor(partialPages)) ? 0 : 1;		totalPages = Math.floor(partialPages) + extraPage;		if (totalPages == 1)			return;		curPage = Math.floor(startDoc / docsPerPage) + 1		startLink = (curPage < (navRange + 1)) ? 1 : curPage - navRange;		endLink = ((curPage + navRange) > totalPages) ? totalPages : curPage + navRange;		var navHTML = "<div class='nav' align='left'><table class='navtable' cellpadding='0\u2032 cellspacing='0\u2032><tr>";		if (startLink > 1) {			navHTML = navHTML + buildLink(1, LANG_VIEW_FIRST);			navHTML = navHTML + buildLink(curPage - (navRange + 1), "<<");		} 		if (curPage > 1) navHTML = navHTML + buildLink(curPage - 1, "<");		for (i = startLink; i <= endLink; i++) {			if (i == curPage) {				navHTML = navHTML + "<td class='navtablecur'>" + i + "</td>"			} else {				navHTML = navHTML + buildLink(i, i);			}		} 		if (curPage < totalPages) navHTML = navHTML + buildLink(curPage + 1, ">");		if (endLink < totalPages) {			navHTML = navHTML + buildLink(curPage + (navRange + 1), ">>");			navHTML = navHTML + buildLink(totalPages, LANG_VIEW_LAST);		}		navHTML = navHTML + "</td>" 		navHTML = navHTML + "<td class='navpagecount'>" + LANG_VIEW_PAGE + " ";		navHTML = navHTML + curPage ;		navHTML = navHTML + " " + LANG_VIEW_OF + " " + totalPages + "</td>";  		navHTML = navHTML + "</tr></table></div>";		$(navDiv1).innerHTML = navHTML;		if (typeof navDiv2 != "undefined")			$(navDiv2).innerHTML = navHTML;		//$('div_view').style.display = 'block';	//}catch (e){}}function buildLink(pageNum, text) {	startLinkDoc = (((pageNum - 1) * docsPerPage) + 1);	endDoc = (pageNum == totalPages) ? totalDocs : startLinkDoc + docsPerPage  // Check for last page when creating tooltip range	linkHTML = "<td class='navtablelink' onmouseover=\"this.className='navtablelink_on'\" onmouseout=\"this.className='navtablelink'\" "	linkHTML = linkHTML + "title='Page " + pageNum + " : " + startLinkDoc + " through " + endDoc + "' ";	var action = "OpenView";	if (viewAlias == "LinksByCreator"){		linkHTML = linkHTML + "onclick=\"document.location.href='" + dbPath + "/" + viewAlias + "?OpenForm&id=" + gup("id") + "&Start=" + startLinkDoc + "&Count=" + docsPerPage + "'\">" + text + "</td>";	}else if (Categories == ""){		linkHTML = linkHTML + "onclick=\"document.location.href='" + dbPath + "/" + viewAlias + "?OpenView&Start=" + startLinkDoc + "&Count=" + docsPerPage + "'\">" + text + "</td>";	}else{		linkHTML = linkHTML + "onclick=\"document.location.href='" + dbPath + "/" + viewAlias + "?OpenView&restricttocategory=" + Categories + "&Start=" + startLinkDoc + "&Count=" + docsPerPage + "'\">" + text + "</td>";	}	return linkHTML;}function getPage(event, field) {	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;	if (keyCode == 13) {		newPage = field.value;		if (newPage > totalPages || newPage < 1) {			field.select();			return false;		}		if (Categories == "")			document.location.href = dbPath + viewAlias + "?OpenView&Start=" + (((newPage - 1) * docsPerPage) + 1) + "&count=" + docsPerPage		else			document.location.href = dbPath + viewAlias + "?OpenView&restricttocategory=" + Categories + "&Start=" + (((newPage - 1) * docsPerPage) + 1) + "&count=" + docsPerPage	}}function openPage(tag){	if (gup("id") == ""){		if (username=="Anonymous" || (viewAlias != "LinksByCreator" & viewAlias != "mytags")){			window.location.href = dbPath + "/tags/" + escape(tag);		}else{			window.location.href = dbPath + "/mytags?readform&tag=" + escape(tag);		}	}else{		window.location.href = dbPath + "/TagsByCreator?readform&tag=" + escape(tag) + "&id=" + gup("id");	}}function initSlider(){	var mySlide = new Slider($('tagslider'), $('knob'), {		steps: 6,			offset: 5,		onChange: function(pos){			pos = (pos - 6) * -1;			var tags = $("tagcloudAllIdeas").getElementsByTagName("a");			for (var i=0; i<tags.length; i++){				if (tags[i].className >= "tag" + pos)					tags[i].style.display = "inline";				else					tags[i].style.display = "none";			}		}	}).set(initialFilter);	$("tagcloudAllIdeas").style.display = "block";}function gup( name ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];}function toggleFavorite(thestar) {	var id = thestar.id.split("_");	id = id[1];	currentUNID = id;	if (username == "Anonymous"){		if (window.location.href.indexOf(".nsf") == -1)			window.location.href=dbPath + "?open&login=1";		else			window.location.href=window.location.href + "?open&login=1";	}else{		var favorite = "true";		if (thestar.className != "star_empty"){			favorite = "false";		}		var url = dbPath + "/toggleFavorite?open&id=" + id + "&favorite=" + favorite + "&rnd=" + Math.floor(Math.random()*1001);		new Ajax(url, {				method: 'get',		          onComplete: function (data) {		          		try {			          		if (data.indexOf("error") > -1){								alert("There was an error storing your favorite");							}else{								if (favorite == "true")									thestar.className = "star";								else									thestar.className = "star_empty";							}						}catch (e){}		          	}	          }).request();	}}function checkFavoriteLinks(){	try {		if (username != "Anonymous"){			var thestars = $$(".star_empty");			for (var i=0; i<thestars.length; i++){				var id = thestars[i].id.split("_");				if (favorites[id[1]])				thestars[i].className = "star";			}		}	}catch (e){}}function editReplace(strTest, strFrom, strTo){	var re = new RegExp(strFrom, "gim");	if ( ! re.exec(strTest) ){		return strTest;	}	return strTest.replace(re,strTo);}