function displayValue(value,currency){if(!currency){currency='CAD';}
var currencySymbol='';var Mycurrency=currency;var dblValue=0;var intCents=0;var strCents='0';var i=0;switch(currency)
{case'GBP':currencySymbol="&pound;";break;case'USD':currencySymbol='$';break;case'CAD':currencySymbol='$';break;case'EUR':currencySymbol='&euro;';break;}
if(currencySymbol!==''&&currency!=='CAD'){Mycurrency='';}
dblValue=parseFloat(value);dblValue=Math.floor(dblValue*100+0.50000000001);intCents=dblValue%100;strCents=intCents.toString();value=Math.floor(dblValue/100).toString();for(i=0;i<Math.floor((value.length-(1+i))/3);i++)
value=value.substring(0,value.length-(4*i+3))+','+value.substring(value.length-(4*i+3));if(intCents<10){strCents="0"+strCents;}
formattedValue=currencySymbol+value;if(strCents>0){formattedValue=currencySymbol+value+'.'+strCents;}
if(Mycurrency)
{formattedValue=formattedValue+' '+Mycurrency;}
return formattedValue;}
function displayError(errorText,container)
{var $c=$(container);if($c.find('div.ko').length){$c.find('div.ko').html(errorText).fadeOut().fadeIn();}else{$('<div class="ko" style="display:none">'+errorText+'</div>').prependTo($c).slideDown('fast');}}
function displayErrorPopup(errorText,container)
{var $c=$(container);if($c.find('div.sm_ko').length){$c.find('div.sm_ko').html(errorText).fadeOut().fadeIn();}else{$('<div class="sm_ko" style="display:none">'+errorText+'</div>').prependTo($c).slideDown('fast');}}
function watchTimerTick(periods)
{if(periods[5]===0&&periods[6]<6){var oId=$(this).parent().find('input[name=myId]').val();var DOMText=$('#liveAuction'+oId+'TimeIntro');var bgColour='white';var hammerText='Going..';if(periods[6]<3){hammerText='<strong>GOING....</strong>';}
if(periods[6]===0)
{var oOutcome=$('#liveAuction'+oId+'outcomeWatch').find('input').val();hammerText='<strong>'+oOutcome+'!</strong>';}
if(periods[6]==5||periods[6]==2||periods[6]===0)
{DOMText.animate({backgroundColor:"red"},1000).html(hammerText).animate({backgroundColor:bgColour},1000);}}
else{var oId=$(this).parent().find('input[name=myId]').val();var DOMText=$('#liveAuction'+oId+'TimeIntro');DOMText.html('&nbsp;');}}
function refreshHomeUpdate(JSONdata)
{list=JSONdata.featuredOffers;if(list){for(var i in list){if(list.hasOwnProperty(i)){id=list[i].id;time=list[i].endDateDelta-countdownCorrection();var price=list[i].currentPrice;if(price>0)
{price=displayValue(price,JSONdata.defaultCurrency);var DOMPrice=$('#featuredOffer'+id+'Price');var bgColor=DOMPrice.closest('td').css('backgroundColor');var bgImage=DOMPrice.closest('td').css('backgroundImage');if(DOMPrice.length&&price!=DOMPrice.text()){DOMPrice.animate({backgroundColor:"red"},1000).text(price).animate({backgroundColor:bgColor},1000);DOMTime=$('#featuredOffer'+id+'Time span.countdown');DOMTime.countdown('destroy').animate({backgroundColor:"red"},1000).countdown({until:time,expiryUrl:window.location.href}).animate({backgroundColor:bgColor,backgroundImage:bgImage},1000);}}}}}
list=JSONdata.specialOffers;if(list){for(var i in list){if(list.hasOwnProperty(i)){id=list[i].id;time=list[i].endDateDelta-countdownCorrection();var price=list[i].currentPrice;if(price>0)
{price=displayValue(price,JSONdata.defaultCurrency);var DOMPrice=$('#specialOffer'+id+'Price');var bgColor=DOMPrice.closest('td').css('backgroundColor');var bgImage=DOMPrice.closest('td').css('backgroundImage');if(DOMPrice.length&&price!=DOMPrice.text()){DOMPrice.animate({backgroundColor:"red"},1000).text(price).animate({backgroundColor:bgColor},1000);DOMTime=$('#specialOffer'+id+'Time span.countdown');DOMTime.countdown('destroy').animate({backgroundColor:"red"},1000).countdown({until:time,expiryUrl:window.location.href}).animate({backgroundColor:bgColor,backgroundImage:bgImage},1000);}}}}}}
function refreshSpecialUpdate(JSONdata)
{list=JSONdata.featuredOffers;if(list){for(var i in list){if(list.hasOwnProperty(i)){id=list[i].id;time=list[i].endDateDelta-countdownCorrection();var price=list[i].currentPrice;if(price>0)
{price=displayValue(price,JSONdata.defaultCurrency);var DOMPrice=$('#featuredOffer'+id+'Price');var bgColor=DOMPrice.closest('td').css('backgroundColor');if(DOMPrice.length&&price!=DOMPrice.text()){DOMPrice.animate({backgroundColor:"red"},1000).text(price).animate({backgroundColor:bgColor},1000);DOMTime=$('#featuredOffer'+id+'Time span.countdown');DOMTime.countdown('destroy').animate({backgroundColor:"red"},1000).countdown({until:time,expiryUrl:window.location.href}).animate({backgroundColor:bgColor},1000);}}}}}
list=JSONdata.specialOffers;if(list){for(var i in list){if(list.hasOwnProperty(i)){id=list[i].id;time=list[i].endDateDelta-countdownCorrection();var price=list[i].currentPrice;var winner=list[i].winner;if(price>0)
{price=displayValue(price,JSONdata.defaultCurrency);var DOMPrice=$('#specialOffer'+id+'Price');var bgColor=DOMPrice.closest('td').css('backgroundColor');if(DOMPrice.length&&price!=DOMPrice.text()){DOMPrice.animate({backgroundColor:"red"},1000).text(price).animate({backgroundColor:bgColor},1000);DOMTime=$('#specialOffer'+id+'Time span.countdown');DOMTime.countdown('destroy').animate({backgroundColor:"red"},1000).countdown({until:time,expiryUrl:window.location.href}).animate({backgroundColor:bgColor},1000);DOMWinner=$('#specialOffer'+id+'Winner');DOMWinner.animate({backgroundColor:"red"},1000).text(winner).animate({backgroundColor:bgColor},1000);}}}}}}
function endLiveAuctionResult()
{var oId=$(this).parent().find('input[name=myId]').val();var DOMText=$('#liveAuction'+oId+'TimeIntro');var oOutcome=$('#liveAuction'+oId+'outcomeWatch').find('input').val();var reserveStatus=$('#liveAuction'+oId+'reserveWatch').find('input').val();hammerText='<strong>'+oOutcome+'!</strong>';var bgColour='white';DOMText.animate({backgroundColor:"red"},1000).html(hammerText).animate({backgroundColor:bgColour},1000);$('#liveAuction'+oId+'Time').html('<br/>'+oOutcome+'<br/>');$('#liveAuction'+oId+'ButtonContainer').html('<br/>BIDDING<br/>CLOSED');if(oOutcome=='SOLD'){$('#soldAuctionTab').removeClass('hidden');endPrice=$('#liveAuction'+oId+'Price').html();$('#soldLiveAuction'+oId+'Price').html(endPrice);winner=$('#liveAuction'+oId+'Winner').find('input').val();$('#soldLiveAuction'+oId+'Winner').html(winner);$('#soldLiveAuction'+oId+'Row').removeClass('hidden');}
if(reserveStatus=='RESERVE'){$('#soldLiveAuction'+oId+'finalOutcome').html('BELOW<br/>RESERVE');}
refreshLive();return false;}
function reloadPage()
{location.reload();}
function refreshLiveUpdate(JSONdata)
{if(template!="liveAuctionIndex"){return;}
var refreshTime=JSONdata.refreshTime;var refreshP=$('input[name=refreshP]').val();var count=0;var IDs=[];var i;var a;var b;if(refreshTime&&refreshP){clearInterval(refreshP);refreshP=setInterval(refreshLive,refreshTime*1000);$('input[name=refreshP]').val(refreshP);}
if(refreshTime){$('.auctionId').each(function(){IDs.push($(this).find('input').val());});}
list=JSONdata.liveAuctions;if(list){for(i in list){var myTime=list[i].absoluteEndDateDelta;var timeRemaining=list[i].endDateDelta;var id=list[i].id;var oDate=$('#liveAuction'+id+'endDateWatch').find('input').val();if(oDate!=myTime){$('#liveAuction'+id+'endDateWatch').find('input').val(myTime);var DOMTime=$('#liveAuction'+id+'Time span.liveAuctionCountdown');countdownTimeRemaining=timeRemaining-countdownCorrection();DOMTime.countdown('destroy').countdown({until:+countdownTimeRemaining,format:'MS',onTick:watchTimerTick,onExpiry:endLiveAuctionResult})}
if(IDs){for(a in IDs){if(IDs[a]===id){IDs.splice(a,1);break;}}}
var liveStatus=0;var overRun=0;var highestBidder=0;var noBidFlash=0;var oExtended=0;var price=displayValue(list[i].currentPrice,JSONdata.defaultCurrency);var bidCount=list[i].bidsCount;var oOutcome=list[i].outcome;oExtended=list[i].extended;var reserveStatus=list[i].reserveStatus;var startTimeDelta=list[i].startTimeDelta;var myPrebid=list[i].myPrebid;var winner=list[i].winnerId;liveStatus=list[i].active;overRun=list[i].overrun;highestBidder=list[i].amIHighestBidder;noBidFlash=list[i].noBidFlash;var outbid=list[i].amIoutBid;var reservePriceNotMet=list[i].reservePriceNotMet;var minBid=displayValue(list[i].minBid,JSONdata.defaultCurrency);if(winner){$('#liveAuction'+id+'Winner').html("<input type='hidden' value='"+winner+"' />");}
if(timeRemaining<=-5){var alreadyFading=$('#liveAuction'+id+'activeWatch').find('input').val();if(alreadyFading!=1){$('#liveAuction'+id+'liveBox').fadeOut(5*1000,reloadPage);$('#liveAuction'+id+'activeWatch').html('<input type="hidden" value="1" />');}}
if(liveStatus==1||(overRun==1&&timeRemaining>=-10)){$('#liveAuction'+id+'liveBox').removeClass('hidden');$('#liveAuction'+id+'pendingRow').addClass('hidden');$('#startTime'+startTimeDelta).removeClass('hidden');}else{$('#liveAuction'+id+'liveBox').addClass('hidden');$('#liveAuction'+id+'pendingRow').removeClass('hidden');if(myPrebid){$('#liveAuction'+id+'pendingRow .prebid_button').addClass('hidden');$('#liveAuction'+id+'pendingRow .prebidupdate_button').removeClass('hidden');$('#liveAuction'+id+'pendingRow .wide_button').addClass('wide_button_green');$('#liveAuction'+id+'pendingRow .wide_button').removeClass('wide_button');}}
var bidEndText='';if(bidCount>1){bidEndText='s';}
var oBidCount=parseFloat($('#liveAuction'+id+'bidCountWatch').find('input').val());var DOMPrice=$('#liveAuction'+id+'Price');if(noBidFlash==1)DOMPrice.css('background-color',"#ffffff");if(reservePriceNotMet){$('#liveAuction'+id+'reservePrice').removeClass('hidden');}else{$('#liveAuction'+id+'reservePrice').addClass('hidden');}
$('#liveAuction'+id+'outcomeWatch').html('<input type="hidden" value="'+oOutcome+'" />');$('#liveAuction'+id+'reserveWatch').html('<input type="hidden" value="'+reserveStatus+'" />');if(oExtended){$('#liveAuction'+id+'Extension').removeClass('hidden');}
if((DOMPrice.length&&price!=DOMPrice.html())||(bidCount&&bidCount!=oBidCount)){DOMPrice.animate({backgroundColor:"red"},1000).text(price).animate({backgroundColor:"white"},1000);$('#liveAuction'+id+'PriceIntro').text('Highest Bid:');$('#liveAuction'+id+'BidsCount').text(bidCount+' bid'+bidEndText);$('#liveAuction'+id+'bidCountWatch').html('<input type="hidden" value="'+bidCount+'" />');$('#liveAuction'+id+'minBid').text(minBid);if(highestBidder==1){$('#liveAuction'+id+'highestBidder').removeClass('hidden');$('#liveAuction'+id+'outBid').addClass('hidden');$('#liveAuction'+id+'liveBox caption').addClass('highBidder');}else{$('#liveAuction'+id+'highestBidder').addClass('hidden');if(bidCount>0&&outbid==1){$('#liveAuction'+id+'outBid').removeClass('hidden');$('#liveAuction'+id+'liveBox caption').addClass('highBidder');}else{$('#liveAuction'+id+'liveBox caption').removeClass('highBidder');$('#liveAuction'+id+'outBid').addClass('hidden');}}}}}
else if(JSONdata.liveAuction){reloadPage();return;}
var missingIDs=IDs;if(missingIDs){for(b in missingIDs){$('#liveAuction'+missingIDs[b]+'liveBox').addClass('hidden');}}
var userCount=JSONdata.visitors;$('#usersOnline').html(userCount+' users watching');}
function refreshDetailsUpdate(JSONdata)
{if(JSONdata){var myTime=JSONdata.endDateDelta;var price=displayValue(JSONdata.currentPrice,JSONdata.defaultCurrency);minimumbid=JSONdata.minimumBid;var DOMPrice=$('#price');var oDate=$('#endDateWatch').find('input').val();if(DOMPrice.length&&price!=DOMPrice.text()){DOMPrice.animate({backgroundColor:"red"},1000).text(price).animate({backgroundColor:"white"},1000);DOMMinBid=$('#minimumbid');if(DOMMinBid)
{DOMMindBid.animate({backgroundColor:"red"},1000).text(minbid).animate({backgroundColor:"white"},1000);}}
DOMTime=$('.countdown');if(myTime>oDate){myTime=myTime-countdownCorrection();DOMTime.countdown('destroy').animate({backgroundColor:"red"},1000).countdown({until:myTime,expiryUrl:window.location.href}).animate({backgroundColor:"white"},1000);}
else if(myTime<oDate){myTime=myTime-countdownCorrection();DOMTime.countdown('destroy').countdown({until:myTime,expiryUrl:window.location.href})}
if(oDate!=myTime){$('#endDateWatch').html('<input type="hidden" value="'+myTime+'" />');}}}
function refreshLive(){if(JSONfeed){$.ajax({url:JSONfeed+'?v=LIVE',success:refreshLiveUpdate,cache:false,dataType:"json"});}}
function refreshDetails(){$.ajax({url:relativePath+'offer/details?v=JSON&offerId='+offerId,success:refreshDetailsUpdate,cache:false,dataType:"json"});}
function refreshHome(){$.ajax({url:relativePath+'index.php?v=JSON',success:refreshHomeUpdate,cache:false,dataType:"json"});}
function refreshSpecial(){$.ajax({url:relativePath+'special?v=JSON',success:refreshSpecialUpdate,cache:false,dataType:"json"});}
function closeAllTabsOpenFirst(){$(".tab_content").hide();$(".tab_content_fullWidth").hide();$("ul.tabs li:first").addClass("active").show();$("ul.dummy_tabs li:first").addClass("active").show();$(".tab_content:first").show();$(".tab_content_fullWidth:first").show();$(".dummy_tab_content_fullWidth:first").show();}
function showMap(address)
{if(GBrowserIsCompatible()){var con=document.getElementById("map");var map=new GMap2(con);var geocoder=new GClientGeocoder();geocoder.getLatLng(address,function(point){if(point){map.setCenter(point,13);var marker=new GMarker(point);map.addOverlay(marker);marker.openInfoWindowHtml(address);setTimeout(closeAllTabsOpenFirst,800);}});}}
$(function(){var $li=$('li');$li.filter(':first-child').addClass('first');$li.filter(':last-child').addClass('last');$('dt:first-child').addClass('first');$('dd:last-child').addClass('last');$('tr').each(function(){var $this=$(this);var $a=$this.find('a, input, select');if(1==$a.length){$this.css({cursor:'pointer'}).click(function(){document.location=$a.get(0).href;}).hover(function(){$this.addClass('hover');},function(){$this.removeClass('hover');});}});if($.browser.msie){var correctMW=function(){if($(window).width()*0.9>900){$('#wrap').width('auto');}else{$('#wrap').width('900px');}};correctMW();$(window).resize(correctMW);}
$('#menu li').mouseenter(function(){$(this).addClass('hover');}).mouseleave(function(){$(this).removeClass('hover');});if(typeof($().fancybox)!="undefined"){$('.bidConfirm').fancybox({'hideOnContentClick':false,'scrolling':'no','type':'iframe'});$('.liveBidConfirm').fancybox({'hideOnContentClick':false,'scrolling':'no','type':'iframe','onClosed':refreshLive()});$('.specialBidConfirm').fancybox({'hideOnContentClick':false,'scrolling':'no','type':'iframe','onClosed':refreshSpecial()});$('.specialBidConfirmHome').fancybox({'hideOnContentClick':false,'scrolling':'no','type':'iframe','onClosed':refreshHome()});$('.liveDetailsBidConfirm').fancybox({'hideOnContentClick':false,'scrolling':'no','type':'iframe','onClosed':reloadPage});}
if(typeof($().ajaxForm)!="undefined"){$('.liveForm').ajaxForm({success:function(responseText){$.fancybox({'content':responseText,'hideOnContentClick':false,'scrolling':'no','type':'iframe','onClosed':refreshDetails});}});}
$('span.countdown').each(function(){var $t=$(this);var oDate=$t.find('input').val()-countdownCorrection();$t.countdown({until:oDate,expiryUrl:window.location.href});});$('span.auctionCountdown').each(function(){var $t=$(this);var oDate=$t.find('input').val()-countdownCorrection();$t.countdown({until:oDate,format:'dHMS',layout:'<b>{d<}{dn} {dl}, {d>} {hn} hours, {mn} minutes and {sn} seconds</b>',expiryUrl:window.location.href});});$('span.liveAuctionCountdown').each(function(){var $t=$(this);var oDate=$t.parent().find('input[name=myDate]').val()-countdownCorrection();$t.countdown({until:oDate,format:'MS',onTick:watchTimerTick,onExpiry:endLiveAuctionResult});});if($('textarea').length){$('textarea').tinymce({theme:"advanced",theme_advanced_buttons1:'bold,italic,underline,strikethrough,separator,undo,redo,separator,cleanup,separator,bullist,numlist',theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_buttons4:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_path:false,theme_advanced_statusbar_location:"bottom",theme_advanced_resizing:true,convert_urls:false});}
$.tablesorter.addParser({id:"enuukMoney",is:function(s){var sp=s.replace(/,/,'.');var test=(/([A-Z]{3} ?\d+\.?\d*|\d+\.?\d* ?[A-Z]{3})/.test(sp))||(/([£$€] ?\d+\.?\d*|\d+\.?\d* ?[£$€])/.test(sp));return test;},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[^\d\.]/g),""));},type:"numeric"});$.tablesorter.addParser({id:"enuukCountdown",is:function(s){var test=/^(\d{1,3}\w+)?\d{1,2}\w+\d{1,2}\w+\d{1,2}\w+$/.test(s);return test;},format:function(s){var fields=s.match(/\d{1,3}/g);var acc=0;for(var i=0;i<fields.length;i++){acc=acc*100+parseInt(fields[i]);}
return acc;},type:"numeric"});$('table.tablesorter').tablesorter({widgets:['zebra'],textExtraction:function(node){return $(node).text();}});if(typeof(address)!="undefined"&&typeof(address)=='string'){showMap(address);}
$('#bidHistory').hide();$('a.newWindow').click(function(){window.open(this.href);return false;});if(typeof(address)=="undefined"){closeAllTabsOpenFirst();}
$("ul.tabs li").click(function(){$("ul.tabs li").removeClass("active");$(this).addClass("active");$(".tab_content").hide();$(".tab_content_fullWidth").hide();var activeTab=$(this).find("a").attr("href");$(activeTab).fadeIn();return false;});$("ul.dummy_tabs li").click(function(){return false;});$("div.tabs").click(function(){$(".tab_content").hide();$(".tab_content_fullWidth").hide();var activeTab=$(this).find("a").attr("href");$(activeTab).fadeIn();$('ul.tabs li').each(function(){var tabName=$(this).find("a").attr("href");if(tabName==activeTab)
{$(this).addClass("active");}
else
{$(this).removeClass("active");}});return false;});$("#filter").change(function(){$("#filterForm").submit();});if(typeof(refreshTime)!="undefined"){if(/index|index2/.test(template)){refreshP=setInterval(refreshHome,refreshTime*1000);}else if(/offerDetailsPenny/.test(template)&&active){refreshDP=setInterval(refreshDetails,refreshTime*1000);}else if(/liveAuctionIndex/.test(template)&&JSONfeed){refreshP1=setInterval(refreshLive,refreshTimeLive*1000);$('input[name=refreshP]').val(refreshP1);}else if(/offerDetails/.test(template)&&offerId){refreshP2=setInterval(refreshDetails,refreshTime*1000);}else if(/special/.test(template)){var refreshP=setInterval(refreshSpecial,refreshTime*1000);}}
if(/userForm/.test(template)){$("#content-login").submit(validateUserForm());}
$('.categories li').hover(function(){$(this).animate({marginLeft:'5px'},200)},function(){$(this).animate({marginLeft:'0'},200)});});$(function(){$('ul.tagList').each(function(){var $list=$(this).find('a');var $details=$(this).next().children();if(1!=$list.filter('.active').length){$list.removeClass('active').eq(0).addClass('active');}
$list.each(function(index){var $t=$(this);if(!$t.hasClass('active')){$details.eq(index).hide();}
$t.click(function(){if(!$details.eq(index).length){return true;}
if($t.hasClass('active')){return false;}
$list.removeClass('active');$t.addClass('active');$details.filter(':visible').slideUp();$details.eq(index).slideDown();$(':checkbox').hide().fadeIn("slow");return false;});});});$('#content-messages div.messageActions').each(function(){var $this=$(this);var $messages=$this.closest('li').find('tr');var checkLinks=function(){var checked=$messages.find('input:checked').length;var unread=$messages.filter('.unread').find('input:checked').length;if(checked){$this.find('a.delete').removeClass('disabled');}else{$this.find('a.delete').addClass('disabled');}
if(checked!=unread){$this.find('a.markAsUnread').removeClass('disabled');}else{$this.find('a.markAsUnread').addClass('disabled');}
if(unread){$this.find('a.markAsRead').removeClass('disabled');}else{$this.find('a.markAsRead').addClass('disabled');}};$messages.find('input').change(checkLinks);$this.find('select').change(function(){switch($('option:selected',this).attr('class')){case'all':$messages.find('input').attr('checked','checked');break;case'none':$messages.find('input').attr('checked',false);break;case'unread':$messages.find('input').attr('checked',false);$messages.filter('.unread').find('input').attr('checked','checked');break;case'read':$messages.find('input').attr('checked',false);$messages.not('.unread').find('input').attr('checked','checked');break;}
checkLinks();});});});function validateOfferForm(){var inputItemTitle=$("#inputItemTitle");var reqItemTitle=$("#reqItemTitle");var selectCategoryId=$("#selectCategoryId");var reqCategoryId=$("#reqCategoryId");var inputStartPrice=$("#inputStartPrice");var reqStartPrice=$("#reqStartPrice");var checkPayMethods=$("#checkPayMethod input");var reqPayMethod=$("#reqPayMethod");function validateTitle(){if(inputItemTitle.val().length<6){reqItemTitle.addClass("error");return false;}
else{reqItemTitle.removeClass("error");return true;}}
function validateCategory(){if(selectCategoryId.val()==null){reqCategoryId.addClass("error");return false;}
else{reqCategoryId.removeClass("error");return true;}}
function validateStartPrice(){if(inputStartPrice.val()<=0){reqStartPrice.addClass("error");return false;}
else{reqStartPrice.removeClass("error");return true;}}
function validatePayMethod(){var atLeastOne=false;for(var i in checkPayMethods.toArray()){if(checkPayMethods[i].checked){atLeastOne=true;reqPayMethod.removeClass("error");break;}}
if(!atLeastOne){reqPayMethod.addClass("error");}
return atLeastOne;}
inputItemTitle.blur(validateTitle);inputStartPrice.blur(validateStartPrice);inputItemTitle.keyup(validateTitle);selectCategoryId.keyup(validateCategory);inputStartPrice.keyup(validateStartPrice);$("#content-offerAdd").submit(function(e){if(validateTitle()&&validateCategory()&&validateStartPrice()&&validatePayMethod()){return true;}else{window.scrollTo(0,0);displayError("<div class=\"fullBox\">Fields in red are required</div>",'#content');return false;}});}
function validateUserForm(){var inputUsername=$("#id");var reqUsername=$("#reqUsername");var inputPassword=$("#password");var inputPassword2=$("#password2");var reqPassword=$("#reqPassword");var reqPassword2=$("#reqPassword2");var inputEmail=$("#email");var reqEmail=$("#reqEmail");var inputName=$("#name");var reqName=$("#reqName");var inputSurname=$("#surname");var reqSurname=$("#reqSurname");var textAreaAddress=$("#address");var reqAddress=$("#reqAddress");var inputCity=$("#city");var reqCity=$("#reqCity");var inputState=$("#state");var reqState=$("#reqState");var inputZip=$("#zip");var reqZip=$("#reqZip");var selectCountry=$("#countryId");var reqCountry=$("#reqCountry");var inputPhone=$("#phone");var reqPhone=$("#reqPhone");function validateUsername(){if(inputUsername.val().length<5){reqUsername.addClass("error");return false;}
else{reqUsername.removeClass("error");return true;}}
function validatePassword(){if(inputPassword.val().length<6){reqPassword.addClass("error");return false;}else{reqPassword.removeClass("error");if(inputPassword.val()!=inputPassword2.val()){reqPassword2.addClass("error");return false;}else{reqPassword2.removeClass("error");return true;}}}
function validateEmail(){if(/^(.+\@.+\..+)$/.test(inputEmail.val())){reqEmail.removeClass("error");return true;}else{reqEmail.addClass("error");return false;}}
function validateName(){if(!inputName.val()){reqName.addClass("error");return false;}
else{reqName.removeClass("error");return true;}}
function validateSurname(){if(!inputSurname.val()){reqSurname.addClass("error");return false;}
else{reqSurname.removeClass("error");return true;}}
function validateAddress(){if(textAreaAddress.attr('value').length<=7){reqAddress.addClass("error");return false;}else{reqAddress.removeClass("error");return true;}}
function validateCity(){if(!inputCity.val()){reqCity.addClass("error");return false;}
else{reqCity.removeClass("error");return true;}}
function validateState(){if(!inputState.val()){reqState.addClass("error");return false;}
else{reqState.removeClass("error");return true;}}
function validateZip(){if(!inputZip.val()){reqZip.addClass("error");return false;}
else{reqZip.removeClass("error");return true;}}
function validateCountry(){if(!selectCountry.attr('value')){reqCountry.addClass("error");return false;}else{reqCountry.removeClass("error");return true;}}
function validatePhone(){if(inputPhone.val().length<10||(!/^\d*\d+$/.test(inputPhone.val()))){reqPhone.addClass("error");return false;}
else{reqPhone.removeClass("error");return true;}}
inputUsername.blur(validateUsername);inputPassword.blur(validatePassword);inputEmail.blur(validateEmail);inputName.blur(validateName);inputSurname.blur(validateSurname);inputCity.blur(validateCity);inputState.blur(validateState);inputZip.blur(validateZip);inputPhone.blur(validatePhone);inputUsername.keyup(validateUsername);inputPassword.keyup(validatePassword);inputPassword2.keyup(validatePassword);inputEmail.keyup(validateEmail);inputName.keyup(validateName);inputSurname.keyup(validateSurname);inputCity.keyup(validateCity);inputState.keyup(validateState);inputZip.keyup(validateZip);inputPhone.keyup(validatePhone);$("#content-login").submit(function(e){if(validateUsername()&&validatePassword()&&validateEmail()&&validateName()&&validateSurname()&&validateAddress()&&validateCity()&&validateState()&&validateZip()&&validateCountry()&&validatePhone()){return true;}else{window.scrollTo(0,0);displayError("<div class=\"fullBox\">Fields in red are required</div>",'#content');return false;}});}
