if(!window.ccs.ugc){ccs.ugc={};} ccs.ugc.path='/shared/content/ugc_content/';ccs.ugc.jsonpath=ccs.contextPath+"/json/"+ccs.appName+"/"+ccs.languageCode+"/content/ugc_content/";ccs.ugc.capturejsonpath=ccs.ugc.jsonpath+"capture/";ccs.ugc.Capture=function(){var self;var umessages;var formValidationErrors;var preValidationState;var multiSubs;var sectionId;var divToShowOnCapture;function constructorFn(){self=this;umessages=new Object();formValidationErrors=new Object();preValidationState=new Object();} constructorFn.prototype.init=function(_multiSubs,_sectionId){self.multiSubs=_multiSubs;self.sectionId=_sectionId;} constructorFn.prototype.clearValidationState=function(oid){var preValidationStateArr=preValidationState[oid+""];if(preValidationStateArr!=null){for(var i=0;i0){alert("Please check the form for errors.");var errs="";var preValidationStateArr=preValidationState[oid+""];if(preValidationStateArr==null){preValidationStateArr=new Array();preValidationState[oid+""]=preValidationStateArr;} for(i=0;i0){eval(validation);} if(self.validate(oid)){self.showLoader(oid);var pars=new Object();pars=Form.serializeElements(Form.getElements(theForm),true);if(isCookiesEnabled()){var rec=getCookie("ugc_"+oid);pars["ugc_rec"]=rec;pars["section_id"]=self.sectionId;new Ajax.Request(ccs.ugc.capturejsonpath+"capture.json",{method:'post',parameters:pars,onSuccess:function(transport){self.showSubmit(oid);var ret=transport.responseText.evalJSON();self.captured(pars,oid,theForm,hideForm,publishImmediately);if(ret.msg.length>0){alert(ret.msg);}},onFailure:function(transport){self.showSubmit(oid);var err=transport.responseText.evalJSON();if(err!=null&&err.error){alert(err.message);}else{alert("Error speaking to server:"+transport.responseText);}}});}else{$("ugcMessage_"+oid).innerHTML="Sorry, Your browser does not support cookies. "+"We use cookies as part of a mechanism to control certain spam bots";}}} constructorFn.prototype.captured=function(pars,oid,theForm,hideForm,publishImmediately){if(hideForm){$("ugcCaptureForm_"+oid).innerHTML=self.getMessageThanks(oid);}else{$("ugcMessage_"+oid).innerHTML=self.getMessageThanks(oid);} var period;if(self.multiSubs=="always"){period=-10000;}else if(self.multiSubs=="never"){period=300*24*60*60*1000;}else if(self.multiSubs=="session"){}else if(self.multiSubs=="day"){period=1*24*60*60*1000;}else if(self.multiSubs=="week"){period=7*24*60*60*1000;} var expire=null;if(self.multiSubs!="session"){expire=new Date();var dateBuffy=expire.getTime()+period;expire.setTime(dateBuffy);} setCookie("ugc_"+oid,"ugc",expire);if($("ugcAddTemplate_"+oid)){var d=new Date();var curr_hour=d.getHours();var curr_min=d.getMinutes();pars["added_at"]=curr_hour+" : "+curr_min;t=cambrient.processTemplate($("ugcAddTemplate_"+oid).value,pars);newDiv=document.createElement("DIV");newDiv.innerHTML=t;$("ugcContentAdd_"+oid).appendChild(newDiv);} if($("ugcGraphData_"+oid)){eval("ccs.ugc.graph"+oid+".loadGraphData()");} if(publishImmediately){if($("ugcList_"+oid)){eval("ccs.ugc.list"+oid+".refreshList()");}} if(divToShowOnCapture!=null&&divToShowOnCapture.length>0){$(divToShowOnCapture).style.display="block";$(divToShowOnCapture).style.visibility="visible";} theForm.reset();} constructorFn.prototype.showSubmit=function(oid){$("ugcLoader_"+oid).style.visibility="hidden";$("ugcLoader_"+oid).style.display="none";$("ugcSubmit_"+oid).style.display="block";$("ugcSubmit_"+oid).style.visibility="visible";} constructorFn.prototype.addMessageThanks=function(oid,msg){umessages["instance_"+oid]=msg;} constructorFn.prototype.showDivOnCapture=function(divId){divToShowOnCapture=divId;} constructorFn.prototype.getMessageThanks=function(oid){return umessages["instance_"+oid];} constructorFn.prototype.showLoader=function(oid){$("ugcLoader_"+oid).style.visibility="visible";$("ugcLoader_"+oid).style.display="block";$("ugcSubmit_"+oid).style.display="none";$("ugcSubmit_"+oid).style.visibility="hidden";} constructorFn.prototype.addValidationError=function(oid,formFieldName,formFieldId,errorSuffix){var myErr=new Object();myErr.fieldName=formFieldName;myErr.formFieldId=formFieldId;myErr.errorSuffix=errorSuffix;var arrErrors=formValidationErrors[oid+""];if(arrErrors==null){arrErrors=new Array();} arrErrors.push(myErr);formValidationErrors[oid+""]=arrErrors;} return new constructorFn();}