﻿
function popCalendar(url,cname)
{

    var val=document.getElementById(cname).value;
    url=url+"?textbox="+cname+"&val="+val;
    window.open(url,'cal','width=220,height=270,left=470,top=380')
}
 function PermissionPopUp(url)
{
    newwindow=window.open(url,'name','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=510,height=605,left = 200,top = 20');
    if (window.focus) {newwindow.focus()}
}

function PollPopUp(url)
{
    newwindow=window.open(url,'name','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=510,height=500,left = 200,top = 20');
    if (window.focus) {newwindow.focus()}
}
 
        function chekAllDay()
        {
            if(document.form1.chk_AllDayEvent.checked==true)
            {
                document.getElementById("div_Startdate").style.visibility="hidden";
                document.getElementById("div_Startdate").style.display="none";
                
                document.getElementById("div_Enddate").style.visibility="hidden";
                document.getElementById("div_Enddate").style.display="none";
            }
            else
            {
                document.getElementById("div_Startdate").style.visibility="visible";
                document.getElementById("div_Startdate").style.display="block";
                
                document.getElementById("div_Enddate").style.visibility="visible";
                document.getElementById("div_Enddate").style.display="block";
            }
        }
        
        
        ////Script for polling
        
        
        
        
        //page_ctc_dt_Button1_OnClick @59-6951C114
function page_ctc_dt_Button1_OnClick()
{
    var result = true;
//End page_ctc_dt_Button1_OnClick

//Custom Code @112-2A29BDB7
    // -------------------------
       // InsertItems();
           ValidateForm();
        result = false;
    // -------------------------
//End Custom Code

//Close page_ctc_dt_Button1_OnClick @59-BC33A33A
    return result;
}
//End Close page_ctc_dt_Button1_OnClick

//page_OnLoad @1-F85B00F0
function page_OnLoad(sender)
{
    var result = true;
//End page_OnLoad


//Close page_OnLoad @1-BC33A33A
    return result;
}
//End Close page_OnLoad


        function ValidateForm()
                  {
                    frm=document.form1;
                   
                  
                    if(frm.txt_Answer.value==""){
                      alert("Answer Required.");
                      frm.txt_Answer.focus();
                      return false
                    }
                    
                   var anum=/(^\d+$)|(^\d+\.\d+$)/
                   if (!anum.test(frm.txt_SortOrder.value))
                   {
                      alert("Please Enter Numeric Sort Order.");
                      frm.txt_SortOrder.focus();
                       return false;
                   }
                   
                                        InsertItems();
//                  return true ; 
                  }
                  
function chkdel(){
                  frm=document.all 
                  len=frm.chk.length;
                  str=""
                  for(k=0;k<len;k=k++)
                  {
                    if(frm.chk[k].checked==true){
                      if(str=="")
                        str=frm.chk[k].value
                      else
                        str=str+","+frm.chk[k].value
                    }   
  
                  }
          frm.delids.value=str            
                  return true
                }  


function InsertItems()
{
   
   if(document.getElementById('count')==null)
   {
        document.getElementById('spanIdCount').innerHTML = '<input type="hidden" id="count" name="count" value="0">';
   }
     
    var theTable =document.getElementById('itemTable');
    
    if (document.form1.count.value=="0"){
       cnt=1
       document.form1.count.value=cnt
    }   
    else{
       cnt=parseFloat(document.form1.count.value)+1
       document.form1.count.value=cnt
    } 
   
    var ccCnt =document.getElementById("itemTable").rows.length-1; 
     
    document.getElementById("itemTable").style.display="Block";
 if(ccCnt<10){
       
        var rowcount=0;
       
        var rownum=theTable.rows.length;
        var x=document.getElementById('itemTable').insertRow(rownum)
        
        
        txtAns="txtAns_"+cnt
        txtSrt="txtSrt_"+cnt
        brandIdHdn="ansIdHdn_"+cnt
        var c=x.insertCell(0)
        text=document.getElementById("itemTable").rows.length-1;
        c.valign="top"
        c.innerHTML=text;
        
               
        var c=x.insertCell(1)
        text="<input type='text' style='width:280px;' name='"+txtAns+"' id='"+txtAns+"' value='"+document.form1.txt_Answer.value+"' onchange=\"return checkAnsText(this.id,'"+document.form1.txt_Answer.value+"',this.value);\">"
        c.valign="top"
        c.innerHTML=text;

        var c=x.insertCell(2)
        text="<input type='text' style='width:25px;' name='"+txtSrt+"' id='"+txtSrt+"' value='"+document.form1.txt_SortOrder.value+"' onchange='return checkSortOrder(this.id,"+document.form1.txt_SortOrder.value+");'>"
        c.valign="top"
        c.innerHTML=text;
          
        var e=x.insertCell(3)
        text="<input type='hidden' name='"+brandIdHdn+"' id='"+brandIdHdn+"' value='0' > <input type='button'  class='Button' value='Remove' onclick=RemoveRow('"+cnt+"',this.parentNode.parentNode.rowIndex,'0') >"
        e.innerHTML=text;
        }
        else
        {
          alert("Max 10 Items are allowed.")
        }
        return false
 }
 
 function RemoveRow(id,rownum,brandid)
 {
   var x=document.getElementById('itemTable').rows[rownum]; 
   document.getElementById("txtAns_"+id).value=""     
   document.getElementById("txtSrt_"+id).value="";
   document.getElementById('itemTable').deleteRow(rownum);
   cnt=0;
   for (i=1;i<document.getElementById('itemTable').rows.length;i++)
   {
     
            cnt++;
            document.getElementById('itemTable').rows[i].cells[0].innerHTML=cnt;           
                
   }
  
    var brandID=document.form1.hdn_AnsID.value;
    document.form1.hdn_AnsID.value=brandid+","+brandID;
    
    if(document.getElementById("itemTable").rows.length==1)
        document.getElementById("itemTable").style.display="none";

 }
 
 
 function RemoveRowWithConfm(id,rownum,brandid)
 {
   
   if (confirm("Are you sure to delete this Answer?")==true)
   {
       var x=document.getElementById('itemTable').rows[rownum]; 
       document.getElementById("txtAns_"+id).value=""     
       document.getElementById("txtSrt_"+id).value="";
       document.getElementById('itemTable').deleteRow(rownum);
       cnt=0;
       for (i=1;i<document.getElementById('itemTable').rows.length;i++)
       {
         
                cnt++;
                document.getElementById('itemTable').rows[i].cells[0].innerHTML=cnt;           
                    
       }
      
        var brandID=document.form1.hdn_AnsID.value;
        document.form1.hdn_AnsID.value=brandid+","+brandID;
        
        if(document.getElementById("itemTable").rows.length==1)
            document.getElementById("itemTable").style.display="none";
            
     return true;
    }
    else
     return false;
 }
 
 function checkSortOrder(id,val)
 {
    var anum=/(^\d+$)|(^\d+\.\d+$)/
   if (!anum.test(document.getElementById(id).value))
   {
      alert("Please Enter Numeric Sort Order.");
      document.getElementById(id).value=val;
      //document.getElementById(id).value.focus();
       return false;
   }
  return true;
 }
 
 
 
 function checkAnsText(id,val,val1)
 {
    if(val1.toString()=="")
    {
      document.getElementById(id).value=val;
      //document.getElementById(id).value.focus();
       return false;
    }
    
    return true;
 }
 
 
 function displayphotoform()
 {
    
    document.getElementById("div_photo").style.display="block";
    //document.getElementById("maintbl").className="transparent_class";
    document.getElementById("lbl_MsgPhoto").innerHTML ="";
    showLayer('div_photo');
 }
 
 function displayphotoformmsg()
 {
    
    document.getElementById("div_photo").style.display="block";
    //document.getElementById("maintbl").className="transparent_class";
    //document.getElementById("lbl_MsgPhoto").innerHTML ="";
    showLayer('div_photo');
 }
 
 function HidePhotoForm()
 {
     
     if(document.getElementById("div_photo").style.display=="block")
     {
        document.getElementById("div_photo").style.display="none";
        document.getElementById("maintbl").className="no";
        hideLayer('div_photo');
     }
     
 }
 
 
 
 
 function displayMoveform(LinkID,LinkName)
 {
    
    document.form1.hdn_LinkID.value=LinkID;
    document.getElementById("div_MoveLink").style.display="block";
   // document.getElementById("maintbl").className="transparent_class";
    showLayer('div_MoveLink');
    document.getElementById("lbl_MoveLinkName").innerHTML =LinkName;
     
 }
    
    
    
    function HidemoveForm()
     {
         
         if(document.getElementById("div_MoveLink").style.display=="block")
         {
            document.getElementById("div_MoveLink").style.display="none";
            document.getElementById("maintbl").className="no";
            document.form1.drp_ModuleList.value="";
            hideLayer('div_MoveLink');
         }
         
     }
     
     function CheckModuleVal()
     {
        if(document.form1.drp_ModuleList.value=="")
        {
            alert("Select Module");
            document.form1.drp_ModuleList.focus();
            return false;
        }
        return true;
     }
 
 
 ///set layer
 
            function showLayer(cdiv) {
                setLayerPosition(cdiv);

                var shadow = document.getElementById("shadow");
                var question = document.getElementById(cdiv);
 
                shadow.style.display = "block"; 
                question.style.display = "block";

                shadow = null;
                question = null;             
            }
            
            function hideLayer(cdiv) {
                var shadow = document.getElementById("shadow");
                var question = document.getElementById(cdiv);
 
                shadow.style.display = "none"; 
                question.style.display = "none";

                shadow = null;
                question = null; 
            }
            
            
            
            function setLayerPosition(cdiv) {
                var shadow = document.getElementById("shadow");
                var question = document.getElementById(cdiv);

                shadow.style.width = "500px";
                shadow.style.height ="700px";
                shadow = null;
                question = null;
            }
            
            
      function displayCreateFolderform()
      {
        document.getElementById("div_CreateFolder").style.display="block";
        showLayer('div_CreateFolder'); 
      }
    
    function HideCreateFolderForm()
     {
         
         if(document.getElementById("div_CreateFolder").style.display=="block")
         {
            document.getElementById("div_CreateFolder").style.display="none";
            document.getElementById("maintbl").className="no";
            hideLayer('div_CreateFolder');
         }
         
     }
     
 function displayCreateFolderformmsg()
 {
    
    document.getElementById("div_CreateFolder").style.display="block";
    showLayer('div_CreateFolder');
 }
 
 
 function DisplayImageInfo(divID,TD_ID)
 {
    var myObj = document.getElementById(TD_ID);
    var pos = findPos(myObj);
    var left=pos[0];
    var top=pos[1];
    left=left+20;
    top=top+70;
    document.getElementById(divID).style.display="block";
    document.getElementById(divID).style.left=left+"px";
    document.getElementById(divID).style.top=top+"px";
 }
 
 
 function displayLogoform()
 {
    
    document.getElementById("div_Logo").style.display="block";
    //document.getElementById("maintbl").className="transparent_class";
    showLayer('div_Logo');
 }
 
 function displaylogoformmsg()
 {
    
    document.getElementById("div_Logo").style.display="block";
    //document.getElementById("maintbl").className="transparent_class";
    //document.getElementById("lbl_MsgPhoto").innerHTML ="";
    showLayer('div_Logo');
 }
 
 function HideLogoForm()
 {
     
     if(document.getElementById("div_Logo").style.display=="block")
     {
        document.getElementById("div_Logo").style.display="none";
        document.getElementById("maintbl").className="no";
        hideLayer('div_Logo');
     }
     
 }
 
 //ticket status 
 
 
  function displayTicketStatusform(TicketID)
 {
    
    document.form1.hdn_TicketID.value=TicketID;
    document.getElementById("div_TicketStatus").style.display="block";
   // document.getElementById("maintbl").className="transparent_class";
    showLayerFullSize('div_TicketStatus');
    document.getElementById("lbl_TicketID").innerHTML =TicketID;
     
 }
    
    
    
    function HideTicketStatusForm()
     {
         
         if(document.getElementById("div_TicketStatus").style.display=="block")
         {
            document.getElementById("div_TicketStatus").style.display="none";
            hideLayerFullSize('div_TicketStatus');
         }
         
     }
     
     
     //fullsize
     
      function showLayerFullSize(cdiv) {
                setLayerPositionFullSize(cdiv);

                var shadow = document.getElementById("shadow");
                var question = document.getElementById(cdiv);
 
                shadow.style.display = "block"; 
                question.style.display = "block";

                shadow = null;
                question = null;             
            }
            
            function hideLayerFullSize(cdiv) {
                var shadow = document.getElementById("shadow");
                var question = document.getElementById(cdiv);
 
                shadow.style.display = "none"; 
                question.style.display = "none";

                shadow = null;
                question = null; 
            }
            
            
            
            function setLayerPositionFullSize(cdiv) {
                var shadow = document.getElementById("shadow");
                var question = document.getElementById(cdiv);

                shadow.style.width = screen.width+"px";
                shadow.style.height =screen.height+"px";
                 
                shadow = null;
                question = null;
            }
 
 
        
        
        ///My profile
        
 function displayMyProfilephotoform()
 {
    
    document.getElementById("div_photo").style.display="block";
    centerScreenOnlywidth("div_photo");
  
    //document.getElementById("maintbl").className="transparent_class";
    document.getElementById("lbl_MsgPhoto").innerHTML ="";
    showLayerFullSize("div_photo");
 }
 
 function displayMyProfilephotoformmsg()
 {
    
    document.getElementById("div_photo").style.display="block";
    centerScreenOnlywidth("div_photo");
    
    //document.getElementById("maintbl").className="transparent_class";
    //document.getElementById("lbl_MsgPhoto").innerHTML ="";
    showLayerFullSize("div_photo");
 }
 
 function HideMyProfilePhotoForm()
 {
     
     if(document.getElementById("div_photo").style.display=="block")
     {
        document.getElementById("div_photo").style.display="none";
        document.getElementById("maintbl").className="no";
        hideLayerFullSize('div_photo');
     }
     
 }
 
 
 function DisplayConfigDetails(Iframe,Url,divid)
 {
    document.getElementById(divid).style.display="block";
    centerScreen(divid);
    document.getElementById(divid).style.top="15px";
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        window.frames[Iframe].location.href =Url;
    }
    else
    {
         document.getElementById(Iframe).src=Url;
    }
    showLayerFullSize(divid);
   
 }
 
 function hideConfigDetails(divid)
 {
     
     if(document.getElementById(divid).style.display=="block")
     {
        document.getElementById(divid).style.display="none";
        hideLayerFullSize(divid);
     }
   
 }
 
 
 function DisplayBackgroundImageForm(divid)
 {
   document.getElementById(divid).style.display="block";    
 }
 
 function HideBackgroundImageForm(divid)
 {
   document.getElementById(divid).style.display="none";    
 }
 
 function displayMyProfilephotoformmenu(divname,lblname)
 {
 
   
    document.getElementById(divname).style.display="block";
    //document.getElementById("maintbl").className="transparent_class";
    document.getElementById(lblname).innerHTML ="";
    
 }
 
 function displayMyProfilephotoformmsgmenu(divname)
 {
 
    
    document.getElementById(divname).style.display="block";
    //document.getElementById("maintbl").className="transparent_class";
    //document.getElementById("lbl_MsgPhoto").innerHTML ="";
    
 }
 
 function HideMyProfilePhotoFormmenu(divname)
 {
     
     if(document.getElementById(divname).style.display=="block")
     {
        document.getElementById(divname).style.display="none";
        document.getElementById("maintbl").className="no";
        
     }
     
 }
 
  function centerScreen(divID)
{
var elem = document.getElementById(divID);
var x = (window.screen.width / 2) - (elem.offsetWidth / 2);
var y = (window.screen.height / 2) - (elem.offsetHeight / 2); 
elem.style.top = y+"px";
elem.style.left = x+"px";
}

function centerScreenOnlywidth(divID)
{
var elem = document.getElementById(divID);
var x = (window.screen.width / 2) - (elem.offsetWidth / 2);
elem.style.left = x+"px";

}
function AttachmentList(id)
 {
    document.getElementById("div_photo").style.display="block";
    centerScreen("div_photo");
    if(navigator.appName == "Microsoft Internet Explorer")
    {
       window.frames['frm_AttachmentList'].location.href ="EditAttachment.aspx?id="+id;
    }
    else
    {
         document.getElementById("frm_AttachmentList").src="EditAttachment.aspx?id="+id;
    }
    
    
    
    showLayerFullSize('div_photo');
    
    
 }
 function FeeedbackForm()
 {
 
    document.getElementById("admin_left1_GenexFooter_div_photo").style.display="block";
   
    centerScreen("admin_left1_GenexFooter_div_photo");
    
    if(navigator.appName == "Microsoft Internet Explorer")
    {
       window.frames['frm_AttachmentList'].location.href ="Feedback.aspx";
    }
    else
    {
         document.getElementById("frm_AttachmentList").src="Feedback.aspx";
    }
    
    
    
    showLayerFullSize('admin_left1_GenexFooter_div_photo');
    
    
 }
 function HideFeedbackForm()
 {
     
     if(document.getElementById("admin_left1_GenexFooter_div_photo").style.display=="block")
     {
        document.getElementById("admin_left1_GenexFooter_div_photo").style.display="none";
        hideLayerFullSize('admin_left1_GenexFooter_div_photo');
     }
 }
function HideDocumentList()
 {
     
     if(document.getElementById("div_photo").style.display=="block")
     {
        document.getElementById("div_photo").style.display="none";
        hideLayerFullSize('div_photo');
     }
 }
 
 
        
        




