var config = {
	az			: 'all',
	type		: 'doctors',
	center		: '',
	program		: '', 
	location	: '', 
	language	: '', 
	gender 		: '',	
	jsonQuery : {
		center		: '',
		program		: '', 
		location	: '', 
		language	: '', 
		gender 		: '',
		term		: ''
	},	
	links		: 7,
	query		: '',
	numPerPage 	: 50,
	href		: '/assets/processing/physicianSearch/resultsList.ashx?json=',
	byIdHref	: '/assets/processing/physicianSearch/physicianById.ashx?json=',
	search		: 'doctors'
};

var mySearch;

dojo.addOnLoad(function(){
	mySearch = new com.mgh.PhysicianSearch(config);
	registerEvents ();
});

/********************************** Search *****************************************/	
	//listeners waiting for data to be ready
	searchDataReady = function(response){
		mySearch.xmlDoc = mySearch.loadXmlString(response);
		mySearch.handleXml();
		mySearch.defaultView();
		//this function hides the timer animation and shows both the categories and results columns
		hideTimer();
	}

	viewAll = function() {
	    dojo.byId('showDescriptions').innerHTML = 'Hide Descriptions';	
		mySearch.defaultView();
	}

	refreshView = function(num) {
	    dojo.byId('showDescriptions').innerHTML = 'Hide Descriptions';	
		mySearch.refreshView(num);
	}

	letterView = function(num) {
	    dojo.byId('showDescriptions').innerHTML = 'Hide Descriptions';
		mySearch.letterView(num);	
	}

	gotoPage = function(num) {
	    dojo.byId('showDescriptions').innerHTML = 'Hide Descriptions';
		mySearch.gotoPage(num);
	}

	nextPage = function() {
	    dojo.byId('showDescriptions').innerHTML = 'Hide Descriptions';		
		mySearch.nextPage();
	}

	previousPage = function() {
	    dojo.byId('showDescriptions').innerHTML = 'Hide Descriptions';			
		mySearch.previousPage();
	}
	
	scrollToResults = function (){
		//window.scroll(0,200);
	}

/********************************** key word *****************************************/
	showDescriptions = function() {
	    var text = dojo.byId('showDescriptions').innerHTML == 'Show Descriptions'
                        ? 'Hide Descriptions' : 'Show Descriptions';
	    dojo.byId('showDescriptions').innerHTML = text;	
	    mySearch.toggleDescriptions();

	    //dojo.byId('keyWord').value = '';
	}
		
	registerEvents = function () {
		dojo.connect(dojo.byId('showDescriptions'),'onclick',function(){
			showDescriptions();
		});
	}		
	
/********************************** Special String function *****************************************/	
	formatString = function(string) {   
		var args = arguments;   
		var pattern = new RegExp("%([1-" + arguments.length + "])", "g");   
		return String(string).replace(pattern, function(match, index) {   
			return args[index];   
		});   
	}	
