 /********************************************************************************************
 * PVCS ... 
 * $Workfile:   web_search.js  $ 
 * $Revision:   1.7  $ 
 * $Date:   Nov 10 2005 14:32:56  $ 
 * $Author:   UCAMPP4  $  
 * $Archive:   //renpmhqa1/mhpvcsdata/archives/web/Martindale-com/v3/www/LawyerLocator/js/web_search.js-arc  $
 * 
 * author: Paul Campbell, Andrew Bergamasco
 * open issues: this file should be renamed profile.js
 * because it contains misc functions needed by profile pages
 *
 * change history:
 * version 1.05			08/26/2005 AB:	fixed email feature by adding '/xp/Martindale/Lawyer_Locator/Search_Lawyer_Locator/'
 * version 1.05			08/26/2005 AB:	fixed profile feature by removing escape
 * version 1.05			08/26/2005 AB:	returning true from passParams 
 * version 1.04			08/26/2005 AB:	added bread crumb to checkParam()   
 * version 1.03			08/26/2005 AB:	added checkParam() to remove certain parameters
 * version 1.02			08/26/2005 AB:	added attyLink to support attorney links on the firm profile
 * version 1.01			08/21/2005 AB:	added email & print functions 
 * version 1.00			08/18/2005 PC:	initial revision
 ********************************************************************************************/

	/**
	* submits the Google WebSearch form 
	* Used by profile pages to submit web searches
	*/		
	function submitWebSearchForm() {
		webSearchForm.target="_blank";  // comment this line if we can't open a daughter window
		webSearchForm.submit();					
	} //-- submitWebSearchForm()

	/**
	* Parses the query string (location.search) removing certain parameters to create a new query string.  
	* Opens the given web resource with the resulting query string. 
	*
	* Used to build links to listing.xml and atty_listing.xml 	
	*
	* This assumes the "resource" argument is of the form "listing.xml?l=XXX&view=XXX" or "atty_listing.xml?a=XXX"	
	*
	* According to Alex we should pass all of the parameters with the exception of pos & cnt			
	*
	* According to Andrew we should not pass view, l or a 
	* as these parameters will be passed inside the "resource" argument
	*	
	* @author: 	Andrew Bergamasco
	* @version:	1.00
	*/		
	function passParams(obj, resource) {

		// resource may contain ampersand entities... so we have to un-encode them 
		resource=unescape(resource);
		
		if (location.search) {
			var vals=location.search.substr(1).split("&");	
			var queryStr ="";
			var QUE = "?";
			var AMP = "&";
			for (var i in vals) {
				// check each parameter before adding it to the query string
				if (!checkParam(vals[i])) {
					queryStr=queryStr+AMP+vals[i];
//				} else {
//					alert(vals[i]);
				}
			}
		}
		window.location=resource+queryStr;
		return true;
	}//-- function passParams(obj, resource)
	
	/**
	* return true if parameter is in the list of ignorable parameters
	* used to strip out parameters from query string
	* pos, cnt, view, l, a
	*	
	*/
	function checkParam(value) {
		if (value.indexOf("pos=")==0) return true;		
		if (value.indexOf("cnt=")==0) return true;
		if (value.indexOf("view=")==0) return true;		
		if (value.indexOf("l=")==0) return true;
		if (value.indexOf("a=")==0) return true;
		if (value.indexOf("bc=")==0) return true;
	} //-- function checkParam(value)


	/**
	* sets the incoming object's href to "send_listing.xml"
	* and passes the url encoded location.href as the "url" request parameter 
	*/		
	function emailProfile(obj) {	
		var loc		= unescape(location.href);
		var begin	= "";
		var end		= "";
		var args	= "";
		var arargs	= ["&mdc_uid=", "&mdc_sid="]; //args to be removed from url		
		for(i=0; i< arargs.length; i++){
			if (loc.indexOf(arargs[i])>0){
				begin 		= loc.substring(0,loc.indexOf(arargs[i]));
				end			= (loc.substring(loc.indexOf(arargs[i]),loc.length));
				args		= end.split("&");
				end			= end.substring(args[1].length+1, end.length);
				loc			= begin + end;
			}
		}
		obj.href = "/xp/Martindale/Lawyer_Locator/Search_Lawyer_Locator/send_listing.xml?url=" + escape(loc);		
		// alert("obj.href: " +obj.href);		
		return true;
	} //-- function emailProfile(obj)

	/**
	* sets the incoming object's href to the current location href
	* adds "css" parameter to the query string in order to open the page 
	* using "printer-friendly" styles
	*
	*/		
	function printProfile(obj) {
		// do NOT use escape here, it will not work
		// obj.href = escape(location.href+"&css=print_styles.css");		
		obj.href = location.href+"&css=print_styles.css";
		// alert("obj.href: " +obj.href);		
		return true;
	} //-- function printProfile(obj)
	
	
	// ===============================================================================================================
	// ARCHIVED FUNCTIONS
	// ===============================================================================================================
		
	/**
	* obtains the request parameters passed to the current page 
	* sets the incoming object's href to send_listing.xml
	* plus the URL encoded query string
	*
	* example... http://renpwwwmhdev09.reedref.com/xp/Martindale/Lawyer_Locator/Search_Lawyer_Locator/send_listing.xml?url=a%3DFB2D5E8FBFF42760%26bcId%3D1042%26STYPE%3DN
	*/		
	function locationInfo() {	
		// Specifies the host and domain name or IP address, of a network host.
		document.write("location.host:" +location.host);
		document.write("<br/>");
		//Specifies the host:port portion of the URL. 	 
		document.write("location.hostname:" +location.hostname);
		document.write("<br/>");
		// Specifies the entire URL. 	 
		document.write("location.href:"+location.href);
		document.write("<br/>");
		// Specifies the URL-path portion of the URL. 	 
		document.write("location.pathname:" +location.pathname);
		document.write("<br/>");
		// Specifies the communications port that the server uses. 	 
		document.write("location.port:"+location.port);
		document.write("<br/>");
		// Specifies the beginning of the URL, including the colon
		document.write("location.protocol:"+location.protocol);
		document.write("<br/>");
		// Specifies a query
		document.write("location.search:"+location.search);
		document.write("<br/>");
	} //-- function locationInfo()
	
	/**
	* obtains the request parameters passed to the current page 
	* and sets the incoming object's href to the given resource 
	* plus URL encoded query string
	*
	* Used to open "send_listing" page
	* example... http://renpwwwmhdev09.reedref.com/xp/Martindale/Lawyer_Locator/Search_Lawyer_Locator/send_listing.xml?url=a%3DFB2D5E8FBFF42760%26bcId%3D1042%26STYPE%3DN
	*/		
	function changeLink(obj, resource){
		var args = location.search.substr(1).split("?");

		// alert("args array contains " +args.length +" items");
		var i = 0;		
		for (i;i<args.length;i++) {
			// alert(i +": " +args[i]);		
		}
						
		//get arguments
		var argstr = args[0]; 	

		// url encoded parameters	
		obj.href = resource +"?url=" + escape(argstr);   
		return false;
	} //-- function changeLink(obj, resource)
	
	/**
	* Parses the query string removing pos & cnt parameters 
	* Sets the incoming object's href to the resulting query string
	* This method could be useful if we ever need to CHANGE parmater values 
	*
	* @author: 	Andrew Bergamasco
	* @version:	1.00
	*/			
	function parseQueryString(obj) {	

		if (location.search){
			var vals=location.search.substr(1).split("&");	
			var queryStr ="";
			var Q = "?";
			var AMP = "&";	

			for (var i in vals) {
				vals[i] = vals[i].replace(/\+/g, " ").split("=");
				vals[i][0] = vals[i][0];
				vals[i][1] = vals[i][1];
		
				document.write(vals[i][0]+"="+vals[i][1]);								
				document.write("<br />");			
					
				if (vals[i][0]!="pos" && vals[i][0]!="cnt"){
					if (i==0) {
						// first parameter gets question mark
						queryStr=Q+vals[i][0]+"="+vals[i][1];			
					} else {
						// subsequent parameters get ampersand
						queryStr=queryStr+AMP+vals[i][0]+"="+vals[i][1];
					}			
				} //-- if (vals[i][0]!="pos" && vals[i][0]!="cnt")
				
			} //-- for (var i in vals)
			document.write("queryStr:" +queryStr);	
			
		} //-- if (location.search)
	} //-- 	function parseQueryString(obj) 
	var newwin;
			
	function launchwin(winurl,winname,winfeatures)
	{
		if (winname == null) {
			winname = 'group_detail';
		}
		if (winfeatures == null) {
			winfeatures = 'height=500,width=500,resizable=yes,scrollbars=yes,toolbar=yes';
		}
		//This launches a new window and then
		//focuses it if window.focus() is supported.
		newwin = window.open(winurl,winname,winfeatures);
	}
	
	function onclick_event()
	{
	         window.close();
	}
				
//-- web_search.js