function SaveReviews()
{
if(ValidateAddReviewsForm()==false)
{
return(false);
}
else
{
return(true);
}
}
function ResetReviewData()
{
document.getElementById("txtTitle").value="";
document.getElementById("txtDescription").value="";
document.getElementById("lblScript").innerHTML="";
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
registrationErrorsDiv.style.display="none";
return(false);
}
function ValidateAddReviewsForm()
{
errors="";
mandatoryFieldsErrorFlag=false;
var status=ValidateAddReviewsFormRoutines();
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
return true;
}
}
function ValidateAddReviewsFormRoutines()
{
errors="";
var status=true;
mandatoryFieldsErrorFlag=false;
var varTemp=document.getElementById("txtTitle");
var alertName=" Title";
var isMandatory='True';
if(bValidate(varTemp,"General",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
varTemp=document.getElementById("txtDescription");
alertName=" Review";
isMandatory='True';
if(bValidate(varTemp,"",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
varTemp=document.getElementById("PhotoUpload");
alertName=" Picture";
if(varTemp!=null&&varTemp!="")
{
varTemp=varTemp.value;
if(varTemp!=null&&varTemp!="")
{
var extension=varTemp.substring(varTemp.length-3);
var ValidImage=CheckImageFileType(varTemp);
if(!ValidImage)
{
errors+=" for "+alertName+'.<br/>'
status=false;
return false;
}
}
}
}
function DeleteReviewRecordConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to delete this record?');
return false;
}
function OffensiveReviewConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to report this review as offensive?');
return false;
}
function SaveReviewMessage(status)
{
if(status=="add")
{
var msg="Congratulations! Review is added successfully.<br>It will be visible after approval of admin.";
}
else
{
var msg="Review has been successfully updated.";
}
ShowMessageBox(msg);
ResetReviewData();
}
function EditReviewValidate()
{
if(ValidateEditReviewsForm()==false)
{
return(false);
}
else
{
return(true);
}
}
function ValidateEditReviewsForm()
{
errors="";
mandatoryFieldsErrorFlag=false;
var status=ValidateEditReviewsFormRoutines();
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
return true;
}
}
function ValidateEditReviewsFormRoutines()
{
errors="";
var status=true;
mandatoryFieldsErrorFlag=false;
var varTemp=document.getElementById("txtTitle");
var alertName=" Title ";
var isMandatory='True';
if(bValidate(varTemp,"AlphaWithSpaceApostropheComma",isMandatory,alertName)!=true)
{
status=false;
varTemp.focus();
return false;
}
varTemp=document.getElementById("txtDescription");
alertName=" Review ";
isMandatory='True';
if(bValidate(varTemp,"",isMandatory,alertName)!=true)
{
status=false;
varTemp.focus();
return false;
}
varTemp=document.getElementById("PhotoUpload");
alertName=" Picture";
if(varTemp!=null&&varTemp!="")
{
varTemp=varTemp.value;
if(varTemp!=null&&varTemp!="")
{
var extension=varTemp.substring(varTemp.length-3);
if(extension=="png"||extension=="gif"||extension=="bmp"||extension=="PNG"||extension=="GIF"||extension=="BMP")
{
}
else
{
errors+="Only bmp, gif and png file types are allowed for "+alertName+".";
status=false;
}
}
}
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
return true;
}
}
function CreateFormReviews(FileName)
{
var form=document.createElement("form");
form.method='post';
form.enctype='multipart/form-data';
form.setAttribute('accept-charset','utf-8');
var urlValue=FileName;
var imageextension=FileName.substring(FileName.length-3);
var currUrl=String(self.location);
var startPos=currUrl.indexOf("WebPages");
currUrl=currUrl.substring(0,startPos);
urlValue=currUrl+"ReviewImages/"+urlValue;
var snipshotoutputoptions="{ 'size': {'max': {'width': "+100+", 'height':"+100+" } },"+
" 'filetype': '"+imageextension+"' }";
addInputElement(document,form,"snipshot_input",urlValue);
urlValue=currUrl+"WebPages/Reviews/ReviewSnapsCallBack.aspx";
addInputElement(document,form,"snipshot_callback",urlValue);
addInputElement(document,form,"snipshot_callback_agent","user");
addInputElement(document,form,"snipshot_output_options",snipshotoutputoptions);
addInputElement(document,form,"snipshot_output","file");
document.body.appendChild(form);
form.action="http://services.snipshot.com/";
form.submit();
document.body.removeChild(form);
return false;
}
function addInputElement(doc,form,name,value)
{
var e=doc.createElement('input');
e.name=name;
e.value=value;
form.appendChild(e);
}
function loadUPReviewHandler()
{
var prm=Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(UPEndRequestHandler);
}
function UPEndRequestHandler(sender,args)
{
var err=args.get_error();
if(err)
{
if(err.name=="Sys.WebForms.PageRequestManagerServerErrorException")
{
args.set_errorHandled(true);
}
if(err.name=="Sys.WebForms.PageRequestManagerParserErrorException")
{
e.set_errorHandled(true);
}
}
var UserMessage=null;
UserMessage=document.getElementById("hidUserMessage");
if(UserMessage!=null&&UserMessage!="")
{
var UserMessageVal=UserMessage.value;
}
switch(UserMessageVal)
{
case"AddReviewSuccessful":
UserMessage.value="";
var msg="Congratulations! Review is added successfully.\nIt will be visible after approval of admin.";
ShowMessageBox(msg);
break;
case"AddReviewCommentSuccessful":
UserMessage.value="";
return closepopup('pnlComment');
var msg="Congratulations! Comments has been added successfully.";
ShowMessageBox(msg);
break;
case"ReviewDeleteDone":
UserMessage.value="";
var msg="Review has been deleted successfully.";
ShowMessageBox(msg);
break;
case"ReviewApproveDone":
UserMessage.value="";
var msg="Review has been approved successfully.";
ShowMessageBox(msg);
break;
case"CommentDeleteDone":
UserMessage.value="";
var msg="Comment has been successfully deleted.";
ShowMessageBox(msg);
break;
}
}
function checkForLogin()
{
var hidAddCommentsEnable=document.getElementById("hidAddCommentsEnable").value;
if(hidAddCommentsEnable=="true")
{
return ShowModalPopup('pnlComment','Add Comments');
}
else
{
ShowMessageBox("You need to login for adding comment");
return false;
}
}
