/**************************************************/
/*  Function Library DocumentDetails              */
/*  Created on 23/06/2006 by Phil Parkyn          */
/**************************************************/


/**************************************************/
/* Displays the pop up box with the WCMS content  */
/* usually linked to from the      */
/*                                                */
/* Parameters: Array with following metadata      */
/*  El 0 - ContentID                              */
/*  El 1 - Document Title                         */
/*  EL 2 - Revision Label                         */
/*  El 3 - Start date                             */
/*  El 4 - Removal date                           */
/*  El 5 - Revision ID                            */
/*                                                */
/* Returns: nothing (creates a pop up window)     */
/**************************************************/

// Function to display page information
function fnDocumentDetails(parms) {

	// set up variables
	var detWin = open("","","width=350,height=400,left=250,top=100") ; 
	var output = '' ;
	var locn = this.parent.document.location.href ;
	var p1 = locn.indexOf('/',8) ;
	var p2 = locn.length ;
	var locn = locn.substring(p1+1,p2+1) ;

	//Extract values from Array sent
	var dDocName = parms[0] ;
	var dDocTitle = parms[1] ;
	var dRevLabel = parms[2] ;
	var dInDate = parms[3] ;
	var dOutDate = parms[4] ;
	var dID = parms[5] ;
	
	var xDescription = parms[6] ;
	
	var csURL = 'http://51.71.34.230/intradoc-cgi/idc_cgi_isapi.dll?' ;
	var csSearch = 'IdcService=GET_SEARCH_RESULTS&QueryText=dDocName+%3CMatches%3E+%60'+dDocName+'%60&ftx=&AdvSearch=True&ResultCount=25&SortField=dInDate&SortOrder=Desc' ;
	var csUpdate = 'IdcService=GET_UPDATE_FORM&dID='+dID+'&dDocName='+dDocName+'&dDocTitle='+ dDocTitle ;
	var csCheckOut = '' ;
	var csCheckInSimilar = 'IdcService=CHECKIN_SIMILAR_FORM&dID='+dID+'&dDocName='+dDocName ;
	
	var mailLink = 'mailto:Intranet-Adviceline-DWP@exmar01.dss.gsi.gov.uk?Subject=Doc ID:' + dDocName + ' / Title: ' + dDocTitle ;
	mailLink += '&Body=%0D%0D%0D%0DPlease add a description of the problem in the above space.%0D(URL = http://intralink/' + locn + ')';
	
	output += '<HTML><HEAD><Title>Document Information</Title></HEAD>\n\n' ;
	output += '<link rel="stylesheet" href="/_shared/_css/_dwp/docDetailsPopup.css" type="text/css">\n' ;
	output += '</HEAD>\n\n<BODY>\n';
	
	var report = '';
	
	report += '<hr/>' ;
	report += '<ul><li><a href="' ;
	report += mailLink ;
	report += '" title="Report a fault">Report a fault</a> with this page to Intranet Adviceline</li></ul>\n';
	report += '<hr/>\n' ;
	
	if (dDocName!='') {
		output += '<h1 align="center">Document Information</h1>\n';
		output += '<hr/>\n' ;
		output += '<table width="100%">\n' ;
		output += '<tr valign="top"><td><b>Content ID:</b></td><td><A href="' +csURL + csSearch + '" target="parent">' + dDocName + '</a>.</td></tr>\n' ;
		output += '<tr valign="top"><td><b>Revision No:</b></td><td>' + dRevLabel + '.</td></tr>\n' ;
		output += '<tr valign="top"><td><b>Name:</b></td><td>' + dDocTitle + '.</td></tr>\n' ;
		output += '<tr valign="top"><td><b>Description:</b></td><td>' + xDescription + '.</td></tr>\n' ;
		output += '<tr valign="top"><td><b>Start Date:</b></td><td>' + dInDate + '.</td></tr>\n' ;
		output += '<tr valign="top"><td><b>Expiry Date:</b></td><td>' + dOutDate + '.</td></tr>\n' ;
		output += '</table><hr/>\n' ;
		
		output += '<h1>Options</h1>\n' ;
		
		output += report ;
		
		output += '<p>(These options require access to the Content Server)</p>\n' ;
		//output += '<li><a href="'+ csURL + csCheckOut +'" target="parent">Check out this document.</a></li>' ;
		output += '<ul>' ;
		output += '<li><a href="'+ csURL + csCheckInSimilar +'" target="parent">Check in a similar document.</a></li>\n' ;
		output += '<li><a href="'+ csURL + csSearch +'" target="parent">Access the Metadata on the source document.</a></li>\n' ;
		output += '<li><a href="'+ csURL + csUpdate +'" target="parent">Update the Metadata on the source document.</a></li>\n' ;
		output += '</ul>' ;
		
		output += '<hr/>\n' ;
	}
	else {
		output += '<p>This is an automatically generated index page and does not have any metadata.<br/>\n' ;
		output += 'If you need to link to this page then use its URL.</p>\n' ;
		output += '<p>URL = /' + locn + '</p>\n' ;
		
		output += report;
	}
/*
	output += '<div align="center"><a href="' ;
	output += mailLink ;
	output += '" title="Report a fault">Report a fault</a> with this page to Intranet Adviceline</div>\n';
	output += '<hr/>\n' ;
*/
	output += '<div align="center"><input type="button" name="Button" value="Close" onClick="window.close()"></div>\n' ;	
	output += '</BODY>\n</HTML>' ;

	detWin.document.write(output) ;

}

