String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}



function Rating(inRate,inPreId,isLock){
    this.rate  = inRate;
    this.preId = inPreId;
    this.Lock  = isLock;//If true it lock show only
    this.compe = document.createElement('div');
    this.compe.id = this.preId+'Comps';
    this.compe.style.margin = '0px 10px';

    this.selRate = document.createElement('select');
    this.selRate.id = this.preId+'Sel';
    this.opRate0 = document.createElement('option');
    this.opRate1 = document.createElement('option');
    this.opRate2 = document.createElement('option');
    this.opRate3 = document.createElement('option');
    this.opRate4 = document.createElement('option');
    this.opRate5 = document.createElement('option');

    this.opRate0.appendChild(document.createTextNode('-'));
    this.opRate0.setAttribute('value','-');
    this.opRate1.appendChild(document.createTextNode('1'));
    this.opRate1.setAttribute('value','1');
    this.opRate2.appendChild(document.createTextNode('2'));
    this.opRate2.setAttribute('value','2');
    this.opRate3.appendChild(document.createTextNode('3'));
    this.opRate3.setAttribute('value','3');
    this.opRate4.appendChild(document.createTextNode('4'));
    this.opRate4.setAttribute('value','4');
    this.opRate5.appendChild(document.createTextNode('5'));
    this.opRate5.setAttribute('value','5');

    this.selRate.appendChild(this.opRate0);
    this.selRate.appendChild(this.opRate1);
    this.selRate.appendChild(this.opRate2);
    this.selRate.appendChild(this.opRate3);
    this.selRate.appendChild(this.opRate4);
    this.selRate.appendChild(this.opRate5);

    this.selRate.style.marginLeft = '5px';
    this.selRate.style.marginTop = '-2px';
    //this.compe.style.width = '100px';
    //this.compe.style.float ='left';

    this.rate1 = document.createElement('img');
    this.rate2 = document.createElement('img');
    this.rate3 = document.createElement('img');
    this.rate4 = document.createElement('img');
    this.rate5 = document.createElement('img');

    this.rate1.id = this.preId+'1';
    this.rate2.id = this.preId+'2';
    this.rate3.id = this.preId+'3';
    this.rate4.id = this.preId+'4';
    this.rate5.id = this.preId+'5';

    this.rate1.setAttribute('title','1');
    this.rate2.setAttribute('title','2');
    this.rate3.setAttribute('title','3');
    this.rate4.setAttribute('title','4');
    this.rate5.setAttribute('title','5');

    this.compe.appendChild(this.rate1);
    this.compe.appendChild(this.rate2);
    this.compe.appendChild(this.rate3);
    this.compe.appendChild(this.rate4);
    this.compe.appendChild(this.rate5);

    

    this.rate1.src = 'Images/Rating1.png';
    this.rate2.src = 'Images/Rating1.png';
    this.rate3.src = 'Images/Rating1.png';
    this.rate4.src = 'Images/Rating1.png';
    this.rate5.src = 'Images/Rating1.png';

    var list = null;
    if(this.rate == '0'){
        if(this.Lock == false){
          list =  this.compe.childNodes;
          for(var i = 0; i< list.length;i++){
              list[i].onclick = function(){
                  rateOnclick(this);
              }
              list[i].onmouseover = function(){
                  rateOnmouseover(this);
              }
              list[i].onmouseout = function(){
                  rateOnmouseout(this);
              }
          }
        //  this.compe.appendChild(document.createElement('br'));
          this.compe.appendChild(this.selRate);
          this.selRate.onchange = function(){
            if(this.getAttribute('value')!='-'){
               var myValue =  parseInt(this.value)-1;
               var imgList = this.parentNode.childNodes;
              // alert(imgList[myValue].nodeName + '  '+myValue);
              // alert(imgList.length + '   '+myValue);

                //alert(imgList[)-1].getAttriubte('title'));
               imgList[myValue].onclick();
            }
          }
        }
        
    }else{
        list =  this.compe.childNodes;
        var count = parseInt(this.rate);
        for(var i = 0; i < count;i++){
            list[i].src = 'Images/Rating3.png';
            list[i].setAttribute('title', '');
        }
        this.compe.setAttribute('title', 'Rating = '+ this.rate);
        objSel = this.compe.getElementsByTagName('select')[0];
        objSel.parentNode.removeChild(objSel);
        
    }

    this.setRate = function(inRate){
        var list =  this.compe.childNodes;
        for(var i = 0; i < 5;i++){
            list[i].src = 'Images/Rating1.png';
            list[i].setAttribute('title', '');
            list[i].onmouseout = function(){}
            list[i].onmouseover = function(){}
            list[i].onclick = function(){}
        }
        var count = 0;
        if(inRate == 1){
          count =1;
        }else if(inRate == 2){
          count =2;
        }else if(inRate == 3){
          count =3;
        }else if(inRate == 4){
          count =4;
        }else if(inRate == 5){
          count =5;
        }
        this.rate = count;
        for(var i = 0; i < count;i++){
            list[i].src = 'Images/Rating3.png';
            list[i].setAttribute('title', '');
            
        }
        this.compe.setAttribute('title', 'Rating = '+ this.rate);

        objSel = this.compe.getElementsByTagName('select')[0];
        
        if(objSel!=null){this.compe.removeChild(objSel);}
        
    }


}
function rateOnmouseover(objImg){
  var divP = objImg.parentNode ;
  var list = divP.childNodes;

  for(var i = 0; i < list.length; i++){
      //alert(list[i].id + '    '+ objImg.id);
      if(list[i].id <= objImg.id){
        list[i].src = 'Images/Rating3.png';
      }else{
        list[i].src = 'Images/Rating1.png';
      }
  }
}
function rateOnmouseout(objImg){
  var divP = objImg.parentNode ;
  var list = divP.childNodes;
  for(var i = 0; i < list.length; i++){
    list[i].src = 'Images/Rating1.png';
  }
}
function rateOnclick(objImg){
  var divP = objImg.parentNode ;
  var list = divP.childNodes;
  for(var i = 0; i < list.length-1; i++){
      if(list[i].id <= objImg.id){
        list[i].src = 'Images/Rating3.png';
        divP.setAttribute('rValue',list[i].getAttribute('title'));
        divP.setAttribute('title', 'Rating = '+ list[i].getAttribute('title'));
        //list[list.length-1].setAttribute('value',list[i].getAttribute('title'));
        list[list.length-1].value = list[i].getAttribute('title');
      }else{
        list[i].src = 'Images/Rating1.png';
      }
    //list[i].setAttribute('title', '');

    list[i].onmouseout = function(){}
    list[i].onmouseover = function(){}
    //list[i].onclick = function(){}

  }

}

function sortProfile(inCmd){
  orderBy = inCmd.getAttribute('orderBy');
  var attFromTo = inCmd.getAttribute('fromTo');
  if(attFromTo == 'A'){
      attFromTo = 'D';
      if(orderBy == 'R'){
        byId('imgRating').src='./Images/sort_desc.png';
        byId('imgRating').title='ลำดับจากมากไปน้อย';
        byId('cmdRating').style.fontWeight = 'bold';
        byId('cmdPrice').style.fontWeight = '';
      }else{
        byId('imgPrice').src='./Images/sort_desc.png';
        byId('imgPrice').title='ลำดับจากมากไปน้อย';
        byId('cmdRating').style.fontWeight = '';
        byId('cmdPrice').style.fontWeight = 'bold';
      }
  }else{
      attFromTo = 'A';
      if(orderBy == 'R'){
        byId('imgRating').src='./Images/sort_asc.png';
        byId('imgRating').title='ลำดับจากน้อยไปมาก';
        byId('cmdRating').style.fontWeight = 'bold';
        byId('cmdPrice').style.fontWeight = '';
      }else{
        byId('imgPrice').src='./Images/sort_asc.png';
        byId('imgPrice').title='ลำดับจากน้อยไปมาก';
        byId('cmdRating').style.fontWeight = '';
        byId('cmdPrice').style.fontWeight = 'bold';
      }
  }

  inCmd.setAttribute('fromTo',attFromTo);  
  fromTo = attFromTo;

  getProfile(curPage,orderBy,fromTo);
}

function getProfile(pageId,orderBy,fromTo){
  var urlAction ='profileByPage.php?ps='+pageId;
  urlAction += '&orderBy='+orderBy;
  urlAction += '&fromTo='+fromTo;
  dojo.io.bind({
	   url: urlAction,
	   handler: callbackGetProfile,
	   mimetype: 'text/plain' ,
	   encoding:'utf-8'
	});
}

function callbackGetProfile(p1,p2,p3){
    if(p1 ==  'error'){

    }else{
        eval('var list ='+p2);
        
        for(var i = 0; i < 5; i++){
            var profileId = 'profile'+i;
            if(i<list.master.length){
              //alert(list.master[i]['name']);
              setMasterDataToProfileGUI(list.master[i],i);
              try{
              byId(profileId).style.display = '';
              }catch(err){


              }
            }else{                
                byId(profileId).style.display = 'none';
            }
        }
    }
}

function setMasterDataToProfileGUI(objMaster,index){

  var msImageId = 'msImg'+index;
  var msName = 'msName'+index;
  var msDesc ='msDesc'+index;
  var objRate ='objRate'+index;
  var msPrice = 'msPrice'+index;
  var msBoard = 'msBoard'+index;
  var msPhone = 'msPhone'+index;
  var msCmdForecast = 'cmdForcast'+index;
  var msOnline = 'msStatus'+index;
  var msTimeService = 'msTimeService'+index;

  if(byId(msImageId)!= null){
      byId(msImageId).src = 'Images/profile/'+objMaster['image'];
  }
  if(byId(msName)!= null){
      //byId(msName).firstChild.nodeValue = objMaster['userId'] +' ' +objMaster['name'];
      byId(msName).firstChild.nodeValue = objMaster['name'];
  }
  if(byId(msDesc)!= null){
      byId(msDesc).firstChild.nodeValue = objMaster['jobDesc'];
  }
  eval(objRate+'.setRate('+objMaster['rating']+');');

  if(byId(msPrice)!= null){
      byId(msPrice).firstChild.nodeValue = objMaster['price'] +' บาท';
  }
  if(byId(msBoard)!= null){
      
        byId(msBoard).href = 'customerComments.php?msId='+objMaster['id']+'&name='+objMaster['userId'];;
        byId(msBoard).target = '_blank';
        byId(msBoard).style.color='#a32828';
        byId(msBoard).style.marginRight='15px';
        byId(msBoard).firstChild.nodeValue = objMaster['comments']+ ' Comments';
      
  }
  if(byId(msPhone)!= null){
      byId(msPhone).firstChild.nodeValue = objMaster['phone'];
  }
  if(byId(msCmdForecast)!=null){
      byId(msCmdForecast).setAttribute('msvalue',objMaster['id']);
      byId(msCmdForecast).setAttribute('msname',objMaster['userId']);
  }
  if(byId(msOnline)!=null){      
    if(objMaster['online']=='B'){
      byId(msOnline).src = 'Images/con_mobile.png';
      byId(msOnline).setAttribute('title','ติดสายพยากรณ์');
    }else{
      byId(msOnline).src = 'Images/status_1.png';
      byId(msOnline).setAttribute('title','ว่าง');
    }
  }
  if(byId(msTimeService)!= null){
      byId(msTimeService).firstChild.nodeValue = objMaster['timeservice'];
  }


}
function getBoardComment(pageId,commentId){
    var urlAction ='boardCommentByPage.php?ps='+pageId+"&cmId="+commentId;
    dojo.io.bind({
	   url: urlAction,
	   handler: callbackGetBoardComment,
	   mimetype: 'text/plain' ,
	   encoding:'utf-8'
	});

}

function callbackGetBoardComment(p1,p2,p3){
    if(p1 == 'error'){

    }else{
        eval('var list ='+p2);
        for(var i = 0; i < 5; i++){
            var commentId = 'comment'+i;
            if(i<list.Quest.length){
              //alert(list.master[i]['name']);
              setBoardCommentDataToGUI(list.Quest[i],i);
              byId(commentId).style.display = '';
            }else{
                byId(commentId).style.display = 'none';
            }
        }
    }
}

function setBoardCommentDataToGUI(objComment ,index){
  var msName = 'custName'+index;
  var msDesc ='msDesc'+index;
  //var objRate ='objRate'+index;
  var msDateTime = 'msDateTime'+index;

  if(byId(msName)!= null){
      byId(msName).firstChild.nodeValue = 'คุณ '+objComment['CustName'] ;
  }
  if(byId(msDesc)!= null){
      byId(msDesc).firstChild.nodeValue = objComment['CommentDesc'];
  }
  if(byId(msDateTime)!= null){
     // byId(msDateTime).firstChild.nodeValue ='วันที่ถาม '+ objQuestion['PostDate'];
     byId(msDateTime).firstChild.nodeValue = 'วันที่ Comment : '+ objComment['PostDate'];
    /* var aTag = document.createElement('a');
     aTag.setAttribute('href','boardQuestDetail.php?pageId='+objComment['Id']);
     aTag.setAttribute('target','_blank');
     aTag.appendChild(document.createTextNode('อ่านคำตอบ'))
     byId(msDateTime).appendChild(aTag);*/
  }
}


function getBoardCustQuestion(pageId){
    var urlAction ='boardCustQuestionByPage.php?ps='+pageId;
    dojo.io.bind({
	   url: urlAction,
	   handler: callbackGetBoardCustQuestion,
	   mimetype: 'text/plain' ,
	   encoding:'utf-8'
	});
}

function callbackGetBoardCustQuestion(p1,p2,p3){
    if(p1 == 'error'){

    }else{
        eval('var list ='+p2);
        for(var i = 0; i < 5; i++){
            var commentId = 'comment'+i;
            if(i<list.Quest.length){
              //alert(list.master[i]['name']);
              setCustQuestionDataToGUI(list.Quest[i],i);
              byId(commentId).style.display = '';
            }else{
                byId(commentId).style.display = 'none';
            }
        }
    }
}

function setCustQuestionDataToGUI(objQuestion ,index){
  var msName = 'custName'+index;
  var msDesc ='msDesc'+index;
  //var objRate ='objRate'+index;
  var msDateTime = 'msDateTime'+index;

  if(byId(msName)!= null){
      byId(msName).firstChild.nodeValue = 'คำถามจากคุณ '+objQuestion['CustName'] +'   ถามเมื่อ '+ objQuestion['PostDate'];
  }
  if(byId(msDesc)!= null){
      byId(msDesc).firstChild.nodeValue = objQuestion['QuestDesc'];
  }
  if(byId(msDateTime)!= null){
     // byId(msDateTime).firstChild.nodeValue ='วันที่ถาม '+ objQuestion['PostDate'];
     byId(msDateTime).firstChild.nodeValue = '';

     if(objQuestion['RowStatus'] =='A'){
       var aTag = document.createElement('a');
       aTag.setAttribute('href','boardQuestDetail.php?pageId='+objQuestion['Id']);
       aTag.setAttribute('target','_blank');
       aTag.appendChild(document.createTextNode('อ่านคำตอบ'))
       removeNode(byId(msDateTime));
       byId(msDateTime).appendChild(aTag);
       byId(msDateTime).appendChild(document.createTextNode('  '));
     }else{
         removeNode(byId(msDateTime));
         byId(msDateTime).appendChild(document.createTextNode(' ยังไม่ได้รับการตอบ '));
         byId(msDateTime).appendChild(document.createTextNode('  '));
     }

     if(objQuestion['RowStatus'] !='A'){
       var aTagDel = document.createElement('a');
       aTagDel.setAttribute('href','boardCustQuestDelete.php?pageId='+objQuestion['Id']);
       //aTagDel.setAttribute('target','_blank');
       aTagDel.appendChild(document.createTextNode('ลบคำถาม'))
       byId(msDateTime).appendChild(aTagDel);
     }
  }
}

function getBoardMasterQuestion(pageId){
    var urlAction ='boardQuestionMasterByPage.php?ps='+pageId;
    dojo.io.bind({
	   url: urlAction,
	   handler: callbackGetBoardMasterQuestion,
	   mimetype: 'text/plain' ,
	   encoding:'utf-8'
	});
}
function callbackGetBoardMasterQuestion(p1,p2,p3){
    if(p1 == 'error'){

    }else{
        eval('var list ='+p2);
        for(var i = 0; i < 5; i++){
            var commentId = 'comment'+i;
            if(i<list.Quest.length){
              //alert(list.master[i]['name']);
              setMasterQuestionDataToGUI(list.Quest[i],i);
              byId(commentId).style.display = '';
            }else{
                byId(commentId).style.display = 'none';
            }
        }
    }
}
function setMasterQuestionDataToGUI(objQuestion ,index){
  var msName = 'custName'+index;
  var msDesc ='msDesc'+index;
  //var objRate ='objRate'+index;
  var msDateTime = 'msDateTime'+index;

  if(byId(msName)!= null){
      byId(msName).firstChild.nodeValue = 'คำถามจากคุณ '+objQuestion['CustName'] +'   ถามเมื่อ '+ objQuestion['PostDate'];
  }
  if(byId(msDesc)!= null){
      byId(msDesc).firstChild.nodeValue = objQuestion['QuestDesc'];
  }
  if(byId(msDateTime)!= null){
     // byId(msDateTime).firstChild.nodeValue ='วันที่ถาม '+ objQuestion['PostDate'];
     byId(msDateTime).firstChild.nodeValue = '';
     var aTag = document.createElement('a');
     aTag.setAttribute('href','boardMasterQuestDetail.php?pageId='+objQuestion['Id']);
     aTag.setAttribute('target','_blank');
     aTag.appendChild(document.createTextNode('อ่านคำถาม'))
     removeNode(byId(msDateTime));
     byId(msDateTime).appendChild(aTag);
  }

  //eval(objRate+'.setRate('+objQuestion['rating']+');');
}

function getBoardQuestion(pageId){
    var urlAction ='boardQuestionByPage.php?ps='+pageId;
    dojo.io.bind({
	   url: urlAction,
	   handler: callbackGetBoardQuestion,
	   mimetype: 'text/plain' ,
	   encoding:'utf-8'
	});
}
function callbackGetBoardQuestion(p1,p2,p3){
    if(p1 == 'error'){

    }else{
        eval('var list ='+p2);
        for(var i = 0; i < 5; i++){
            var commentId = 'comment'+i;
            if(i<list.Quest.length){
              //alert(list.master[i]['name']);
              setQuestionDataToGUI(list.Quest[i],i);
              byId(commentId).style.display = '';
            }else{
                byId(commentId).style.display = 'none';
            }
        }
    }
}
function setQuestionDataToGUI(objQuestion ,index){
  var msName = 'custName'+index;
  var msDesc ='msDesc'+index;
  //var objRate ='objRate'+index;
  var msDateTime = 'msDateTime'+index;

  if(byId(msName)!= null){
      byId(msName).firstChild.nodeValue = 'คำถามจากคุณ '+objQuestion['CustName'] +'   ถามเมื่อ '+ objQuestion['PostDate'];
  }
  if(byId(msDesc)!= null){
      byId(msDesc).firstChild.nodeValue = objQuestion['QuestDesc'];
  }
  if(byId(msDateTime)!= null){
     // byId(msDateTime).firstChild.nodeValue ='วันที่ถาม '+ objQuestion['PostDate'];
     byId(msDateTime).firstChild.nodeValue = '';
     var aTag = document.createElement('a');
     aTag.setAttribute('href','boardQuestDetail.php?pageId='+objQuestion['Id']);
     aTag.setAttribute('target','_blank');
     aTag.appendChild(document.createTextNode('อ่านคำตอบ'))
     removeNode(byId(msDateTime));
     byId(msDateTime).appendChild(aTag);
  }

  //eval(objRate+'.setRate('+objQuestion['rating']+');');
}

function getComment(pageId,msId){
  var urlAction ='commentByPage.php?ps='+pageId;
  urlAction += '&msId='+msId;

  dojo.io.bind({
	   url: urlAction,
	   handler: callbackGetComment,
	   mimetype: 'text/plain' ,
	   encoding:'utf-8'
	});
}

function callbackGetComment(p1,p2,p3){
    if(p1=='error'){

    }else{
        eval('var list ='+p2);
        for(var i = 0; i < 5; i++){
            var commentId = 'comment'+i;
            if(i<list.comment.length){
              //alert(list.master[i]['name']);
              setCommentDataToGUI(list.comment[i],i);
              byId(commentId).style.display = '';
            }else{
                byId(commentId).style.display = 'none';
            }
        }
    }
}
function setCommentDataToGUI(objComment , index){
  //var msImageId = 'msImg'+index;
  var msName = 'custName'+index;
  var msDesc ='msDesc'+index;
  var objRate ='objRate'+index;
  var msDateTime = 'msDateTime'+index;
  
  if(byId(msName)!= null){
      byId(msName).firstChild.nodeValue = 'โดย '+objComment['userId'];
  }
  if(byId(msDesc)!= null){
      byId(msDesc).firstChild.nodeValue = objComment['commentDesc'];
  }
  if(byId(msDateTime)!= null){
      byId(msDateTime).firstChild.nodeValue ='เวลา '+ objComment['datecomment'];
  }

  eval(objRate+'.setRate('+objComment['rating']+');');

  
}

var autoDialogTimeout = null;
function showAutoDialog(x,y,msg){
   if(byId('Dialog')!= null){
       closeDialog();
   }
   var objDialog = document.createElement('div');
   objDialog.id = 'Dialog';

   objDialog.style.top = y+'px';
   objDialog.style.left = x+'px';

   var objDiHead = document.createElement('div');
   var objDiBody = document.createElement('div');
   objDiHead.className = 'DialogHeade';
   objDiBody.className = 'DialogBody';
   objDiHead.style.color ='#FFFFFF';
   objDiHead.appendChild(document.createTextNode('Close'));
   objDiHead.onclick= function(){
       closeDialog();
   }

   objDialog.appendChild(objDiHead);
   objDialog.appendChild(objDiBody);
   objDiBody.appendChild(document.createTextNode(msg));

   var cardContainer = byId('PageBody');
   cardContainer.appendChild(objDialog);

   //autoDialogTimeout = setTimeOut('closeDialogAuto',500);
   //alert('Hello1');
   autoDialogTimeout = setTimeout(closeDialogAuto,5000);
}

function closeDialogAuto(){ 
 if(byId('Dialog')!= null){
    byId('Dialog').parentNode.removeChild(byId('Dialog'));
    clearTimeout(autoDialogTimeout);
 }  
}

function showDialogFree20Min(){
  if(byId('service_msg')!=null){
     byId('service_msg').parentNode.removeChild(byId('service_msg'));
  }
  var objServiceMsg = document.createElement('div');
  objServiceMsg.appendChild(document.createTextNode('ฟรีค่าบริการสำหรับ 20 นาที แรก'));
  objServiceMsg.id ='service_msg';
  objServiceMsg.className = 'service_msg';
  objServiceMsg.style.top = '210px';
  objServiceMsg.style.left = '790px';
  var cardContainer = byId('PageBody');
  cardContainer.appendChild(objServiceMsg);
  autoDialogTimeout = setTimeout(showDialogNotFree,1200000);
}


function showDialogNotFree(){
  if(byId('service_msg')!=null){
     byId('service_msg').parentNode.removeChild(byId('service_msg'));
  }
  var objServiceMsg = document.createElement('div');
  //objServiceMsg.appendChild(document.createTextNode('ค่าบริการ 300 บาท'));
  objServiceMsg.id ='service_msg';
  objServiceMsg.className = 'service_msg';
  objServiceMsg.style.top = '210px';
  objServiceMsg.style.left = '790px';
  objServiceMsg.style.width = '130px';
  var objMARQUEE = document.createElement('MARQUEE');
  objMARQUEE.setAttribute('scrollAmount','2');
  objMARQUEE.setAttribute('scrollDelay','50');
  objMARQUEE.setAttribute('direction','left');
  objMARQUEE.setAttribute('height','20');
  objMARQUEE.appendChild(document.createTextNode('ค่าบริการ 300 บาท'));
  objServiceMsg.appendChild(objMARQUEE);

  var cardContainer = byId('PageBody');
  cardContainer.appendChild(objServiceMsg);
}

function showDialog(x,y,msg){
   if(byId('Dialog')!= null){
       closeDialog();
   }
   var objDialog = document.createElement('div');
   objDialog.id = 'Dialog';

   objDialog.style.top = y+'px';
   objDialog.style.left = x+'px';

   var objDiHead = document.createElement('div');
   var objDiBody = document.createElement('div');
   objDiHead.className = 'DialogHeade';
   objDiBody.className = 'DialogBody';
   objDiHead.style.color ='#FFFFFF';
   objDiHead.appendChild(document.createTextNode('Close'));
   objDiHead.onclick= function(){
       closeDialog();
   }

   objDialog.appendChild(objDiHead);
   objDialog.appendChild(objDiBody);
   objDiBody.appendChild(document.createTextNode(msg));

   var cardContainer = byId('PageBody');
   cardContainer.appendChild(objDialog);
}

function closeDialog(){
  if(byId('Dialog')!= null){
    byId('Dialog').parentNode.removeChild(byId('Dialog'));
  }
}

