HJ.Resource = Class.create();

HJ.Resource.prototype = {

	initialize: function() {
		this.url = basePageURL + "CommunityResources.htm";		
		this.targetContainerId = "pageBottom";
		this.data = null;
		this.tl = null;	
		this.resourceUUID = null;
		this.emailToSendThanks = null;
		this.emailToName = null;
		this.catName = null;
		this.CatUUID = null;
		this.categoryUUID = null;
		this.IsAddToMyResource = false;
	},

	loadCommunityResourcesTemplate: function () {	  		
        if(this.tl == null) {
            this.tl = new Af.TemplateLoader(this.url, this.targetContainerId, "communityResourcesTemplate");
            this.tl.listener = this;
            this.tl.loadTemplate();	
        } else {		 
            this.tl.reAttachElement();		  
            this.searchText.value = this.defaultValue;
            this.beforeReviewShow.style.display = "block";
            this.afterReviewShow.style.display = "none"; 
            this.searchResultsShowDiv.style.display = "none"; 
            this.browseCatLink.className="open";
            this.recentAddnTopLink.className="open";
            this.categoryInfoTable.style.display="block";
            this.recentAdditions.style.display="block";
            this.resultDiv.style.display ="none";		  
            this.loadCategoryInfo();
            return false; 	
        }
	},

	templateLoaded: function() {		
		this.loadCategoryInfo();
		this.resultDiv = document.getElementById("resultDiv");
		this.browseCatLink = document.getElementById("browseCatTopLink");
		this.recentAddnTopLink = document.getElementById("recentAddnTopLink");
		this.resultTitle = document.getElementById("resultTitle");
		this.categoryInfoTable = document.getElementById("categoryInfoTable");
		this.doSearchButton = document.getElementById("doSearchButton");
		this.searchText = document.getElementById("searchText");
		this.recentAdditions = document.getElementById("recentAdditionsTable");
		this.searchResultsShowDiv = document.getElementById("searchResultsShowDiv");
		this.addCommResource = document.getElementById("addCommResource");
		this.addCommResource.onclick = this.doAddCommResource.bind(this);
		this.afterReviewShow = document.getElementById("afterReviewShow");
		this.beforeReviewShow = document.getElementById("beforeReviewShow");
		this.resourceSortBy = document.getElementById("resourceSortBy");
		this.goToSeeingStarPage = document.getElementById("goToSeeingStarPage");
		this.goToSeeingStarPage.onclick = this.doShowPoints.bind(this);
		//this.goToSeeingStarPage.onmouseover = this.doShowPoints.bind(this);
		//this.goToSeeingStarPage.onmouseout = this.doHidePoints.bind(this);

		this.defaultValue = this.searchText.value;
		
		this.searchText.onchange = this.doSearchResource.bindAsEventListener(this);
		this.searchText.onfocus = this.focusOnTextBox.bindAsEventListener(this);
		this.searchText.onblur = this.focusLostTextBox.bindAsEventListener(this);
		
		if (is_ie) {
			 this.textChanger = new Af.TextChanger(this.searchText);
		}

		this.browseCatLink.onclick= this.doShowHideCatgory.bind(this);
		this.recentAddnTopLink.onclick = this.doShowHideRecentAddn.bind(this);
		
		this.resourceSortBy.onchange = this.doResourceSortBy.bind(this);
		this.doSearchButton.onclick = this.doSearchResource.bind(this);

        this.dontSeeCommRes = 
                  document.getElementById("dontSeeCommunityResources");
        this.createCommResLink = 
                  document.getElementById("createCommunityResourceLink");
        this.createCommResLink.onclick = this.doAddCommResource.bind(this);
        this.loadMyProfile();
        return false;
	},

	loadCategoryInfo: function() {	
		 var req = new Af.DataRequest(svcURL,this.reqResorceCompleted.bind(this), this.reqFailed.bind(this), null, this.reqTimedOut.bind(this));		   		
		 req.addService("CommunityResourceService", "getResourceCategoryList");
		  ajaxEngine.processRequest(req);
	},
    reqResorceCompleted: function(response, msg) {			
		  this.resourceTable = new Af.HtmlColumnRepeater2("planeCategoryTable","name,count",2);
		  this.holidayCategoryTable = new Af.HtmlColumnRepeater("holidayCategoryTable","name,count",1);
		  this.resourceTable.listener = this;
		  this.holidayCategoryTable.listener = this;
		  var resourceDS = new Af.XMLToDataSet(response.responseXML);
		  this.resourceData = resourceDS.data;

		  var holidayCatList = new Array();
		  var planeCatList = new Array();
		  for(var i = 0; i < this.resourceData["CategoryInfo"].length; i++){
			  if(this.resourceData["CategoryInfo"][i]["owner"] == "Camps"){
				  holidayCatList.push(this.resourceData["CategoryInfo"][i]);
			  }else{
  				  planeCatList.push(this.resourceData["CategoryInfo"][i]);
			  }
		  }		  
		   this.resourceTable.setDataList(planeCatList);	
		  this.holidayCategoryTable.setDataList(holidayCatList);

		 
		 // this.dataTable = new Af.DataTable(this.resourceData["CategoryInfo"]);
		  this.loadRecentAdditions();
		  return false;
	},
		
	reqFailed: function(dataRequest, msg) {
		    showMessageDialog("We are currently unable to display Community Resources.  Please try again.", "Excuse us!", 300, 100);
	},

	reqTimedOut: function(dataRequest) {
		    showMessageDialog("We are currently unable to display Community Resources.  Please try again.","Excuse us!", 300, 100);
			this.IsAddToMyResource = false;
	},
	loadRecentAdditions: function() {
		var req = new Af.DataRequest(svcURL,this.recentAdditionLoadCompleted.bind(this), this.reqRecentResFailed.bind(this), null, this.reqRecentResTimedOut.bind(this));		   
		req.addService("CommunityResourceService", "getRecentAdditions");		   
		ajaxEngine.processRequest(req);		
	},
	recentAdditionLoadCompleted: function(dataRequest, msg) {	
		this.resultDiv.style.display="none";
		this.recentAdditions.innerHTML = dataRequest.responseText;		
		this.handleReviewDetailTemplateRecntAdd();
		return false;
	},
	
	reqRecentResFailed: function() {
		showMessageDialog("We are currently unable to load  Resources.  Please try again.", "Excuse us!", 300, 100);

	},

	reqRecentResTimedOut: function() {
		showMessageDialog("We are currently unable to load  Resources.  Please try again.", "Excuse us!", 300, 100);

	},
	
	doAddCommResource: function() {		
		if(this.dialog == null) {
			this.dialog = new HJ.HomajoonResource("Add a Jooners Resource", this, null);
			 this.dialog.width = "520px";
		}
		var obj = new Object();
		this.dialog.showHTMLTemplate(basePageURL + "HomajoonResource.htm", "pageBottom", "homajoonResourceContent");	
		this.dialog.centerDialog(350, 350);
        this.dialog.setObj(obj, true);
        return false;		
	},

	columnSelected: function(columnRepeater, n) {		
       var obj = columnRepeater.dlist[n]; 
       this.catName = obj['name'];	  	
	   this.CatUUID = obj.UUID;     
	   this.closeRecentAndCatgory();
	   this.getCatSearchResult();
	   if(this.resourceSortBy != null) {
		this.resourceSortBy[0].selected = true; 
	   }
	   return false;
	},

	columnRepeaterRowSelected: function(columnRepeater,  n) {	         
		this.columnSelected(columnRepeater, n);
		return false;
    },

	getCatSearchResult: function() {
	   var req = new Af.DataRequest(svcURL,
	   this.requestSearchResourceCompleted.bind(this), this.reqCatResFailed.bind(this), null, this.reqCatResTimedout.bind(this));
	   req.addService("CommunityResourceService", "getBrowseSearchResults");
	   req.addParameter("xslTemplate", "SearchResourcesByRate.xsl");	
	   req.addParameter("UUID", this.CatUUID );	   
	   ajaxEngine.processRequest(req);
	},
	
	requestSearchResourceCompleted: function(response) {    

	  this.resultDiv.style.display="block";
	  this.resultTitle.innerHTML = this.catName;
	  this.searchResultsShowDiv.innerHTML = "";
	  this.searchResultsShowDiv.style.display = "block";
	  this.searchResultsShowDiv.innerHTML = response.responseText;			  	
	  this.handleReviewDetailTemplate();
	  return false;
    },
	
	reqCatResFailed: function() {
		showMessageDialog("We are currently unable to show Resources for category.  Please try again.", "Excuse us!", 300, 100);
	},
	reqCatResTimedout: function() {
		showMessageDialog("We are currently unable to show Resources for category.  Please try again.", "Excuse us!", 300, 100);
	},

	handleReviewDetailTemplateRecntAdd: function() { 		
		 this.categoryNames = document.getElementsByName("categoryName");		
		 this.showReviewDetail = document.getElementsByName("showReviewDetail");  
		 this.showReviewerInfo1 = document.getElementsByName("showReviewerInfo");  		 
		 for (InfoIdx = 0;InfoIdx < this.showReviewerInfo1.length ;InfoIdx++ ) {
			 this.showReviewerInfo1[InfoIdx].onclick = this.doShowReviewerInfo.bindAsEventListener(this); 			 
		 }
		 for (revwIdx = 0;revwIdx < this.showReviewDetail.length ;revwIdx++ ) {
			 this.showReviewDetail[revwIdx].onclick = this.doGetResourceUUID.bindAsEventListener(this); 			 
		 }	
		 for (Idx = 0;Idx<this.categoryNames.length ;Idx++ ) {
			 this.categoryNames[Idx].onclick = this.doShowCatgoryDetail.bindAsEventListener(this);
		 }
		 return false;
	},
	handleReviewDetailTemplate: function() {	
		 this.categoryNames = document.getElementsByName("categoryName");			 
		 this.showReviewDetailSearch = document.getElementsByName("showReviewDetailSearch"); 
		  this.showReviewerInfo2 = document.getElementsByName("showReviewerInfo");  		 
		 for (InfoIdx = 0;InfoIdx < this.showReviewerInfo2.length ;InfoIdx++ ) {
			 this.showReviewerInfo2[InfoIdx].onclick = this.doShowReviewerInfo.bindAsEventListener(this); 			 
		 }
		 for (revwIdx = 0;revwIdx < this.showReviewDetailSearch.length ;revwIdx++ ) {
			 this.showReviewDetailSearch[revwIdx].onclick = this.doGetResourceUUID.bindAsEventListener(this); 			 			
		 }
		  for (Idx = 0;Idx<this.categoryNames.length ;Idx++ ) {
			 this.categoryNames[Idx].onclick = this.doShowCatgoryDetail.bindAsEventListener(this);
		 }
		 return false;
	},

	doGetResourceUUID: function(evt) {			
		var e = evt.target ? evt.target : evt.srcElement;		 	  	
		if (e != null) {	
		this.resourceUUID = e.id;		
		this.doShowReviewDetail();
		}
		return false;					 		
	},
	doShowReviewDetail: function() {
		var req = new Af.DataRequest(svcURL,this.reqReviewDetailLoadCompleted.bind(this), this.reqDetailFailed.bind(this), null, this.reqDetailTimedOut.bind(this));		   
		req.addService("CommunityResourceService", "getReviewDetails");		   
		req.addParameter("UUID", this.resourceUUID);
		ajaxEngine.processRequest(req);		
	},		
	reqReviewDetailLoadCompleted: function(response, msg) {			
		this.beforeReviewShow.style.display = "none";
		this.afterReviewShow.style.display = "block"; 
		this.afterReviewShow.innerHTML = response.responseText;		
		this.addToMyResource = document.getElementById("addToMyResource");
		var info = document.getElementById("resourceInfo");
		if(info != null ){
			this.resourceInfo = info.innerHTML;
		} else {  
			this.resourceInfo = "unabe to show information";
		}
		var info1 = document.getElementById("businessName");
		if(info1 != null) {
			this.businessName = info1.innerHTML;
		} else {
			this.businessName = "unale to show name";
		}
		this.addReview = document.getElementsByName("addReview");	
		this.resourceRank = document.getElementById("resourceRank");
		this.sendThanks	= document.getElementsByName("sendThanks");
		this.shareToFriends	= document.getElementById("shareToFriends");	
		this.shareToFriends.onclick = this.doShareToFriends.bind(this);
		for (tnxIdx=0; tnxIdx<this.sendThanks.length;++tnxIdx ){
			this.sendThanks[tnxIdx].onclick = this.doConfirmSendThanks.bindAsEventListener(this);
		}
		for (idx=0; idx < this.addReview.length ; idx++ ) {
			this.addReview[idx].onclick = this.doAddReview.bind(this);
		}

		 this.showReviewerInfo3 = document.getElementsByName("showReviewerInfo");  		 
		 for (InfoIdx = 0;InfoIdx < this.showReviewerInfo3.length ;InfoIdx++ ) {
			 this.showReviewerInfo3[InfoIdx].onclick = this.doShowReviewerInfo.bindAsEventListener(this); 			 
		 }

		this.addToMyResource.onclick = this.doAddToMyResource.bind(this);
		//this.searchText.focus();
		return false;
	},

	reqDetailFailed: function() {
		showMessageDialog("We are currently unable to show Resource Detail. <br/> Please try again.", "Excuse us!", 300, 100);

	},
	reqDetailTimedOut: function() {
		showMessageDialog("We are currently unable to show Resource Detail. <br/> Please try again.", "Excuse us!", 300, 100);
	},

	doAddReview: function() {					
		this.reqXSLLoadedCompleted();
	},
	
	reqXSLLoadedCompleted: function() {		

		if(this.rvDialog == null) {
		   this.rvDialog = new HJ.WriteReview("Write a Review", this, null);
		   this.rvDialog.width = "554px";
		}
		var obj = new Object();
		this.rvDialog.showHTMLTemplate(basePageURL + "WriteReview.htm", "pageBottom", "writeReviewContent");			
		this.rvDialog.centerDialog(350, 350);
        this.rvDialog.setObj(this.resourceUUID, obj, this.businessName, this.resourceInfo);       
		return false;
	},
	doAddToMyResource: function() {	 
	  this.IsAddToMyResource = true;
	  this.doAddNow();
	  return false;  
	},															 
	
	doAddNow: function() {				
		if(this.notifyDialog != null) {
			this.notifyDialog.hide();
		}
		var req = new Af.DataRequest(svcURL,this.reqAddComResToMyResourceCompleted.bind(this), this.reqAddMyResourceFailed.bind(this), null, this.reqTimedOut.bind(this));		   
		req.addService("CommunityResourceService", "addCommResToMyResource");		   
		req.addParameter("UUID", this.resourceUUID);
		ajaxEngine.processRequest(req);		
	},
	doDuplicatAddNow: function() {				
		if(this.notifyDialog != null) {
			this.notifyDialog.hide();
		}
		var req = new Af.DataRequest(svcURL,this.reqAddComResToMyResourceCompleted.bind(this), this.reqAddMyResourceFailed.bind(this), null, this.reqTimedOut.bind(this));		   
		req.addService("CommunityResourceService", "addCommResToMyResource");		   
		req.addParameter("UUID", this.resourceUUID);
		req.addParameter("isDuplicateAddNow", "Yes");
		ajaxEngine.processRequest(req);		
	},

	reqAddComResToMyResourceCompleted: function(response) {				
	   if(response.responseText == "resourceExist") {
		   this.showDuplicatResMsgDialog();
		   return false;
	   }
	   if(this.IsAddToMyResource == true) {
		    this.IsAddToMyResource = false;
			showMessageDialog("This Community Resource has been added as"+
							   " a new listing in your 'My Resources'.", "Success", 300, 100);
	   }
	   var xds = new Af.XMLToDataSet(response.responseXML);
	   var res = xds.data
	   var dlist = app.myResources.dataTable.getDataList();
	   if (dlist != null) {
		   dlist.push(res);
		  app.myResources.setDataList(dlist);		 
	   }	
	   return false;
	},
	reqAddMyResourceFailed: function(dataRequest, msg) {
		this.IsAddToMyResource = false;
		showMessageDialog(msg, "Excuse us!", 300, 100);
	},
	
	doConfirmSendThanks: function(evt) {
		var e = evt.target ? evt.target : evt.srcElement;		 	  			
		if (e != null) {				
			this.emailToSendThanks = e.id;					
			this.emailToName = e.title;
		} 
		if (this.rThanksDialog != null) {
			delete this.rThanksDialog;
		}
        var handler = {
           templateLoaded: function() {
              this.parent.reviewThanksDialogLoaded();
           },
			parent:this
        }
        this.rThanksDialog = new Af.HtmlDialog("Thank You", handler, null);
        this.rThanksDialog.width = "235px";
         this.rThanksDialog.showHTMLTemplate(basePageURL + "ReviewThank.htm", "pageBottom", "reviewThanksContent");     
		 this.rThanksDialog.centerDialog(100, 100);
		 this.setValuesToThanksDialog();
		 return false;
	},
	reviewThanksDialogLoaded: function() {		
		this.fromMail = document.getElementById("fromMail");
		this.toMail = document.getElementById("toMail");  
		this.reviewThanksMessage = document.getElementById("reviewThanksMessage");
		this.reviewThanksDontSend = document.getElementById("reviewThanksDontSend");
		this.reviewThanksSend = document.getElementById("reviewThanksSend");		
		this.reviewThanksDontSend.onclick = this.doReviewThanksDontSend.bind(this);
		this.reviewThanksSend.onclick = this.doReviewThanksSend.bind(this);	
		this.setValuesToThanksDialog();
		return false;
	},
	setValuesToThanksDialog: function() {
		if(this.toMail != null && this.fromMail != null) {
			this.toMail.innerHTML = "To: " + this.emailToName;
			this.fromMail.innerHTML = "<br/>"+login.userId;;			
		}
		if(this.reviewThanksMessage != null && this.businessName != null) {			
			this.reviewThanksMessage.value = "Thank you for your review of "+
											this.businessName +" on Jooners. "+
				"I found this so helpful and I just wanted to let you know.  Thank you!";
		}
		return false;
	},
	doReviewThanksDontSend: function() {
		this.rThanksDialog.hide();
		this.toMail.innerHTML = "";
		return false;
	},
	doReviewThanksSend: function() { 
		this.toMail.innerHTML = "";
		  var s = "<messages>";
		  s += "<message>" + xmlEncode(this.reviewThanksMessage.value) + "</message>";		 
		  s += "</messages>";

		var req = new Af.DataRequest(svcURL,this.reqSendThanksCompleted.bind(this), this.reqThanksFailed.bind(this), null, this.reqThanksTimedOut.bind(this));		   
		req.addService("CommunityResourceService", "sendReviewThanksEMail");		   
		req.addParameter("emailId", this.emailToSendThanks);		
		req.addParameter("xslTemplate", "ReviewThanks.xsl");
		
		req.xmlDoc = s;
		ajaxEngine.processRequest(req);	
		this.rThanksDialog.hide();
		return false;
	},
	reqSendThanksCompleted: function(response) {			
		 app.thankYouNote.doOpenThankYouDialog(response.responseText);
	},

	reqThanksFailed: function() {
		showMessageDialog("We are currently unable to send thank you mail. <br/> Please try again.", "Excuse us!", 300, 100);
	},	
	reqThanksTimedOut: function() {
		showMessageDialog("We are currently unable to send thank you mail. <br/> Please try again.", "Excuse us!", 300, 100);
	},

	doResourceSortBy: function() {	 		
		if(this.showReviewDetailSearch == null || this.showReviewDetailSearch == undefined) {
			return;
		}							 		
		var uuidList = "";			 
		for (revwIdx = 0;revwIdx < this.showReviewDetailSearch.length ;revwIdx++ ) {
		  if(uuidList == "")  {
			uuidList = this.showReviewDetailSearch[revwIdx].id; 
		  }	else {
			  uuidList += "," + this.showReviewDetailSearch[revwIdx].id;
			}
		} 
		if(uuidList == "") {
			return;
		}							 
		
		var req = new Af.DataRequest(svcURL,this.reqSortByCompleted.bind(this), this.reqSortFailed.bind(this), null, this.reqSortTimedOut.bind(this));		   
		req.addService("CommunityResourceService", "getCatResourceSortBy");		   		
		if(this.resourceSortBy.value == "mostReviewed") {
			req.addParameter("xslTemplate", "SearchResourcesByReview.xsl");
		}
		else if(this.resourceSortBy.value == "highestRated") {
			req.addParameter("xslTemplate", "SearchResourcesByRate.xsl");
		}					 
		req.addParameter("resUUIDList", uuidList);			
		ajaxEngine.processRequest(req);	
		
	},
	reqSortByCompleted: function(response) {		
		this.resultDiv.style.display="block";
		this.requestSearchResourceCompleted(response);
	},

	reqSortFailed: function() {
		showMessageDialog("We are currently unable to sort resources. <br/> Please try again.", "Excuse us!", 300, 100);
	},

	reqSortTimedOut: function() {
		showMessageDialog("We are currently unable to sort resources. <br/> Please try again.", "Excuse us!", 300, 100);
	},


	doShareToFriends: function() {
	  if (this.shareToFrndDialog == null) {
         this.shareToFrndDialog = new HJ.ShareComResourcesToFriend("Share a Resource", this, null);        
         this.shareToFrndDialog.width = "370px";
      }
	  var obj = new Object();
      this.shareToFrndDialog.showHTMLTemplate(basePageURL + "ShareComResourcesToFriend.htm", "pageBottom", "shareToFrndContent");
	  this.shareToFrndDialog.centerDialog(100, 100);
	  this.shareToFrndDialog.isCommunityResource = true;
      this.shareToFrndDialog.setObj(obj);
      return false;				
	},
	doSearchResource: function() {				
		if(this.searchText.value == "" || this.searchText.value == undefined)  {
			showMessageDialog("Please enter search text", "No search text found", 300, 100);
			return; 
		}
		var req = new Af.DataRequest(svcURL,this.reqSearchCompleted.bind(this), this.reqFailed.bind(this), null, this.reqTimedOut.bind(this));		   
		req.addService("CommunityResourceService", "doSearchResource");		   
		req.addParameter("searchText", this.searchText.value);		
		req.addParameter("xslTemplate", "SearchResourcesByRate.xsl");				
		ajaxEngine.processRequest(req);	
		return false;
	},
	reqSearchCompleted: function(response) {	
		this.closeRecentAndCatgory();
		this.requestSearchResourceCompleted(response);
		return false;
	},
	
	doShowCatgoryDetail: function(evt) {		
		this.closeRecentAndCatgory();
		var e = evt.target ? evt.target : evt.srcElement;		 	  			
		if (e != null) {	
		 this.CatUUID = e.id;      	  
	     this.getCatSearchResult();
		}	
		if(this.resourceSortBy != null) {
			this.resourceSortBy[0].selected = true; 
		}	
		return false;
	},
	
	doShowReviewerInfo: function(evt) {		
		var e = evt.target ? evt.target : evt.srcElement;	
		if (e != null) {  		
		 app.memberProfile.loadMemberProfileTemplate(e.id);
		}
		return false;
	}, 	
	
	doOpenSeeingStarMainPage: function() {		
		app.seeingStar.loadSeeingStarTemplate();
		return false;
	},
	doShowHideCatgory: function() {
		if (this.browseCatLink.className=="open"){
				this.categoryInfoTable.style.display="none";
				this.browseCatLink.className="closed";
		 }
		 else{
				this.categoryInfoTable.style.display="block";
				this.browseCatLink.className="open";
		}
	},
	doShowHideRecentAddn: function() {		
		if(this.recentAddnTopLink.className == "open") {
			this.recentAdditions.style.display="none";
			this.recentAddnTopLink.className="closed";
			return false;
		}
		else {
			this.recentAdditions.style.display="block";
			this.recentAddnTopLink.className="open";
			return false;
		}
	},

	closeRecentAndCatgory: function() {
	//	 this.browseCatLink.className="closed";
		this.recentAddnTopLink.className="closed";
	//	this.categoryInfoTable.style.display="none";
		this.recentAdditions.style.display="none";
		this.beforeReviewShow.style.display = "block";
		this.afterReviewShow.style.display = "none";
		return false; 
	},

	doShowPoints:function(){
		app.seeingStar.doLearnAboutPoints();
	},

	doHidePoints:function(){
		app.seeingStar.hideLearnAboutPoints();
	},
	
	showDuplicatResMsgDialog: function() {
		 if (this.dplResDialog != null) {
			 delete this.dplResDialog;
		 }
        var handler = {
           templateLoaded: function() {
              this.parent.duplicatResDialogLoaded();
           },
			parent:this
        };
        this.dplResDialog = new Af.HtmlDialog("Informing You", handler, null);
        this.dplResDialog.width = "350px";
         this.dplResDialog.showHTMLTemplate(basePageURL + "DlgToShowDuplicatResource.htm", "MainArea", "duplicatResDailog");     
		 this.dplResDialog.centerDialog(350, 350);
	},
	duplicatResDialogLoaded: function() {		
		this.addDuplicat = document.getElementById("addDuplicat");
		this.dontAddDuplicat = document.getElementById("dontAddDuplicat");
		this.addDuplicat.onclick = this.addDuplicatNow.bind(this);
		this.dontAddDuplicat.onclick = this.dontAddDuplicatNow.bind(this);		
		
	},
	addDuplicatNow: function() {		
		 this.dplResDialog.hide();
		 //this.doSaveHelpResult();	
		 this.doDuplicatAddNow();
		 return;
	},
	dontAddDuplicatNow: function() {		
		 this.dplResDialog.hide();		 		
	},
		
	 focusOnTextBox: function(evt) {		 
			this.searchText.value = "";
			consumeEvent(evt);	 
		//	this.searchText.focus();				 
	   },
   
	focusLostTextBox: function(evt) {    		
		  var s = this.searchText.value;
		  if (s == null) {
			s = "";
		  } else {
			s = trim(s);
		  }
		  if (s == trim(this.defaultValue) || s == "") {
			 this.searchText.value = this.defaultValue;
			 consumeEvent(evt);
		  }
		  return false;	         
	 },

	loadMyProfile: function() {
	   var req = new Af.DataRequest(svcURL,
       this.requestMyProfileLoadCompleted.bind(this), this.requestFailedCommon.bind(this), null, this.requestTimedoutCommon.bind(this));
	   req.addService("AccessControlSvc", "getMyProfile");
	   ajaxEngine.processRequest(req);
	},
	 
	 requestMyProfileLoadCompleted: function(response) {
	   //debugA(response.responseText);
		var xds = new Af.XMLToDataSet(response.responseXML);
        var userObj = xds.data;
        if (userObj.zip != null && userObj.zip.substring(0,2) == "94") {
		    this.dontSeeCommRes.style.display = "none";
        } else {
		    this.dontSeeCommRes.style.display = "block";
        }
		return false;
     },

	 requestFailedCommon: function(dataRequest, msg) {
        //no-op
   },

	 requestTimedoutCommon: function(dataRequest, msg) {
        //no-op
    }
}

