/////////////////////////////////////////////////////////////////////////////
// Function : Link functions available to be used within docs.
// Comments : 
// Usage: Use by making links like: javascript:download('<Content ID>')
/////////////////////////////////////////////////////////////////////////////
var GetDC = httpCgiPath + "?IdcService=GET_DYNAMIC_CONVERSION&RevisionSelectionMethod=LatestReleased&dDocName="
var GetFl = httpCgiPath + "?IdcService=GET_FILE&RevisionSelectionMethod=LatestReleased&Rendition=Primary&allowInterrupt=1&noSaveAs=1&dDocName="

var dhs_getFileURL =  httpCgiPath + "?IdcService=GET_FILE&RevisionSelectionMethod=LatestReleased&noSaveAs=1&Rendition=Primary&allowInterrupt=1&dDocName=";

function download(dDocName, openNewWin) {
	//window.location = dhs_getFileURL + dDocName.toLowerCase();
	if(!openNewWin) {
		window.location = GetFl + dDocName.toLowerCase();
	} else {
		var newURL = GetFl + dDocName.toLowerCase();
		var newWindow = window.open(newURL, "newWin", "resizable=true,width=300,height=300");
	}
}


function link(dDocName, bookMark) { 
	var newUrl, dArr, dExt, docID, newDocID;
	if ((dDocName.search("http://") != -1) || (dDocName.search("https://") != -1)) {
		window.open(dDocName);
	} else {
		dArr = dDocName.split("\.");
		docID = dArr[0].toLowerCase();
			dExt = dArr[1];
		if((dExt == "hcsp") || (!dExt)) {	 
			newDocID = docID.replace("dhs_","");
			newUrl = GetDC + newDocID;
			if(bookMark != null) { 
				// newUrl += bookMark;
				newUrl = newUrl + "#" + bookMark;
			}
			window.location = newUrl;
		} else { 
			newUrl = GetFl + docID;
			window.open(newUrl);
		}
	}
}

function linkNewWin(dDocName, bookMark) {
	var newURL;
	
	
	if(!bookMark) {
		newURL = GetDC + dDocName;
	} else {
		newURL = GetDC + dDocName + "#" + bookMark;
	}
	//alert(newURL);
	var newWindow = window.open(newURL, "newWin", "resizable=true,width=300,height=300");
}

