/*
Faslodex additional JS functions

*/
function addMasterScript(){
	//this adds in the master root.js file which includes all basic JS functionality
	//this must be included in all local js files 
	//Do not copy code from the root.js file, use this function to import it instead
	if(document.getElementById){
		//browser supports getElementById - attempt to add js functionality
		//this is a site-specific js file so include the master
		//create a script element
		if(document.createElement){
			elRootScript=document.createElement('script');		
			if(elRootScript){
				//include master file
				elRootScript.src='/_mshost81109/system/styles/root/javascript/root.js';
				//elRootScript.src='../styles/root/javascript/root.js';
				elRootScript.type='text/javascript';
				//get a handle to this script file
				elHead=document.getElementsByTagName('head');
				if(elHead){
					//get script
					elExistingScript=document.getElementsByTagName('script');
					if(elExistingScript){
						//add into head before previous element
						elHead[0].insertBefore(elRootScript,elExistingScript[0]);
						//attachEvents function is called when the master file loads 
						//so global functionality is still enabled
					}
				}
				elScript=document.createElement('script');
				//elScript.src='../styles/root/javascript/sortby.js';
				elScript.src='/_mshost81109/system/styles/root/javascript/sortby.js';
				elScript.type='text/javascript';
				if(elHead){
					//get script
					elExistingScript=document.getElementsByTagName('script');
					if(elExistingScript){
						//add into head before previous element
						elHead[0].insertBefore(elScript,elExistingScript[0]);
					}
				}
			}
		}
	}
}	

//call the above function
addMasterScript();

function firePageFilter() { 
	//fire the location search on submission of the form
	var form_id_test=new Array;
		if (document.getElementById('sortbypanel').getElementsByTagName('form')) {
		form_id_test=document.getElementById('sortbypanel').getElementsByTagName('form');
		}
	//Select submitted form if more than one sortby form on page
	if (form_id_test.length > 0) {
	 	for (var i = 0; i < form_id_test.length; i++) {
			//sort by form submitted so attach event
				form_id_test[i].onsubmit = function () {	
				return pageFilter(this);
			}	
		}
	}
}

var toCall=new Array;	
toCall[0]=firePageFilter;	