/* -------------------------------------------
		Paramter Object
------------------------------------------- */
function Parameter()
{
    // variables
    var parameters 		= new Object;

	// functions
	this.addParameter 	= addParameter;
	this.getParameter 	= getParameter;
	this.getKeys 		= getKeys;

	// return the parameter for looping of the keys
    	function getKeys() {
		return parameters;
 	}

	// add the parameter
    	function addParameter(key, value) {
		if(!parameters[key])
			parameters[key] = new Array();

    	parameters[key].push(value);
 	}

	// get the parameter
	function getParameter(key, separator) {
		if(!parameters[key])
			return;
    	
		return parameters[key].join(separator);
	}
}


/* -------------------------------------------
			MetaDataManager
------------------------------------------- */
function MetaDataManager()
{
	var m = new Parameter();
	this.addParameter = m.addParameter;
	this.getParameter = m.getParameter;
	this.getKeys = m.getKeys;
	
	this.getPageType = getPageType;
	this.getPageTitle = getPageTitle;
	this.getSite = getSite;
	this.getSctnId = getSctnId;
	this.getSctnName = getSctnName;
	this.getSponsorship = getSponsorship;
	this.getAbstract = getAbstract;
	this.getKeywords = getKeywords;
	this.getClassification = getClassification;
	this.getSctnDspName = getSctnDspName;
	this.getCategoryDspName = getCategoryDspName;
	this.getShowAbbr = getShowAbbr;
	this.getChefName = getChefName;
	this.getMealPart = getMealPart;
	this.getCusine = getCusine;
	this.getOccasion = getOccasion;
	this.getSpecialInterest = getSpecialInterest;
	this.getMainIngredient = getMainIngredient;
	this.getSeason = getSeason;
	this.getTechnique = getTechnique;
	this.getVodType = getVodType;
	this.getRole = getRole;
	this.getMultimediaFlag = getMultimediaFlag;
	this.setMultimediaFlag = setMultimediaFlag;
	this.getDetailId = getDetailId;
	this.getSearchTerm = getSearchTerm;
	this.getPageNumber = getPageNumber;
	this.getUniqueId = getUniqueId;
	this.getUserId = getUserId;
	this.getUserIdEmail = getUserIdEmail;
	this.getUserIdCreateDt = getUserIdCreateDt;
	this.getUserIdVersion = getUserIdVersion;
	
	function getPageType ( ) {
		var type =  this.getParameter( "Type"," ");
		if ( type == null ) {
			type = "";
		}
		return type;
	}
	
	function getPageTitle ( ) {
		var title =  this.getParameter( "Title"," ");
		if ( title == null ) {
			title = "" ;
		}
		return title;
	}
	
	function getSite ( ) {
		var site = this.getParameter("Site"," ");
		if ( site == null ) {
			site = "" ;
		}
		return site;
	}
	
	function getSctnId ( ) {
		var sctnId = this.getParameter("SctnId"," ");
		if ( sctnId == null ) {
			sctnId = 0;
		}
		return sctnId;
	}
	
	function getSctnName ( ) {
		var sctnName = this.getParameter("SctnName"," ");
		if ( sctnName == null ) {
			sctnName = "";
		}
		return sctnName;
	}
	
	function getSponsorship ( ) {
		var sponsor = this.getParameter("Sponsorship"," ");
		if ( sponsor == null ) {
			sponsor = "";
		}
		return sponsor;
	}
	
	function getAbstract ( ) {
		var abst = this.getParameter("Abstract"," ");
		if ( abst == null ) {
			abst = "";
		}
		return abst;
	}
	
	function getKeywords ( ) {
		var keywords = this.getParameter("Keywords"," ");
		if ( keywords == null ) {
			keywords = "";
		}
		return keywords;
	}
	
	function getClassification ( ) {
		var classification = this.getParameter("Classification"," ");
		if ( classification == null ) {
			classification = "";
		}
		return classification;
	}
	
	function getSctnDspName ( ) {
		var sctnDspName = this.getParameter("SctnDspName"," ");
		if ( sctnDspName == null ) { 
			sctnDspName = "";
		}
		return sctnDspName;
	}
	
	function getCategoryDspName ( ) {
		var categoryDspName = this.getParameter("CategoryDspName"," ");
		if ( categoryDspName == null ) {
			categoryDspName = "";
		}
		return categoryDspName;
	}
	
	function getShowAbbr ( ) {
		var showAbbr = this.getParameter("Show_Abbr"," ");
		if ( showAbbr == null ) {
			showAbbr = "";
		}
		return showAbbr;
	}
	
	function getMultimediaFlag ( ) {
		var flag = this.getParameter("MultimediaFlag"," ");
		if ( flag == null ) { 
			flag = "";
		}
		return flag;
	}
	function setMultimediaFlag ( flag ) {
		if ( flag != null ) {
			this.addParameter("MultimediaFlag",flag);
		} else {
			this.addParameter("MultimediaFlag","");
		}
	}
	
	function  getChefName ( ) {
		var chefName = this.getParameter("ChefName", " ");
		if ( chefName == null ) {
			chefName = "";
		}
		return chefName;
	}
	
	function getMealPart ( ) {
		var mealPart = this.getParameter("MealPart", " ");
		if ( mealPart == null ) {
			mealPart = "";
		}
		return mealPart;
	}
	
	function getCusine ( ) {
		var cusine = this.getParameter("Cusine", " ");
		if ( cusine == null ) {
			cusine = "";
		}
		return cusine;
	}
	
	function getOccasion ( ) {
		var occasion = this.getParameter("Occasion", " ");
		if ( occasion == null ) {
			occasion = "";
		}
		return occasion;
	}
	
	function getSpecialInterest ( ) {
		var special = this.getParameter("SpecialInterest"," ");
		if ( special == null ) {
			special = "";
		}
		return special;
	}
	
	function getMainIngredient ( ) {
		var mainIngredient = this.getParameter("MainIngredient"," ");
		if ( mainIngredient == null ) {
			mainIngredient = "";
		}
		return mainIngredient;
	}
	
	function getSeason ( ) {
		var season = this.getParameter("Season", " ");
		if ( season == null ) {
			season = "";
		}
		return season;
	}
	
	function getTechnique ( ) {
		var technique = this.getParameter( "Season", " ");
		if ( technique == null ) {
			technique = "";
		}
		return technique;
	}
	
	function getVodType ( ) {
		var vtype = this.getParameter("VodType"," ");
		if ( vtype == null ) {
			vtype = "";
		}
		return vtype;
	}
	
	function getRole ( ) {
		var vrole = this.getParameter("Role"," ");
		if ( vrole == null ) {
			vrole = "";
		}
		return vrole;
	}
	
	function getDetailId ( ) {
		var vdid = this.getParameter("DetailId"," ");
		if ( vdid == null ) {
			vdid = "";
		}
		return vdid;
	}
	
	function getPageNumber ( ) {
		var vpn = this.getParameter("PageNumber"," ");
		if ( vpn == null ) {
			vpn = "";
		}
		return vpn;
	}
	
	function getUniqueId ( ) {
		var vpn = this.getParameter("UniqueId"," ");
		if ( vpn == null ) {
			vpn = "";
		}
		return vpn;
	}
	
	function getUserId ( ) {
		var uId = this.getParameter("UserId"," ");
		if ( uId == null ) {
			uId = "";
		}
		return uId;
	}
	
	function getUserIdEmail ( ) {
		var eId = this.getParameter("UserIdEmail"," ");
		if ( eId == null ) {
			eId = "";
		}
		return eId;
	}
	
	function getUserIdCreateDt ( ) {
		var uCdt = this.getParameter("UserIdCreateDt"," ");
		if ( uCdt == null ) {
			uCdt = "";
		}
		return uCdt;
	}
	
	function getUserIdVersion ( ) {
		var uVer = this.getParameter("UserIdVersion"," ");
		if ( uVer == null ) {
			uVer = "";
		}
		return uVer;
	}
	
	function getSearchTerm ( ) {
		var args = parseQueryString ();
		for (var arg in args) {
			var s = arg.toUpperCase();
			if ( s == 'SEARCHSTRING' ){
				return args[arg];
			}
		}
		return "";
	}
	
	function parseQueryString (str) {
	  str = str ? str : document.location.search;
	  var query = str.charAt(0) == '?' ? str.substring(1) : str;
	  var args = new Object();
	  if (query) {
	    var fields = query.split('&');
	    for (var f = 0; f < fields.length; f++) {
	      var field = fields[f].split('=');
	      args[unescape(field[0].replace(/\+/g, ' '))] = 
			unescape(field[1].replace(/\+/g, ' '));
	    }
	  }
	  return args;
	}

}



//==ENDECA Functions Begin ===============================================================
	
// mdManager.getFilters() function. would extend existing metadata manager library.
// it can be stored in a separate file that is only referenced by the search results pages.  
// our code won't use it, but it may be good to add for consistency since
// metadataManager library in general has get functions defined for the other parameter values
function getFilters ( ) {
	var keywords = this.getParameter("Filters"," ");
	if (filters == null ) {
		filters = "";
	}
	return filters;
}

//==ENDECA Functions End ===============================================================
