// Template Object - Easy to use.
var _Template = {
   myProfessionRow : function(d) {
      return '<li id="myProfession_'+d.id+'">\
                  <table class="rowTable">\
                     <tr>\
                        <td class="professionTitleCol">'+d.profession_title+'</td>\
                        <td class="startDateCol"><select name="startYear_'+d.id+'">'+this.yearDropDown()+'</select></td>\
                        <td class="untilCol"> until </td>\
                        <td class="endDateCol"><select name="endYear_'+d.id+'">'+this.yearDropDown()+'</select></td>\
                        <td class="removeCol"><a class="removeProfession"><img src="http://admin.inspiredrealty.ca/static/images/icon_delete.png" /></a></td>\
                     </tr>\
                  </table>\
               </li>';
   },
	findProfessionRow : function(d) {
      return '<li id="myProfession_'+d.rowId+'">\
                  <table class="rowTable">\
                     <tr>\
                        <td class="professionTitleCol">'+d.profession_title+'<input type="hidden" name="profession_'+d.rowId+'" value="'+d.id+'" /></td>\
								<td class="wageCol"><input type="text" class="wageInput" name="wage_'+d.rowId+'" /><sub>/hour</sub></td>\
								<td class="unionCol"><select name="union_'+d.rowId+'">'+d.unionList+'</select></td>\
                        <td class="startDateCol"><input type="text" class="dateInput" name="startDate_'+d.rowId+'" /></td>\
                        <td class="untilCol"> - </td>\
                        <td class="endDateCol"><input type="text" class="dateInput" name="endDate_'+d.rowId+'" /></td>\
                        <td class="removeCol"><a class="removeProfession"><img src="http://admin.inspiredrealty.ca/static/images/icon_delete.png" /></a></td>\
                     </tr>\
                  </table>\
               </li>';
   },
	yearDropDown : function() {
		var minus = 40
		var date = new Date();
      var html = '';
		var cur = date.getFullYear();
		
		for(var mindate = cur-minus; mindate < cur; cur--) {
			html += '<option value="'+cur+'">'+cur+'</option>'; 
		}
		return html;
	}
};

// Some Handy Functions
function isDefined(v,u) {
   return (v === u) ? false : true;	
}
