function ltrim(str){return str.replace(/^\s+/,'')}function showNote(note_length){if(note_length>0){$('#no-notes').hide();$('#counter').text('Characters left: '+(1000-($("#note_text").val().length)));$("#existing-notes").show()}else{$("#existing-notes").hide()}}function updateNotes(justStars){var prop_id=document.shortlist.prop_id.value;var store;if(document.property_notes.store.checked){store="1"}rating=$("#rating_check").val();var note_text=escape(document.property_notes.note_text.value);if(justStars){var urlString="http://"+document.location.hostname+"/property-notes.cgi?prop_id="+prop_id+"&rating="+rating+"&uniq="+new Date().getTime()}else{var urlString="http://"+document.location.hostname+"/property-notes.cgi?prop_id="+prop_id+"&rating="+rating+"&note_text="+note_text+"&uniq="+new Date().getTime()}if($("#db_call").attr("name")=="insert"){urlString=urlString+"&insert=1";$("#db_call").attr("name","update")}else{urlString=urlString+"&update=1"}if(store=="1"){urlString=urlString+"&store=1"}urlString+="&uniq="+new Date().getTime();$.ajax({url:urlString,success:function(data){if(!justStars){$('#property-notes').html(data);range=$("#rating_check").val();for(var i=0;i<range;i++){$("#star-link-"+(i+1)).addClass("star-on");$("#star-link-ro"+(i+1)).addClass("star-on")}var patt2=new RegExp(">(\.+)<\/textarea");patt2.exec(data);var prop_note=RegExp.$1;$('#counter').text('Characters left: '+(1000-($("#note_text").val().length)));$('#no-notes').show();$("#notes-form").hide();showNote($("#note_text").val().length)}}})}function loadContent(){if($.cookies.get('mys1_eid')){var prop_id=document.shortlist.prop_id.value;var urlString="http://"+document.location.hostname+"/property-notes.cgi?prop_id="+prop_id+"&uniq="+new Date().getTime();$(document).ready(function(){$.get(urlString,{itemId:'property-notes'},function(data){$("#property-notes").html(data);range=$("#rating_check").val();var patt2=new RegExp(">(\.+)<\/textarea");patt2.exec(data);var prop_note=RegExp.$1;if(range>0){for(var i=0;i<range;i++){$("#star-link-"+(i+1)).addClass("star-on");$("#star-link-ro"+(i+1)).addClass("star-on")}}if(prop_note.length>0){$("#notes-form").hide();$('#counter').text('Characters left: '+(1000-($("#note_text").val().length)));$('#no-notes').hide();$("#existing-notes").show()}else{$('#counter').text('Characters left: 1000');$("#no-notes").show();$("#notes-form").hide();$("#existing-notes").hide()}showNote($("#note_text").val().length)})})}else{$("#notes-sign-in").show()}}function removeNote(){var prop_id=document.shortlist.prop_id.value;var rating=$("#rating_check").val();var urlString="http://"+document.location.hostname+"/property-notes.cgi?prop_id="+prop_id+"&note_text="+''+"&uniq="+new Date().getTime();$.ajax({url:urlString,success:function(data){$('#property-notes').html(data);$('#no-notes').show();$("#notes-form").hide();$('#existing-notes').hide();var range=$("#rating_check").val();if(range>0){for(var i=0;i<range;i++){$("#star-link-"+(i+1)).addClass("star-on");$("#star-link-ro"+(i+1)).addClass("star-on")}}}})}function getGenContent(){$('#note_text').live('keyup',function(){var left=1000-$(this).val().length;if(left<0){$('#counter').css('color','red')}$('#counter').text('Characters left: '+left)});$("#save-button").live('click',function(){$('#notes-form').fadeOut('slow',function(){updateNotes(false)})});$("#edit-button").live('click',function(){$('#existing-notes').fadeOut('slow',function(){$("#notes-form").fadeIn()})});$("#remove-note-button").live('click',function(){$('#notes-form').fadeOut('slow',function(){removeNote()})});$("#add-button").live('click',function(){$('#no-notes').fadeOut('slow',function(){$('#counter').text('Characters left: 1000');$("#notes-form").fadeIn()})});$(".star").live('click',function(){$(".star").attr('checked',false);$(".star").removeClass("star-on");$(".star").removeClass("star-hover");$(this).addClass("star-on");var id=read_cookie('mys1_eid');var starNo=$(this).attr("title");$("#rating_check").attr('value',starNo);for(var i=1;i<starNo;i++){$("#star-link-"+i).addClass("star-on")}updateNotes(true)});$(".star").live('hover',function(){var starNo=$(this).attr("title");$(".star").removeClass("star-hover");for(var i=0;i<starNo;i++){$("#star-link-"+(i+1)).addClass("star-hover")}});$(".star").live('mouseout',function(){$(".star").removeClass("star-hover")})}function getGenContentMyAccount(){for(i=0;i<document.forms.length;i++){if(document.forms[i].rating){var range=document.forms[i].rating.value;var prop_id=document.forms[i].prop_id.value;for(var j=0;j<range;j++){$("#star-link-"+(j+1)+"_"+prop_id).addClass("star-on");$("#star-link-ro"+(j+1)+"_"+prop_id).addClass("star-on")}}}$(".star").live('click',function(){var starNo=$(this).attr("title");var patt1=new RegExp("_(\.+)");patt1.exec($(this).attr("id"));var local_prop_id=RegExp.$1;$("#rating_check").attr('value',starNo);var urlString="http://"+document.location.hostname+"/property-notes.cgi?prop_id="+local_prop_id+"&rating="+starNo+"&uniq="+new Date().getTime();if($("#db_call").attr("name")=="insert"){urlString=urlString+"&insert=1";$("#db_call").attr("name","update")}else{urlString=urlString+"&update=1"}$.ajax({url:urlString,success:function(data){for(var i=starNo;i<=5;i++){$("#star-link-"+(i)+"_"+local_prop_id).removeClass("star-on")}for(var i=1;i<=starNo;i++){$("#star-link-"+(i)+"_"+local_prop_id).addClass("star-on")}}})});$(".star").live('hover',function(){var starNo=$(this).attr("title");var patt1=new RegExp("_(\.+)");patt1.exec($(this).attr("id"));var local_prop_id=RegExp.$1;for(var i=0;i<=starNo;i++){$("#star-link-"+(i)+"_"+local_prop_id).addClass("star-hover")}});$(".star").live('mouseout',function(){$(".star").removeClass("star-hover")});$(document).ready(function(){$('#remove_prop').click(function(){var props=new Array();for(i=0;i<document.forms.length;i++){if(document.forms[i].elements["check"]){if(document.forms[i].elements["check"].checked==true){props.push(document.forms[i].elements["check"].value)}}}$("#myProps").attr('value',props)})})}function trim(strText){while(strText.substring(0,1)==' ')strText=strText.substring(1,strText.length);return strText}$(document).ready(function(){if($("#nav4_on").length){getGenContentMyAccount()}else{loadContent();getGenContent()}});
