function PopUpCal(){this._nextId=0;this._inst=[];this._curInst=null;this._disabledInputs=[];this._popUpShowing=false;this._inDialog=false;this.regional=[];this.regional['']={clearText:'Clear',closeText:'Close',prevText:'&lt;Prev',nextText:'Next&gt;',currentText:'Today',dayNames:['Su','Mo','Tu','We','Th','Fr','Sa'],monthNames:['January','February','March','April','May','June','July','August','September','October','November','December'],dateFormat:'DMY/'};this._defaults={autoPopUp:'focus',appendText:'',buttonText:'...',buttonImage:'',buttonImageOnly:false,closeAtTop:true,hideIfNoPrevNext:false,changeMonth:true,changeYear:true,yearRange:'-10:+10',firstDay:0,changeFirstDay:true,showOtherMonths:false,minDate:null,maxDate:null,speed:'',customDate:null,fieldSettings:null,onSelect:null};$.extend(this._defaults,this.regional['']);this._calendarDiv=$('<div id="calendar_div"></div>');$(document.body).append(this._calendarDiv);$(document.body).mousedown(this._checkExternalClick);}
$.extend(PopUpCal.prototype,{_register:function(inst){var id=this._nextId++;this._inst[id]=inst;return id;},_getInst:function(id){return this._inst[id]||id;},setDefaults:function(settings){$.extend(this._defaults,settings||{});},_doKeyDown:function(e){var inst=popUpCal._getInst(this._calId);if(popUpCal._popUpShowing){switch(e.keyCode){case 9:popUpCal.hideCalendar(inst,'');break;case 13:popUpCal._selectDate(inst);break;case 27:popUpCal.hideCalendar(inst,inst._get('speed'));break;case 33:popUpCal._adjustDate(inst,-1,(e.ctrlKey?'Y':'M'));break;case 34:popUpCal._adjustDate(inst,+1,(e.ctrlKey?'Y':'M'));break;case 35:if(e.ctrlKey)popUpCal._clearDate(inst);break;case 36:if(e.ctrlKey)popUpCal._gotoToday(inst);break;case 37:if(e.ctrlKey)popUpCal._adjustDate(inst,-1,'D');break;case 38:if(e.ctrlKey)popUpCal._adjustDate(inst,-7,'D');break;case 39:if(e.ctrlKey)popUpCal._adjustDate(inst,+1,'D');break;case 40:if(e.ctrlKey)popUpCal._adjustDate(inst,+7,'D');break;}}
else if(e.keyCode==36&&e.ctrlKey){popUpCal.showFor(this);}},_doKeyPress:function(e){var inst=popUpCal._getInst(this._calId);var chr=String.fromCharCode(e.charCode==undefined?e.keyCode:e.charCode);return(chr<' '||chr==inst._get('dateFormat').charAt(3)||(chr>='0'&&chr<='9'));},_connectCalendar:function(target,inst){var $input=$(target);var appendText=inst._get('appendText');if(appendText){$input.after('<span class="calendar_append">'+appendText+'</span>');}
var autoPopUp=inst._get('autoPopUp');if(autoPopUp=='focus'||autoPopUp=='both'){$input.focus(this.showFor);}
if(autoPopUp=='button'||autoPopUp=='both'){var buttonText=inst._get('buttonText');var buttonImage=inst._get('buttonImage');var buttonImageOnly=inst._get('buttonImageOnly');var trigger=$(buttonImageOnly?'<img class="calendar_trigger" src="'+
buttonImage+'" alt="'+buttonText+'" title="'+buttonText+'"/>':'<button type="button" class="calendar_trigger">'+(buttonImage!=''?'<img src="'+buttonImage+'" alt="'+buttonText+'" title="'+buttonText+'"/>':buttonText)+'</button>');$input.wrap('<span class="calendar_wrap"></span>').after(trigger);trigger.click(this.showFor);}
$input.keydown(this._doKeyDown).keypress(this._doKeyPress);$input[0]._calId=inst._id;},_inlineCalendar:function(target,inst){$(target).append(inst._calendarDiv);target._calId=inst._id;var date=new Date();inst._selectedDay=date.getDate();inst._selectedMonth=date.getMonth();inst._selectedYear=date.getFullYear();popUpCal._adjustDate(inst);},dialogCalendar:function(dateText,onSelect,settings,pos){var inst=this._dialogInst;if(!inst){inst=this._dialogInst=new PopUpCalInstance({},false);this._dialogInput=$('<input type="text" size="1" style="position: absolute; top: -100px;"/>');this._dialogInput.keydown(this._doKeyDown);$('body').append(this._dialogInput);this._dialogInput[0]._calId=inst._id;}
$.extend(inst._settings,settings||{});this._dialogInput.val(dateText);if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
this._pos=pos||[(windowWidth/2)-100,(windowHeight/2)-100];this._dialogInput.css('left',this._pos[0]+'px').css('top',this._pos[1]+'px');inst._settings.onSelect=onSelect;this._inDialog=true;this._calendarDiv.addClass('calendar_dialog');this.showFor(this._dialogInput[0]);if($.blockUI){$.blockUI(this._calendarDiv);}},enableFor:function(inputs){inputs=(inputs.jquery?inputs:$(inputs));inputs.each(function(){this.disabled=false;$('../button.calendar_trigger',this).each(function(){this.disabled=false;});$('../img.calendar_trigger',this).css({opacity:'1.0',cursor:''});var $this=this;popUpCal._disabledInputs=$.map(popUpCal._disabledInputs,function(value){return(value==$this?null:value);});});},disableFor:function(inputs){inputs=(inputs.jquery?inputs:$(inputs));inputs.each(function(){this.disabled=true;$('../button.calendar_trigger',this).each(function(){this.disabled=true;});$('../img.calendar_trigger',this).css({opacity:'0.5',cursor:'default'});var $this=this;popUpCal._disabledInputs=$.map(popUpCal._disabledInputs,function(value){return(value==$this?null:value);});popUpCal._disabledInputs[popUpCal._disabledInputs.length]=this;});},reconfigureFor:function(control,settings){var inst=this._getInst(control._calId);if(inst){$.extend(inst._settings,settings||{});this._updateCalendar(inst);}},setDateFor:function(control,date){var inst=this._getInst(control._calId);if(inst){inst._setDate(date);}},getDateFor:function(control){var inst=this._getInst(control._calId);return(inst?inst._getDate():null);},showFor:function(target){var input=(target.nodeName&&target.nodeName.toLowerCase()=='input'?target:this);if(input.nodeName.toLowerCase()!='input'){input=$('input',input.parentNode)[0];}
if(popUpCal._lastInput==input){return;}
for(var i=0;i<popUpCal._disabledInputs.length;i++){if(popUpCal._disabledInputs[i]==input){return;}}
var inst=popUpCal._getInst(input._calId);popUpCal.hideCalendar(inst,'');popUpCal._lastInput=input;inst._setDateFromField(input);if(popUpCal._inDialog){input.value='';}
if(!popUpCal._pos){popUpCal._pos=popUpCal._findPos(input);popUpCal._pos[1]+=input.offsetHeight;}
inst._calendarDiv.css('position',(popUpCal._inDialog&&$.blockUI?'static':'absolute')).css('left',popUpCal._pos[0]+'px').css('top',popUpCal._pos[1]+'px');popUpCal._pos=null;var fieldSettings=inst._get('fieldSettings');$.extend(inst._settings,(fieldSettings?fieldSettings(input):{}));popUpCal._showCalendar(inst);},_showCalendar:function(id){var inst=this._getInst(id);popUpCal._updateCalendar(inst);if(!inst._inline){var speed=inst._get('speed');inst._calendarDiv.show(speed,function(){popUpCal._popUpShowing=true;popUpCal._afterShow(inst);});if(speed==''){popUpCal._popUpShowing=true;popUpCal._afterShow(inst);}
if(inst._input[0].type!='hidden'){inst._input[0].focus();}
this._curInst=inst;}},_updateCalendar:function(inst){inst._calendarDiv.empty().append(inst._generateCalendar());if(inst._input&&inst._input!='hidden'){inst._input[0].focus();}},_afterShow:function(inst){if($.browser.msie){$('#calendar_cover').css({width:inst._calendarDiv[0].offsetWidth+4,height:inst._calendarDiv[0].offsetHeight+4});}},hideCalendar:function(id,speed){var inst=this._getInst(id);if(popUpCal._popUpShowing){speed=(speed!=null?speed:inst._get('speed'));inst._calendarDiv.hide(speed,function(){popUpCal._tidyDialog(inst);});if(speed==''){popUpCal._tidyDialog(inst);}
popUpCal._popUpShowing=false;popUpCal._lastInput=null;inst._settings.prompt=null;if(popUpCal._inDialog){popUpCal._dialogInput.css('position','absolute').css('left','0px').css('top','-100px');if($.blockUI){$.unblockUI();$('body').append(this._calendarDiv);}}
popUpCal._inDialog=false;}
popUpCal._curInst=null;},_tidyDialog:function(inst){inst._calendarDiv.removeClass('calendar_dialog');$('.calendar_prompt',inst._calendarDiv).remove();},_checkExternalClick:function(event){if(!popUpCal._curInst){return;}
var target=$(event.target);if((target.parents("#calendar_div").length==0)&&(target.attr('class')!='calendar_trigger')&&popUpCal._popUpShowing&&!(popUpCal._inDialog&&$.blockUI))
{popUpCal.hideCalendar(popUpCal._curInst,'');}},_adjustDate:function(id,offset,period){var inst=this._getInst(id);inst._adjustDate(offset,period);this._updateCalendar(inst);},_gotoToday:function(id){var date=new Date();var inst=this._getInst(id);inst._selectedDay=date.getDate();inst._selectedMonth=date.getMonth();inst._selectedYear=date.getFullYear();this._adjustDate(inst);this._selectDate(inst);},_selectMonthYear:function(id,select,period){var inst=this._getInst(id);inst._selectingMonthYear=false;inst[period=='M'?'_selectedMonth':'_selectedYear']=select.options[select.selectedIndex].value-0;this._adjustDate(inst);},_clickMonthYear:function(id){var inst=this._getInst(id);if(inst._input&&inst._selectingMonthYear&&!$.browser.msie){inst._input[0].focus();}
inst._selectingMonthYear=!inst._selectingMonthYear;},_changeFirstDay:function(id,a){var inst=this._getInst(id);var dayNames=inst._get('dayNames');var value=a.firstChild.nodeValue;for(var i=0;i<7;i++){if(dayNames[i]==value){inst._settings.firstDay=i;break;}}
this._updateCalendar(inst);},_selectDay:function(id,td){var inst=this._getInst(id);inst._selectedDay=$("a",td).html();this._selectDate(id);},_clearDate:function(id){this._selectDate(id,'');},_selectDate:function(id,dateStr){var inst=this._getInst(id);dateStr=(dateStr!=null?dateStr:inst._formatDate());if(inst._input){inst._input.val(dateStr);}
var onSelect=inst._get('onSelect');if(onSelect){onSelect(dateStr);}
else{inst._input.trigger('change');}
if(inst._inline){this._updateCalendar(inst);}
else{this.hideCalendar(inst,inst._get('speed'));}},noWeekends:function(date){var day=date.getDay();return[(day>0&&day<6),''];},_findPos:function(obj){if(obj.type=='hidden'){obj=obj.nextSibling;}
var curleft=curtop=0;if(obj.offsetParent){curleft=obj.offsetLeft;curtop=obj.offsetTop;while(obj=obj.offsetParent){var origcurleft=curleft;curleft+=obj.offsetLeft;if(curleft<0){curleft=origcurleft;}
curtop+=obj.offsetTop;}}
return[curleft,curtop];}});function PopUpCalInstance(settings,inline){this._id=popUpCal._register(this);this._selectedDay=0;this._selectedMonth=0;this._selectedYear=0;this._input=null;this._inline=inline;this._calendarDiv=(!inline?popUpCal._calendarDiv:$('<div id="calendar_div_'+this._id+'" class="calendar_inline"></div>'));if(inline){var date=new Date();this._currentDay=date.getDate();this._currentMonth=date.getMonth();this._currentYear=date.getFullYear();}
this._settings=$.extend({},settings||{});}
$.extend(PopUpCalInstance.prototype,{_get:function(name){return(this._settings[name]!=null?this._settings[name]:popUpCal._defaults[name]);},_setDateFromField:function(input){this._input=$(input);var dateFormat=this._get('dateFormat');var currentDate=this._input.val().split(dateFormat.charAt(3));if(currentDate.length==3){this._currentDay=parseInt(currentDate[dateFormat.indexOf('D')],10);this._currentMonth=parseInt(currentDate[dateFormat.indexOf('M')],10)-1;this._currentYear=parseInt(currentDate[dateFormat.indexOf('Y')],10);}
else{var date=new Date();this._currentDay=date.getDate();this._currentMonth=date.getMonth();this._currentYear=date.getFullYear();}
this._selectedDay=this._currentDay;this._selectedMonth=this._currentMonth;this._selectedYear=this._currentYear;this._adjustDate();},_setDate:function(date){this._selectedDay=this._currentDay=date.getDate();this._selectedMonth=this._currentMonth=date.getMonth();this._selectedYear=this._currentYear=date.getFullYear();this._adjustDate();},_getDate:function(){return new Date(this._currentYear,this._currentMonth,this._currentDay);},_generateCalendar:function(){var today=new Date();today=new Date(today.getFullYear(),today.getMonth(),today.getDate());var controls='<div class="calendar_control">'+'<a class="calendar_clear" onclick="popUpCal._clearDate('+this._id+');">'+
this._get('clearText')+'</a>'+'<a class="calendar_close" onclick="popUpCal.hideCalendar('+this._id+');">'+
this._get('closeText')+'</a></div>';var prompt=this._get('prompt');var closeAtTop=this._get('closeAtTop');var hideIfNoPrevNext=this._get('hideIfNoPrevNext');var html=(prompt?'<div class="calendar_prompt">'+prompt+'</div>':'')+
(closeAtTop&&!this._inline?controls:'')+'<div class="calendar_links">'+
(this._canAdjustMonth(-1)?'<a class="calendar_prev" '+'onclick="popUpCal._adjustDate('+this._id+', -1, \'M\');">'+this._get('prevText')+'</a>':(hideIfNoPrevNext?'':'<label class="calendar_prev">'+this._get('prevText')+'</label>'))+
(this._isInRange(today)?'<a class="calendar_current" '+'onclick="popUpCal._gotoToday('+this._id+');">'+this._get('currentText')+'</a>':'')+
(this._canAdjustMonth(+1)?'<a class="calendar_next" '+'onclick="popUpCal._adjustDate('+this._id+', +1, \'M\');">'+this._get('nextText')+'</a>':(hideIfNoPrevNext?'':'<label class="calendar_next">'+this._get('nextText')+'</label>'))+'</div><div class="calendar_header">';var minDate=this._get('minDate');var maxDate=this._get('maxDate');var monthNames=this._get('monthNames');if(!this._get('changeMonth')){html+=monthNames[this._selectedMonth]+'&nbsp;';}
else{var inMinYear=(minDate&&minDate.getFullYear()==this._selectedYear);var inMaxYear=(maxDate&&maxDate.getFullYear()==this._selectedYear);html+='<select class="calendar_newMonth" '+'onchange="popUpCal._selectMonthYear('+this._id+', this, \'M\');" '+'onclick="popUpCal._clickMonthYear('+this._id+');">';for(var month=0;month<12;month++){if((!inMinYear||month>=minDate.getMonth())&&(!inMaxYear||month<=maxDate.getMonth())){html+='<option value="'+month+'"'+
(month==this._selectedMonth?' selected="selected"':'')+'>'+monthNames[month]+'</option>';}}
html+='</select>';}
if(!this._get('changeYear')){html+=this._selectedYear;}
else{var years=this._get('yearRange').split(':');var year=0;var endYear=0;if(years.length!=2){year=this._selectedYear-10;endYear=this._selectedYear+10;}
else if(years[0].charAt(0)=='+'||years[0].charAt(0)=='-'){year=this._selectedYear+parseInt(years[0],10);endYear=this._selectedYear+parseInt(years[1],10);}
else{year=parseInt(years[0],10);endYear=parseInt(years[1],10);}
year=(minDate?Math.max(year,minDate.getFullYear()):year);endYear=(maxDate?Math.min(endYear,maxDate.getFullYear()):endYear);html+='<select class="calendar_newYear" onchange="popUpCal._selectMonthYear('+
this._id+', this, \'Y\');" '+'onclick="popUpCal._clickMonthYear('+
this._id+');">';for(;year<=endYear;year++){html+='<option value="'+year+'"'+
(year==this._selectedYear?' selected="selected"':'')+'>'+year+'</option>';}
html+='</select>';}
html+='</div><table class="calendar" cellpadding="0" cellspacing="0"><thead>'+'<tr class="calendar_titleRow">';var firstDay=this._get('firstDay');var changeFirstDay=this._get('changeFirstDay');var dayNames=this._get('dayNames');for(var dow=0;dow<7;dow++){html+='<td>'+(!changeFirstDay?'':'<a onclick="popUpCal._changeFirstDay('+
this._id+', this);">')+dayNames[(dow+firstDay)%7]+
(changeFirstDay?'</a>':'')+'</td>';}
html+='</tr></thead><tbody>';var daysInMonth=this._getDaysInMonth(this._selectedYear,this._selectedMonth);this._selectedDay=Math.min(this._selectedDay,daysInMonth);var leadDays=(this._getFirstDayOfMonth(this._selectedYear,this._selectedMonth)-firstDay+7)%7;var currentDate=new Date(this._currentYear,this._currentMonth,this._currentDay);var selectedDate=new Date(this._selectedYear,this._selectedMonth,this._selectedDay);var printDate=new Date(this._selectedYear,this._selectedMonth,1-leadDays);var numRows=Math.ceil((leadDays+daysInMonth)/7);var customDate=this._get('customDate');var showOtherMonths=this._get('showOtherMonths');for(var row=0;row<numRows;row++){html+='<tr class="calendar_daysRow">';for(var dow=0;dow<7;dow++){var customSettings=(customDate?customDate(printDate):[true,'']);var otherMonth=(printDate.getMonth()!=this._selectedMonth);var unselectable=otherMonth||!customSettings[0]||(minDate&&printDate<minDate)||(maxDate&&printDate>maxDate);html+='<td class="calendar_daysCell'+
((dow+firstDay+6)%7>=5?' calendar_weekEndCell':'')+
(otherMonth?' calendar_otherMonth':'')+
(printDate.getTime()==selectedDate.getTime()?' calendar_daysCellOver':'')+
(unselectable?' calendar_unselectable':'')+
(!otherMonth||showOtherMonths?' '+customSettings[1]:'')+
(printDate.getTime()==currentDate.getTime()?' calendar_currentDay':(printDate.getTime()==today.getTime()?' calendar_today':''))+'"'+
(unselectable?'':' onmouseover="$(this).addClass(\'calendar_daysCellOver\');"'+' onmouseout="$(this).removeClass(\'calendar_daysCellOver\');"'+' onclick="popUpCal._selectDay('+this._id+', this);"')+'>'+
(otherMonth?(showOtherMonths?printDate.getDate():'&nbsp;'):(unselectable?printDate.getDate():'<a>'+printDate.getDate()+'</a>'))+'</td>';printDate.setDate(printDate.getDate()+1);}
html+='</tr>';}
html+='</tbody></table>'+(!closeAtTop&&!this._inline?controls:'')+'<div style="clear: both;"></div>'+(!$.browser.msie?'':'<!--[if lte IE 6.5]><iframe src="javascript:false;" class="calendar_cover"></iframe><![endif]-->');return html;},_adjustDate:function(offset,period){this._selectedYear+=(period=='Y'?offset:0);this._selectedMonth+=(period=='M'?offset:0);if(period=='D'){this._selectedDay+=offset;}else{this._selectedDay=Math.min(this._selectedDay,this._getDaysInMonth(this._selectedYear,this._selectedMonth));}
var date=new Date(this._selectedYear,this._selectedMonth,this._selectedDay);var minDate=this._get('minDate');var maxDate=this._get('maxDate');date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);this._selectedDay=date.getDate();this._selectedMonth=date.getMonth();this._selectedYear=date.getFullYear();},_getDaysInMonth:function(year,month){return 32-new Date(year,month,32).getDate();},_getFirstDayOfMonth:function(year,month){return new Date(year,month,1).getDay();},_canAdjustMonth:function(offset){var date=new Date(this._selectedYear,this._selectedMonth+offset,1);if(offset<0){date.setDate(this._getDaysInMonth(date.getFullYear(),date.getMonth()));}
return this._isInRange(date);},_isInRange:function(date){var minDate=this._get('minDate');var maxDate=this._get('maxDate');return((!minDate||date>=minDate)&&(!maxDate||date<=maxDate));},_formatDate:function(){var day=this._currentDay=this._selectedDay;var month=this._currentMonth=this._selectedMonth;var year=this._currentYear=this._selectedYear;month++;var dateFormat=this._get('dateFormat');var dateString='';for(var i=0;i<3;i++){dateString+=dateFormat.charAt(3)+
(dateFormat.charAt(i)=='D'?(day<10?'0':'')+day:(dateFormat.charAt(i)=='M'?(month<10?'0':'')+month:(dateFormat.charAt(i)=='Y'?year:'?')));}
return dateString.substring(dateFormat.charAt(3)?1:0);}});$.fn.calendar=function(settings){return this.each(function(){var inlineSettings=null;for(attrName in popUpCal._defaults){var attrValue=this.getAttribute('cal:'+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue);}
catch(err){inlineSettings[attrName]=attrValue;}}}
var nodeName=this.nodeName.toLowerCase();if(nodeName=='input'){var instSettings=(inlineSettings?$.extend($.extend({},settings||{}),inlineSettings||{}):settings);var inst=(inst&&!inlineSettings?inst:new PopUpCalInstance(instSettings,false));popUpCal._connectCalendar(this,inst);}
else if(nodeName=='div'||nodeName=='span'){var instSettings=$.extend($.extend({},settings||{}),inlineSettings||{});var inst=new PopUpCalInstance(instSettings,true);popUpCal._inlineCalendar(this,inst);}});};$(document).ready(function(){popUpCal=new PopUpCal();});

jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};

function AJAXException(message){this.message=message;this.toString=function(){return'AJAXException: '+this.message;}}
function AJAXDomToObjectConverter(){this.getBool=function(node){return(node.firstChild.nodeValue=='1')?true:false;}
this.getInt=function(node){return parseInt(node.firstChild.nodeValue);}
this.getFloat=function(node){return parseFloat(node.firstChild.nodeValue);}
this.getArray=function(node){var arr=new Array();for(var i=0;i<node.childNodes.length;i++){if(node.childNodes.item(i).nodeType==1){arr.push(this.getValue(node.childNodes.item(i)));}}
return arr;}
this.getObject=function(node){var obj=new Object();this.convert(node,obj);return obj;}
this.getString=function(node){try{return node.firstChild.nodeValue;}catch(ex){return'';}}
this.getValue=function(node){var attr=node.attributes.getNamedItem('type');var type=(attr)?attr.nodeValue:'string';switch(type){case'null':return null;case'bool':return this.getBool(node);case'int':return this.getInt(node);case'float':return this.getFloat(node);case'array':return this.getArray(node);case'object':return this.getObject(node);default:return this.getString(node);}}
this.convert=function(node,obj){for(var i=0;i<node.childNodes.length;i++){if(node.childNodes.item(i).nodeType==1){var child=node.childNodes.item(i);var name=child.nodeName;obj[name]=this.getValue(child);}}}
this.toString=function(){return'AJAXDomToObjectConverter';}}
function AJAXResponse(dom){var dom2obj=new AJAXDomToObjectConverter();dom2obj.convert(dom,this);this.toString=function(){return'AJAXResponse';}}
function AJAXRequest(url,callback){this.url=url;this.createHttp=function(callback){var http=(navigator.appName.indexOf('Microsoft')>=0)?new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();http.onreadystatechange=function(){if(http.readyState==4){if(http.status==200){try{var rootNode;if(http.responseXML&&(rootNode=http.responseXML.documentElement)){rootNode.normalize();if('response'==rootNode.nodeName){callback(new AJAXResponse(rootNode));}else if('error'==rootNode.nodeName){var error=new AJAXResponse(rootNode);throw new AJAXException("There were errors while processing request by server side:\n\n"
+error.message+"\n"
+error.description);}else{throw new AJAXException("Unsupported response format:\n"+http.responseText);}}else{callback(http.responseText);}}catch(ex){throw new AJAXException(ex.message);}}else{throw new AJAXException("There was a problem retrieving the XML data:\n"+http.statusText);}}}
return http;}
this.http=this.createHttp(callback);this.send=function(content){if(content&&content.length>0){this.http.open('POST',this.url,true);this.http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');this.http.send(content);}else{this.http.open('GET',this.url,true);this.http.send(null);}}
this.toString=function(){return'AJAXRequest';}}
function AJAX(){this.urlEncode=function(str){if(str==null)return'';str=encodeURI(str);str=str.replace(/\+/g,"%2B");return str.replace(/&/g,"%26");}
this.sendRequest=function(command,callback,params){if(typeof(params)=='undefined'){params={};}
if(arguments[3]!=true){$("#loading").show();showLoading=true;}
if(arguments[4]=='POST'){$.post(command,params,callback,"json");}else{$.getJSON(command,params,callback);}}
this.sendRequestWithTimeout=function(command,callback,params,timeout,errorCallback){if(typeof(params)=='undefined'){params={};}
if(arguments[5]!=true){$("#loading").show();showLoading=true;}
if(jQuery.isFunction(params)){callback=params;params=null;}
jQuery.ajax({type:"GET",url:command,data:params,timeout:timeout,error:errorCallback,success:callback,dataType:'json'});}
this.sendRequestAuto=function(command,callback,params){var req=new AJAXRequest(command,callback);var content='';for(var i=2;i<arguments.length;i++){for(var name in arguments[i]){var value=arguments[i][name];content+=this.urlEncode(name)+'='+this.urlEncode(value)+'&';}}
req.send(content);}
this.toString=function(){return'AJAX';}}
var ajax=new AJAX();

function centerPos(width,height){var scrollLeft=document.documentElement.scrollLeft;var scrollTop=document.documentElement.scrollTop;if($.browser.safari){scrollLeft=document.body.scrollLeft;scrollTop=document.body.scrollTop;}
var x=(document.documentElement.clientWidth-width)/2+scrollLeft;var y=(document.documentElement.clientHeight-height)/2+scrollTop;x=(x<0)?0:x;y=(y<0)?0:y;return{'x':x,'y':y}}
function elementPos(el){var offset=$(el).offset();return{'x':offset.left,'y':offset.top}}
function displayWindow(obj,width,height,draggable,leftShift,topShift,el){leftShift=leftShift||0;topShift=topShift||0;if(height==0){height=obj.height();}
obj.css('display','block');obj.css('width',width);obj.css('min-height',height);obj.css('position','absolute');if(el){pos=elementPos(el);}else{pos=centerPos(width,obj.height());}
obj.css('left',pos.x-leftShift+'px');obj.css('top',pos.y-topShift+'px');obj.bgiframe();if(draggable){obj.draggable({handle:'.ui-drag-bar',cancel:'td,input,select,textarea,.can-copy'});}}
function openWindow(id,src,width,height,draggable,leftShift,topShift,el,callback){$('#'+id).remove();$('body').append('<div id="'+id+'" class="popup-body popup-window"></div>');var obj=$('#'+id);var load_callback=function(){if(typeof callback=='function'){callback.apply(this);}
displayWindow(obj,width,height,draggable,leftShift,topShift,el);}
obj.load(src,{},load_callback);}
function closeWindow(id){$('#'+id).remove();}
function hideWindow(id){$('#'+id).css('display','none');}

function formatBidPrice(bid,isCutOff){if(isCutOff==null)
{isCutOff=1;}
var str=String(bid);var end=str.indexOf('.');if(end==-1){end=str.length;}
str=str.substring(0,end);var result='';while(str.length>3){strCut=str.substring(str.length-3,str.length);str=str.substring(0,str.length-3);result=','+strCut+result;}
return str+result+((isCutOff)?'':'.00');}
var htmlCalculator;function HTMLCalculator(){var wnd=$('<div>');wnd.css('position','absolute');wnd.css('left',-2000);wnd.css('top',0);wnd.css('z-index',-1);$('body').append(wnd);this.body=wnd;this.calculate=function(text,options,breakWords){for(var i in options){this.body.css(i,options[i]);}
this.body[0].innerHTML=(breakWords)?breakLongWords(text):text;var width=this.body.width();var height=this.body.height();this.reset();return{"width":width,"height":height};}
this.reset=function(){this.body.css('width','auto');this.body.css('height','auto');this.body.css('font-size','12px');this.body.css('font-weight','');this.body.html('');}}
function getHTMLCalculator(){if(!htmlCalculator){htmlCalculator=new HTMLCalculator();}
return htmlCalculator;}
function cutHTML(node,maxWidth,maxHeight,eps){var isCutted=false;var maxNumber=node.text().length;var cutText=node[0].innerHTML;var calc=getHTMLCalculator();var height=calc.calculate(cutText,{'width':maxWidth},true).height;eps=eps||Math.min(Math.max(Math.round(maxNumber/100),1),30);if(height>=maxHeight){var end=false;var step=-Math.round(maxNumber/2);var bestHeight=0;var bestText=cutText;while(!end){maxNumber=maxNumber+step;cutText=node.truncate({max_length:maxNumber});height=calc.calculate(cutText,{'width':maxWidth},true).height;if(height>=maxHeight){step=-Math.abs(Math.round(step/2));}else{step=Math.abs(Math.round(step/2));if(height>bestHeight){bestHeight=height;bestText=cutText;}}
end=(Math.abs(step)<eps);}
cutText=bestText;isCutted=true;}
return{'text':cutText,'isCutted':isCutted}}
function cutText(text,length){if(text.length>length){return text.substring(0,length)+"...";}
return text;}
function breakLongWords(text,step){text=text.replace(/&nbsp;/ig," ");text=text.replace(/&quot;/ig,"\"");step=step||20;var openTag=false,result='',count=0,currentChar='';for(var i=0;i<text.length;i++){currentChar=text.charAt(i);result=result+currentChar;if(currentChar=="<"||text.substr(i,4)=='&lt;'){openTag=true;continue;}
if(openTag&&(currentChar==">"||(i>=4&&text.substr(i-4,4)=='&gt;'))){openTag=false;continue;}
if(!openTag){count=(currentChar==" ")?0:count+1;if(count>=step){result=result+"<wbr/>";count=0;}}}
return result;}
var timerShowId=null;var timerHideId=null;var defaultProgressShowTime=500;var defaultHideTimeout=3000;function showHelpProcess(id,el,timeout,timeoutBeforeShow){var show=function(){$(el).trigger('showhelp');showHelp(id,el,timeout);}
timerShowId=window.setTimeout(show,timeoutBeforeShow||defaultProgressShowTime);}
function hideHelpProcess(closeNow){cancelHelpHide();timeout=$("#helpWindow").data('timeout')||defaultHideTimeout;if(closeNow){timeout=0;}
var hide=function(){var el=$("#helpWindow").data('element');$(el).trigger('hidehelp');$("#helpWindow").hide();}
timerHideId=window.setTimeout(hide,timeout);}
function getHelpWindow(){return $('#helpWindow').css('z-index',500).show();}
function showHelp(text,el,timeout){cancelHelpShow();cancelHelpHide();var wnd=getHelpWindow();wnd.find('#help_content')[0].innerHTML=text;if($.browser.msie&&$.browser.version.substr(0,1)<=6){wnd.find('#help_content').css('width','auto');wnd.css('width','');var width=wnd.find('#help_content')[0].offsetWidth+20;if(width>parseInt(wnd.css('max-width'))){width=parseInt(wnd.css('max-width'));}else if(width<parseInt(wnd.css('min-width'))){width=parseInt(wnd.css('min-width'));}
wnd.css('width',width);wnd.find('#help_content').css('width','100%');}
var wndHeight=wnd[0].offsetHeight;var wndWidth=wnd[0].offsetWidth;var offset=$(el).offset();var left=offset.left;var top=offset.top+$(el).height()+2;var scrollTop=($.browser.safari)?document.body.scrollTop:document.documentElement.scrollTop;var scrollLeft=($.browser.safari)?document.body.scrollLeft:document.documentElement.scrollLeft;if(left+wndWidth-scrollLeft>document.documentElement.clientWidth){left=document.documentElement.clientWidth-wndWidth+scrollLeft-10;}
if(top+wndHeight-scrollTop>document.documentElement.clientHeight){top=offset.top-wndHeight;}
wnd.css('left',Math.max(left,0));wnd.css('top',Math.max(top,0));wnd.removeData('timeout');hideHelpProcess();wnd.data('timeout',timeout||defaultHideTimeout);wnd.data('element',el);}
function cancelHelpShow(){window.clearTimeout(timerShowId);}
function cancelHelpHide(){window.clearTimeout(timerHideId);}
function validateEmail(email){var reg=/^([A-Za-z0-9_\-\.\+\!\#\$\%\*\/\?\|\^\{\}\`\~\&\'\=])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;return reg.test(email.toString());}
function validateDomain(domain){var reg=/^(?!www\.|-)[-a-z0-9]*[a-z0-9](\.[a-z]{2,63})?\.[a-z]{2,63}$/i;return reg.test(domain.toString())&&domain.length<256;}
function validateNickname(nick){var reg=/[^-A-Za-z0-9_\s]/;return!reg.test(nick.toString());}
function checkIntegerOnly(value){var reg=/^\d+(.0+)*$/;return reg.test(value.toString());}
function checkFloatOnly(value){var reg=/^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;return reg.test(value.toString());}
function validateZip(value){var reg=/^(([A-Za-z0-9-]{3,10})|([a-z0-9-]{3,5}\s?[a-z0-9]{0,5}))$/i;return reg.test(value.toString());}
function validateFirstName(value){var reg=/^[A-z- ]+$/;return reg.test(value.toString());}
function validateLastName(value){var reg=/^[A-z- ]+$/;return reg.test(value.toString());}
function validateDate(day,month,year){if(!checkIntegerOnly(day)){alert(day);return false;}
if(year.length!=4){return false;}
if(month>12||month<1){return false;}
var max_day=31;if(month==4||month==6||month==9||month==11){max_day=30;}else if(month==2){if(year%4==0){max_day=29;}else{max_day=28;}}
if(day>max_day||day<1){return false;}
return true;}
function validateTime(hour,minute){if(hour>24||hour<1){return false;}
if(minute>59||minute<0){return false;}
return true;}
function checkCreditCardNumber(number){if(checkIntegerOnly(number)&&(number.length==15)){return true;}
if(!checkIntegerOnly(number)||(number.length!=16)){return false;}
var numSum=0;for(i=number.length-1;i>=0;i--){c=number.charAt(i);if(i%2==1){currentNum=parseInt(c);}else{currentNum=parseInt(c)*2;}
if(currentNum>9){firstNum=currentNum%10;secondNum=(currentNum-firstNum)/10;currentNum=firstNum+secondNum;}
numSum+=currentNum;}
return(numSum%10==0);}
function checkPhone(phone){if(!phone){return false;}
if(isNaN(phone.charAt(0))&&phone.charAt(0)!='('&&phone.charAt(0)!='+'){return false;}
if(phone.charAt(phone.length-1)=='('||phone.charAt(phone.length-1)=='-'||phone.charAt(phone.length-1)==')'){return false;}
if(phone.match(/[^-0-9 ()+]/)){return false;}
phone=phone.replace(/ \(/,'(').replace(/\) /,')');for(i=0;i<phone.length;i++){if((phone.charAt(i)==' ')||(phone.charAt(i)=='(')||(phone.charAt(i)==')')||(phone.charAt(i)=='-')){if(isNaN(phone.charAt(i+1))||(phone.charAt(i+1)==' ')||isNaN(phone.charAt(i-1))||(phone.charAt(i-1)==' ')||(phone.charAt(i-1)==')')||(phone.charAt(i+1)=='(')||(phone.charAt(i-1)=='-')||(phone.charAt(i+1)=='-')){return false;}}}
return true;}
function escapeHTML(text){var str=String(text);str=str.replace(/&/g,"&amp;");str=str.replace(/</g,"&lt;");str=str.replace(/>/g,"&gt;");str=str.replace(/\"/g,"&quot;");str=str.replace(/\n/g,"<br/>");str=str.replace(/\'/g,"&#39;");return str;}
function cursorLoading(flag){var tstyle;var disabled=(flag)?false:true;if($.browser.msie){tstyle=document.styleSheets('cursor_wait');tstyle.disabled=disabled;}else{tstyle=document.getElementById("cursor_wait");tstyle.sheet.disabled=disabled;}}
function getAbsX(element){var x=element.offsetLeft;while(element=element.offsetParent){x+=element.offsetLeft;x-=element.scrollLeft;}
return($.browser.msie?document.documentElement.scrollLeft:document.body.scrollLeft)+x;}
function getAbsY(element){var y=element.offsetTop;while(element=element.offsetParent){y+=element.offsetTop;y-=element.scrollTop;}
return($.browser.msie?document.documentElement.scrollTop:document.body.scrollTop)+y;}
function secondsToTime(seconds){var secPerDay=86400;var secPerHour=3600;var secPerMinute=60;seconds=seconds+59;var dd=Math.floor(seconds/secPerDay);var hh=Math.floor(seconds%secPerDay/secPerHour);var mm=Math.floor(seconds%secPerDay%secPerHour/secPerMinute);if(seconds<secPerHour){return(mm==1)?"< 1 minute":mm+' minutes';}else{return(dd?dd+'d ':'')+(hh?hh+'h ':'')+mm+'m';}}
var dateFormat=function(){var token=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g;var timezone=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;var timezoneClip=/[^-+\dA-Z]/g;var pad=function(val,len){val=String(val);len=len||2;while(val.length<len)val="0"+val;return val;};return function(date,mask,utc){var dF=dateFormat;if(arguments.length==1&&Object.prototype.toString.call(date)=="[object String]"&&!/\d/.test(date)){mask=date;date=undefined;}
date=date?new Date(date):new Date;if(isNaN(date))throw SyntaxError("invalid date");mask=String(dF.masks[mask]||mask||dF.masks["default"]);if(mask.slice(0,4)=="UTC:"){mask=mask.slice(4);utc=true;}
var _=utc?"getUTC":"get";var d=date[_+"Date"]();var D=date[_+"Day"]();var m=date[_+"Month"]();var y=date[_+"FullYear"]();var H=date[_+"Hours"]();var M=date[_+"Minutes"]();var s=date[_+"Seconds"]();var L=date[_+"Milliseconds"]();var o=utc?0:date.getTimezoneOffset();var flags={d:d,dd:pad(d),ddd:dF.i18n.dayNames[D],dddd:dF.i18n.dayNames[D+7],m:m+1,mm:pad(m+1),mmm:dF.i18n.monthNames[m],mmmm:dF.i18n.monthNames[m+12],yy:String(y).slice(2),yyyy:y,h:H%12||12,hh:pad(H%12||12),H:H,HH:pad(H),M:M,MM:pad(M),s:s,ss:pad(s),l:pad(L,3),L:pad(L>99?Math.round(L/10):L),t:H<12?"a":"p",tt:H<12?"am":"pm",T:H<12?"A":"P",TT:H<12?"AM":"PM",Z:utc?"UTC":(String(date).match(timezone)||[""]).pop().replace(timezoneClip,""),o:(o>0?"-":"+")+pad(Math.floor(Math.abs(o)/60)*100+Math.abs(o)%60,4),S:["th","st","nd","rd"][d%10>3?0:(d%100-d%10!=10)*d%10]};return mask.replace(token,function($0){return $0 in flags?flags[$0]:$0.slice(1,$0.length-1);});};}();dateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};dateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};Date.prototype.format=function(mask,utc){return dateFormat(this,mask,utc);};$.fn.priceKeyFilter=function(){$(this).unbind('keydown keyup').bind('keydown',function(){if($(this).attr('oldValue')==null){$(this).attr('oldValue',$(this).val());}}).bind('keyup',function(){var oldValue=$(this).attr('oldValue');oldValue=isNaN(oldValue)||oldValue==null?'':oldValue;$(this).removeAttr('oldValue');var value=parseInt($(this).val());if($(this).val()!=''&&(isNaN(value)||value<=0||value!=$(this).val())){$(this).val(oldValue)[0].focus();}})};function calcTitleFontSize(title){var calc=getHTMLCalculator();var fontSize=17,minSize=10,width=calc.calculate(title,{'font-size':fontSize,'font-weight':'bold'}).width;while(width>170&&fontSize>minSize){fontSize=fontSize-1;width=calc.calculate(title,{'font-size':fontSize,'font-weight':'bold'}).width;}
return fontSize;}
jQuery.fn.priceFilter=function(){var format=/^([0-9]*(\.0{0,2})?)?$/;this.bind('keydown',function(){if($(this).data('old-value')==null){$(this).data('old-value',$(this).val());}}).bind('keyup',function(){if(!format.test($(this).val())){$(this).blur();}
$(this).removeData('old-value');}).bind('blur',function(){var input=$(this);var old_value=typeof input.data('old-value')=='undefined'?'':input.data('old-value');if(format.test(input.val())){input.val(input.val().replace(/^0+/,'').replace(/\.0*$/,''));}else{alert('Please enter whole dollar amounts only.',function(){input.val(old_value).focus();});}});return this;}
function extend(Child,Parent){var F=function(){}
F.prototype=Parent.prototype;Child.prototype=new F();Child.prototype.constructor=Child;Child.superclass=Parent.prototype;}
$.preloadImages=function(){$.each(arguments,function(){$("<img>").attr('src',this);});}

var commentsSettings={}
function editComment(id,mode){switchDisplay('#edit_'+id,'#show_'+id);if(mode){if(oEditors['text_'+id]==undefined){createEditor('text_'+id,mode);}}else{var html=$('#text_'+id).attr('value');html=html.replace(/<br\/>/g,'\n');$('#text_'+id).attr('value',html);}}
function deleteComment(id){if(confirm('Delete comment?')){ajax.sendRequest('/ajax.DeleteComment',function(response){if(response.status=='OK'){alert(response.message);$('#edit_0').hide();$('#show_0').show();$('#text_0').val('');getComments('page='+currentPage);showAddButton();}else{}},{'id':id});}}
function saveComment(auction,id,user,cut,isAdmin){var html;if(isAdmin){if(isActual){oEditors['text_'+id].setEditorHTML($('#text_'+id).attr('value'));}
html=oEditors['text_'+id].getEditorHTML();html=html.replace(/\n/g,'<br/>');}else{html=$('#text_'+id).attr('value');html=escapeHTML(html);}
if(html.length==0||html=='<br>'){alert("Please fill comment field.");return false;}
html=html.replace(/(<|&lt;)script.*(<|&lt;)\/script(>|&gt;)/ig,"");var cuttedSize=getCuttedSize(html);ajax.sendRequest('/ajax.SaveComment',function(response){if(response.status=='OK'){if(isAdmin){alert('Comment was saved.',function(){document.location=document.location;});}else{$('#user_comment').hide();try{getComments('page='+currentPage);alert(response.message);}catch(err){alert(response.message,function(){document.location=document.location;});}
getComment(auction);}}else{alert(response.message,function(){document.location=document.location;});}},{'auction':auction,'comment':id,'text':html,'cut':cut,'cuttedSize':cuttedSize},false,'POST');}
function getComment(auction){ajax.sendRequest('/ajax.GetComment',function(response){if(response.status=='OK'){if(response.approved){return;}
if(response.comment){$('#no-comments').hide();$('#notApprovedLink').show();$('#user_comment').html(response.comment);}else{showAddButton();}}},{'auction':auction},true);}
function showAddButton(){if($('#no-comments').css('display')=='none'){$('.addCommentButton').show();$('.commentsHeader').show();}else{$('#addCommentBtnIn').show();}}
function getCuttedSize(text){var wnd=$('#temporary_node');if(!wnd){wnd=$('<div>');wnd.css('position','absolute');wnd.css('left',-2000);wnd.css('top',0);wnd.css('z-index',-1);}
try{$('body').append(wnd);wnd[0].innerHTML=text;var cutted=cutHTML(wnd,473,150,2);return(cutted.isCutted)?cutted.text.length:0;}catch(ex){}
return 0;}
function showComment(id){$('#no-comments').css('display','none');$('#comment_'+id).css('display','block');editComment(id);}
function cancelEditingComment(id){switchDisplay('#show_'+id,'#edit_'+id);}
function switchDisplay(id1,id2){style=$(id1).css('display');$(id1).css('display',$(id2).css('display'));$(id2).css('display',style);}
function cutScripts(text){text=text.replace(/<script>/ig,"&lt;script&gt;");text=text.replace(/<\/script>/ig,"&lt;/script&gt;");text=text.replace(/<iframe/ig,"&lt;iframe");return text;}
function setPosition(comment,position){ajax.sendRequest('/ajax.SetCommentPosition',function(response){if(response.status!='OK'){alert(response.message);}},{'id':comment,'position':position});}
function approve(id){ajax.sendRequest('/ajax.ApproveComment',function(response){if(response.status!='OK'){alert(response.message);}else{var text='Approve ('+response.approves+' of '+needApproves+')';document.getElementById('approve_'+response.id).innerHTML=text;}},{'id':id});}
var refuseCommentId=0;function refuse(){hideWindow('refuseWindow');var reason=document.getElementById('reason').value;cursorLoading(true);ajax.sendRequest('/ajax.RefuseComment',function(response){cursorLoading(false);if(response.status!='OK'){alert(response.message);}else{var comment=$('#comments_'+response.id)||$('#comment_'+response.id);if(comment.length){comment.hide();}else{document.location.reload(true);}}},{'id':refuseCommentId,'reason':reason});}
function showRefuseWindow(id){document.getElementById('reason').value='';refuseCommentId=id;displayWindow($('#refuseWindow'),330,260,true);}
function vote(id,type){var name='vote'+id;if(parseInt($.cookie(name))!=1){ajax.sendRequest('/ajax.VoteForComment',function(response){if(response.status=='OK'){$.cookie(name,'1',{expires:1});$('#thumbs_'+id+'_for').attr('onclick','').removeClass('cursor');thumbs=$('div.thumbs_'+id+'_'+type);thumbs.html('('+response.votes+')');}},{'id':id,'type':type});}}
function abuse(id,sourceType){if(!sourceType){sourceType='Comment';}
if(confirm('Send abuse report?')){ajax.sendRequest('/ajax.ReportAbuse',function(response){if(response.status=='OK'){document.getElementById('abuse_'+response.id).style.display='none';}
alert(response.message);},{'id':id,'type':sourceType});}}
function feature(id,auction){var value=$('#feature_'+id).text()=='Feature'?1:0;ajax.sendRequest('/ajax.FeatureComment',function(response){if(response.status!='OK'){alert(response.message);}else{if(response.featured){$('.featured_'+auction).css('color','#999b9d');$('#feature_'+response.id).css('color','');$('#comment_body_'+response.id).addClass('featured_commentary');$('#comment_body_row_'+response.id).css('background-color','#ffe6e6');$('#comment_body_row_'+response.id+'>td:first').css('border-width','1px 0px 1px 1px');$('#comment_body_row_'+response.id+'>td:last').css('border-width','1px 1px 1px 0px');$('#comment_body_row_'+response.id+'>td').css('border-style','solid');$('#comment_body_row_'+response.id+'>td').css('border-color','#fa9090');$('#comment_body_row_'+response.id).css('border','10px solid red');$('#feature_'+response.id).text('Un-feature');}else{$('.featured_'+auction).css('color','');$('#comment_body_'+response.id).removeClass('featured_commentary');$('#comment_body_row_'+response.id).css('background-color','');$('#comment_body_row_'+response.id+'>td').css('border-width','0px 0px 1px 0px');$('#comment_body_row_'+response.id+'>td').css('border-color','#e5e5e5');$('#feature_'+response.id).text('Feature');}}},{'id':id,'feature':value});}
function changeDisclaimerBidding(auction,user){ajax.sendRequest('/ajax.SetBidding',function(response){if(response.status=='OK'){if(response.answer){$('.comment-disclaimer-'+auction+'-'+response.user).show();$('.disclaimer-link-'+auction+'-'+response.user).text('Remove bidding disclaimer');}else{$('.comment-disclaimer-'+auction+'-'+response.user).hide();$('.disclaimer-link-'+auction+'-'+response.user).text('Add bidding disclaimer');}}},{'auction':auction,'answer':$('.comment-disclaimer-'+auction+'-'+user).css('display')=='none'?1:0,'user':user});}
function getSettings(auction){if(commentsSettings[auction]){return settings=commentsSettings[auction];}
return settings={'byVotes':'','currentPage':1,'allComments':0}}
function getAuction(uri){var matches=uri.match(/AuctionBlock\?id=(\d+)/);return matches?parseInt(matches[1]):'main';}
function getComments(params,toggleAll){var auction=getAuction(params);var settings=getSettings(auction);matches=params.match(/page=(\d+)/);settings.currentPage=matches?matches[1]:1;if(toggleAll){settings.allComments=!settings.allComments;}
commentsSettings[auction]=settings;ajax.sendRequest('/ajax.GetComments',function(response){if(response.status=='OK'){if(response.block=='auction_block'){var blockId='#auction_block_'+response.auction;var settings=commentsSettings[response.auction];}else{var blockId='#comments_main_block';var settings=commentsSettings['main'];}
$(blockId+' .comments').html(response.comments);if(settings.allComments){$(blockId+' .toggleAllComments').text('Show part');$(blockId+' .commentsPager').hide();}else{$(blockId+' .toggleAllComments').text('Show all');$(blockId+' .commentsPager').html(response.pager).show();}
if(response.commentsCount>1){$(blockId+' .commentsSortBlock').show();}else{$(blockId+' .commentsSortBlock').hide();}
var scrollTop=parseInt(document.documentElement.scrollTop)+parseInt(document.body.scrollTop);}else{alert(response.message);}},{'auction':auction=='main'?app.main_auction.id:auction,'page':settings.currentPage,'byVotes':settings.byVotes,'all':settings.allComments?1:'','block':auction=='main'?'main':'auction_block'});}
function getVote(el){matches=$(el).attr('class').match(/comment_(\d+)/);if(matches){var id=matches[1];}else{return 0;}
var voteText=$(el).find('div.thumbs_'+id+'_for').text();voteText=voteText.replace(')','');voteText=voteText.replace('(','');voteText=$.trim(voteText);return!isNaN(Number(voteText))?Number(voteText):0;}
function sortByVotes(comments,blockId,settings){if(settings.byVotes=='desc'){comments=comments.sort(function(a,b){return getVote(b)-getVote(a);});}else{comments=comments.sort(function(a,b){return getVote(a)-getVote(b);});}
for(var i=0;i<comments.length;i++){$(comments[i]).remove();}
for(var i=0;i<comments.length;i++){$(blockId+' .comments').append($(comments[i]));}
var commentNumber=1;$(blockId+' .comment_ordinal_number > a').each(function(){$(this).text('#'+commentNumber++);});}
function orderComments(id,uri){var auction=getAuction(uri);var settings=getSettings(auction);settings.byVotes=(settings.byVotes=='desc')?'asc':'desc';if(auction=='main'){var blockId='#comments_main_block';}else{var blockId='#auction_block_'+id;}
var expertComments=$(blockId+' .comments>div');var comments=new Array();for(var i=0;i<expertComments.length;i++){if(i==0&&$(expertComments[i]).find('a[text=Un-feature]').length){continue;}
comments[comments.length]=expertComments[i];}
if($(blockId+' .commentsPager a:visible').length){getComments(uri);}else{sortByVotes(comments,blockId,settings);}
if(settings.byVotes=='desc'){$(blockId+' .comment-sort-icon').attr('src','/images/icons/up.png');}else{$(blockId+' .comment-sort-icon').attr('src','/images/icons/down.png');}
commentsSettings[auction]=settings;}

function getAuctionTab(id){cursorLoading(true);ajax.sendRequest('/ajax.GetAuctionTab',function(response){cursorLoading(false);if(response.status=='OK'){oEditors['text'].setEditorHTML(response.text);$("#name").val(response.name);if(response.order>0){if($('#tab_order')[0].options[response.order-1]){$('#tab_order')[0].options[response.order-1].selected=true;}else{$('#tab_order')[0].options[response.order-1]=new Option(response.order,response.order,false,true);}}}},{'id':id});}
function showEditor(){$('#wysiwyg').show();$('#editor-buttons').show();$('#button').hide();if($('#tabId').attr('value')==0){$('#order_row').hide();$('#create-tab').show();$('#save-tab').hide();$('#delete-tab').hide();}else{$('#order_row').show();$('#create-tab').hide();$('#save-tab').show();$('#delete-tab').show();}}
function hideEditor(){$('#wysiwyg').hide();$('#editor-buttons').hide();$('#button').show();$('#create-tab').hide();}
function checkTabs(){if(!$('#name').val().length){$('#name').focus();return false;}
if(isActual){oEditors['text'].setEditorHTML($('#text').val());}
return oEditor.saveHTML();}
function manageAuctionTab(action,auction){if($('#create-tab').css('display')=='none'&&$('#save-tab').css('display')=='none'){showEditor();return false;}
var sel=document.getElementById("tabId");var id=$('#tabId').attr('value');var name=$('#name').attr('value');var text=checkTabs();if(text===false){if(id>0){alert('Make sure auction tab name are not empty.');}
return false;}
cursorLoading(true);ajax.sendRequest('/ajax.ManageAuctionTab',function(response){cursorLoading(false);if(response.status=='OK'){if(response.action=='delete'){sel.options[sel.selectedIndex]=null;sel.options[0].selected=true;getAuctionTab(0);showEditor(auction);}else{if(id!=response.id){sel.options[sel.options.length]=new Option(name,response.id,false,true);$('#create-tab').hide();$('#delete-tab').show();$('#save-tab').show();}}}else{alert(response.message);}},{'name':name,'text':text,'auction':auction,'action':action,'order':$("#tab_order").attr('value'),'id':id});}
function showCommentTab(id,tabType){$("div.tab-act").removeClass("tab-act").addClass("tab");$("#tab-"+id).removeClass("tab").addClass("tab-act");$("div.tab-"+tabType).each(function(){$('b.buttonActiveb1',this).removeClass("buttonActiveb1").addClass("buttonInactiveb1");$('b.buttonActiveb2',this).removeClass("buttonActiveb2").addClass("buttonInactiveb2");$('b.buttonActiveb3',this).removeClass("buttonActiveb3").addClass("buttonInactiveb3");$('b.buttonActiveb4',this).removeClass("buttonActiveb4").addClass("buttonInactiveb4");$('div.buttonActivecontentb',this).removeClass("buttonActivecontentb").addClass("buttonInactivecontentb");});$("#tab-button-"+id+' b.buttonInactiveb1').removeClass("buttonInactiveb1").addClass("buttonActiveb1");$("#tab-button-"+id+' b.buttonInactiveb2').removeClass("buttonInactiveb2").addClass("buttonActiveb2");$("#tab-button-"+id+' b.buttonInactiveb3').removeClass("buttonInactiveb3").addClass("buttonActiveb3");$("#tab-button-"+id+' b.buttonInactiveb4').removeClass("buttonInactiveb4").addClass("buttonActiveb4");$("#tab-button-"+id+' div.buttonInactivecontentb').removeClass("buttonInactivecontentb").addClass("buttonActivecontentb");$("div.tab-block-"+tabType).hide();$("#tab-content-"+id).show();}
function expand(cutted,full,showFull,top){if(typeof(cutted)!='object'){cutted=$('#'+cutted);}
if(typeof(full)!='object'){full=$('#'+full);}
if(showFull==1){cutted.hide();full.show();}else{full.hide();cutted.show();}
if(top){scroll(0,0);}}
function deleteTab(auction){if(confirm('Delete content section?')){manageAuctionTab('delete',auction);}}
function cancelTab(){$("#name").val('');oEditors['text'].setEditorHTML('');hideEditor();}

function posX(e){return e.offsetLeft+(e.offsetParent!=null&&e.tagName!='BODY'?posX(e.offsetParent):0);}
function posY(e){return e.offsetTop+(e.offsetParent!=null&&e.tagName!='BODY'?posY(e.offsetParent):0);}
function showMenu(name){menuTimer=null;if(arguments[1]){$('#menu_'+name).css('left',posX(arguments[1])-posX($('.bg-line')[0]));var elementHeight=arguments[1].offsetHeight?arguments[1].offsetHeight:arguments[1].parentNode.offsetHeight;$('#menu_'+name).css('top',posY(arguments[1])+elementHeight+1);}
$('.menu').hide();$('#menu_'+name).show();}
function hideMenu(name){if(menuTimer){return;}
menuTimer=setTimeout(function(){if(menuTimer){$('.menu').hide();}
menuTimer=null;},1500);}

