/*** switchbox.js ***/
/////////
// :NOTE:
// requires prototype.js
/////////
function TransferOptions(select1, select2) {
  // transfer selected options
  var options = $A($(select1).getElementsByTagName('option'));
  options.each(function(option) {
    if (option.selected == true) {
      AddOption(select2, option.value, option.text);
      Element.remove(option);
    }
  });
  
  // resort select list
  SortSelect(select2);
  
}
function AddOption(id, value, text) {
  var option = document.createElement('option');
  option.setAttribute('value', value);
  option.appendChild(document.createTextNode(text));
  $(id).appendChild(option);
}
function SortSelect(id) {
  var options = $A($(id).getElementsByTagName('option'));
  var sorted  = new Array();
  if (options.length > 0) {
    // sort
    sorted = options.sortBy(function(option) {
      return option.text;
    });
    
    // remove unsorted
    options.each(function(option) {
      Element.remove(option);
    });
    
    // add sorted
    sorted.each(function(option) {
      AddOption(id, option.value, option.text);
    });
  }
}
function SelectAllOptions(id) {
  if ($(id)) {
    var options = $A($(id).getElementsByTagName('option'));
    options.each(function(option) {
      option.selected = true;
    });
  }
}
function PostSwitchboxes(id) {
  // find all switchboxes
  var elements = $(id).getElementsByClassName('switchbox');
  $A(elements).each(function(e) {
    if (e.id.indexOf('selected_') == 0) {
      // select options so they are posted
      SelectAllOptions(e.id)
    }
  });
}


/*** date_select.js ***/
function CheckDateFormat(e) {
  var d = parseDate(e.value);
  if(d == null) {
    // clear value
    e.value = '';
  } else{
    e.value = formatDate(d, 'MM/dd/yyyy');
  }
}

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================


function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false,use_css=false,use_layers=false;if(document.getElementById){use_gebi=true;}
else if(document.all){use_css=true;}
else if(document.layers){use_layers=true;}
if(use_gebi&&document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}
else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}
else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}
else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}
if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}
x=document.anchors[i].x;y=document.anchors[i].y;}
else{coordinates.x=0;coordinates.y=0;return coordinates;}
coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}
else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}
else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}
else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}
coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent)!=null){ol+=el.offsetLeft;}
return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent)!=null){ot+=el.offsetTop;}
return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}
return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0||d2==0){return-1;}
else if(d1>d2){return 1;}
return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length<4){y=""+(y-0+1900);}
value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}
else if(H>12){value["h"]=H-12;}
else{value["h"]=H;}
value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}
value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H>11){value["a"]="PM";}
else{value["a"]="AM";}
value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format<format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c)&&(i_format<format.length)){token+=format.charAt(i_format++);}
if(value[token]!=null){result=result+value[token];}
else{result=result+token;}}
return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i<val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}
return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length<minlength){return null;}
if(_isInteger(token)){return token;}}
return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format<format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c)&&(i_format<format.length)){token+=format.charAt(i_format++);}
if(token=="yyyy"||token=="yy"||token=="y"){if(token=="yyyy"){x=4;y=4;}
if(token=="yy"){x=2;y=2;}
if(token=="y"){x=2;y=4;}
year=_getInt(val,i_val,x,y);if(year==null){return 0;}
i_val+=year.length;if(year.length==2){if(year>70){year=1900+(year-0);}
else{year=2000+(year-0);}}}
else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month-=12;}
i_val+=month_name.length;break;}}}
if((month<1)||(month>12)){return 0;}}
else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val+=day_name.length;break;}}}
else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}
i_val+=month.length;}
else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}
i_val+=date.length;}
else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}
i_val+=hh.length;}
else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}
i_val+=hh.length;}
else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}
i_val+=hh.length;}
else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}
i_val+=hh.length;hh--;}
else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}
i_val+=mm.length;}
else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}
i_val+=ss.length;}
else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}
else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}
else{return 0;}
i_val+=2;}
else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}
else{i_val+=token.length;}}}
if(i_val!=val.length){return 0;}
if(month==2){if(((year%4==0)&&(year%100!=0))||(year%400==0)){if(date>29){return 0;}}
else{if(date>28){return 0;}}}
if((month==4)||(month==6)||(month==9)||(month==11)){if(date>30){return 0;}}
if(hh<12&&ampm=="PM"){hh=hh-0+12;}
else if(hh>11&&ampm=="AM"){hh-=12;}
var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst=new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}
return null;}
function PopupWindow_getXYPosition(anchorname){var coordinates;if(this.type=="WINDOW"){coordinates=getAnchorWindowPosition(anchorname);}
else{coordinates=getAnchorPosition(anchorname);}
this.x=coordinates.x;this.y=coordinates.y;}
function PopupWindow_setSize(width,height){this.width=width;this.height=height;}
function PopupWindow_populate(contents){this.contents=contents;this.populated=false;}
function PopupWindow_setUrl(url){this.url=url;}
function PopupWindow_setWindowProperties(props){this.windowProperties=props;}
function PopupWindow_refresh(){if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).innerHTML=this.contents;}
else if(this.use_css){document.all[this.divName].innerHTML=this.contents;}
else if(this.use_layers){var d=document.layers[this.divName];d.document.open();d.document.writeln(this.contents);d.document.close();}}
else{if(this.popupWindow!=null&&!this.popupWindow.closed){if(this.url!=""){this.popupWindow.location.href=this.url;}
else{this.popupWindow.document.open();this.popupWindow.document.writeln(this.contents);this.popupWindow.document.close();}
this.popupWindow.focus();}}}
function PopupWindow_showPopup(anchorname){this.getXYPosition(anchorname);this.x+=this.offsetX;this.y+=this.offsetY;if(!this.populated&&(this.contents!="")){this.populated=true;this.refresh();}
if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).style.left=this.x+"px";document.getElementById(this.divName).style.top=this.y+"px";document.getElementById(this.divName).style.visibility="visible";}
else if(this.use_css){document.all[this.divName].style.left=this.x;document.all[this.divName].style.top=this.y;document.all[this.divName].style.visibility="visible";}
else if(this.use_layers){document.layers[this.divName].left=this.x;document.layers[this.divName].top=this.y;document.layers[this.divName].visibility="visible";}}
else{if(this.popupWindow==null||this.popupWindow.closed){if(this.x<0){this.x=0;}
if(this.y<0){this.y=0;}
if(screen&&screen.availHeight){if((this.y+this.height)>screen.availHeight){this.y=screen.availHeight-this.height;}}
if(screen&&screen.availWidth){if((this.x+this.width)>screen.availWidth){this.x=screen.availWidth-this.width;}}
var avoidAboutBlank=window.opera||(document.layers&&!navigator.mimeTypes['*'])||navigator.vendor=='KDE'||(document.childNodes&&!document.all&&!navigator.taintEnabled);this.popupWindow=window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");}
this.refresh();}}
function PopupWindow_hidePopup(){if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).style.visibility="hidden";}
else if(this.use_css){document.all[this.divName].style.visibility="hidden";}
else if(this.use_layers){document.layers[this.divName].visibility="hidden";}}
else{if(this.popupWindow&&!this.popupWindow.closed){this.popupWindow.close();this.popupWindow=null;}}}
function PopupWindow_isClicked(e){if(this.divName!=null){if(this.use_layers){var clickX=e.pageX;var clickY=e.pageY;var t=document.layers[this.divName];if((clickX>t.left)&&(clickX<t.left+t.clip.width)&&(clickY>t.top)&&(clickY<t.top+t.clip.height)){return true;}
else{return false;}}
else if(document.all){var t=window.event.srcElement;while(t.parentElement!=null){if(t.id==this.divName){return true;}
t=t.parentElement;}
return false;}
else if(this.use_gebi&&e){var t=e.originalTarget;try{while(t.parentNode!=null){if(t.id==this.divName){return true;}
	t=t.parentNode;}}catch(err){}
return false;}
return false;}
return false;}
function PopupWindow_hideIfNotClicked(e){if(this.autoHideEnabled&&!this.isClicked(e)){this.hidePopup();}}
function PopupWindow_autoHide(){this.autoHideEnabled=true;}
function PopupWindow_hidePopupWindows(e){for(var i=0;i<popupWindowObjects.length;i++){if(popupWindowObjects[i]!=null){var p=popupWindowObjects[i];p.hideIfNotClicked(e);}}}
function PopupWindow_attachListener(){if(document.layers){document.captureEvents(Event.MOUSEUP);}
window.popupWindowOldEventListener=document.onmouseup;if(window.popupWindowOldEventListener!=null){document.onmouseup=new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");}
else{document.onmouseup=PopupWindow_hidePopupWindows;}}
function PopupWindow(){if(!window.popupWindowIndex){window.popupWindowIndex=0;}
if(!window.popupWindowObjects){window.popupWindowObjects=new Array();}
if(!window.listenerAttached){window.listenerAttached=true;PopupWindow_attachListener();}
this.index=popupWindowIndex++;popupWindowObjects[this.index]=this;this.divName=null;this.popupWindow=null;this.width=0;this.height=0;this.populated=false;this.visible=false;this.autoHideEnabled=false;this.contents="";this.url="";this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";if(arguments.length>0){this.type="DIV";this.divName=arguments[0];}
else{this.type="WINDOW";}
this.use_gebi=false;this.use_css=false;this.use_layers=false;if(document.getElementById){this.use_gebi=true;}
else if(document.all){this.use_css=true;}
else if(document.layers){this.use_layers=true;}
else{this.type="WINDOW";}
this.offsetX=0;this.offsetY=0;this.getXYPosition=PopupWindow_getXYPosition;this.populate=PopupWindow_populate;this.setUrl=PopupWindow_setUrl;this.setWindowProperties=PopupWindow_setWindowProperties;this.refresh=PopupWindow_refresh;this.showPopup=PopupWindow_showPopup;this.hidePopup=PopupWindow_hidePopup;this.setSize=PopupWindow_setSize;this.isClicked=PopupWindow_isClicked;this.autoHide=PopupWindow_autoHide;this.hideIfNotClicked=PopupWindow_hideIfNotClicked;}
function CalendarPopup(){var c;if(arguments.length>0){c=new PopupWindow(arguments[0]);}
else{c=new PopupWindow();c.setSize(150,175);}
c.offsetX=-152;c.offsetY=25;c.autoHide();c.monthNames=new Array("January","February","March","April","May","June","July","August","September","October","November","December");c.monthAbbreviations=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");c.dayHeaders=new Array("S","M","T","W","T","F","S");c.returnFunction="CP_tmpReturnFunction";c.returnMonthFunction="CP_tmpReturnMonthFunction";c.returnQuarterFunction="CP_tmpReturnQuarterFunction";c.returnYearFunction="CP_tmpReturnYearFunction";c.weekStartDay=0;c.isShowYearNavigation=false;c.displayType="date";c.disabledWeekDays=new Object();c.disabledDatesExpression="";c.yearSelectStartOffset=2;c.currentDate=null;c.todayText="Today";c.cssPrefix="";c.isShowNavigationDropdowns=false;c.isShowYearNavigationInput=false;window.CP_calendarObject=null;window.CP_targetInput=null;window.CP_dateFormat="MM/dd/yyyy";c.copyMonthNamesToWindow=CP_copyMonthNamesToWindow;c.setReturnFunction=CP_setReturnFunction;c.setReturnMonthFunction=CP_setReturnMonthFunction;c.setReturnQuarterFunction=CP_setReturnQuarterFunction;c.setReturnYearFunction=CP_setReturnYearFunction;c.setMonthNames=CP_setMonthNames;c.setMonthAbbreviations=CP_setMonthAbbreviations;c.setDayHeaders=CP_setDayHeaders;c.setWeekStartDay=CP_setWeekStartDay;c.setDisplayType=CP_setDisplayType;c.setDisabledWeekDays=CP_setDisabledWeekDays;c.addDisabledDates=CP_addDisabledDates;c.setYearSelectStartOffset=CP_setYearSelectStartOffset;c.setTodayText=CP_setTodayText;c.showYearNavigation=CP_showYearNavigation;c.showCalendar=CP_showCalendar;c.hideCalendar=CP_hideCalendar;c.getStyles=getCalendarStyles;c.refreshCalendar=CP_refreshCalendar;c.getCalendar=CP_getCalendar;c.select=CP_select;c.setCssPrefix=CP_setCssPrefix;c.showNavigationDropdowns=CP_showNavigationDropdowns;c.showYearNavigationInput=CP_showYearNavigationInput;c.copyMonthNamesToWindow();return c;}
function CP_copyMonthNamesToWindow(){if(typeof(window.MONTH_NAMES)!="undefined"&&window.MONTH_NAMES!=null){window.MONTH_NAMES=new Array();for(var i=0;i<this.monthNames.length;i++){window.MONTH_NAMES[window.MONTH_NAMES.length]=this.monthNames[i];}
for(var i=0;i<this.monthAbbreviations.length;i++){window.MONTH_NAMES[window.MONTH_NAMES.length]=this.monthAbbreviations[i];}}}
function CP_tmpReturnFunction(y,m,d){if(window.CP_targetInput!=null){var dt=new Date(y,m-1,d,0,0,0);if(window.CP_calendarObject!=null){window.CP_calendarObject.copyMonthNamesToWindow();}
window.CP_targetInput.value=formatDate(dt,window.CP_dateFormat);}
else{alert('Use setReturnFunction() to define which function will get the clicked results!');}}
function CP_tmpReturnMonthFunction(y,m){alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m);}
function CP_tmpReturnQuarterFunction(y,q){alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q);}
function CP_tmpReturnYearFunction(y){alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y);}
function CP_setReturnFunction(name){this.returnFunction=name;}
function CP_setReturnMonthFunction(name){this.returnMonthFunction=name;}
function CP_setReturnQuarterFunction(name){this.returnQuarterFunction=name;}
function CP_setReturnYearFunction(name){this.returnYearFunction=name;}
function CP_setMonthNames(){for(var i=0;i<arguments.length;i++){this.monthNames[i]=arguments[i];}
this.copyMonthNamesToWindow();}
function CP_setMonthAbbreviations(){for(var i=0;i<arguments.length;i++){this.monthAbbreviations[i]=arguments[i];}
this.copyMonthNamesToWindow();}
function CP_setDayHeaders(){for(var i=0;i<arguments.length;i++){this.dayHeaders[i]=arguments[i];}}
function CP_setWeekStartDay(day){this.weekStartDay=day;}
function CP_showYearNavigation(){this.isShowYearNavigation=(arguments.length>0)?arguments[0]:true;}
function CP_setDisplayType(type){if(type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year"){alert("Invalid display type! Must be one of: date,week-end,month,quarter,year");return false;}
this.displayType=type;}
function CP_setYearSelectStartOffset(num){this.yearSelectStartOffset=num;}
function CP_setDisabledWeekDays(){this.disabledWeekDays=new Object();for(var i=0;i<arguments.length;i++){this.disabledWeekDays[arguments[i]]=true;}}
function CP_addDisabledDates(start,end){if(arguments.length==1){end=start;}
if(start==null&&end==null){return;}
if(this.disabledDatesExpression!=""){this.disabledDatesExpression+="||";}
if(start!=null){start=parseDate(start);start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}
if(end!=null){end=parseDate(end);end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}
if(start==null){this.disabledDatesExpression+="(ds<="+end+")";}
else if(end==null){this.disabledDatesExpression+="(ds>="+start+")";}
else{this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")";}}
function CP_setTodayText(text){this.todayText=text;}
function CP_setCssPrefix(val){this.cssPrefix=val;}
function CP_showNavigationDropdowns(){this.isShowNavigationDropdowns=(arguments.length>0)?arguments[0]:true;}
function CP_showYearNavigationInput(){this.isShowYearNavigationInput=(arguments.length>0)?arguments[0]:true;}
function CP_hideCalendar(){if(arguments.length>0){window.popupWindowObjects[arguments[0]].hidePopup();}
else{this.hidePopup();}}
function CP_refreshCalendar(index){var calObject=window.popupWindowObjects[index];if(arguments.length>1){calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));}
else{calObject.populate(calObject.getCalendar());}
calObject.refresh();}
function CP_showCalendar(anchorname){if(arguments.length>1){if(arguments[1]==null||arguments[1]==""){this.currentDate=new Date();}
else{this.currentDate=new Date(parseDate(arguments[1]));}}
this.populate(this.getCalendar());this.showPopup(anchorname);}
function CP_select(inputobj,linkname,format){var selectedDate=(arguments.length>3)?arguments[3]:null;if(!window.getDateFromFormat){alert("calendar.select: To use this method you must also include 'date.js' for date formatting");return;}
if(this.displayType!="date"&&this.displayType!="week-end"){alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");return;}
if(inputobj.type!="text"&&inputobj.type!="hidden"&&inputobj.type!="textarea"){alert("calendar.select: Input object passed is not a valid form input object");window.CP_targetInput=null;return;}
if(inputobj.disabled){return;}
window.CP_targetInput=inputobj;window.CP_calendarObject=this;this.currentDate=null;var time=0;if(selectedDate!=null){time=getDateFromFormat(selectedDate,format)}
else if(inputobj.value!=""){time=getDateFromFormat(inputobj.value,format);}
if(selectedDate!=null||inputobj.value!=""){if(time==0){this.currentDate=null;}
else{this.currentDate=new Date(time);}}
window.CP_dateFormat=format;this.showCalendar(linkname);}
function getCalendarStyles(){var result="";var p="";if(this!=null&&typeof(this.cssPrefix)!="undefined"&&this.cssPrefix!=null&&this.cssPrefix!=""){p=this.cssPrefix;}
result+="<STYLE>\n";result+="."+p+"cpYearNavigation,."+p+"cpMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold; }\n";result+="."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n";result+="TD."+p+"cpDayColumnHeader { text-align:right; border:solid thin #C0C0C0;border-width:0px 0px 1px 0px; }\n";result+="."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate  { text-align:right; text-decoration:none; }\n";result+="."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n";result+="."+p+"cpCurrentMonthDate, .cpCurrentDate { color:#000000; }\n";result+="."+p+"cpOtherMonthDate { color:#808080; }\n";result+="TD."+p+"cpCurrentDate { color:white; background-color: #C0C0C0; border-width:1px; border:solid thin #800000; }\n";result+="TD."+p+"cpCurrentDateDisabled { border-width:1px; border:solid thin #FFAAAA; }\n";result+="TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled { border:solid thin #C0C0C0; border-width:1px 0px 0px 0px;}\n";result+="A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled { height:20px; }\n";result+="A."+p+"cpTodayText { color:black; }\n";result+="."+p+"cpTodayTextDisabled { color:#D0D0D0; }\n";result+="."+p+"cpBorder { border:solid thin #808080; }\n";result+="</STYLE>\n";return result;}
function CP_getCalendar(){var now=new Date();if(this.type=="WINDOW"){var windowref="window.opener.";}
else{var windowref="";}
var result="";if(this.type=="WINDOW"){result+="<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";result+='<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';}
else{result+='<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';result+='<TR><TD ALIGN=CENTER>\n';result+='<CENTER>\n';}
if(this.displayType=="date"||this.displayType=="week-end"){if(this.currentDate==null){this.currentDate=now;}
if(arguments.length>0){var month=arguments[0];}
else{var month=this.currentDate.getMonth()+1;}
if(arguments.length>1&&arguments[1]>0&&arguments[1]-0==arguments[1]){var year=arguments[1];}
else{var year=this.currentDate.getFullYear();}
var daysinmonth=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);if(((year%4==0)&&(year%100!=0))||(year%400==0)){daysinmonth[2]=29;}
var current_month=new Date(year,month-1,1);var display_year=year;var display_month=month;var display_date=1;var weekday=current_month.getDay();var offset=0;offset=(weekday>=this.weekStartDay)?weekday-this.weekStartDay:7-this.weekStartDay+weekday;if(offset>0){display_month--;if(display_month<1){display_month=12;display_year--;}
display_date=daysinmonth[display_month]-offset+1;}
var next_month=month+1;var next_month_year=year;if(next_month>12){next_month=1;next_month_year++;}
var last_month=month-1;var last_month_year=year;if(last_month<1){last_month=12;last_month_year--;}
var date_class;if(this.type!="WINDOW"){result+="<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";}
result+='<TR>\n';var refresh=windowref+'CP_refreshCalendar';var refreshLink='javascript:'+refresh;if(this.isShowNavigationDropdowns){result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';for(var monthCounter=1;monthCounter<=12;monthCounter++){var selected=(monthCounter==month)?'SELECTED':'';result+='<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';}
result+='</select></TD>';result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';for(var yearCounter=year-this.yearSelectStartOffset;yearCounter<=year+this.yearSelectStartOffset;yearCounter++){var selected=(yearCounter==year)?'SELECTED':'';result+='<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';}
result+='</select></TD>';}
else{if(this.isShowYearNavigation){result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;</A></TD>';result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;</A></TD>';result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');">&lt;</A></TD>';if(this.isShowYearNavigationInput){result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';}
else{result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';}
result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">&gt;</A></TD>';}
else{result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;&lt;</A></TD>\n';result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;&gt;</A></TD>\n';}}
result+='</TR></TABLE>\n';result+='<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';result+='<TR>\n';for(var j=0;j<7;j++){result+='<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';}
result+='</TR>\n';for(var row=1;row<=6;row++){result+='<TR>\n';for(var col=1;col<=7;col++){var disabled=false;if(this.disabledDatesExpression!=""){var ds=""+display_year+LZ(display_month)+LZ(display_date);eval("disabled=("+this.disabledDatesExpression+")");}
var dateClass="";if((display_month==this.currentDate.getMonth()+1)&&(display_date==this.currentDate.getDate())&&(display_year==this.currentDate.getFullYear())){dateClass="cpCurrentDate";}
else if(display_month==month){dateClass="cpCurrentMonthDate";}
else{dateClass="cpOtherMonthDate";}
if(disabled||this.disabledWeekDays[col-1]){result+=' <TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';}
else{var selected_date=display_date;var selected_month=display_month;var selected_year=display_year;if(this.displayType=="week-end"){var d=new Date(selected_year,selected_month-1,selected_date,0,0,0,0);d.setDate(d.getDate()+(7-col));selected_year=d.getYear();if(selected_year<1000){selected_year+=1900;}
selected_month=d.getMonth()+1;selected_date=d.getDate();}
result+=' <TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';}
display_date++;if(display_date>daysinmonth[display_month]){display_date=1;display_month++;}
if(display_month>12){display_month=1;display_year++;}}
result+='</TR>';}
var current_weekday=now.getDay()-this.weekStartDay;if(current_weekday<0){current_weekday+=7;}
result+='<TR>\n';result+=' <TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';if(this.disabledDatesExpression!=""){var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());eval("disabled=("+this.disabledDatesExpression+")");}
if(disabled||this.disabledWeekDays[current_weekday+1]){result+='  <SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';}
else{result+='  <A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';}
result+='  <BR>\n';result+=' </TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';}
if(this.displayType=="month"||this.displayType=="quarter"||this.displayType=="year"){if(arguments.length>0){var year=arguments[0];}
else{if(this.displayType=="year"){var year=now.getFullYear()-this.yearSelectStartOffset;}
else{var year=now.getFullYear();}}
if(this.displayType!="year"&&this.isShowYearNavigation){result+="<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";result+='<TR>\n';result+=' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');">&lt;&lt;</A></TD>\n';result+=' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';result+=' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">&gt;&gt;</A></TD>\n';result+='</TR></TABLE>\n';}}
if(this.displayType=="month"){result+='<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<4;i++){result+='<TR>';for(var j=0;j<3;j++){var monthindex=((i*3)+j);result+='<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';}
result+='</TR>';}
result+='</TABLE></CENTER></TD></TR></TABLE>\n';}
if(this.displayType=="quarter"){result+='<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<2;i++){result+='<TR>';for(var j=0;j<2;j++){var quarter=((i*2)+j+1);result+='<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';}
result+='</TR>';}
result+='</TABLE></CENTER></TD></TR></TABLE>\n';}
if(this.displayType=="year"){var yearColumnSize=4;result+="<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";result+='<TR>\n';result+=' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');">&lt;&lt;</A></TD>\n';result+=' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">&gt;&gt;</A></TD>\n';result+='</TR></TABLE>\n';result+='<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<yearColumnSize;i++){for(var j=0;j<2;j++){var currentyear=year+(j*yearColumnSize)+i;result+='<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';}
result+='</TR>';}
result+='</TABLE></CENTER></TD></TR></TABLE>\n';}
if(this.type=="WINDOW"){result+="</BODY></HTML>\n";}
return result;}

// set styles
document.write(getCalendarStyles());

// init calendar
var date_select = new CalendarPopup("calendar-div");
// :NOTE: removed; broken in FF3
//date_select.setCssPrefix("CAL");
//date_select.showNavigationDropdowns();
date_select.offsetX = 35;
date_select.offsetY = 0;

// changes to work with drop downs
function SelectDate(prefix) {
  date_select.dateFormat = 'MM/dd/yyyy'
  date_select.setReturnFunction('SetDateValues');
  date_select.showCalendar('anchor_' + prefix);
  field_prefix = prefix;
}
function SetDateValues(y, m, d) {
  m = LZ(m);
  d = LZ(d);
  $(field_prefix + '_year').value  = y;
  $(field_prefix + '_month').value = m;
  $(field_prefix + '_day').value   = d;
}
function ClearDateValues(field_prefix) {
  $(field_prefix + '_year').value  = '';
  $(field_prefix + '_month').value = '';
  $(field_prefix + '_day').value   = '';
}


/*** window.js ***/
function BuildWindow(parameters) {
  // set values
  var id          = parameters.id;
  var title       = parameters.title       != null ? parameters.title       : 'Popup Action';
  var width       = parameters.width       != null ? parameters.width       : 500;
  var height      = parameters.height      != null ? parameters.height      : 500;
  var top         = parameters.top         != null ? parameters.top         : 0;
  var left        = parameters.left        != null ? parameters.left        : 0;
  var minimizable = parameters.minimizable != null ? parameters.minimizable : false;
  var maximizable = parameters.maximizable != null ? parameters.maximizable : false;
  var modal       = parameters.modal       != null ? true                   : false;
  var url         = parameters.url
  var content     = parameters.content;
  
  // build window
  if (url != null) {
    var win = new Window(id, {title:title, width:width, height:height, url:url, showEffectOptions:{duration:0.3}, hideEffectOptions:{duration:0.4}, top:top, left:left, minimizable:minimizable, maximizable:maximizable, zIndex:100});
    win.setDestroyOnClose();
    if (top > 0 || left > 0) {
      win.show(modal, top, left);
    } else {
      win.showCenter(modal);
    }
  } else if (content != null) {
    var win = new Window(id, {title:title, width:width, height:height, showEffectOptions:{duration:0.3}, hideEffectOptions:{duration:0.4}, top:top, left:left, minimizable:minimizable, maximizable:maximizable, zIndex:100});
    win.getContent().innerHTML = content
    win.setDestroyOnClose();
    if (top > 0 || left > 0) {
      win.show(modal, top, left);
    } else {
      win.showCenter(modal);
    }
  } else {
    return false;
  }
}

// Copyright (c) 2006 Sébastien Gruhier (http://xilinus.com, http://itseb.com)
// 
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// VERSION 1.3

var Window=Class.create();Window.keepMultiModalWindow=false;Window.hasEffectLib=(typeof Effect!="undefined");Window.resizeEffectDuration=0.4;Window.prototype={initialize:function(){var c;var b=0;if(arguments.length>0){if(typeof arguments[0]=="string"){c=arguments[0];b=1}else{c=arguments[0]?arguments[0].id:null}}if(!c){c="window_"+new Date().getTime()}if($(c)){alert("Window "+c+" is already registered in the DOM! Make sure you use setDestroyOnClose() or destroyOnClose: true in the constructor")}this.options=Object.extend({className:"dialog",blurClassName:null,minWidth:100,minHeight:20,resizable:true,closable:true,minimizable:true,maximizable:true,draggable:true,userData:null,showEffect:(Window.hasEffectLib?Effect.Appear:Element.show),hideEffect:(Window.hasEffectLib?Effect.Fade:Element.hide),showEffectOptions:{},hideEffectOptions:{},effectOptions:null,parent:document.body,title:"&nbsp;",url:null,onload:Prototype.emptyFunction,width:200,height:300,opacity:1,recenterAuto:true,wiredDrag:false,closeCallback:null,destroyOnClose:false,gridX:1,gridY:1},arguments[b]||{});if(this.options.blurClassName){this.options.focusClassName=this.options.className}if(typeof this.options.top=="undefined"&&typeof this.options.bottom=="undefined"){this.options.top=this._round(Math.random()*500,this.options.gridY)}if(typeof this.options.left=="undefined"&&typeof this.options.right=="undefined"){this.options.left=this._round(Math.random()*500,this.options.gridX)}if(this.options.effectOptions){Object.extend(this.options.hideEffectOptions,this.options.effectOptions);Object.extend(this.options.showEffectOptions,this.options.effectOptions);if(this.options.showEffect==Element.Appear){this.options.showEffectOptions.to=this.options.opacity}}if(Window.hasEffectLib){if(this.options.showEffect==Effect.Appear){this.options.showEffectOptions.to=this.options.opacity}if(this.options.hideEffect==Effect.Fade){this.options.hideEffectOptions.from=this.options.opacity}}if(this.options.hideEffect==Element.hide){this.options.hideEffect=function(){Element.hide(this.element);if(this.options.destroyOnClose){this.destroy()}}.bind(this)}if(this.options.parent!=document.body){this.options.parent=$(this.options.parent)}this.element=this._createWindow(c);this.element.win=this;this.eventMouseDown=this._initDrag.bindAsEventListener(this);this.eventMouseUp=this._endDrag.bindAsEventListener(this);this.eventMouseMove=this._updateDrag.bindAsEventListener(this);this.eventOnLoad=this._getWindowBorderSize.bindAsEventListener(this);this.eventMouseDownContent=this.toFront.bindAsEventListener(this);this.eventResize=this._recenter.bindAsEventListener(this);this.topbar=$(this.element.id+"_top");this.bottombar=$(this.element.id+"_bottom");this.content=$(this.element.id+"_content");Event.observe(this.topbar,"mousedown",this.eventMouseDown);Event.observe(this.bottombar,"mousedown",this.eventMouseDown);Event.observe(this.content,"mousedown",this.eventMouseDownContent);Event.observe(window,"load",this.eventOnLoad);Event.observe(window,"resize",this.eventResize);Event.observe(window,"scroll",this.eventResize);Event.observe(this.options.parent,"scroll",this.eventResize);if(this.options.draggable){var a=this;[this.topbar,this.topbar.up().previous(),this.topbar.up().next()].each(function(d){d.observe("mousedown",a.eventMouseDown);d.addClassName("top_draggable")});[this.bottombar.up(),this.bottombar.up().previous(),this.bottombar.up().next()].each(function(d){d.observe("mousedown",a.eventMouseDown);d.addClassName("bottom_draggable")})}if(this.options.resizable){this.sizer=$(this.element.id+"_sizer");Event.observe(this.sizer,"mousedown",this.eventMouseDown)}this.useLeft=null;this.useTop=null;if(typeof this.options.left!="undefined"){this.element.setStyle({left:parseFloat(this.options.left)+"px"});this.useLeft=true}else{this.element.setStyle({right:parseFloat(this.options.right)+"px"});this.useLeft=false}if(typeof this.options.top!="undefined"){this.element.setStyle({top:parseFloat(this.options.top)+"px"});this.useTop=true}else{this.element.setStyle({bottom:parseFloat(this.options.bottom)+"px"});this.useTop=false}this.storedLocation=null;this.setOpacity(this.options.opacity);if(this.options.zIndex){this.setZIndex(this.options.zIndex)}if(this.options.destroyOnClose){this.setDestroyOnClose(true)}this._getWindowBorderSize();this.width=this.options.width;this.height=this.options.height;this.visible=false;this.constraint=false;this.constraintPad={top:0,left:0,bottom:0,right:0};if(this.width&&this.height){this.setSize(this.options.width,this.options.height)}this.setTitle(this.options.title);Windows.register(this)},destroy:function(){this._notify("onDestroy");Event.stopObserving(this.topbar,"mousedown",this.eventMouseDown);Event.stopObserving(this.bottombar,"mousedown",this.eventMouseDown);Event.stopObserving(this.content,"mousedown",this.eventMouseDownContent);Event.stopObserving(window,"load",this.eventOnLoad);Event.stopObserving(window,"resize",this.eventResize);Event.stopObserving(window,"scroll",this.eventResize);Event.stopObserving(this.content,"load",this.options.onload);if(this._oldParent){var c=this.getContent();var a=null;for(var b=0;b<c.childNodes.length;b++){a=c.childNodes[b];if(a.nodeType==1){break}a=null}if(a){this._oldParent.appendChild(a)}this._oldParent=null}if(this.sizer){Event.stopObserving(this.sizer,"mousedown",this.eventMouseDown)}if(this.options.url){this.content.src=null}if(this.iefix){Element.remove(this.iefix)}Element.remove(this.element);Windows.unregister(this)},setCloseCallback:function(a){this.options.closeCallback=a},getContent:function(){return this.content},setContent:function(h,g,b){var a=$(h);if(null==a){throw"Unable to find element '"+h+"' in DOM"}this._oldParent=a.parentNode;var f=null;var e=null;if(g){f=Element.getDimensions(a)}if(b){e=Position.cumulativeOffset(a)}var c=this.getContent();this.setHTMLContent("");c=this.getContent();c.appendChild(a);a.show();if(g){this.setSize(f.width,f.height)}if(b){this.setLocation(e[1]-this.heightN,e[0]-this.widthW)}},setHTMLContent:function(a){if(this.options.url){this.content.src=null;this.options.url=null;var b='<div id="'+this.getId()+'_content" class="'+this.options.className+'_content"> </div>';$(this.getId()+"_table_content").innerHTML=b;this.content=$(this.element.id+"_content")}this.getContent().innerHTML=a},setAjaxContent:function(b,a,d,c){this.showFunction=d?"showCenter":"show";this.showModal=c||false;a=a||{};this.setHTMLContent("");this.onComplete=a.onComplete;if(!this._onCompleteHandler){this._onCompleteHandler=this._setAjaxContent.bind(this)}a.onComplete=this._onCompleteHandler;new Ajax.Request(b,a);a.onComplete=this.onComplete},_setAjaxContent:function(a){Element.update(this.getContent(),a.responseText);if(this.onComplete){this.onComplete(a)}this.onComplete=null;this[this.showFunction](this.showModal)},setURL:function(a){if(this.options.url){this.content.src=null}this.options.url=a;var b="<iframe frameborder='0' name='"+this.getId()+"_content'  id='"+this.getId()+"_content' src='"+a+"' width='"+this.width+"' height='"+this.height+"'> </iframe>";$(this.getId()+"_table_content").innerHTML=b;this.content=$(this.element.id+"_content")},getURL:function(){return this.options.url?this.options.url:null},refresh:function(){if(this.options.url){$(this.element.getAttribute("id")+"_content").src=this.options.url}},setCookie:function(b,c,n,e,a){b=b||this.element.id;this.cookie=[b,c,n,e,a];var l=WindowUtilities.getCookie(b);if(l){var m=l.split(",");var j=m[0].split(":");var i=m[1].split(":");var k=parseFloat(m[2]),f=parseFloat(m[3]);var g=m[4];var d=m[5];this.setSize(k,f);if(g=="true"){this.doMinimize=true}else{if(d=="true"){this.doMaximize=true}}this.useLeft=j[0]=="l";this.useTop=i[0]=="t";this.element.setStyle(this.useLeft?{left:j[1]}:{right:j[1]});this.element.setStyle(this.useTop?{top:i[1]}:{bottom:i[1]})}},getId:function(){return this.element.id},setDestroyOnClose:function(){this.options.destroyOnClose=true},setConstraint:function(a,b){this.constraint=a;this.constraintPad=Object.extend(this.constraintPad,b||{});if(this.useTop&&this.useLeft){this.setLocation(parseFloat(this.element.style.top),parseFloat(this.element.style.left))}},_initDrag:function(b){if(Event.element(b)==this.sizer&&this.isMinimized()){return}if(Event.element(b)!=this.sizer&&this.isMaximized()){return}if(Prototype.Browser.IE&&this.heightN==0){this._getWindowBorderSize()}this.pointer=[this._round(Event.pointerX(b),this.options.gridX),this._round(Event.pointerY(b),this.options.gridY)];if(this.options.wiredDrag){this.currentDrag=this._createWiredElement()}else{this.currentDrag=this.element}if(Event.element(b)==this.sizer){this.doResize=true;this.widthOrg=this.width;this.heightOrg=this.height;this.bottomOrg=parseFloat(this.element.getStyle("bottom"));this.rightOrg=parseFloat(this.element.getStyle("right"));this._notify("onStartResize")}else{this.doResize=false;var a=$(this.getId()+"_close");if(a&&Position.within(a,this.pointer[0],this.pointer[1])){this.currentDrag=null;return}this.toFront();if(!this.options.draggable){return}this._notify("onStartMove")}Event.observe(document,"mouseup",this.eventMouseUp,false);Event.observe(document,"mousemove",this.eventMouseMove,false);WindowUtilities.disableScreen("__invisible__","__invisible__",this.overlayOpacity);document.body.ondrag=function(){return false};document.body.onselectstart=function(){return false};this.currentDrag.show();Event.stop(b)},_round:function(b,a){return a==1?b:b=Math.floor(b/a)*a},_updateDrag:function(b){var a=[this._round(Event.pointerX(b),this.options.gridX),this._round(Event.pointerY(b),this.options.gridY)];var k=a[0]-this.pointer[0];var j=a[1]-this.pointer[1];if(this.doResize){var i=this.widthOrg+k;var d=this.heightOrg+j;k=this.width-this.widthOrg;j=this.height-this.heightOrg;if(this.useLeft){i=this._updateWidthConstraint(i)}else{this.currentDrag.setStyle({right:(this.rightOrg-k)+"px"})}if(this.useTop){d=this._updateHeightConstraint(d)}else{this.currentDrag.setStyle({bottom:(this.bottomOrg-j)+"px"})}this.setSize(i,d);this._notify("onResize")}else{this.pointer=a;if(this.useLeft){var c=parseFloat(this.currentDrag.getStyle("left"))+k;var g=this._updateLeftConstraint(c);this.pointer[0]+=g-c;this.currentDrag.setStyle({left:g+"px"})}else{this.currentDrag.setStyle({right:parseFloat(this.currentDrag.getStyle("right"))-k+"px"})}if(this.useTop){var f=parseFloat(this.currentDrag.getStyle("top"))+j;var e=this._updateTopConstraint(f);this.pointer[1]+=e-f;this.currentDrag.setStyle({top:e+"px"})}else{this.currentDrag.setStyle({bottom:parseFloat(this.currentDrag.getStyle("bottom"))-j+"px"})}this._notify("onMove")}if(this.iefix){this._fixIEOverlapping()}this._removeStoreLocation();Event.stop(b)},_endDrag:function(a){WindowUtilities.enableScreen("__invisible__");if(this.doResize){this._notify("onEndResize")}else{this._notify("onEndMove")}Event.stopObserving(document,"mouseup",this.eventMouseUp,false);Event.stopObserving(document,"mousemove",this.eventMouseMove,false);Event.stop(a);this._hideWiredElement();this._saveCookie();document.body.ondrag=null;document.body.onselectstart=null},_updateLeftConstraint:function(b){if(this.constraint&&this.useLeft&&this.useTop){var a=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;if(b<this.constraintPad.left){b=this.constraintPad.left}if(b+this.width+this.widthE+this.widthW>a-this.constraintPad.right){b=a-this.constraintPad.right-this.width-this.widthE-this.widthW}}return b},_updateTopConstraint:function(c){if(this.constraint&&this.useLeft&&this.useTop){var a=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var b=this.height+this.heightN+this.heightS;if(c<this.constraintPad.top){c=this.constraintPad.top}if(c+b>a-this.constraintPad.bottom){c=a-this.constraintPad.bottom-b}}return c},_updateWidthConstraint:function(a){if(this.constraint&&this.useLeft&&this.useTop){var b=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;var c=parseFloat(this.element.getStyle("left"));if(c+a+this.widthE+this.widthW>b-this.constraintPad.right){a=b-this.constraintPad.right-c-this.widthE-this.widthW}}return a},_updateHeightConstraint:function(b){if(this.constraint&&this.useLeft&&this.useTop){var a=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var c=parseFloat(this.element.getStyle("top"));if(c+b+this.heightN+this.heightS>a-this.constraintPad.bottom){b=a-this.constraintPad.bottom-c-this.heightN-this.heightS}}return b},_createWindow:function(a){var f=this.options.className;var d=document.createElement("div");d.setAttribute("id",a);d.className="dialog";var e;if(this.options.url){e='<iframe frameborder="0" name="'+a+'_content"  id="'+a+'_content" src="'+this.options.url+'"> </iframe>'}else{e='<div id="'+a+'_content" class="'+f+'_content"> </div>'}var g=this.options.closable?"<div class='"+f+"_close' id='"+a+"_close' onclick='Windows.close(\""+a+"\", event)'> </div>":"";var h=this.options.minimizable?"<div class='"+f+"_minimize' id='"+a+"_minimize' onclick='Windows.minimize(\""+a+"\", event)'> </div>":"";var i=this.options.maximizable?"<div class='"+f+"_maximize' id='"+a+"_maximize' onclick='Windows.maximize(\""+a+"\", event)'> </div>":"";var c=this.options.resizable?"class='"+f+"_sizer' id='"+a+"_sizer'":"class='"+f+"_se'";var b="../themes/default/blank.gif";d.innerHTML=g+h+i+"      <table id='"+a+"_row1' class=\"top table_window\">        <tr>          <td class='"+f+"_nw'></td>          <td class='"+f+"_n'><div id='"+a+"_top' class='"+f+"_title title_window'>"+this.options.title+"</div></td>          <td class='"+f+"_ne'></td>        </tr>      </table>      <table id='"+a+"_row2' class=\"mid table_window\">        <tr>          <td class='"+f+"_w'></td>            <td id='"+a+"_table_content' class='"+f+"_content' valign='top'>"+e+"</td>          <td class='"+f+"_e'></td>        </tr>      </table>        <table id='"+a+"_row3' class=\"bot table_window\">        <tr>          <td class='"+f+"_sw'></td>            <td class='"+f+"_s'><div id='"+a+"_bottom' class='status_bar'><span style='float:left; width:1px; height:1px'></span></div></td>            <td "+c+"></td>        </tr>      </table>    ";Element.hide(d);this.options.parent.insertBefore(d,this.options.parent.firstChild);Event.observe($(a+"_content"),"load",this.options.onload);return d},changeClassName:function(a){var b=this.options.className;var c=this.getId();$A(["_close","_minimize","_maximize","_sizer","_content"]).each(function(d){this._toggleClassName($(c+d),b+d,a+d)}.bind(this));this._toggleClassName($(c+"_top"),b+"_title",a+"_title");$$("#"+c+" td").each(function(d){d.className=d.className.sub(b,a)});this.options.className=a},_toggleClassName:function(c,b,a){if(c){c.removeClassName(b);c.addClassName(a)}},setLocation:function(c,b){c=this._updateTopConstraint(c);b=this._updateLeftConstraint(b);var a=this.currentDrag||this.element;a.setStyle({top:c+"px"});a.setStyle({left:b+"px"});this.useLeft=true;this.useTop=true},getLocation:function(){var a={};if(this.useTop){a=Object.extend(a,{top:this.element.getStyle("top")})}else{a=Object.extend(a,{bottom:this.element.getStyle("bottom")})}if(this.useLeft){a=Object.extend(a,{left:this.element.getStyle("left")})}else{a=Object.extend(a,{right:this.element.getStyle("right")})}return a},getSize:function(){return{width:this.width,height:this.height}},setSize:function(c,b,a){c=parseFloat(c);b=parseFloat(b);if(!this.minimized&&c<this.options.minWidth){c=this.options.minWidth}if(!this.minimized&&b<this.options.minHeight){b=this.options.minHeight}if(this.options.maxHeight&&b>this.options.maxHeight){b=this.options.maxHeight}if(this.options.maxWidth&&c>this.options.maxWidth){c=this.options.maxWidth}if(this.useTop&&this.useLeft&&Window.hasEffectLib&&Effect.ResizeWindow&&a){new Effect.ResizeWindow(this,null,null,c,b,{duration:Window.resizeEffectDuration})}else{this.width=c;this.height=b;var f=this.currentDrag?this.currentDrag:this.element;f.setStyle({width:c+this.widthW+this.widthE+"px"});f.setStyle({height:b+this.heightN+this.heightS+"px"});if(!this.currentDrag||this.currentDrag==this.element){var d=$(this.element.id+"_content");d.setStyle({height:b+"px"});d.setStyle({width:c+"px"})}}},updateHeight:function(){this.setSize(this.width,this.content.scrollHeight,true)},updateWidth:function(){this.setSize(this.content.scrollWidth,this.height,true)},toFront:function(){if(this.element.style.zIndex<Windows.maxZIndex){this.setZIndex(Windows.maxZIndex+1)}if(this.iefix){this._fixIEOverlapping()}},getBounds:function(b){if(!this.width||!this.height||!this.visible){this.computeBounds()}var a=this.width;var c=this.height;if(!b){a+=this.widthW+this.widthE;c+=this.heightN+this.heightS}var d=Object.extend(this.getLocation(),{width:a+"px",height:c+"px"});return d},computeBounds:function(){if(!this.width||!this.height){var a=WindowUtilities._computeSize(this.content.innerHTML,this.content.id,this.width,this.height,0,this.options.className);if(this.height){this.width=a+5}else{this.height=a+5}}this.setSize(this.width,this.height);if(this.centered){this._center(this.centerTop,this.centerLeft)}},show:function(b){this.visible=true;if(b){if(typeof this.overlayOpacity=="undefined"){var a=this;setTimeout(function(){a.show(b)},10);return}Windows.addModalWindow(this);this.modal=true;this.setZIndex(Windows.maxZIndex+1);Windows.unsetOverflow(this)}else{if(!this.element.style.zIndex){this.setZIndex(Windows.maxZIndex+1)}}if(this.oldStyle){this.getContent().setStyle({overflow:this.oldStyle})}this.computeBounds();this._notify("onBeforeShow");if(this.options.showEffect!=Element.show&&this.options.showEffectOptions){this.options.showEffect(this.element,this.options.showEffectOptions)}else{this.options.showEffect(this.element)}this._checkIEOverlapping();WindowUtilities.focusedWindow=this;this._notify("onShow")},showCenter:function(a,c,b){this.centered=true;this.centerTop=c;this.centerLeft=b;this.show(a)},isVisible:function(){return this.visible},_center:function(c,b){var d=WindowUtilities.getWindowScroll(this.options.parent);var a=WindowUtilities.getPageSize(this.options.parent);if(typeof c=="undefined"){c=(a.windowHeight-(this.height+this.heightN+this.heightS))/2}c+=d.top;if(typeof b=="undefined"){b=(a.windowWidth-(this.width+this.widthW+this.widthE))/2}b+=d.left;this.setLocation(c,b);this.toFront()},_recenter:function(b){if(this.centered){var a=WindowUtilities.getPageSize(this.options.parent);var c=WindowUtilities.getWindowScroll(this.options.parent);if(this.pageSize&&this.pageSize.windowWidth==a.windowWidth&&this.pageSize.windowHeight==a.windowHeight&&this.windowScroll.left==c.left&&this.windowScroll.top==c.top){return}this.pageSize=a;this.windowScroll=c;if($("overlay_modal")){$("overlay_modal").setStyle({height:(a.pageHeight+"px")})}if(this.options.recenterAuto){this._center(this.centerTop,this.centerLeft)}}},hide:function(){this.visible=false;if(this.modal){Windows.removeModalWindow(this);Windows.resetOverflow()}this.oldStyle=this.getContent().getStyle("overflow")||"auto";this.getContent().setStyle({overflow:"hidden"});this.options.hideEffect(this.element,this.options.hideEffectOptions);if(this.iefix){this.iefix.hide()}if(!this.doNotNotifyHide){this._notify("onHide")}},close:function(){if(this.visible){if(this.options.closeCallback&&!this.options.closeCallback(this)){return}if(this.options.destroyOnClose){var a=this.destroy.bind(this);if(this.options.hideEffectOptions.afterFinish){var b=this.options.hideEffectOptions.afterFinish;this.options.hideEffectOptions.afterFinish=function(){b();a()}}else{this.options.hideEffectOptions.afterFinish=function(){a()}}}Windows.updateFocusedWindow();this.doNotNotifyHide=true;this.hide();this.doNotNotifyHide=false;this._notify("onClose")}},minimize:function(){if(this.resizing){return}var a=$(this.getId()+"_row2");if(!this.minimized){this.minimized=true;var d=a.getDimensions().height;this.r2Height=d;var c=this.element.getHeight()-d;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,null,null,null,this.height-d,{duration:Window.resizeEffectDuration})}else{this.height-=d;this.element.setStyle({height:c+"px"});a.hide()}if(!this.useTop){var b=parseFloat(this.element.getStyle("bottom"));this.element.setStyle({bottom:(b+d)+"px"})}}else{this.minimized=false;var d=this.r2Height;this.r2Height=null;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,null,null,null,this.height+d,{duration:Window.resizeEffectDuration})}else{var c=this.element.getHeight()+d;this.height+=d;this.element.setStyle({height:c+"px"});a.show()}if(!this.useTop){var b=parseFloat(this.element.getStyle("bottom"));this.element.setStyle({bottom:(b-d)+"px"})}this.toFront()}this._notify("onMinimize");this._saveCookie()},maximize:function(){if(this.isMinimized()||this.resizing){return}if(Prototype.Browser.IE&&this.heightN==0){this._getWindowBorderSize()}if(this.storedLocation!=null){this._restoreLocation();if(this.iefix){this.iefix.hide()}}else{this._storeLocation();Windows.unsetOverflow(this);var g=WindowUtilities.getWindowScroll(this.options.parent);var b=WindowUtilities.getPageSize(this.options.parent);var f=g.left;var e=g.top;if(this.options.parent!=document.body){g={top:0,left:0,bottom:0,right:0};var d=this.options.parent.getDimensions();b.windowWidth=d.width;b.windowHeight=d.height;e=0;f=0}if(this.constraint){b.windowWidth-=Math.max(0,this.constraintPad.left)+Math.max(0,this.constraintPad.right);b.windowHeight-=Math.max(0,this.constraintPad.top)+Math.max(0,this.constraintPad.bottom);f+=Math.max(0,this.constraintPad.left);e+=Math.max(0,this.constraintPad.top)}var c=b.windowWidth-this.widthW-this.widthE;var a=b.windowHeight-this.heightN-this.heightS;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,e,f,c,a,{duration:Window.resizeEffectDuration})}else{this.setSize(c,a);this.element.setStyle(this.useLeft?{left:f}:{right:f});this.element.setStyle(this.useTop?{top:e}:{bottom:e})}this.toFront();if(this.iefix){this._fixIEOverlapping()}}this._notify("onMaximize");this._saveCookie()},isMinimized:function(){return this.minimized},isMaximized:function(){return(this.storedLocation!=null)},setOpacity:function(a){if(Element.setOpacity){Element.setOpacity(this.element,a)}},setZIndex:function(a){this.element.setStyle({zIndex:a});Windows.updateZindex(a,this)},setTitle:function(a){if(!a||a==""){a="&nbsp;"}Element.update(this.element.id+"_top",a)},getTitle:function(){return $(this.element.id+"_top").innerHTML},setStatusBar:function(b){var a=$(this.getId()+"_bottom");if(typeof(b)=="object"){if(this.bottombar.firstChild){this.bottombar.replaceChild(b,this.bottombar.firstChild)}else{this.bottombar.appendChild(b)}}else{this.bottombar.innerHTML=b}},_checkIEOverlapping:function(){if(!this.iefix&&(navigator.appVersion.indexOf("MSIE")>0)&&(navigator.userAgent.indexOf("Opera")<0)&&(this.element.getStyle("position")=="absolute")){new Insertion.After(this.element.id,'<iframe id="'+this.element.id+'_iefix" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.element.id+"_iefix")}if(this.iefix){setTimeout(this._fixIEOverlapping.bind(this),50)}},_fixIEOverlapping:function(){Position.clone(this.element,this.iefix);this.iefix.style.zIndex=this.element.style.zIndex-1;this.iefix.show()},_getWindowBorderSize:function(b){var c=this._createHiddenDiv(this.options.className+"_n");this.heightN=Element.getDimensions(c).height;c.parentNode.removeChild(c);var c=this._createHiddenDiv(this.options.className+"_s");this.heightS=Element.getDimensions(c).height;c.parentNode.removeChild(c);var c=this._createHiddenDiv(this.options.className+"_e");this.widthE=Element.getDimensions(c).width;c.parentNode.removeChild(c);var c=this._createHiddenDiv(this.options.className+"_w");this.widthW=Element.getDimensions(c).width;c.parentNode.removeChild(c);var c=document.createElement("div");c.className="overlay_"+this.options.className;document.body.appendChild(c);var a=this;setTimeout(function(){a.overlayOpacity=($(c).getStyle("opacity"));c.parentNode.removeChild(c)},10);if(Prototype.Browser.IE){this.heightS=$(this.getId()+"_row3").getDimensions().height;this.heightN=$(this.getId()+"_row1").getDimensions().height}if(Prototype.Browser.WebKit&&Prototype.Browser.WebKitVersion<420){this.setSize(this.width,this.height)}if(this.doMaximize){this.maximize()}if(this.doMinimize){this.minimize()}},_createHiddenDiv:function(b){var a=document.body;var c=document.createElement("div");c.setAttribute("id",this.element.id+"_tmp");c.className=b;c.style.display="none";c.innerHTML="";a.insertBefore(c,a.firstChild);return c},_storeLocation:function(){if(this.storedLocation==null){this.storedLocation={useTop:this.useTop,useLeft:this.useLeft,top:this.element.getStyle("top"),bottom:this.element.getStyle("bottom"),left:this.element.getStyle("left"),right:this.element.getStyle("right"),width:this.width,height:this.height}}},_restoreLocation:function(){if(this.storedLocation!=null){this.useLeft=this.storedLocation.useLeft;this.useTop=this.storedLocation.useTop;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,this.storedLocation.top,this.storedLocation.left,this.storedLocation.width,this.storedLocation.height,{duration:Window.resizeEffectDuration})}else{this.element.setStyle(this.useLeft?{left:this.storedLocation.left}:{right:this.storedLocation.right});this.element.setStyle(this.useTop?{top:this.storedLocation.top}:{bottom:this.storedLocation.bottom});this.setSize(this.storedLocation.width,this.storedLocation.height)}Windows.resetOverflow();this._removeStoreLocation()}},_removeStoreLocation:function(){this.storedLocation=null},_saveCookie:function(){if(this.cookie){var a="";if(this.useLeft){a+="l:"+(this.storedLocation?this.storedLocation.left:this.element.getStyle("left"))}else{a+="r:"+(this.storedLocation?this.storedLocation.right:this.element.getStyle("right"))}if(this.useTop){a+=",t:"+(this.storedLocation?this.storedLocation.top:this.element.getStyle("top"))}else{a+=",b:"+(this.storedLocation?this.storedLocation.bottom:this.element.getStyle("bottom"))}a+=","+(this.storedLocation?this.storedLocation.width:this.width);a+=","+(this.storedLocation?this.storedLocation.height:this.height);a+=","+this.isMinimized();a+=","+this.isMaximized();WindowUtilities.setCookie(a,this.cookie)}},_createWiredElement:function(){if(!this.wiredElement){if(Prototype.Browser.IE){this._getWindowBorderSize()}var b=document.createElement("div");b.className="wired_frame "+this.options.className+"_wired_frame";b.style.position="absolute";this.options.parent.insertBefore(b,this.options.parent.firstChild);this.wiredElement=$(b)}if(this.useLeft){this.wiredElement.setStyle({left:this.element.getStyle("left")})}else{this.wiredElement.setStyle({right:this.element.getStyle("right")})}if(this.useTop){this.wiredElement.setStyle({top:this.element.getStyle("top")})}else{this.wiredElement.setStyle({bottom:this.element.getStyle("bottom")})}var a=this.element.getDimensions();this.wiredElement.setStyle({width:a.width+"px",height:a.height+"px"});this.wiredElement.setStyle({zIndex:Windows.maxZIndex+30});return this.wiredElement},_hideWiredElement:function(){if(!this.wiredElement||!this.currentDrag){return}if(this.currentDrag==this.element){this.currentDrag=null}else{if(this.useLeft){this.element.setStyle({left:this.currentDrag.getStyle("left")})}else{this.element.setStyle({right:this.currentDrag.getStyle("right")})}if(this.useTop){this.element.setStyle({top:this.currentDrag.getStyle("top")})}else{this.element.setStyle({bottom:this.currentDrag.getStyle("bottom")})}this.currentDrag.hide();this.currentDrag=null;if(this.doResize){this.setSize(this.width,this.height)}}},_notify:function(a){if(this.options[a]){this.options[a](this)}else{Windows.notify(a,this)}}};var Windows={windows:[],modalWindows:[],observers:[],focusedWindow:null,maxZIndex:0,overlayShowEffectOptions:{duration:0.5},overlayHideEffectOptions:{duration:0.5},addObserver:function(a){this.removeObserver(a);this.observers.push(a)},removeObserver:function(a){this.observers=this.observers.reject(function(b){return b==a})},notify:function(a,b){this.observers.each(function(c){if(c[a]){c[a](a,b)}})},getWindow:function(a){return this.windows.detect(function(b){return b.getId()==a})},getFocusedWindow:function(){return this.focusedWindow},updateFocusedWindow:function(){this.focusedWindow=this.windows.length>=2?this.windows[this.windows.length-2]:null},register:function(a){this.windows.push(a)},addModalWindow:function(a){if(this.modalWindows.length==0){WindowUtilities.disableScreen(a.options.className,"overlay_modal",a.overlayOpacity,a.getId(),a.options.parent)}else{if(Window.keepMultiModalWindow){$("overlay_modal").style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex+=1;WindowUtilities._hideSelect(this.modalWindows.last().getId())}else{this.modalWindows.last().element.hide()}WindowUtilities._showSelect(a.getId())}this.modalWindows.push(a)},removeModalWindow:function(a){this.modalWindows.pop();if(this.modalWindows.length==0){WindowUtilities.enableScreen()}else{if(Window.keepMultiModalWindow){this.modalWindows.last().toFront();WindowUtilities._showSelect(this.modalWindows.last().getId())}else{this.modalWindows.last().element.show()}}},register:function(a){this.windows.push(a)},unregister:function(a){this.windows=this.windows.reject(function(b){return b==a})},closeAll:function(){this.windows.each(function(a){Windows.close(a.getId())})},closeAllModalWindows:function(){WindowUtilities.enableScreen();this.modalWindows.each(function(a){if(a){a.close()}})},minimize:function(c,a){var b=this.getWindow(c);if(b&&b.visible){b.minimize()}Event.stop(a)},maximize:function(c,a){var b=this.getWindow(c);if(b&&b.visible){b.maximize()}Event.stop(a)},close:function(c,a){var b=this.getWindow(c);if(b){b.close()}if(a){Event.stop(a)}},blur:function(b){var a=this.getWindow(b);if(!a){return}if(a.options.blurClassName){a.changeClassName(a.options.blurClassName)}if(this.focusedWindow==a){this.focusedWindow=null}a._notify("onBlur")},focus:function(b){var a=this.getWindow(b);if(!a){return}if(this.focusedWindow){this.blur(this.focusedWindow.getId())}if(a.options.focusClassName){a.changeClassName(a.options.focusClassName)}this.focusedWindow=a;a._notify("onFocus")},unsetOverflow:function(a){this.windows.each(function(b){b.oldOverflow=b.getContent().getStyle("overflow")||"auto";b.getContent().setStyle({overflow:"hidden"})});if(a&&a.oldOverflow){a.getContent().setStyle({overflow:a.oldOverflow})}},resetOverflow:function(){this.windows.each(function(a){if(a.oldOverflow){a.getContent().setStyle({overflow:a.oldOverflow})}})},updateZindex:function(a,b){if(a>this.maxZIndex){this.maxZIndex=a;if(this.focusedWindow){this.blur(this.focusedWindow.getId())}}this.focusedWindow=b;if(this.focusedWindow){this.focus(this.focusedWindow.getId())}}};var Dialog={dialogId:null,onCompleteFunc:null,callFunc:null,parameters:null,confirm:function(d,c){if(d&&typeof d!="string"){Dialog._runAjaxRequest(d,c,Dialog.confirm);return}d=d||"";c=c||{};var f=c.okLabel?c.okLabel:"Ok";var a=c.cancelLabel?c.cancelLabel:"Cancel";c=Object.extend(c,c.windowParameters||{});c.windowParameters=c.windowParameters||{};c.className=c.className||"alert";var b="class ='"+(c.buttonClass?c.buttonClass+" ":"")+" ok_button'";var e="class ='"+(c.buttonClass?c.buttonClass+" ":"")+" cancel_button'";var d="      <div class='"+c.className+"_message'>"+d+"</div>        <div class='"+c.className+"_buttons'>          <input type='button' value='"+f+"' onclick='Dialog.okCallback()' "+b+"/>          <input type='button' value='"+a+"' onclick='Dialog.cancelCallback()' "+e+"/>        </div>    ";return this._openDialog(d,c)},alert:function(c,b){if(c&&typeof c!="string"){Dialog._runAjaxRequest(c,b,Dialog.alert);return}c=c||"";b=b||{};var d=b.okLabel?b.okLabel:"Ok";b=Object.extend(b,b.windowParameters||{});b.windowParameters=b.windowParameters||{};b.className=b.className||"alert";var a="class ='"+(b.buttonClass?b.buttonClass+" ":"")+" ok_button'";var c="      <div class='"+b.className+"_message'>"+c+"</div>        <div class='"+b.className+"_buttons'>          <input type='button' value='"+d+"' onclick='Dialog.okCallback()' "+a+"/>        </div>";return this._openDialog(c,b)},info:function(b,a){if(b&&typeof b!="string"){Dialog._runAjaxRequest(b,a,Dialog.info);return}b=b||"";a=a||{};a=Object.extend(a,a.windowParameters||{});a.windowParameters=a.windowParameters||{};a.className=a.className||"alert";var b="<div id='modal_dialog_message' class='"+a.className+"_message'>"+b+"</div>";if(a.showProgress){b+="<div id='modal_dialog_progress' class='"+a.className+"_progress'>  </div>"}a.ok=null;a.cancel=null;return this._openDialog(b,a)},setInfoMessage:function(a){$("modal_dialog_message").update(a)},closeInfo:function(){Windows.close(this.dialogId)},_openDialog:function(e,d){var c=d.className;if(!d.height&&!d.width){d.width=WindowUtilities.getPageSize(d.options.parent||document.body).pageWidth/2}if(d.id){this.dialogId=d.id}else{var b=new Date();this.dialogId="modal_dialog_"+b.getTime();d.id=this.dialogId}if(!d.height||!d.width){var a=WindowUtilities._computeSize(e,this.dialogId,d.width,d.height,5,c);if(d.height){d.width=a+5}else{d.height=a+5}}d.effectOptions=d.effectOptions;d.resizable=d.resizable||false;d.minimizable=d.minimizable||false;d.maximizable=d.maximizable||false;d.draggable=d.draggable||false;d.closable=d.closable||false;var f=new Window(d);f.getContent().innerHTML=e;f.showCenter(true,d.top,d.left);f.setDestroyOnClose();f.cancelCallback=d.onCancel||d.cancel;f.okCallback=d.onOk||d.ok;return f},_getAjaxContent:function(a){Dialog.callFunc(a.responseText,Dialog.parameters)},_runAjaxRequest:function(c,b,a){if(c.options==null){c.options={}}Dialog.onCompleteFunc=c.options.onComplete;Dialog.parameters=b;Dialog.callFunc=a;c.options.onComplete=Dialog._getAjaxContent;new Ajax.Request(c.url,c.options)},okCallback:function(){var a=Windows.focusedWindow;if(!a.okCallback||a.okCallback(a)){$$("#"+a.getId()+" input").each(function(b){b.onclick=null});a.close()}},cancelCallback:function(){var a=Windows.focusedWindow;$$("#"+a.getId()+" input").each(function(b){b.onclick=null});a.close();if(a.cancelCallback){a.cancelCallback(a)}}};if(Prototype.Browser.WebKit){var array=navigator.userAgent.match(new RegExp(/AppleWebKit\/([\d\.\+]*)/));Prototype.Browser.WebKitVersion=parseFloat(array[1])}var WindowUtilities={getWindowScroll:function(parent){var T,L,W,H;parent=parent||document.body;if(parent!=document.body){T=parent.scrollTop;L=parent.scrollLeft;W=parent.scrollWidth;H=parent.scrollHeight}else{var w=window;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft}}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}}}return{top:T,left:L,width:W,height:H}},getPageSize:function(d){d=d||document.body;var c,g;var e,b;if(d!=document.body){c=d.getWidth();g=d.getHeight();b=d.scrollWidth;e=d.scrollHeight}else{var f,a;if(window.innerHeight&&window.scrollMaxY){f=document.body.scrollWidth;a=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){f=document.body.scrollWidth;a=document.body.scrollHeight}else{f=document.body.offsetWidth;a=document.body.offsetHeight}}if(self.innerHeight){c=self.innerWidth;g=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){c=document.documentElement.clientWidth;g=document.documentElement.clientHeight}else{if(document.body){c=document.body.clientWidth;g=document.body.clientHeight}}}if(a<g){e=g}else{e=a}if(f<c){b=c}else{b=f}}return{pageWidth:b,pageHeight:e,windowWidth:c,windowHeight:g}},disableScreen:function(c,a,d,e,b){WindowUtilities.initLightbox(a,c,function(){this._disableScreen(c,a,d,e)}.bind(this),b||document.body)},_disableScreen:function(c,b,e,f){var d=$(b);var a=WindowUtilities.getPageSize(d.parentNode);if(f&&Prototype.Browser.IE){WindowUtilities._hideSelect();WindowUtilities._showSelect(f)}d.style.height=(a.pageHeight+"px");d.style.display="none";if(b=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayShowEffectOptions){d.overlayOpacity=e;new Effect.Appear(d,Object.extend({from:0,to:e},Windows.overlayShowEffectOptions))}else{d.style.display="block"}},enableScreen:function(b){b=b||"overlay_modal";var a=$(b);if(a){if(b=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayHideEffectOptions){new Effect.Fade(a,Object.extend({from:a.overlayOpacity,to:0},Windows.overlayHideEffectOptions))}else{a.style.display="none";a.parentNode.removeChild(a)}if(b!="__invisible__"){WindowUtilities._showSelect()}}},_hideSelect:function(a){if(Prototype.Browser.IE){a=a==null?"":"#"+a+" ";$$(a+"select").each(function(b){if(!WindowUtilities.isDefined(b.oldVisibility)){b.oldVisibility=b.style.visibility?b.style.visibility:"visible";b.style.visibility="hidden"}})}},_showSelect:function(a){if(Prototype.Browser.IE){a=a==null?"":"#"+a+" ";$$(a+"select").each(function(b){if(WindowUtilities.isDefined(b.oldVisibility)){try{b.style.visibility=b.oldVisibility}catch(c){b.style.visibility="visible"}b.oldVisibility=null}else{if(b.style.visibility){b.style.visibility="visible"}}})}},isDefined:function(a){return typeof(a)!="undefined"&&a!=null},initLightbox:function(e,c,a,b){if($(e)){Element.setStyle(e,{zIndex:Windows.maxZIndex+1});Windows.maxZIndex++;a()}else{var d=document.createElement("div");d.setAttribute("id",e);d.className="overlay_"+c;d.style.display="none";d.style.position="absolute";d.style.top="0";d.style.left="0";d.style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex++;d.style.width="100%";b.insertBefore(d,b.firstChild);if(Prototype.Browser.WebKit&&e=="overlay_modal"){setTimeout(function(){a()},10)}else{a()}}},setCookie:function(b,a){document.cookie=a[0]+"="+escape(b)+((a[1])?"; expires="+a[1].toGMTString():"")+((a[2])?"; path="+a[2]:"")+((a[3])?"; domain="+a[3]:"")+((a[4])?"; secure":"")},getCookie:function(c){var b=document.cookie;var e=c+"=";var d=b.indexOf("; "+e);if(d==-1){d=b.indexOf(e);if(d!=0){return null}}else{d+=2}var a=document.cookie.indexOf(";",d);if(a==-1){a=b.length}return unescape(b.substring(d+e.length,a))},_computeSize:function(e,a,b,g,d,f){var i=document.body;var c=document.createElement("div");c.setAttribute("id",a);c.className=f+"_content";if(g){c.style.height=g+"px"}else{c.style.width=b+"px"}c.style.position="absolute";c.style.top="0";c.style.left="0";c.style.display="none";c.innerHTML=e;i.insertBefore(c,i.firstChild);var h;if(g){h=$(c).getDimensions().width+d}else{h=$(c).getDimensions().height+d}i.removeChild(c);return h}};

/*** prototip.js ***/
var Tips={tips:[],zIndex:1200,add:function(a){this.tips.push(a)},remove:function(a){var b=this.tips.find(function(c){return c.element==$(a)});if(!b){return}this.tips=this.tips.reject(function(c){return c==b});b.deactivate();if(b.tooltip){b.wrapper.remove()}if(b.underlay){b.underlay.remove()}}};var Tip=Class.create();Tip.prototype={initialize:function(b,e){this.element=$(b);Tips.remove(this.element);this.content=e;this.options=Object.extend({className:"tooltip",duration:0.3,effect:false,hook:false,offset:(arguments[2]&&arguments[2].hook)?{x:0,y:0}:{x:16,y:16},fixed:false,target:this.element,title:false,viewport:true},arguments[2]||{});this.target=$(this.options.target);if(this.options.hook){this.options.fixed=true;this.options.viewport=false}if(this.options.effect){this.queue={position:"end",limit:1,scope:""};var f="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";for(var a=0;a<6;a++){var d=Math.floor(Math.random()*f.length);this.queue.scope+=f.substring(d,d+1)}}this.buildWrapper();Tips.add(this);this.activate()},activate:function(){this.eventShow=this.showTip.safeBind(this);this.eventHide=this.hideTip.safeBind(this);this.element.observe("mousemove",this.eventShow);this.element.observe("mouseout",this.eventHide)},deactivate:function(){this.element.stopObserving("mousemove",this.eventShow);this.element.stopObserving("mouseout",this.eventHide)},buildWrapper:function(){this.wrapper=document.createElement("div");Element.setStyle(this.wrapper,{position:"absolute",zIndex:Tips.zIndex+1,display:"none"});if(Prototype.Browser.IE){this.underlay=document.createElement("iframe");this.underlay.src="javascript:;";Element.setStyle(this.underlay,{position:"absolute",display:"none",border:0,margin:0,opacity:0.01,padding:0,background:"none",zIndex:Tips.zIndex})}},buildTip:function(){if(Prototype.Browser.IE){document.body.appendChild(this.underlay)}this.tooltip=this.wrapper.appendChild(document.createElement("div"));this.tooltip.className=this.options.className;this.tooltip.style.position="relative";if(this.options.title){this.title=this.tooltip.appendChild(document.createElement("div"));this.title.className="title";Element.update(this.title,this.options.title)}this.tip=this.tooltip.appendChild(document.createElement("div"));this.tip.className="content";Element.update(this.tip,this.content);document.body.appendChild(this.wrapper);var a=this.wrapper.getDimensions();this.wrapper.setStyle({width:a.width+"px",height:a.height+"px"});if(Prototype.Browser.IE){this.underlay.setStyle({width:a.width+"px",height:a.height+"px"})}Element.hide(this.tooltip)},showTip:function(a){if(!this.tooltip){this.buildTip()}this.positionTip(a);if(this.wrapper.visible()&&this.options.effect!="appear"){return}if(Prototype.Browser.IE){this.underlay.show()}this.wrapper.show();if(!this.options.effect){this.tooltip.show()}else{if(this.activeEffect){Effect.Queues.get(this.queue.scope).remove(this.activeEffect)}this.activeEffect=Effect[Effect.PAIRS[this.options.effect][0]](this.tooltip,{duration:this.options.duration,queue:this.queue})}},hideTip:function(a){if(!this.wrapper.visible()){return}if(!this.options.effect){if(Prototype.Browser.IE){this.underlay.hide()}this.tooltip.hide();this.wrapper.hide()}else{if(this.activeEffect){Effect.Queues.get(this.queue.scope).remove(this.activeEffect)}this.activeEffect=Effect[Effect.PAIRS[this.options.effect][1]](this.tooltip,{duration:this.options.duration,queue:this.queue,afterFinish:function(){if(Prototype.Browser.IE){this.underlay.hide()}this.wrapper.hide()}.bind(this)})}},positionTip:function(a){var e={left:this.options.offset.x,top:this.options.offset.y};var f=Position.cumulativeOffset(this.target);var b=this.wrapper.getDimensions();var i={left:(this.options.fixed)?f[0]:Event.pointerX(a),top:(this.options.fixed)?f[1]:Event.pointerY(a)};i.left+=e.left;i.top+=e.top;if(this.options.hook){var k={target:this.target.getDimensions(),tip:b};var l={target:Position.cumulativeOffset(this.target),tip:Position.cumulativeOffset(this.target)};for(var h in l){switch(this.options.hook[h]){case"topRight":l[h][0]+=k[h].width;break;case"bottomLeft":l[h][1]+=k[h].height;break;case"bottomRight":l[h][0]+=k[h].width;l[h][1]+=k[h].height;break}}i.left+=-1*(l.tip[0]-l.target[0]);i.top+=-1*(l.tip[1]-l.target[1])}if(!this.options.fixed&&this.element!==this.target){var c=Position.cumulativeOffset(this.element);i.left+=-1*(c[0]-f[0]);i.top+=-1*(c[1]-f[1])}if(!this.options.fixed&&this.options.viewport){var j=this.getScrollOffsets();var g=this.viewportSize();var d={left:"width",top:"height"};for(var h in d){if((i[h]+b[d[h]]-j[h])>g[d[h]]){i[h]=i[h]-b[d[h]]-2*e[h]}}}this.wrapper.setStyle({left:i.left+"px",top:i.top+"px"});if(Prototype.Browser.IE){this.underlay.setStyle({left:i.left+"px",top:i.top+"px"})}},viewportWidth:function(){if(Prototype.Browser.Opera){return document.body.clientWidth}return document.documentElement.clientWidth},viewportHeight:function(){if(Prototype.Browser.Opera){return document.body.clientHeight}if(Prototype.Browser.WebKit){return this.innerHeight}return document.documentElement.clientHeight},viewportSize:function(){return{height:this.viewportHeight(),width:this.viewportWidth()}},getScrollLeft:function(){return this.pageXOffset||document.documentElement.scrollLeft},getScrollTop:function(){return this.pageYOffset||document.documentElement.scrollTop},getScrollOffsets:function(){return{left:this.getScrollLeft(),top:this.getScrollTop()}}};Function.prototype.safeBind=function(){var a=this,c=$A(arguments),b=c.shift();return function(){if(typeof $A=="function"){return a.apply(b,c.concat($A(arguments)))}}};

/*** ratings.js ***/
// protoype check
if (typeof(Prototype) == 'undefined') { throw('Prototype not loaded'); }

// globals
var rating_submitted = false;

// showRating function
function showRating(num, perm) {
	// already rated?
	if (rating_submitted) { return; }
	
	// permanent?
	if (perm) {
		rating_submitted = true;
	}
	
	// change star classes
	for (var i = 1; i <= 5; i++) {
		if (num == 0) {
			$('rating-star-' + i).removeClassName('temp-white');
			$('rating-star-' + i).removeClassName('hover');
		} else if (i <= num) {
			$('rating-star-' + i).addClassName('hover');
			$('rating-star-' + i).removeClassName('temp-white');
		} else {
			$('rating-star-' + i).removeClassName('hover');
			if (perm) {
				$('rating-star-' + i).removeClassName('marked');
			} else {
				$('rating-star-' + i).addClassName('temp-white');
			}
		}
	}
}

// submitRating function
function submitRating(type, type_id, rating) {
	// validate
	if (!type || !type_id || !rating) { return false; }
	
	rating_submitted = false;
	
	// submit ajax
	new Ajax.Request(
		'/ajax_submit_rating.php',
		{
			method: 'post',
			parameters: {
				form_action: 'submit_rating',
				type:        type,
				type_id:     type_id,
				rating:      rating
		},
		onSuccess: function() {
			showRating(rating, true);
		}
	});
	
	return false;
}


/*** forms.js ***/
// define behavior to highlight field on focus
var FieldFocus = Behavior.create({
  onfocus:function() {
    this.element.addClassName('field-focus');
  },
  onblur:function() {
    this.element.removeClassName('field-focus');
  }
});

// define behavior for textarea maxlength
var TextareaMaxlength = Behavior.create({
  onkeydown:function(event) {
    var obj = this.element;
    var max = $(obj).getAttribute('maxlength');
    if (!max || $F(obj).length < max) {
      return true;
    } else {
      // truncate if already longer
      if ($F(obj).length > max) {
        obj.value = $F(obj).substr(0, parseInt(max) + 1);
      }
      // get keycode
      var keynum = (window.event)
        ? event.keyCode  // IE
        : event.which;   // everything else
      if (
        keynum < 32 || keynum > 126 ||  // control chars
        (keynum > 36 && keynum < 41) || // arrow keys
        keynum == 46                    // backspace
        ) {
        return true;
      }
      // block event
      return false;
    }
  },
  onchange:function() {
    var obj = this.element;
    var max = $(obj).getAttribute('maxlength');
    // truncate if already longer
    if (max && $F(obj).length > max) {
      obj.value = $F(obj).substr(0, parseInt(max) + 1);
    }
  }
});

// add behavior to form fields
function AddFieldFocus(input) {
  // init list
  var list = [];
  
  // check input, can be either array of form ids or an element id
  // if neither, default to all forms in document
  if (IsArray(input)) {
    list = input;
  } else if (input != '' && (input = $(input))) {
    list = $A(input.getElementsByTagName('form'));
  } else {
    list = $A(document.getElementsByTagName('form'));
  }
  
  // add behavior
  list.each(function(form) {
    if (form = $(form)) {
      $A(form.getElements()).each(function(e) {
        var types = ['text', 'textarea', 'select-one', 'select-multiple', 'password'];
        if (types.indexOf(e.type) >= 0) {
          FieldFocus.attach(e);
        }
      });
    }
  });
}
// add behavior to textareas
function AddTextareaMaxlength() {
	$$('textarea[maxlength]').each(function(element) {
		TextareaMaxlength.attach(element);
	});
}

// toggleAllStates function
function toggleAllStates(chk, qid) {
	$$('.'+qid).each(function(obj) {
		obj.checked = chk.checked;
	});
}

// clear "all states" if individual state unchecked
function checkAllStates(chk, quid) {
	if (chk.checked) { return; }
	
	$(quid+'-all-states').checked = false;
}

// add when loaded
Event.observe(window, 'load', function() {
  AddFieldFocus();
	AddTextareaMaxlength();
});

/*** sortable_table.js ***/
var SortableTable={Version:"0.0.1",UpStyle:"up",DownStyle:"down",sortTable:function(f,e,d){if($(e).className==SortableTable.UpStyle){$(e).className=SortableTable.DownStyle}else{$(e).className=SortableTable.UpStyle}for(var c=0;c<$(f).tHead.rows[0].cells.length;++c){if($(f).tHead.rows[0].cells[c]!=$(e)&&$(f).tHead.rows[0].cells[c].className!="nosort"){$(f).tHead.rows[0].cells[c].className=""}}if($(f).tBodies.length==0||$(f).tBodies[0].rows.length==0||$(f).tBodies[0].rows[0].cells.length<d){return}var g=$(f).tBodies[0].rows[0].cells[d].innerHTML;if(g.match(/<input.*?/)){var a="input"}else{var a=$(f).tBodies[0].rows[0].cells[d].innerHTML.stripTags().strip()}var b=new Array();for(var c=0;c<$(f).tBodies[0].rows.length;++c){b[c]=$(f).tBodies[0].rows[c]}if(a.match(/^input/)){b=b.sortBy(function(k,i){var h=k.cells[d].innerHTML;var l=h.substring(h.lastIndexOf('value="')+7);var l=l.substring(0,(l.indexOf('"')));var j=parseFloat(l);return isNaN(j)?0:j})}else{if(a.match(/^[�$]/)){b=b.sortBy(function(i,h){return parseFloat(i.cells[d].innerHTML.stripTags().replace(/[^0-9.]/g,""))})}else{if(a.match(/^[\d\.]+$/)){b=b.sortBy(function(j,h){var i=parseFloat(j.cells[d].innerHTML.stripTags());return isNaN(i)?0:i})}else{if(Date.parse(a)){b=b.sortBy(function(i,h){return Date.parse(i.cells[d].innerHTML.stripTags())})}else{b=b.sortBy(function(i,h){return i.cells[d].innerHTML.stripTags().toLowerCase()})}}}}if($(e).className==SortableTable.DownStyle){b.reverse()}for(var c=0;c<b.length;c++){$(f).tBodies[0].appendChild(b[c])}},load:function(){if(typeof Prototype=="undefined"){throw ("sortable requires Prototype JavaScript framework.")}Event.observe(window,"load",function(){var a=document.getElementsByClassName("sortable");a.each(function(c){if(c.tHead==undefined){return}for(var b=0;b<c.tHead.rows[0].cells.length;++b){if(c.tHead.rows[0].cells[b].className=="nosort"){continue}var d=c.tHead.rows[0].cells[b];d.columnIndex=b;Event.observe(d,"click",function(g){var f=Event.element(g);SortableTable.sortTable(Event.findElement(g,"table"),f,f.columnIndex);StripeTable(c.id)})}})})}};SortableTable.load();

