var gtvt_wiz={
addQuestion:function(type,tag,position){
var newQ=new this.Question();
newQ.setAge("new");
var qId=0;
if(gtvt_ui.isNull(position)){
this.inQues.push(newQ);
qId=this.inQues.length;}else{
this.inQues.splice(position,0,newQ);
qId=position+1;}
var tagId=gtvt_ui.isNull(tag)?"new_"+qId:tag;
var element=document.createElement("div");
element.setAttribute("id","new_"+qId);
element.setAttribute("align","left");
gtvt_ui.getTag('questions_main').appendChild(element);
this.editQuestion(type,qId,'true',tagId);},
sortQuestion:function(isUp,qId){
if(isUp){
var first=this.inQues[qId-2];
var second=this.inQues[qId-1];
this.inQues[qId-2]=second;
this.inQues[qId-1]=first;}else{
var second=this.inQues[qId-1];
var first=this.inQues[qId];
this.inQues[qId]=second;
this.inQues[qId-1]=first;}
this.listQuestion('questions_main');},
cancelQuestion:function(type,qId,isNew){
errorTag=gtvt_ui.getTag('question_err').className='invisible';
if(isNew=='true'){
this.inQues.splice(qId-1,1);}
gtvt_ui.closeDialog('q_div');
this.listQuestion('questions_main');},
validateQuestion:function(type,qId){
gtvt_ui.getTag('question_err').className='invisible';
var text=gtvt_ui.getTag(qId+'_text');
if(gtvt_ui.anyNullTextError(text.value,'Question Text','question_err')){
text.focus();
return false;}
if('M'==type||'R'==type){
var choices=gtvt_ui.getTag(qId+'_choices');
if(gtvt_ui.anyNullTextError(choices.value,'Question Choices','question_err')){
choices.focus();
return false;}}else if('N'==type){
var expectedAns=document.getElementsByName(qId+'_exAns')[0];
var operator=document.getElementsByName(qId+'_operator')[0];
if(!gtvt_ui.isNull(operator.value)){
if(gtvt_ui.anyNumberError(expectedAns.value,'Expected Answer',true,true,'question_err')){
operator.focus();
return false;}}}
return true;},
saveQuestion:function(type,qId,isNew){
if(this.validateQuestion(type,qId)){
var text=gtvt_ui.getTag(qId+'_text').value;
var question=this.inQues[qId-1];
question.type=type;
question.text=text;
if('M'==type||'R'==type){
var choices=gtvt_ui.getTag(qId+'_choices').value;
var newChoices=gtvt_ui.uniqueList(choices);
var choicesArray=new Array(newChoices.length);
for(var i=0;i<newChoices.length;i++){
var qChoice=new this.QuestionChoice();
if(question.choices&&question.choices.length>i){
qChoice=question.choices[i];}
qChoice.choice=newChoices[i];
choicesArray[i]=qChoice;}
question.addChoices(choicesArray);}else if('N'==type){
question.exAns=document.getElementsByName(qId+'_exAns')[0].value;
question.operator=document.getElementsByName(qId+'_operator')[0].value;}else if('B'==type){
if(gtvt_ui.getTag(qId+'_yes').checked==true){
question.exAns='Y';}else if(gtvt_ui.getTag(qId+'_no').checked){
question.exAns='N';}else{question.exAns='';}}else if('T'==type){
if(gtvt_ui.getTag(qId+'_long').checked==true){
question.longShort='L';}else{question.longShort='S';}}
gtvt_ui.closeDialog('q_div');
this.listQuestion('questions_main');}},
deleteQuestion:function(qId,isNew){
if(isNew=='true'){
this.inQues.splice(qId-1,1);}else{
var question=this.inQues[qId-1];
this.inQues.splice(qId-1,1);
this.outQues.push(question);}
this.listQuestion('questions_main');},
listQuestion:function(tag){
var innerHtml='',parentTag=gtvt_ui.getTag(tag);
parentTag.innerHTML=innerHtml;
for(index=0;index<this.inQues.length;index++){
var qId=index+1;
var question=this.inQues[index];
var type=question.type;
var isNew=question.isNew();
var text="",choices="";
var option=('M'==type)?'<input type="checkbox" readonly=""/>&#160; ':'<input type="radio" readonly/>&#160; ';
if(question!=null){
for(var i=0;i<question.choices.length;i++){
choices=choices+option+question.choices[i].choice+'<br/>';}
text=question.text;}
var moveDown=(index+1==this.inQues.length)?'':'href="javascript:gtvt_wiz.sortQuestion(false, \''+qId+'\');"';
var moveUp=(index==0)?'':'href="javascript:gtvt_wiz.sortQuestion(true, \''+qId+'\');"';
var insert='href="javascript:gtvt_wiz.addQuestion(\''+type+'\', \''+qId+'_insert\', '+qId+');"';
innerHtml+='<div id="div_'+qId+'"><table width="100%" cellpadding="0" cellspacing="0">'+'<tr><td colspan="2" class="divider" height="1"></td></tr>'+'<tr><td class="content padding" valign="top" align="left">&#160;<span class="contentMedium">'+text+'</span> &#160;  &#160;'+'<a href="javascript:gtvt_wiz.editQuestion(\''+type+'\', \''+qId+'\', \'false\', \'div_'+qId+'\');" class="contentMedium">edit</a> / '+'<a href="javascript:gtvt_wiz.deleteQuestion(\''+qId+'\', \''+isNew+'\');" class="contentMedium">delete</a><br/><br/>';
if('M'==type||'R'==type){
innerHtml+=choices+'</td>'+'<td width="12%" align="left" valign="top" class="paddingClass">';}else if('N'==type){
innerHtml+='&#160;Please enter a number&#160;<input type="text"  readonly="" size="40" />'+'</td><td width="12%" align="left" valign="top" rowspan="2" class="paddingClass">';}else if('B'==type){
innerHtml+='<input type="radio"  readonly=""/>&#160;Yes  &#160;  &#160;  &#160; <input type="radio" readonly=""/>&#160;No'+'</td><td width="12%" align="left" valign="top" rowspan="2" class="paddingClass">';}else if('T'==type){
innerHtml+='&#160; <textarea cols="150" rows="3" name="OpenEndedQuestions" readonly=""></textarea></td>'+'<td width="12%" align="left" valign="top" rowspan="2" class="paddingClass">';}
innerHtml+='<table width="100%" cellpadding="0" cellspacing="0" class="rightQMenu">'+'<tr><td class="rightQMenuBg"><a '+moveUp+' class="rightQMenuText"><img src="http://appscdn.grouptivity.com/socialmail/groups/images/move_up.gif" '+moveUp+' hspace="4" vspace="4" align="absmiddle" border="0" /> &#160;move up</a></td>'+'</tr>'+'<tr><td class="rightQMenuBg"><a '+insert+' class="rightQMenuText"><img src="http://appscdn.grouptivity.com/socialmail/groups/images/insert.gif" '+insert+' hspace="4" vspace="4" align="absmiddle" border="0" /> &#160;insert</a></td>'+'<tr><td class="rightQMenuBg"><a '+moveDown+' class="rightQMenuText"><img src="http://appscdn.grouptivity.com/socialmail/groups/images/move_down.gif" '+moveDown+' hspace="4" vspace="4" align="absmiddle" border="0" /> &#160;move down</a></td>'+'</tr>'+'</tr></table></td></tr></table></div><div id="'+qId+'_insert"></div>';}
parentTag.innerHTML='<div id="gtvt_body">'+innerHtml+'</div>';},
editQuestion:function(type,qId,isNew,tag){
var question=null,divTag=gtvt_ui.getTag('q_div');
if(this.inQues.length>=qId){
question=this.inQues[qId-1];}
var text="",choices="";
if(question!=null){
for(var i=0;i<question.choices.length;i++){
choices=choices+question.choices[i].choice;
if((i+1)<question.choices.length){
choices=choices+'\n';}}
text=question.getText();
if(question.type!=type&&type=='N'){question.exAns='';}}
var innerHtml='<form action="javascript:void(null);" name="qForm"><table cellpadding="0" cellspacing="0" border="0" width="400">'+'<tr><td colspan="2" align="left" class="subSectionTitle paddingClass"><div style="float:right;" id="qndetails_cls_hider" class="closeBtn" onClick="gtvt_ui.closeDialog(\'q_div\');return false;">&#160;</div>Question:</td></tr>'+'<tr class="subNavDiffSectionBg paddingClass"><td colspan="2" align="left" valign="middle"><span class="content"><b>Question Type</b></span> '+'<select class="dropDown" name="'+qId+'_qList" onchange="gtvt_wiz.editQuestion(this.value, \''+qId+'\', \''+isNew+'\', \''+tag+'\');">'+'<option value="B" '+('B'==type?'selected':'')+'>YES/NO answer</option><option value="R" '+('R'==type?'selected':'')+'>Multiple Radio(one choice)</option>'+'<option value="M" '+('M'==type?'selected':'')+'>Multiple Choice</option><option value="T"'+('T'==type?'selected':'')+'>Textbox answer</option>'+'<option value="N" '+('N'==type?'selected':'')+'>Number type answer</option>'+'</select></td></tr>'+'<tr class="error"><td colspan="2" align="left"><div class="invisible" id="question_err"></div></td></tr>'+'<tr class="QeditingBg"><td class="paddingClass " colspan="2" align="left">';
if('M'==type||'R'==type){
innerHtml+='&#160; <br/>';
innerHtml+='<span class="content">Please type your question in the box below</span> <br/>'+'<textarea  id="'+qId+'_text" cols="70" rows="3">'+text+'</textarea><br/><br/>'+'<span class="content">Please type your answer choices in the box below. </span><br/>'+' <span class="contentSmall">All answers are separated by clicking return or enter on your keyboard (separate lines)</span> <br/>'+'<textarea id="'+qId+'_choices" cols="70" rows="3">'+choices+'</textarea><br/><br/>';}else if('N'==type){
var operator=question.operator;
innerHtml+='<span class="content"><b>Note: </b></span><span class="contentSmall">Use this question type when you are looking for an answer in the form of a number (i.e. how old are you, how many people will you be bringing, rate this product, etc.)</span><br/>';
innerHtml+='&#160; <br/>'+'<span class="content">Please type your question in the box below</span> <br/>'+'<textarea  id="'+qId+'_text" cols="70" rows="3">'+text+'</textarea><br/><br/>'+'<span class="content paddingRight"><b>Correct Answer</b></span>'+'<select class="dropDown" name="'+qId+'_operator">'+'<option value="et" '+('et'==operator?'selected':'')+'>Equal To</option>'+'<option value="lt" '+('lt'==operator?'selected':'')+'>Less Than</option>'+'<option value="le" '+('le'==operator?'selected':'')+'>Less Than or Equal To</option>'+'<option value="gt" '+('gt'==operator?'selected':'')+'>Greater Than</option>'+'<option value="ge" '+('ge'==operator?'selected':'')+'>Greater Than or Equal To</option>'+'</select>&#160;'+' <input type="text" value="'+question.exAns+'" name="'+qId+'_exAns" size="10"/><br/>'+'<span class="contentSmall">(An expected answer helps you to see which group members have answered incorrectly) </span><br/><br/>';}else if('B'==type){
innerHtml+='&#160; <br/>';
innerHtml+='<span class="content">Please type your question in the box below </span><br/>'+'<textarea id="'+qId+'_text" cols="70" rows="3">'+text+'</textarea><br/><br/>'+'<span class="content"><b>Correct Answer</b></span><span class="content"> <input type="radio" name="'+qId+'_exAns" id="'+qId+'_yes" '+('Y'==question.exAns?'checked':'')+' value="Y"/> Yes &#160;'+'<input type="radio" '+('N'==question.exAns?'checked':'')+' value="N" name="'+qId+'_exAns" id="'+qId+'_no" /> No </span><br/>'+'<span class="contentSmall">(An expected answer helps you to see which group members have answered incorrectly) </span> <br/><br/>';}else if('T'==type){
innerHtml+='&#160; <br/>';
innerHtml+='<span class="content">Please type your question in the box below</span><br/>'+'<textarea id="'+qId+'_text" cols="70" rows="3">'+text+'</textarea><br/><br/>'+'<span class="content"><b>Answer Length</b></span> <span class="content"><input type="radio" name="'+qId+'_longShort" id="'+qId+'_long" value="L" '+('L'==question.longShort?'checked':'')+' /> Paragraph &#160;  &#160; '+'<input type="radio" name="'+qId+'_longShort" id="'+qId+'_short" value="S" '+('S'==question.longShort?'checked':'')+' /> One Line</span><br/>'+'<span class="contentSmall">(select paragraph for a long answer and select one line for a short answer) </span><br/><br/>';}
innerHtml+='&#160; <input type="button" value="Save" name="SaveQuestion" class="button" onclick="gtvt_wiz.saveQuestion(\''+type+'\', \''+qId+'\', \''+isNew+'\');" id="q_hider"/>&#160; '+'<input type="button" value="Cancel" name="CancelQuestion"  class="button" onclick="gtvt_wiz.cancelQuestion(\''+type+'\', \''+qId+'\', \''+isNew+'\');return false;"/><br/><br/></td></tr></table></form>';
var wId=dojo.widget.createWidget("dojo:Dialog",{id:"q_div",bgColor:"white",bgOpacity:0.5,toggle:"fade",toggleDuration:500,closeOnBackgroundClick:"true"},dojo.byId("q_div"));
wId.setContent('<div id="gtvt_body">'+innerHtml+'</div>');
wId.show();},
addAttachment:function(fileId){
var file=gtvt_ui.getTag(fileId);
var fileUrl=gtvt_ui.trim(file.value);
if(gtvt_ui.isNull(fileUrl)||fileUrl.length<=0){
return;}
if(this.inAttachments.length==1){document.forms.gtvtForm.upload_button.setAttribute("disable","disable");
gtvt_ui.setErrorTag('Cannot upload more than 1 file.','options_err');return;}
gtvt_ui.hideTag(fileId);
file.removeAttribute("id");
file.setAttribute("name","cbBrowse_"+(this.inAttachments.length+1));
var hd=document.createElement("input");
hd.type='file';hd.id='upload';
hd.size='19';
document.forms.gtvtForm.appendChild(hd);
gtvt_ui.getTag("test").appendChild(hd);
var newAttch=new this.Attachment();newAttch.url=fileUrl;newAttch.name=this.getFileName(fileUrl);newAttch.isNew=true;this.inAttachments.push(newAttch);this.listAttachment('attachments_main');
this.listAttachment('attachments_main');},
getFileName:function(file){
if(!file){return;}
while(file.indexOf("\\")!=-1){
file=file.slice(file.indexOf("\\")+1);
if(file.indexOf("\\")<0){
return file;}}},
deleteAttachment:function(id,isNew){
if(isNew=='true'){
this.inAttachments.splice(id-1,1);}else{
var attch=this.inAttachments[id-1];
this.inAttachments.splice(id-1,1);
this.outAttachments.push(attch);}
if(this.inAttachments.length<3){
document.forms.gtvtForm.upload_button.removeAttribute("disable");}
this.listAttachment('attachments_main');},
listAttachment:function(tag){
var innerHtml='';
for(i=0;i<this.inAttachments.length;i++){
var attachment=this.inAttachments[i];
innerHtml+=attachment.name;
if(!gtvt_ui.isNull(attachment.size)){innerHtml+='('+attachment.size+')';}
innerHtml+=' <a href="javascript:gtvt_wiz.deleteAttachment('+(i+1)+', '+attachment.isNew+
');" class="redLink">remove</a>';
innerHtml+=(i<(this.inAttachments.length-1))?', ':'';}
var divTag=gtvt_ui.getTag(tag);
if(!gtvt_ui.isNull(divTag)){
divTag.innerHTML='<div id="gtvt_body">'+innerHtml+'</div>';}},
preview:function(){
var mainForm=document.forms.gtvtForm;
gtvt_ui.getTag('pre_from').innerHTML=mainForm.from.value;
gtvt_ui.getTag('pre_to').innerHTML=mainForm.to.value;
if(dojo.widget.byId("gtvt_calendar_id_sendDate_")){
gtvt_ui.getTag('pre_sendDate').innerHTML=dojo.widget.byId("gtvt_calendar_id_sendDate_").getValue();}else{
gtvt_ui.getTag('pre_sendDate').innerHTML=mainForm.sendDate.value;}
gtvt_ui.getTag('pre_subject').innerHTML=mainForm.subject.value;
gtvt_ui.getTag('pre_description').innerHTML=mainForm.description.value;
gtvt_ui.getTag('pre_comments').innerHTML=tinyMCE.getContent();
this.appendEventPreview();
this.appendAttachmentPreview();
this.appendQuestionPreview();
if(dlg_pre==null){dlg_pre=dojo.widget.createWidget("dojo:Dialog",{id:"pre_div",bgColor:"white",bgOpacity:0.5,toggle:"fade",toggleDuration:500,executeScripts:"true",cacheContent:"false",href:"",closeOnBackgroundClick:"true"},dojo.byId("pre_div"));}
dlg_pre.setContent(gtvt_ui.getTag('pre_div').innerHTML);
dlg_pre.show();},
appendEventPreview:function(){
var mainForm=document.forms.gtvtForm;
var innerHtml='';
if(mainForm.addEventYn.value=="Y"){
var evtToDate=dojo.widget.byId("gtvt_calendar_id_eventToDate_").getValue();
var evtFromDate=dojo.widget.byId("gtvt_calendar_id_eventFromDate_").getValue();
if(mainForm.eventAllDayYn.checked==true&&evtToDate==evtFromDate){
innerHtml='<table cellpadding="0" cellspacing="0" width="100%"><tr><td width="20%" class="content paddingLeft"><b>Event:</b></td><td width="80%" class="previewContent">'+mainForm.eventWhere.value+'</td></tr>'+
'<tr><td class="contentMedium"></td><td class="previewContent">'+
evtFromDate+'. This is an all day event.</td></tr></table>';}else if(mainForm.eventAllDayYn.checked==true){
innerHtml='<table cellpadding="0" cellspacing="0" width="100%"><tr><td width="20%" class="content paddingLeft"><b>Event:</b></td><td width="80%" class="previewContent">'+mainForm.eventWhere.value+'</td></tr>'+
'<tr><td class="contentMedium"></td><td class="previewContent">'+
evtFromDate+' TO '+evtToDate+'. This is an all day event.</td></tr></table>';}else{
innerHtml='<table cellpadding="0" cellspacing="0" width="100%"><tr><td width="20%" class="content paddingLeft"><b>Event:</b></td><td width="80%" class="previewContent">'+mainForm.eventWhere.value+'</td></tr>'+
'<tr><td class="contentMedium"></td><td class="previewContent">'+
evtFromDate+' '+mainForm.eventFromTime.value+' TO '+evtToDate+' '+mainForm.eventToTime.value+'.</td></tr></table>';}}
gtvt_ui.getTag('pre_event').innerHTML='<div id="gtvt_body">'+innerHtml+'</div>';},
appendAttachmentPreview:function(){
var innerHtml='';
if(this.inAttachments.length>0){
innerHtml='<table cellpadding="0" cellspacing="0" width="100%"><tr><td width="20%" class="content paddingLeft"><b>Attachment:</b></td><td width="80%" class="previewContent">';}else{
return;}
for(i=0;i<this.inAttachments.length;i++){
var attachment=this.inAttachments[i];
var attHtml=attachment.name;
if(!gtvt_ui.isNull(attachment.size)){attHtml+='('+attachment.size+')';}
innerHtml+=' <a class="contentMedium" href="#">'+attHtml+'</a>';
innerHtml+=(i<(this.inAttachments.length-1))?', ':'</td></tr></table>';}
gtvt_ui.getTag('pre_attach').innerHTML='<div id="gtvt_body">'+innerHtml+'</div>';},
appendQuestionPreview:function(){
var qTitleHtml='',innerHtml='';
if(this.inQues.length>0){
qTitleHtml='<table width="100%" cellpadding="0" cellspacing="0"><tr><td width="20%" class="content paddingLeft"><b>Questions:</b></td><td width="80%" ></td></tr></table>';
gtvt_ui.getTag('pre_qtitle').innerHTML=qTitleHtml;}else{
return;}
for(index=0;index<this.inQues.length;index++){
var qId=index+1;
var question=this.inQues[index];
var type=question.type;
var text="",choices="";
var option=('M'==type)?'<input type="checkbox" readonly=""/>&#160; ':'<input type="radio" readonly/>&#160; ';
if(question!=null){
for(var i=0;i<question.choices.length;i++){
choices=choices+option+question.choices[i].choice+'<br/>';}
text=question.text;}
innerHtml+='<table width="100%" cellpadding="0" cellspacing="0" class="aBg3"><tr><td class="reportQline"/></tr><tr><td class="qBG3">'+text+'</td></tr>';
if('M'==type||'R'==type){
innerHtml+='<tr><td class="aBg3Content">'+choices+'</td></tr>';}else if('N'==type){
innerHtml+='<tr><td class="aBg3 aBg3Content">&#160; Please enter a number <input class="txtBox" size="10" type="text" readonly=""></td></tr>';}else if('B'==type){
innerHtml+='<tr><td class="aBg3Content"><input type="radio" readonly=""/> Yes <br/><input type="radio" readonly=""/>No</td></tr>';}else if('T'==type){
innerHtml+='<tr><td class="aBg3 inputPadding paddingClass">&#160; <textarea cols="50" rows="3" readonly=""></textarea></td></tr>';}
innerHtml+='<tr><td class="padding"/></tr></table>';}
gtvt_ui.getTag('pre_qlist').innerHTML='<div id="gtvt_body">'+innerHtml+'</div>';},
composeReLogin:function(isItEmailPlus){
if(isItEmailPlus==true)
document.forms.gtvtForm.action='emailplus.do?loginAsDiffUser=Y';
else
document.forms.gtvtForm.action='saveplus.do?loginAsDiffUser=Y';
document.forms.gtvtForm.submit();},
advanceOptions:function(){
this.appendRcpts();
var hd=document.createElement("input");
hd.type='hidden';
hd.value='moreOptions';
hd.name='action';
document.forms.gtvtForm.appendChild(hd);
document.forms.gtvtForm.action='wizard.do';
document.forms.gtvtForm.submit();},
quickCompose:function(){
if(this.validateComposeSection()){
this.appendRcpts();
var hd=document.createElement("input");
hd.type='hidden';
hd.value='quickComposeSend';
hd.name='action';
document.forms.gtvtForm.sendBtn.value='Sending..';
document.forms.gtvtForm.sendBtn.disabled=true;
document.forms.gtvtForm.firstDisplay.value='N';
document.forms.gtvtForm.appendChild(hd);
document.forms.gtvtForm.submit();}},
sendMessage:function(){
if(this.validateComposeSection()&&this.validateDateSettings()){
this.setVariables();
var hd=document.createElement("input");
hd.type='hidden';
hd.value='send';
hd.name='action';
document.forms.gtvtForm.appendChild(hd);
document.forms.gtvtForm.submit();}},
saveQuickComposeMessage:function(){
if(this.validateComposeSection(true)){
var hd=document.createElement("input");
hd.type='hidden';
hd.value='saveTask';
hd.name='action';
document.forms.gtvtForm.firstDisplay.value='N';
document.forms.gtvtForm.appendChild(hd);
document.forms.gtvtForm.submit();}},
saveMessage:function(){
if(this.validateComposeSection(true)&&this.validateDateSettings()){
this.setVariables();
var hd=document.createElement("input");
hd.type='hidden';
hd.value='saveTask';
hd.name='action';
document.forms.gtvtForm.appendChild(hd);
document.forms.gtvtForm.submit();}},
validateComposeSection:function(saveAsDraft){
errorTag=gtvt_ui.getTag('compose_err').className='invisible';
if(saveAsDraft==true){
if(gtvt_ui.anyNullTextError(document.forms.gtvtForm.title.value,'Title','compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
if(gtvt_ui.anyNullTextError(document.forms.gtvtForm.url.value,'URL/LInk','compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
return true;}
if(gtvt_ui.anyNullTextError(document.forms.gtvtForm.subject.value,'Subject','compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
if(gtvt_ui.anyEmailIdsError(document.forms.gtvtForm.to.value,'Recipient','compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
if(document.forms.gtvtForm.addEventYn.value=='Y'){
if(gtvt_ui.anyNullTextError(document.forms.gtvtForm.eventWhere.value,'Where','compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
if(gtvt_ui.anyDateError(dojo.widget.byId("gtvt_calendar_id_eventFromDate_").getValue(),'From Date',false,'compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
if(gtvt_ui.anyDateError(dojo.widget.byId("gtvt_calendar_id_eventToDate_").getValue(),'To Date',false,'compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
if(gtvt_ui.anyDateCompareError(dojo.widget.byId("gtvt_calendar_id_eventFromDate_").getValue(),'From Date',">",
dojo.widget.byId("gtvt_calendar_id_eventToDate_").getValue(),'To Date','compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
if(document.forms.gtvtForm.eventAllDayYn.checked!=true){
if(gtvt_ui.anyTimeError(document.forms.gtvtForm.eventFromTime.value,'From Time',false,'compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}
if(gtvt_ui.anyTimeError(document.forms.gtvtForm.eventToTime.value,'To Time',false,'compose_err')){
document.forms.gtvtForm.xyz.focus();
return false;}}}
return true;},
validateDateSettings:function(){
errorTag=gtvt_ui.getTag('settings_err').className='invisible';
if(dojo.widget.byId("gtvt_calendar_id_sendDate_")){
if(gtvt_ui.anyDateError(dojo.widget.byId("gtvt_calendar_id_sendDate_").getValue(),'Send Date','settings_err')){
document.forms.gtvtForm.sendDate.focus();
return false;}}else{
if(gtvt_ui.anyDateError(document.forms.gtvtForm.sendDate.value,'Send Date','settings_err')){
document.forms.gtvtForm.sendDate.focus();
return false;}}
var reminder=document.getElementsByName('reminderYn');
var reminderYn=false;
for(i=0;i<reminder.length;i++){
if(reminder[i].checked=='checked'&&reminder[i].value=='Y'){reminderYn=true;}}
if(reminderYn){
if(gtvt_ui.anyDateError(dojo.widget.byId("gtvt_calendar_id_reminderDate_").getValue(),'Reminder Date','settings_err')){
document.forms.gtvtForm.reminderDate.focus();
return false;}
if(dojo.widget.byId("gtvt_calendar_id_sendDate_")){
if(gtvt_ui.anyDateCompareError(dojo.widget.byId("gtvt_calendar_id_sendDate_").getValue(),'Send Date',"<=",
dojo.widget.byId("gtvt_calendar_id_reminderDate_").getValue(),'Reminder Date','settings_err')){
document.forms.gtvtForm.reminderDate.focus();
return false;}else{
if(gtvt_ui.anyDateCompareError(document.forms.gtvtForm.sendDate.value,'Send Date',"<=",
dojo.widget.byId("gtvt_calendar_id_reminderDate_").getValue(),'Reminder Date','settings_err')){
document.forms.gtvtForm.reminderDate.focus();
return false;}}}}
var recurrence=document.getElementsByName('recurrenceYn');
var recurrenceYn=false;
for(i=0;i<recurrence.length;i++){
if(recurrence[i].checked=='checked'&&recurrence[i].value=='Y'){recurrenceYn=true;}}
if(recurrenceYn){
var recurrenceEnd=document.getElementsByName('recurrenceEndYn');
var recurrenceEndYn=false;
for(i=0;i<recurrenceEnd.length;i++){
if(recurrenceEnd[i].checked=='checked'&&recurrenceEnd[i].value=='Y'){recurrenceEndYn=true;}}}
if(recurrenceEndYn){
if(gtvt_ui.anyDateError(dojo.widget.byId("gtvt_calendar_id_recurrenceEndDate_").getValue(),'Repeat End Date','settings_err')){
document.forms.gtvtForm.recurrenceEndDate.focus();
return false;}
if(dojo.widget.byId("gtvt_calendar_id_sendDate_")){
if(gtvt_ui.anyDateCompareError(dojo.widget.byId("gtvt_calendar_id_sendDate_").getValue(),'Send Date',"<",dojo.widget.byId("gtvt_calendar_id_recurrenceEndDate_").getValue(),'Repeat End Date','settings_err')){
document.forms.gtvtForm.recurrenceEndDate.focus();
return false;}}else{
if(gtvt_ui.anyDateCompareError(document.forms.gtvtForm.sendDate.value,'Send Date',"<",dojo.widget.byId("gtvt_calendar_id_recurrenceEndDate_").getValue(),'Repeat End Date','settings_err')){
document.forms.gtvtForm.recurrenceEndDate.focus();
return false;}}}
return true;},
inQues:[],
outQues:[],
inAttachments:[],
outAttachments:[],
Attachment:function(id,name,url,size,isNew){
this.id=id;
this.name=name;
this.url=url;
this.size=size;
this.isNew=function(){if(this.age=='old'){return false;}return true;};
this.age="new";},
Question:function(id,type,text,exAns,operator,longShort){
this.id=id;
this.type=type;
this.text=text;
this.exAns=exAns;
this.operator=operator;
this.longShort=longShort;
this.age="new";
this.setAge=function(age){this.age=age;};
this.isNew=function(){
if(this.age=='old'){return false;}
return true;};
this.choices=[];
this.addChoices=function(choices){
this.choices=choices;};
this.getText=function(){if(gtvt_ui.isNull(this.text)){return '';}return gtvt_ui.trim(this.text);};},
QuestionChoice:function(id,choice){
this.id=id;
this.choice=choice;
this.setChoice=function(choice){this.choice=choice;};},
setVariables:function(){
this.appendQs();
this.appendRcpts();
this.appendAttchmnts();},
appendQs:function(){
var edtCount=0,newCount=0;
for(i=0;i<this.inQues.length;i++){
if(this.inQues[i].age=="old"){
this.addQInput('edt_q',edtCount,this.inQues[i],i);
edtCount+=1;}else if(this.inQues[i].age=="new"){
this.addQInput('add_q',newCount,this.inQues[i],i);
newCount+=1;}}
for(i=0;i<this.outQues.length;i++){
this.addQInput('dtl_q',i,this.outQues[i]);}
this.addInput('edt_q',edtCount);
this.addInput('add_q',newCount);
this.addInput('dtl_q',this.outQues.length);},
appendRcpts:function(){
var emails=gtvt_ui.trim(document.forms.gtvtForm.to.value);
if(gtvt_ui.isNull(emails)||emails==''){return;}
var emailList=emails.split(/[,;]/);
for(var i=0;i<emailList.length;i++){
this.addInput("recipients",emailList[i]);}},
appendAttchmnts:function(){
var dltdAttachments=this.outAttachments.length;
var addAttachments=this.inAttachments.length;
for(i=0;i<dltdAttachments;i++){
this.addInput('dtl_att'+i+'_id',this.outAttachments[i].id);}
this.addInput('dtl_att',dltdAttachments);
var oldAttCt=0;
for(i=0;i<addAttachments;i++){
if(this.inAttachments[i].age=='old'){
this.addInput('edt_a'+i+'_id',this.inAttachments[i].id);
this.addInput('edt_a'+i+'_name',this.inAttachments[i].name);
this.addInput('edt_a'+i+'_size',this.inAttachments[i].size);
oldAttCt=oldAttCt+1;}}
this.addInput('edt_a',oldAttCt);},
addQInput:function(prefix,index,ques,sortOrder){
if(gtvt_ui.isNull(ques)||ques=='undefined'){return;}
this.addInput(prefix+index+'_id',ques.id);
this.addInput(prefix+index+'_txt',ques.text);
this.addInput(prefix+index+'_op',ques.operator);
this.addInput(prefix+index+'_ea',ques.exAns);
if(!gtvt_ui.isNull(sortOrder)){
var soCount=sortOrder+1;
this.addInput(prefix+index+'_so',(soCount));}else{
this.addInput(prefix+index+'_so',index);}
if(ques.type=='T'){
this.addInput(prefix+index+'_typ',ques.longShort);}else{
this.addInput(prefix+index+'_typ',ques.type);}
var choicesCount=ques.choices.length;
for(c=0;c<choicesCount;c++){
this.addInput(prefix+index+'_ctxt'+c,ques.choices[c].choice);
this.addInput(prefix+index+'_cid'+c,ques.choices[c].id);}
if(choicesCount>0){
this.addInput(prefix+index+'_c',ques.choices.length);}},
addInput:function(name,value,type){
if(gtvt_ui.isNull(value)){return;}
if(gtvt_ui.isNull(type)){type='hidden';}
var ques=document.createElement("input");
ques.value=value;
ques.name=name;
ques.type=type;
document.forms.gtvtForm.appendChild(ques);},
openid_authenticate:function(){
if (document.forms.gtvtForm.openid.value =="") {
      window.document.gtvtForm.openid.focus();
      window.close();
  }
  var xyz=document.forms.gtvtForm.openid.value;
  mywindow = window.open('groups/jsp/openidredirect.jsp?openid='+xyz,'emailplus','toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=no,location=no,width=824,left=150, top=150,height=500');
}
};
