﻿// JScript File


//Added For ETWeb

//For Whom We Service
function ShowMore(td1,td2,lnk)
{
    var Mlnk=document.getElementById(lnk);
    var Ftd=document.getElementById(td1);
    var Std=document.getElementById(td2);
    
    if(Mlnk!=null && Ftd!=null && Std!=null)
    {
      if(Mlnk.innerHTML == 'More &gt;&gt;')
      {
        Std.style.display='';
        Mlnk.innerHTML='<< Back'
        return false;
      }
      else if(Mlnk.innerHTML == '&lt;&lt; Back')
      {
        Std.style.display='none';
        Mlnk.innerHTML='More >>'
        return false;
      }
    }
    
}
    
function LoadSchedule(img, imgsrc,img1,img2, img3, trToDisplay, trTwo, trThree, flag)
{
    var IMG=document.getElementById(img);
    var IMG1=document.getElementById(img1);
    var IMG2=document.getElementById(img2);
    var IMG3=document.getElementById(img3);

    var TRDISPLAY=document.getElementById(trToDisplay);
    var TRTWO=document.getElementById(trTwo);
    var TRTHREE=document.getElementById(trThree);
    
//    IMG.src="../../images/webimages/Schedules/et_04.gif";
    IMG1.src="../../images/webimages/Schedules/et_04.gif";
    IMG2.src="../../images/webimages/Schedules/et_05.gif";
    IMG3.src="../../images/webimages/Schedules/et_06.gif";
    
    IMG.src=imgsrc;
    
    TRDISPLAY.style.display="";
    
    TRTWO.style.display="none";
    TRTHREE.style.display="none";
    
    SetCookie(flag,"schedule");
}


function LoadContent(tr1,tr2, lnk, img, imgsrc,img1, img2, img3, img4, img5,img6, trToDisplay, trOne, trTwo, trThree, trFour, trFive, flag)
{
    var IMG=document.getElementById(img);
    var IMG1=document.getElementById(img1);
    var IMG2=document.getElementById(img2);
    var IMG3=document.getElementById(img3);
    var IMG4=document.getElementById(img4);
    var IMG5=document.getElementById(img5);
    var IMG6=document.getElementById(img6);
    var TRDISPLAY=document.getElementById(trToDisplay);
    var TRONE=document.getElementById(trOne);
    var TRTWO=document.getElementById(trTwo);
    var TRTHREE=document.getElementById(trThree);
    var TRFOUR=document.getElementById(trFour);
    var TRFIVE=document.getElementById(trFive);
    
    
    if(tr1!=' ' && tr2!=' ' && lnk!=' ')
    {
        var TR1=document.getElementById(tr1);
        var TR2=document.getElementById(tr2);
        var LNK=document.getElementById(lnk);
        TR1.style.display="";
        TR2.style.display="none";
        LNK.innerHTML="more >>";
    }
    
    IMG1.src="../../images/webimages/whomweserve/top_02.gif";
    IMG2.src="../../images/webimages/whomweserve/top_03.gif";
    IMG3.src="../../images/webimages/whomweserve/top_04.gif";
    IMG4.src="../../images/webimages/whomweserve/top_05.gif";
    IMG5.src="../../images/webimages/whomweserve/top_06.gif";
    IMG6.src="../../images/webimages/whomweserve/top_07.gif";
    
    IMG.src=imgsrc;
    
    TRDISPLAY.style.display="";
    
    TRONE.style.display="none";
    TRTWO.style.display="none";
    TRTHREE.style.display="none";
    TRFOUR.style.display="none";
    TRFIVE.style.display="none";
    
    
    
    
    SetCookie(flag,"whomweserve");
}

function DisplayHideTr(trtodisplayhide, btn)
{
    var BTN=document.getElementById(btn);
    var TR=document.getElementById(trtodisplayhide);
   
    if(BTN.innerHTML=="more &gt;&gt;")
    {
        TR.style.display="";
        BTN.innerHTML="<< back";
    }
    else
    {
        BTN.innerHTML="more >>";
        TR.style.display="none";
    }
}


//For Location

function LoadLocationTab(img, imgsrc,img1, img2, img3, img4, img5, trToDisplay, trOne, trTwo, trThree, trFour, flag)
{
    var IMG=document.getElementById(img);
    var IMG1=document.getElementById(img1);
    var IMG2=document.getElementById(img2);
    var IMG3=document.getElementById(img3);
    var IMG4=document.getElementById(img4);
    var IMG5=document.getElementById(img5);
   
    var TRDISPLAY=document.getElementById(trToDisplay);
    var TRONE=document.getElementById(trOne);
    var TRTWO=document.getElementById(trTwo);
    var TRTHREE=document.getElementById(trThree);
    var TRFOUR=document.getElementById(trFour);
    
    IMG1.src="../../images/webimages/location/location_04.gif";
    IMG2.src="../../images/webimages/location/location_05.gif";
    IMG3.src="../../images/webimages/location/location_06.gif";
    IMG4.src="../../images/webimages/location/location_07.gif";
    IMG5.src="../../images/webimages/location/location_08.gif";
   
    IMG.src=imgsrc;
    
    TRDISPLAY.style.display="";
    TRONE.style.display="none";
    TRTWO.style.display="none";
    TRTHREE.style.display="none";
    TRFOUR.style.display="none";
    
    SetCookie(flag,"location");
}

//For Printing the Calender

function PrintPage(imgbtn)
{
    var ImgButton=document.getElementById(imgbtn);
    if(ImgButton.style.display=="")
    {
        ImgButton.style.display="none";
        window.print();
        ImgButton.style.display="";
    }
}


//For Calender ToolTip


var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = '';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = '';
				b.style.display = '';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();



function TabMouseOver(tableCell, menuDetail)
   {
        var element;
        var Hidden=document.getElementById('ctl00_ContentPlaceHolderContent_hdnMenu');
        var Menu=document.getElementById(menuDetail);
        var MenuArray=new Array(10);
        
        MenuArray=Hidden.value.split(",");
        for(var i=0;i < MenuArray.length; i++)
        {
            document.getElementById(MenuArray[i]).style.display="none";
        }
        Menu.style.display="";
   }
   
function TabMouseOut(tableCell, menuDetail)
{
    
    //var Menu=document.getElementById(menuDetail);
    //Menu.style.display="none";
    //Menu.style.display="block";
 
}


function RollOver(imgbtnname, imgsrc)
   {
        var ImageBtn=document.getElementById(imgbtnname);
   
        ImageBtn.src = imgsrc;
   }


 function SaveTabIdSelected(sender, args)	
        {	    
            var activetabindex = sender.get_activeTab().get_tabIndex();
            SetCookie(activetabindex,"tabIndexajax");
        }	
        
 // For Setting The Cookie Values           
        
 function SetCookie(value,cookiename)
    {
        document.cookie = cookiename+"=" + escape(value);
    } 



 function RequestDetails(tbl, Send, Request, label)
     {
        
        var tblPublic=document.getElementById(tbl);
        var trRequest=document.getElementById(Request);
        var trSend=document.getElementById(Send);
        var Label=document.getElementById(label);
        
        if(tblPublic.style.display=="none")
        {
            Label.innerText="";
            trRequest.style.display="none"
            trSend.style.display=""
            tblPublic.style.display=""
            return false;
        }
    }

    
    function SendDetails(table,send,group)
     {
        var trSend=document.getElementById(send);
        var tblPublic=document.getElementById(table);
       
        if(Page_ClientValidate(group))
        {
            trSend.style.display="none"
            tblPublic.style.display="none"
            showCustomIBox('#Mail','Sending Mail',200,200);
            return true;
        }
    }
    function SendMailToFriend(group)
    {
         if(Page_ClientValidate(group))
         {
            showCustomIBox('#Mail','Sending Mail',200,200);
            return true;
         }
    }
   

//Added For ET Admin


//Function For Validation FCK Editor

function ValidateEditor(question, answerone, answertwo, answerthree, answerfour, answerfive)
{
    var AnswerOne=document.getElementById(answerone);
    var AnswerTwo=document.getElementById(answertwo);
    var AnswerThree=document.getElementById(answerthree);
    var AnswerFour=document.getElementById(answerfour);
    var AnswerFive=document.getElementById(answerfive);
    var Question=document.getElementById(question);
    
    
    if(Page_ClientValidate('Question'))
    {
        if(Question.innerHTML=="")
        {
            alert("Enter Question");
        }
        else if(AnswerOne.value=="")
        {
            alert("Enter Answer For Option A");
        }
        else if(AnswerTwo.value=="")
        {
            alert("Enter Answer For Option B");
        }
        else if(AnswerThree.value=="")
        {
            alert("Enter Answer For Option C");
        }
        else if(AnswerFour.value=="")
        {
            alert("Enter Answer For Option D");
        }
        else if(AnswerFive.value=="")
        {
            alert("Enter Answer For Option E");
        }
    }
}

// Function to Confirm the Delete Operation With Custom Message

function ConfirmCustomDelete(CustomMsg)
 {
     var msg=confirm(CustomMsg);
     if (msg) 
     {
       return true;
     }
     else
     {
       return false;
     }
}

//var IboxShow=0;

function ConfirmExam(CustomMsg,btnReview)
 {
     var msg=confirm(CustomMsg);
     if (msg) 
     {
//        //showCustomIBox('#Mail','Sending Mail',200,200);
//        IboxShow=1;
        return true;
     }
     else
     {
        //document.getElementById(btnReview).display='none';
        return false;
     }
}

function ConfirmClose(CustomMsg)
 {
     var msg=confirm(CustomMsg);
     if (msg) 
     {
        return true;
     }
     else
        return false;
}



//For AddAdvertisement Images

function CheckContentLength(fileuploader1,fileuploader2,fileuploader3,fileuploader4)
{
    if(Page_ClientValidate())
    {
        var Uploader1=document.getElementById(fileuploader1);
        var Uploader2=document.getElementById(fileuploader2);
        var Uploader3=document.getElementById(fileuploader3);
        var Uploader4=document.getElementById(fileuploader4);

        if(Uploader1.value=="" && Uploader2.value=="" && Uploader3.value=="" && Uploader4.value=="") 
        {
            alert('No Images To Upload !');
            return false;
        }
        else
        {
            return true;
        }
    }
}


function CheckImageExists(gridview)
{
     var GridView=document.getElementById(gridview);
     
     if(Page_ClientValidate())
     {
         if(GridView.rows.length>1)
         {
            return true;
         }
         else
         {
            alert('No Images To Save !');
            return false;
         }
     }
     
}

//function for CreateWebsiteMenu Starts

 function confirmDeleteMenu()
  {
            var agree=confirm("You are going to delete an Item. Wish to continue?");
            if (agree)
            {
	            return true ;
	        }
            else
            {
	            return false ;
	        }

   }
   
   function confirmSave()
   {
      if(Page_ClientValidate())
      {
            var agree=confirm("By adding a new item,you will lose the existing link. Wish to continue?");
            if (agree)
            {
	            return true ;
	        }
            else
            {
	            return false ;
	        }
	   }
   }
    
   function ValidateItems(radiobuttonlist,ddlSbu,ddlGroup,ddlSub,ddlProduct,txtUrl)
   {
       var RadioList=document.getElementById(radiobuttonlist).getElementsByTagName("input");
       var DDLSBU=document.getElementById(ddlSbu);
       var DDLGroup=document.getElementById(ddlGroup);
       var DDLSubGroup=document.getElementById(ddlSub);
       var DDLProduct=document.getElementById(ddlProduct);
       var TxtURL=document.getElementById(txtUrl);
       var Chk=0;
      
      if(Page_ClientValidate("Menu"))
      {
        
        for(i=0; i<RadioList.length; i++) 
        {
            if(RadioList[i].checked)
            {
                Chk=1;
                break;
            }
        }
        if (Chk==0)
        { 
            alert('Select Link Menu Item To');
            return false;
        }   

        
        
      
        if(RadioList[0].checked && DDLSBU.selectedIndex==0)
        {
            alert('Select SBU');
            return false;
        }
        else if(RadioList[1].checked && DDLGroup.selectedIndex==0)
        {
             alert('Select Product Group');
             return false;
        }
        else if(RadioList[2].checked && DDLSubGroup.selectedIndex==0)
        {
             alert('Select Product Sub Group');
             return false;
        }
        
        else if(RadioList[3].checked && DDLProduct.selectedIndex==0)
        {
             alert('Select Product');
             return false;
        }
        else if(RadioList[4].checked && TxtURL.value=="")
        {
             alert('Enter Navigate URL');
             return false;
        }
        else
        {
            return true;
        }
      }
      
   }
   
   function EnableLinkTo(n,radiobuttonlist, trSbu, trGroup, trSub, trProduct, trUrl, hidden)
   {
        var RadioList=document.getElementById(radiobuttonlist).getElementsByTagName("input");
        var TrSBU=document.getElementById(trSbu);
        var TrGroup=document.getElementById(trGroup);
        var TrSubGroup=document.getElementById(trSub);
        var TrProduct=document.getElementById(trProduct);
        var TrURL=document.getElementById(trUrl);
        var Hidden=document.getElementById(hidden);
       
        Hidden.value="";
            
            
        if(n=="load")
        {
            if(Hidden.value=="")
	        {
    		    n=0; //Set default Value
	        }
	        else
	        {
    		    //load the stored value
    		    n=Hidden.value;
	        }
        }
    
        //Store the current value
        Hidden.value=n;
        
        TrSBU.style.display="none";
        TrGroup.style.display="none";
        TrSubGroup.style.display="none";
        TrProduct.style.display="none";
        TrURL.style.display="none";
        
        if(RadioList[0].checked)
        {
            TrSBU.style.display="";
        }
        else if(RadioList[1].checked)
        {
            TrGroup.style.display="";
        }
        else if(RadioList[2].checked)
        {
            TrSubGroup.style.display="";
        }
        
        else if(RadioList[3].checked)
        {
            TrProduct.style.display="";
        }
        else if(RadioList[4].checked)
        {
            TrURL.style.display="";
        }
   }

//function for CreateWebsiteMenu Ends



//function for Product Master Starts


function DurationCheck(radio,label,textbox)
{
    var Radio=document.getElementById(radio).getElementsByTagName("input");
    var Label=document.getElementById(label);
    var TextBox=document.getElementById(textbox);
    if(Radio[0].checked==true)
    {
        Label.innerHTML="Days";
    }
    else
    {
        Label.innerHTML="Hours";
    }
    TextBox.value="";
}

function DurationTextBox(radio,textbox)
{
var Radio=document.getElementById(radio).getElementsByTagName("input");
var TextBox=document.getElementById(textbox);
 
 if(Radio[0].checked==true)
 {
         if(TextBox.value<1)
         {
            TextBox.value="";
            alert('Minimum Days Should Be One');
         }
 }
 else
 {
      if(TextBox.value>24)
        {
            TextBox.value="";
            alert('Minimum Hours Should Be Less Than 24');
        }
 }
   
}

function InvisibleTextBox(ChkBox,td)
{

var Id=document.getElementById(ChkBox);
var Td=document.getElementById(td);

    if(Id.checked==true)
    {

    Td.style.display ="";
    }
    else
    {
    Td.style.display ="none";
    }

}

function EnablePdfPath(radio,tr)
{
    var Radio=document.getElementById(radio).getElementsByTagName("input");
    var Tr=document.getElementById(tr);

    if(Radio[0].checked==true)
        {
            Tr.style.display ="";
        }
        else
        {
            Tr.style.display ="none";
        }
}

//function for Product Master Ends

//functions for Trainer Master Starts Here

function AddressTransfer(ParentAddress,ChildAddress,ParentName,ChildName,ParentNo,ChildNo)
{
    var parentadd=document.getElementById(ParentAddress);
    var childadd=document.getElementById(ChildAddress);
    var parentname=document.getElementById(ParentName);
    var childname=document.getElementById(ChildName);
    var parentno=document.getElementById(ParentNo);
    var childno=document.getElementById(ChildNo);
    childadd.value=parentadd.value;
    childname.value=parentname.value;
    childno.value=parentno.value;
    return false;
}

//functions for Trainer Master Ends Here

//function for Price Master Starts Here
function InvisibleBatchSize(dropdown,tr)
{
var DropDown=document.getElementById(dropdown);
var Tr=document.getElementById(tr);

    if(DropDown.selectedIndex=='1')
    {
    Tr.style.display ="none";
    }
    else
    {
    Tr.style.display ="";
    }

}



function EnablePdfPath(radio,tr)
{
var Radio=document.getElementById(radio).getElementsByTagName("input");
var Tr=document.getElementById(tr);

if(Radio[0].checked==true)
    {
    Tr.style.display ="";
   
    }
    else
    {
     Tr.style.display ="none";
    }
}
//functions for Price Master Ends Here
   
   
   function GetMessageandClose(message)
    {
        alert(message);
        CloseWindow();  
    }
    
    function CloseWindow()
    {
        window.opener.location.href=window.opener.location .href;
        window.close();
    }

// Function to Set Status Message

function StatusWord(Message,MaxLength,Mandatory)
{
    if(MaxLength!='')
    {
        if(Mandatory==1)
        {
            window.status=Message+' - Max. Characters Allowed '+MaxLength +' (Mandatory).';
        }
        else
        {
            window.status=Message+' - Max. Characters Allowed '+MaxLength+'.';
        }
    }
    else
    {
        window.status='';
    }
    if(MaxLength=='' && Message!='' )
    {
        if(Mandatory==1)
        {
            window.status=Message + ' (Mandatory).';
        }
        else
        {
            window.status=Message;
        }
    }
}

// Function to Confirm the Delete Operation

function ConfirmDelete()
 {
     var msg=confirm("Do you want to delete");
     if (msg) 
     {
       return true;
     }
     else
     {
       return false;
     }
}
//Function to Confirm the Delete Operation

function ConfirmDeletion()
{
    
        if(Page_ClientValidate('LeaveApproved'))
            {
            if (confirm("Do You Want To Delete ?"))
                {
                    return true
                }
            else
                {
                    return false
                }
                
            }

}
//Function for clearing two fields values 
function ClearControls(text1,text2)
{
    document.getElementById(text1).value="";
    document.getElementById(text2).value="";
}
//Function to display Messages

function CustomMessage(message)
{
    alert(message);
    return false;
}

//Method To Prevent Resizing Window

function NoResize()
{
window.resizeTo(screen.width,screen.height);
}


///function to open popup window

var OpenPopup=null;

function openPopupWin(Url,name,wid,hght)
{
    windowFeatures ="menubar=no,scrollbars=yes,location=no,favorites=no,resizable=no,status=no,toolbar=no,directories=no";
    width=wid;
    height=hght;

    winLeft = (screen.width-width)/2;
    winTop = (screen.height-(height+110))/2;   
    
    ClosePopUp();
    
    OpenPopup=window.open(Url, 'EIM', "width="+width+",height="+height+",left=" + winLeft + ",top=" + winTop + ","+windowFeatures);
}

function ClosePopUp()
{
    if (OpenPopup != null)
    {
        if (!OpenPopup.closed)
        {
        OpenPopup.close();
        }
    }
}



//Function to check the validity of the date

function isValidDate(d,convert) 
{
	var strDatestyle = "EU";  //European date style
	var strDate;
	var strDateArray;
	var strDay;
	var strMonth;
	var strYear;
	var intDay;
	var intMonth;
	var intYear;
	var booFound = false;
	var strSeparatorArray = new Array("-"," ","/",".");
	var intElementNr;
	var err = 0;
	var strMonthArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	strDate = d;
	if (strDate.length < 1) {
		return false;
	}
	if (strDate.toLowerCase()=="today" || strDate.toLowerCase()=="now"){return true;}

	for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
		if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
			strDateArray = strDate.split(strSeparatorArray[intElementNr]);
			if (strDateArray.length != 3) 
			{
				err = 1;
				return false;
			}
			else 
			{
				strDay = strDateArray[0];
				strMonth = strDateArray[1];
				strYear = strDateArray[2];
			}
			booFound = true;
		}
	}

	if (booFound == false) {
		if (strDate.length>5) {
			strDay = strDate.substr(0, 2);
			strMonth = strDate.substr(2, 2);
			strYear = strDate.substr(4);
		}
		else
			return false;
	}
	
	// verify year part	2 or 4 digits
	if (strYear.length != 2 && strYear.length != 4) {return false;}
	if (isNaN(strYear)){return false;}
	// US style (swap month and day)
	if (strDatestyle == "US") {
		strTemp = strDay;
		strDay = strMonth;
		strMonth = strTemp;
	}

	// verify 1 or 2 digit integer day
	if (strDay.length<1 || strDay.length>2) {return false;}
	if (isNaN(strDay)){return false;}
	
	// month may be digits of characters, hence following check
	intMonth = parseInt(strMonth, 10);
	
	if (isNaN(intMonth)) {
		for (i = 0;i<12;i++) {
			if (strMonth.substr(0,3).toUpperCase() == strMonthArray[i].toUpperCase()) {
				intMonth = i+1;
				strMonth = strMonthArray[i];
				i = 12;
			}
		}
		if (isNaN(intMonth)) {
			err = 3;
			return false;
		}
	}

	intDay=parseInt(strDay,10);
	intYear = parseInt(strYear, 10);
	
	if (intMonth>12 || intMonth<1) {
		err = 5;
		return false;
	}
	
	// day in month check
	if (intDay < 1 || intDay > 31){return false;}
		
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30)) {
		return false;
	}
	
	if (intMonth == 2) {
		if (LeapYear(intYear)) {
			if (intDay > 29) {return false;}
		}
		else 
		{
			if (intDay > 28) {return false;}
		}
	}
	
	if (!convert)
		return true;
	else
	{
		if (intYear<=99){intYear=intYear+2000;}
		return intMonth+"/"+intDay+"/"+intYear;
	}
}

//Function to calculate the Date Difference

function DateDifferece()
{
  
var date1= document.getElementById("ctl00_ContentPlaceHolder1_ctl00_txtCalStart").value;
if(date1!='')
{
    dateFrom =new Date(isValidDate(date1,'1'));
    var date2= document.getElementById("ctl00_ContentPlaceHolder1_ctl00_txtCalEnd").value;
    if(date2!='')
    {
       dateTo=new Date(isValidDate(date2,'1'));
        var one_day=1000*60*60*24;
        var totalday=Math.ceil((dateTo -dateFrom)/(one_day));
        if(totalday==0)
        {
              totalday=1
        }
        document.getElementById("ctl00_ContentPlaceHolder1_ctl00_txtTotalDays").value=totalday;
    }
 }
}

///Function to Confirm the disabling of the user

function ConfirmDisableUser()
{
     var msg=confirm("Do you want to Disable this User?");
     if (msg) 
     {
       return true;
     }
     else
     {
       return false;
     }
}


//Function for implementing rights validation in manage rights

function RoleCheckBoxForView(CheckBoxInsert,CheckBoxEdit,CheckBoxDelete,CheckBoxView)
{  
   if(CheckBoxInsert.checked || CheckBoxEdit.checked || CheckBoxDelete.checked )
   {
        CheckBoxView.checked=true;
   }
  
   if(CheckBoxInsert.checked==false && CheckBoxEdit.checked==false && CheckBoxDelete.checked==false && CheckBoxView.checked==false)
   {
        CheckBoxView.checked=false;
   }
}

//Function to Open Contact Popup

var ContactPage = null;

function ContactPopup(url,_width,_height)
{
    winLeft = (screen.width-_width)/2;
    winTop = (screen.height-(_height+110))/2;
    
    windowFeatures="'toolbar=no,width=" + _width + ",height=" + _height + ",top="+winTop+",left="+winLeft+"'";
    
    CloseContactPage();
    ContactPage=window.open(url,'ContactNumber',windowFeatures);
}

//Method To Close the contact Popup If the parent page is closed.
function CloseContactPage()
{
    if (ContactPage != null)
    {   
        if (!ContactPage.closed)
        {
        ContactPage.close();        
        }
    }
}

function isNumberKey(evt,Control)
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 65 && charCode < 117))
    {
        return true;
    }
       Control.value='';
        Control.focus();
        return false;
        
}

    //--Method To Disable Copy and Paste Property From A TextBox.
    function noCopyMouse(e) 
    {
         var isRight = (e.button) ? (e.button == 2) : (e.which == 3);
        
        if(isRight) 
        {
            alert('Right Click Not Allowed.');            
            return false;
        }
        return true;

    }

    function noCopyKey(e) 
    {
        var forbiddenKeys = new Array('c','x','v');
        var keyCode = (e.keyCode) ? e.keyCode : e.which;
        var isCtrl;

        if(window.event)
            isCtrl = e.ctrlKey
        else
            isCtrl = (window.Event) ? ((e.modifiers & Event.CTRL_MASK) == Event.CTRL_MASK) : false;
    
        if(isCtrl) 
        {
            for(i = 0; i < forbiddenKeys.length; i++) {
                if(forbiddenKeys[i] == String.fromCharCode(keyCode).toLowerCase()) {                    
                    return false;
                }
            }
        }
        return true;
    }
   
  




function SelectGender(Salutation,Gender)
{
    var CtrlSalute=document.getElementById(Salutation);
    var CtrlGender=document.getElementById(Gender+"_"+CtrlSalute.selectedIndex);
    CtrlGender.checked=true;
}


//Function for Checking cookies while login
function login(Control,hdnUserC0ntrol,hdnPassControl,txtPasswordControl,chkControl)
  {
    
       var chkValue = Control.value;
       if(chkValue!='')
       {
            var userName = hdnUserC0ntrol.value;
            var password = hdnPassControl.value;
            
            var userArray = userName.split("/");
            var passArray = password.split("/");
            var i=0; 
            for(i=0; i <= userArray.length-1; i++)
            {      
                if(userArray[i] == chkValue)
                {           
                    txtPasswordControl.value = passArray[i];
                    chkControl.checked = true;      
                }
            }  
        }
  }



// -------------------------------------------------------------------
// swapOptions(select_object,option1,option2)
//  Swap positions of two options in a select list
// -------------------------------------------------------------------

function swapOptions(obj,i,j) 
    {
    
	var o = obj.options;
	var i_selected = o[i].selected;
	var j_selected = o[j].selected;
	var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
	o[i] = temp2;
	o[j] = temp;
	o[i].selected = j_selected;
	o[j].selected = i_selected;	
	
	}
	
	
// -------------------------------------------------------------------
// hasOptions(obj)
//  Utility function to determine if a select object has an options array
// -------------------------------------------------------------------

function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
	}


	
// -------------------------------------------------------------------
// moveOptionUp(select_object)
//  Move selected option in a select list up one
// -------------------------------------------------------------------

function moveOptionUp(obj) 
{
    obj=document.getElementById(obj);
    
	if (!hasOptions(obj)) { return; }
	for (i=0; i<obj.options.length; i++) 
	{
		if (obj.options[i].selected) 
		{
			if (i != 0 && !obj.options[i-1].selected) 
			{
				swapOptions(obj,i,i-1);
				obj.options[i-1].selected = true;
			}
		}
	}
	GetSortOrder(obj);
}

// -------------------------------------------------------------------
// moveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------

function moveOptionDown(obj) 
{
    obj=document.getElementById(obj);
    
	if (!hasOptions(obj)) { return; }
	for (i=obj.options.length-1; i>=0; i--) 
	{
		if (obj.options[i].selected) 
		{
			if (i != (obj.options.length-1) && ! obj.options[i+1].selected) 
			{
				swapOptions(obj,i,i+1);
				obj.options[i+1].selected = true;
			}
		}
	}
	GetSortOrder(obj);
}

function GetSortOrder(obj)
{
        
    var ArrayLength=obj.options.length;
    var faq = new Array()
    for (i=0; i <(ArrayLength); i++)
    { 
            faq[i]=new Array(2);
       
            var o = obj.options;    
            faq[i][0] = o[i].value;            
            faq[i][1] = i+1;
            
    }
    document.getElementById("ctl00_ContentPlaceHolder1_ctl00_hidListBox").value=faq;
    }


function postBackByObject(mEvent)
{
    var o;
    // Internet Explorer    
    if (mEvent.srcElement)
    {
        o = mEvent.srcElement;
    }
    // Netscape and Firefox
    else if (mEvent.target)
    {
        o = mEvent.target;
    }
    if (o.tagName == "INPUT" && o.type == "checkbox")
    {
       __doPostBack("","");
    } 
}


function AppraisalReportPopup(url,_width,_height)
{
    winLeft = (screen.width-_width)/2;
    winTop = (screen.height-(_height+110))/2;
    
    windowFeatures ="menubar=no,scrollbars=yes,location=no,favorites=no,resizable=yes,status=no,toolbar=no,directories=no";
    windowFeatures+="'toolbar=no,width=" + _width + ",height=" + _height + ",top="+winTop+",left="+winLeft+"'";
    
    CloseContactPage();
    ContactPage=window.open(url,'ContactNumber',windowFeatures);
}

//THIS SCRIPT IS USED ONLY FOR RoleRights.ascx 
//THIS IS USED TO SELECT  ALL  CHECK BOX IN THE GRID WITH VIEW HEADER TEXT
//WHEN THE CHECK BOX NEAR VIEW TEXT IS  UNTICKED THEN ALL BELOW CHECK BOX ARE UNTICKED
//EXCEPT THOSE WHOSE NEIGHBOURING CHECK BOX ARE TICKED 

function UnSelectAllView(id,GrdView,cellIndex)
        {  
            
            var grid = document.getElementById(GrdView);
            //variable to contain the cell of the grid
            var cell;
            
            if (grid.rows.length > 0)
            {
               
                for (i=1; i<grid.rows.length; i++)
                {
                    //get the reference of first column
                    cell = grid.rows[i].cells[cellIndex];
                    
                    //loop according to the number of childNodes in the cell
                    for (j=0; j<cell.childNodes.length; j++)
                    {           
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type =="checkbox")
                        {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                              cell.childNodes[j].checked = document.getElementById(id).checked;
                             
                          
                               if(grid.rows[i].cells[4].childNodes[j].checked ||grid.rows[i].cells[5].childNodes[j].checked ||grid.rows[i].cells[6].childNodes[j].checked)
                               {
                                
                                cell.childNodes[j].checked = true; 
                                }
                                                               
                            
                        
                          }
                     
                     
                     }
                 }
            }
        }
        
        
   //THIS SCRIPT IS USED ONLY FOR RoleRights.ascx 
//THIS IS USED TO SELECT  ALL  CHECK BOX IN THE GRID WITH EDIT,DELETE,INSERT HEADER TEXT
 //WHEN ANY OF THE MENTIONED ABOVE TEXT ARE CLICKED THEN ALL CHECK BOX BELOW VIEW TEXT  
 // ARE CHECKED
      function SelectAllAndView(id,GrdView,cellIndex)
    {  
           
            var grid = document.getElementById(GrdView);
            //variable to contain the cell of the grid
            var cell;
            
        if (grid.rows.length > 0)
        {
                //loop starts from 1. rows[0] points to the header.
                for (i=1; i<grid.rows.length; i++)
                {
                    //get the reference of first column
                    cell = grid.rows[i].cells[cellIndex];
                    
                    //loop according to the number of childNodes in the cell
                    for (j=0; j<cell.childNodes.length; j++)
                    {           
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type =="checkbox")
                        {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                            cell.childNodes[j].checked = document.getElementById(id).checked;
                            grid.rows[i].cells[3].childNodes[j].checked = true;
                            
                        }
                     }
                     grid.rows[0].cells[3].getElementsByTagName("input")[0].checked = true;
                 }
               
              
          }
     } 

// Function to Select All CheckBoxes in a GridView 
function SelectAll(id,GrdView,cellIndex)
        {  
            //get reference of GridView control
           // var grid = document.getElementById("<%= grdEmployee.ClientID %>");
            var grid = document.getElementById(GrdView);
            //variable to contain the cell of the grid
            var cell;
            
            if (grid.rows.length > 0)
            {
                //loop starts from 1. rows[0] points to the header.
                for (i=1; i<grid.rows.length; i++)
                {
                    //get the reference of first column
                    cell = grid.rows[i].cells[cellIndex];
                    
                    //loop according to the number of childNodes in the cell
                    for (j=0; j<cell.childNodes.length; j++)
                    {           
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type =="checkbox")
                        {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                            cell.childNodes[j].checked = document.getElementById(id).checked;
                        }
                    }
                }
            }
        }
        
/* Method to find the sum of Textbox fields in a gridview*/

    function Add(ControlName)
    {      
        var obj = window.event.srcElement; 
        var tBox; 
        var sum = 0.00; 
        
        if(obj.tagName == "INPUT" && obj.type == "text") 
        {                   
          tBox = document.getElementsByTagName("INPUT"); 
            
          for(i = 0; i< (tBox.length - 2) ; i++) 
          {                   
             if(tBox[i].type == "text") 
             {            
             sum += Number(tBox[i].value);  
             } 
          } 
            //alert(sum.toFixed(2));
            //document.getElementById(ControlName).innerText = sum.toFixed(2);
            document.getElementById(ControlName).innerText = sum.toFixed(2);
        }                
    }
    
// -------------------------------------------------------------------
// moveOptionUp(select_object)for appraisal form group question
//  Move selected option in a select list up one
// -------------------------------------------------------------------

function moveOptionUpQuestion(obj) 
{
    obj=document.getElementById(obj);
    
	if (!hasOptions(obj)) { return; }
	for (i=0; i<obj.options.length; i++) 
	{
		if (obj.options[i].selected) 
		{
		
		 var FindGroup = obj.options[i].value.split(",");		 
		 if(FindGroup.length > 0)
		 {   
	         if(FindGroup[0] != '0')
	         {
	            var FindFirstParameter =obj.options[i-1].value.split(",");
	            
	            if(FindFirstParameter.length > 0)
	            {
	                if(FindFirstParameter[0] != '0')
	                {
		                if (i != 0 && !obj.options[i-1].selected) 
		                {
			                swapOptions(obj,i,i-1);
			                obj.options[i-1].selected = true;
		                }
		            }
	            
	            }
	                
	        }
		 }	
	    }
	}
	GetSortOrder(obj);
}

// -------------------------------------------------------------------
// moveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------

function moveOptionDownQuestion(obj) 
{
    obj=document.getElementById(obj);
    
	if (!hasOptions(obj)) { return; }
	for (i=obj.options.length-1; i>=0; i--) 
	{
		if (obj.options[i].selected) 
		{		
		 var FindGroup = obj.options[i].value.split(",");	
		
		 if(FindGroup.length > 0)
		 {   
	         if(FindGroup[0] != '0')
	         {
	            
	             if(obj.options[i+1] !=null)
	             {
	                var FindFirstParameter =obj.options[i+1].value.split(",");
    	            
	                if(FindFirstParameter.length > 0)
	                {
	                    if(FindFirstParameter[0] != '0')
	                    {
	                    if (i != (obj.options.length-1) && ! obj.options[i+1].selected) 
			                {
				                swapOptions(obj,i,i+1);
				                obj.options[i+1].selected = true;
			                }
	             	    }
	                }
	            }
	         }
	       }
		}
	}
	GetSortOrder(obj);
}




// -------------------------------------------------------------------
// moveOptionUp(select_object)for appraisal form Competency Parameter
//  Move selected option in a select list up one
// -------------------------------------------------------------------

function moveOptionUpCompParameter(obj) 
{
    obj=document.getElementById(obj);
    
	if (!hasOptions(obj)) { return; }
	for (i=0; i<obj.options.length; i++) 
	{
		if (obj.options[i].selected) 
		{
		
		 var FindGroup = obj.options[i].value.split("~");		 
		 if(FindGroup.length > 0)
		 {   
	         if(FindGroup[1] != '0')
	         {
	            var FindFirstParameter =obj.options[i-1].value.split("~");
	            
	            if(FindFirstParameter.length > 0)
	            {
	                if(FindFirstParameter[1] != '0')
	                {
		                if (i != 0 && !obj.options[i-1].selected) 
		                {
			                swapOptions(obj,i,i-1);
			                obj.options[i-1].selected = true;
		                }
		            }
	            
	            }
	                
	        }
		 }	
	    }
	}
	GetSortOrder(obj);
}

// -------------------------------------------------------------------
// moveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------

function moveOptionDownCompParameter(obj) 
{
    obj=document.getElementById(obj);
    
	if (!hasOptions(obj)) { return; }
	for (i=obj.options.length-1; i>=0; i--) 
	{
		if (obj.options[i].selected) 
		{		
		     var FindGroup = obj.options[i].value.split("~");		 
		     if(FindGroup.length > 0)
		     {   
	             if(FindGroup[1] != '0')
	             {
	                 if(obj.options[i+1] !=null)
	                 {
	                    var FindFirstParameter =obj.options[i+1].value.split("~");
        	            
	                    if(FindFirstParameter.length > 0)
	                    {
	                        if(FindFirstParameter[1] != '0')
	                        {
	                        if (i != (obj.options.length-1) && ! obj.options[i+1].selected) 
			                    {
				                    swapOptions(obj,i,i+1);
				                    obj.options[i+1].selected = true;
			                    }
	             	        }
	                    }
	                }
	             }
	           }
		}
	}
	GetSortOrder(obj);
}

// -------------------------------------------------------------------
// moveOptionUp(select_object)for appraisal form GroupQuestionMapping
//  Move selected option in a select list up one
// -------------------------------------------------------------------

function moveOptionUpQuestionForAppraisalStaff(obj) 
{
    obj=document.getElementById(obj);
    
	if (!hasOptions(obj)) { return; }
	for (i=0; i<obj.options.length; i++) 
	{
		if (obj.options[i].selected) 
		{
		
		 var FindGroup = obj.options[i].value.split(",");		 
		 if(FindGroup.length > 0)
		 {   
	         if(FindGroup[0] != '0'&&FindGroup[1] != '0' )
	         {
	            var FindFirstParameter =obj.options[i-1].value.split(",");
	            
	            if(FindFirstParameter.length > 0)
	            {
	                if(FindFirstParameter[0] != '0'&& FindGroup[1] != '0')
	                {
		                if (i != 0 && !obj.options[i-1].selected) 
		                {
			                swapOptions(obj,i,i-1);
			                obj.options[i-1].selected = true;
		                }
		            }
	            
	            }
	                
	        }
		 }	
	    }
	}
	GetSortOrder(obj);
}






// -------------------------------------------------------------------
// moveOptionDown(select_object) for appraisal GroupQuestionMapping
//  Move selected option in a select list down one
// -----------------------------------------------------------------

function moveOptionDownQuestionForAppraisalStaff(obj) 
{
    obj=document.getElementById(obj);
    
	if (!hasOptions(obj)) { return; }
	for (i=obj.options.length-1; i>=0; i--) 
	{
		if (obj.options[i].selected) 
		{		
		 var FindGroup = obj.options[i].value.split(",");	
		
		 if(FindGroup.length > 0)
		 {   
	         if(FindGroup[0] != '0' && FindGroup[1] != '0' )
	         {
	            
	            
	             if(obj.options[i+1] !=null)
	             {
	                var FindFirstParameter =obj.options[i+1].value.split(",");
    	            
	                if(FindFirstParameter.length > 0)
	                {
	                    if(FindFirstParameter[0] != '0'&& FindFirstParameter[1] != '0' )
	                    {
	                    if (i != (obj.options.length-1) && ! obj.options[i+1].selected) 
			                {
				                swapOptions(obj,i,i+1);
				                obj.options[i+1].selected = true;
			                }
	             	    }
	                }
	            }
	         }
	       }
		}
	}
	GetSortOrder(obj);
}














//Function FOr Bringing a div for Parent Click

 function OnTreeClick(evt)
    {   
        var src = window.event != window.undefined ? window.event.srcElement : evt.target;    
        var nodeClick = src.tagName.toLowerCase() == "a";    
        if(nodeClick)    
        {
            var nodeValue = GetNodeValue(src);
            if(nodeValue == '#PNode')
            {        
            document.getElementById('subcontent').style.visibility = 'visible';             
            return false;
            }           
            else
            return true;
        }
        //return false; //uncomment this if you do not want postback on node click
   }
   
   function GetNodeValue(node)
   {    
       var nodeValue = "";    
       var nodePath = node.href.substring(node.href.indexOf(",")+2,node.href.length-2);    
       var nodeValues = nodePath.split("\\");    
       if(nodeValues.length > 1)        
       nodeValue = nodeValues[nodeValues.length - 1];    
       else        
       nodeValue = nodeValues[0].substr(1);
       return nodeValue;
   }

function Divclose()
   {
      document.getElementById('subcontent').style.visibility="hidden";
      return false;
   }


//Method for selecting only one Radio button in AttendanceRoll grid: done by Anoop
function ChekMe(rdoId)
{
    /* Getting an array of all the “INPUT” controls on the form.*/
    var all = document.getElementsByTagName("input");    
    for(i=0;i<all.length-1;i++)
    {
    
    /*Checking if it is a radio button, and also checking if the id of that radio button is different than “rdoId” */
        if(all[i].type=="radio")
        {
            all[i].checked=false;
        }
    }
    rdoId.checked=true;/* Finally making the clicked radio button CHECKED */
}



function client_OnTreeNodeChecked(event) 
{
    var TreeNode = event.srcElement || event.target ; 
        if (TreeNode.tagName == "INPUT" && TreeNode.type == "checkbox")
        { 
            if(TreeNode.checked) 
            { 
            uncheckOthers(TreeNode.id);
            }
        }
}
function uncheckOthers(id) 
{
    var elements = document.getElementsByTagName('input');
    // loop through all input elements in form 
    for(var i = 0; i < elements.length; i++) 
    {
        if(elements.item(i).type == "checkbox") 
        {
            if(elements.item(i).id!=id) 
            {
                elements.item(i).checked=false; 
            }
        }
    }
}

//Method for selecting only one Radio button in AttendanceRoll grid: done by Anoop
function ChekMe(rdoId)
{   
    var all = document.getElementsByTagName("input");        
    for(i=0;i<all.length;i++)
    {
        if(all[i].type=="radio")
        {
            all[i].checked=false;
        }
    }
    rdoId.checked=true;
}

function OnTreeClick(evt)
    {   
        var src = window.event != window.undefined ? window.event.srcElement : evt.target;    
        var nodeClick = src.tagName.toLowerCase() == "a";    
        if(nodeClick)    
        {
            var nodeValue = GetNodeValue(src);
            if(nodeValue == '#PNode')
            {        
            document.getElementById('subcontent').style.visibility = 'visible';             
            return false;
            }           
            else
            return true;
        }
        //return false; //uncomment this if you do not want postback on node click
   }
   
   function GetNodeValue(node)
   {    
       var nodeValue = "";    
       var nodePath = node.href.substring(node.href.indexOf(",")+2,node.href.length-2);    
       var nodeValues = nodePath.split("\\");    
       if(nodeValues.length > 1)        
       nodeValue = nodeValues[nodeValues.length - 1];    
       else        
       nodeValue = nodeValues[0].substr(1);
       return nodeValue;
   }
   

//Function to check whether any radiobutton is checked 
   
function CheckedStatus(Message)
{   
    var all = document.getElementsByTagName("input");  
    var status=false;      
    for(i=0;i<all.length;i++)
    {
        if(all[i].type=="radio")
        {
            if(all[i].checked)
            {
                status=true;
                break;
            }
        }
    }
    if(status==false && Message!='')
    {
        alert(Message);
        return false;
    }
    else
    {
        return true;
    }
}

//***************************************************************************
// Scripts For Home Page

function MM_swapImgRestore() 
{ 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() 
{ 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) 
{ 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Scripts For Home Page
//***************************************************************************

//PopUp For Reports

function openReportPopup(Url,name,wid,hght)
{
    windowFeatures ="menubar=no,scrollbars=yes,location=no,favorites=no,resizable=yes,status=no,toolbar=no,directories=no";
    width=wid;
    height=hght;

    winLeft = (screen.width-width)/2;
    winTop = (screen.height-(height+110))/2;

    var PopupWin= window.open(Url, name, "width="+width+",height="+height+",left=" + winLeft + ",top=" + winTop + ","+windowFeatures);
}



function GetTotal(txtBoxID)
{   
    var obj = window.event.srcElement; 
    var tBox; 
    var sum = 0.00; 
    
    if(obj.tagName == "INPUT" && obj.type == "text") 
    {                   
      tBox = document.getElementsByTagName("INPUT"); 
        
      for(i = 0; i< (tBox.length - 2) ; i++) 
      {                   
         if(tBox[i].type == "text") 
         {            
            sum += Number(tBox[i].value);  
         } 
      } 
        //alert(sum.toFixed(2));
        document.getElementById(txtBoxID).innerText = sum.toFixed(2);
    }                
}

// Method to Check Whether 
function ConfirmationForListBox(obj,Group) 
{
    obj=document.getElementById(obj);
   
	if (obj.options.length<=0) 
	{ 
	    if(typeof(Page_ClientValidate) == 'function') 
        {
            if(Page_ClientValidate(Group)) 
            {
                var msg=confirm("You are about to Delete all the Data Mapped to the PA Form. Are you sure want to continue ?");
                if (msg) 
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
	}
	else
	{
	     if(typeof(Page_ClientValidate) == 'function') 
         {
            if(Page_ClientValidate(Group)) 
            {
	            return true; 
	        }
	     }
	}
}

//Method for gridview dropdown enable
var strGrid;
function SetPage(objName)
{        
    if(objName=='Master')
    {

       //strGrid="ctl00_ContentPlaceHolder1_ctl00_grdAttendanceCapture_ctl02_";  //GridID ( Old )
        strGrid="ctl00_ContentPlaceHolder1_ctl00_grdAttendanceCapture_";  //GridID
    }
    else
    {
        //strGrid="AttendanceCapture1_grdAttendanceCapture_ctl02_"; ( Old )
        strGrid="AttendanceCapture1_grdAttendanceCapture_";
    }
}

function ValidateGrid_ddlSelection()
{
    var strAttGrid="ctl00_ContentPlaceHolder1_ctl00_grdAttendanceCapture";     //Newly hardcoded
    //var spanChk=document.getElementById(strGrid+"ctl02_ddlhrOffIN");
    
    var spanChk=document.getElementById(strAttGrid+"_ctl02_ddlhrOffIN");
    var gvAtt=document.getElementById(strAttGrid);
    
    var isChecked=0;
    var theBox= (spanChk.type=="select-one") ? spanChk : spanChk.children.item[0];
    if(gvAtt!=null)
    {
            var Inputs = gvAtt.getElementsByTagName("select");
            for(j=0;j<gvAtt.rows.length-1;j++)
            {
               elm=theBox.form.elements;
               var k=(j*10)+7;
               for(i=k;i<elm.length;i++)
               {
                 if(elm[i].type=="select-one")
                  {
                      if(elm[i].selectedIndex!=0)
                        {
                            isChecked=1;
                            if(ValidateGridOfficeIN(GetLineNumber(elm[i])))
                            {
                                break;
                            }
                            else
                            {
                              return false;   
                            }
                        }
                   }
               }
            }
       if(isChecked==0)
        {
            alert('Please select atleast one row for processing !');
            return false;
        }
        
    }
    
}

function ValidateGridBussIN(LNO)
 {
     var BushrOUT=document.getElementById(strGrid+ LNO +"_ddlhrBusOut");
     var BushrIN=document.getElementById(strGrid+ LNO +"_ddlhrBusIn");
     var BusMnIN=document.getElementById(strGrid+ LNO +"_ddlMnBusIn");

    if(BushrIN.disabled==false)
    {
        if(BushrIN.value=='NA' ||BusMnIN.value=='NA')
        {
            alert('Please select Business IN Hour & Minutes');
            return false;
        }
    }
    return true;
 }
 
function ValidateGridOfficeIN(LNO)
{
 if(Page_ClientValidate())
 {
      var OffhrIN=document.getElementById(strGrid+ LNO +"_ddlhrOffIN");   
      var OffMnIN=document.getElementById(strGrid+ LNO +"_ddlMnOffIN");
      var BushrOUT=document.getElementById(strGrid+ LNO +"_ddlhrBusOut");
      var BusMnOUT=document.getElementById(strGrid+ LNO +"_ddlMnBusOut");
      var OffhrOut=document.getElementById(strGrid+ LNO +"_ddlhrOffOut");
      var OffMnOut=document.getElementById(strGrid+ LNO +"_ddlMnOffOut");
      var BushrIN=document.getElementById(strGrid+ LNO +"_ddlhrBusIn");
      var BusMnIN=document.getElementById(strGrid+ LNO +"_ddlMnBusIn");

      if(OffhrIN!=null)
      {
        if(OffhrIN.value=='NA'|| OffMnIN.value=='NA')
        {
            alert('Please select Office IN Hour & Minutes');
            return false;
        }
      }
      
      if(OffhrOut.value!='NA')
      {
        if(parseInt(OffhrOut.value)< parseInt(OffhrIN.value))
        {
            alert('Office OUT time must be greater than Office IN Time');
            return false;
        }
        else if(parseInt(OffhrOut.value) == parseInt(OffhrIN.value))
        {
            if(parseInt(OffMnOut.value) < parseInt(OffMnIN.value))
            {    
                alert('Office OUT time must be greater than Office IN Time');
                return false;
            }
        }
      }
      
      if(parseInt(BushrOUT.value) < parseInt(OffhrIN.value))
      {
        alert('Business OUT time must be greater than Office IN Time');
        return false;
      }
      else if(parseInt(BushrOUT.value) == parseInt(OffhrIN.value))
      {
        if(parseInt(BusMnOUT.value) < parseInt(OffMnIN.value))
           {
                alert('Business OUT time must be greater than Office IN Time');
                return false;
           }
      }
      
      if(OffhrOut.value!='NA' && BushrIN.value !='NA')
      {
         if(parseInt(BushrIN.value) > parseInt(OffhrOut.value))
         {
             alert('Business In time must be less than Office Out Time');
             return false;
         }
      }
      
      if(OffhrOut.value!='NA' && parseInt(BushrIN.value) == parseInt(OffhrOut.value))
      {
        if(parseInt(BusMnIN.value) > parseInt(OffMnOut.value))
           {
                alert('Business In time must be less than Office Out Time');
                return false;
           }
      }
      
      if(parseInt(BushrIN.value)<parseInt(BushrOUT.value))
      {
        alert('Business In Time must be greater than Business Out Time');
        return false;
      }
      else if(parseInt(BushrIN.value) == parseInt(BushrOUT.value))
      {
        if(parseInt(BusMnIN.value) < parseInt(BusMnOUT.value))
           {
                alert('Business In Time must be greater than Business Out Time');
                return false;
           }
      }
      if(OffhrOut.value=='NA' && OffMnOut.value!='NA')
      {
        alert('Please select Office OUT Hour.');
        return false;
      }
      
        return ValidateGridBussIN(LNO);
  }
  else
  {
    return false;
  }
}

function ValidateOfficeIN()
{
 if(Page_ClientValidate())
 {
  var strPopGrid="AttendanceCapture1_grdAttendanceCapture_ctl02_";
  var OffhrIN=document.getElementById(strPopGrid+"ddlhrOffIN");   
  var OffMnIN=document.getElementById(strPopGrid+"ddlMnOffIN");
  var BushrOUT=document.getElementById(strPopGrid+"ddlhrBusOut");
  var BusMnOUT=document.getElementById(strPopGrid+"ddlMnBusOut");
  var OffhrOut=document.getElementById(strPopGrid+"ddlhrOffOut");
  var OffMnOut=document.getElementById(strPopGrid+"ddlMnOffOut");
  var BushrIN=document.getElementById(strPopGrid+"ddlhrBusIn");
  var BusMnIN=document.getElementById(strPopGrid+"ddlMnBusIn");

  if(OffhrIN!=null)
  {
    if(OffhrIN.value=='NA'|| OffMnIN.value=='NA')
    {
        alert('Please select Office IN Hour & Minutes');
        return false;
    }
  }
  
  if(OffhrOut.value!='NA')                                  // OfficeHr Out less then OfficeHr In
  {
    if(parseInt(OffhrOut.value)< parseInt(OffhrIN.value))
    {
        alert('Office OUT time must be greater than Office IN Time');
        return false;
    }
    else if(parseInt(OffhrOut.value) == parseInt(OffhrIN.value))
    {
        if(parseInt(OffMnOut.value) < parseInt(OffMnIN.value))
        {    
            alert('Office OUT time must be greater than Office IN Time');
            return false;
        }
    }
  }
  
  if(parseInt(BushrOUT.value) < parseInt(OffhrIN.value))
  {
    alert('Business OUT time must be greater than Office IN Time');
    return false;
  }
  else if(parseInt(BushrOUT.value) == parseInt(OffhrIN.value))
  {
    if(parseInt(BusMnOUT.value) < parseInt(OffMnIN.value))
       {
            alert('Business OUT time must be greater than Office IN Time');
            return false;
       }
  }
  
  if(OffhrOut.value!='NA' && BushrIN.value !='NA')
  {
     if(parseInt(BushrIN.value) > parseInt(OffhrOut.value))
     {
         alert('Business In time must be less than Office Out Time');
         return false;
     }
  }
  
  if(OffhrOut.value!='NA' && parseInt(BushrIN.value) == parseInt(OffhrOut.value))
  {
    if(parseInt(BusMnIN.value) > parseInt(OffMnOut.value))
       {
            alert('Business In time must be less than Office Out Time');
            return false;
       }
  }
  
  if(parseInt(BushrIN.value)<parseInt(BushrOUT.value))
  {
    alert('Business In Time must be greater than Business Out Time');
    return false;
  }
  else if(parseInt(BushrIN.value) == parseInt(BushrOUT.value))
  {
    if(parseInt(BusMnIN.value) < parseInt(BusMnOUT.value))
       {
            alert('Business In Time must be greater than Business Out Time');
            return false;
       }
  }
  if(OffhrOut.value=='NA' && OffMnOut.value!='NA')
  {
    alert('Please select Office OUT Hour.');
    return false;
  }
  
  return ValidateBussIN();
  }
  else
  {
    return false;
  }
}

function GetLineNumber(obj)
{
    var Ctl = new RegExp("ctl\\d+");
    var LineNumber = "";
    LineNumber = Ctl.exec(obj.name.substring(3).toString());
    var NameArray=obj.name.toString().split("$");
    if(NameArray[2]=="ctl02")
    {
        LineNumber=NameArray[2];
    }
    else
    {
        for(i=0; i <= NameArray.length-1; i++)
            {
               LineNumber=NameArray[4];
               break;
            }  
     }       
    return LineNumber;
}

function EnableBusnessIN(obj)
{
     var LNO=GetLineNumber(obj);
     var BushrOUT=document.getElementById(strGrid+ LNO +"_ddlhrBusOut");
     var BusMnOUT=document.getElementById(strGrid+ LNO +"_ddlMnBusOut");
     var BushrIN=document.getElementById(strGrid+ LNO +"_ddlhrBusIn");
     var BusMnIN=document.getElementById(strGrid+ LNO +"_ddlMnBusIn");
 
 if(BushrOUT!=null)
 {
    if(BushrOUT.value=='NA')
    {
        BusMnOUT.options.selectedIndex=0;
        BushrIN.options.selectedIndex=0;
        BusMnIN.options.selectedIndex=0;
        BushrIN.disabled=true;
        BusMnIN.disabled=true;
    }
    else
    {
        BusMnOUT.options.selectedIndex=1;
        BushrIN.disabled=false;
        BusMnIN.disabled=false;
    }
 }
}

function ValidateBussIN()
 {
     var strPopGrid="AttendanceCapture1_grdAttendanceCapture_ctl02_";
     var BushrOUT=document.getElementById(strPopGrid+"ddlhrBusOut");
     var BushrIN=document.getElementById(strPopGrid+"ddlhrBusIn");
     var BusMnIN=document.getElementById(strPopGrid+"ddlMnBusIn");

    if(BushrIN.disabled==false)
    {
        if(BushrIN.value=='NA' ||BusMnIN.value=='NA')
        {
            alert('Please select Business IN Hour & Minutes');
            return false;
        }
    }
 }
 
 function ValidateBussOutMn(obj)
 {
    var LNO=GetLineNumber(obj);
    var BushrOUT=document.getElementById(strGrid+ LNO +"_ddlhrBusOut");
    var BusMnOUT=document.getElementById(strGrid+ LNO +"_ddlMnBusOut");
    if(BushrOUT.value!='NA')
    {
        if(BusMnOUT.value=='NA')
        {
            alert('Please select Business Out minute other than NA');
            BusMnOUT.options.selectedIndex=1;
            return false;
        }
    }
 }
 
 function ValidateOffOutMn(obj)
 {
    var LNO=GetLineNumber(obj);
    var OffhrOut=document.getElementById(strGrid+ LNO +"_ddlhrOffOut");
    var OffMnOut=document.getElementById(strGrid+ LNO +"_ddlMnOffOut");
    if(OffhrOut.value!='NA')
    {
        if(OffMnOut.value=='NA')
        {
            alert('Please select Office Out minute other than NA');
            OffMnOut.options.selectedIndex=1;
            return false;
        }
    }
 }
 
 function ChangeOffOutMn(obj)
 {
    var LNO=GetLineNumber(obj);
    var OffhrOut=document.getElementById(strGrid+ LNO +"_ddlhrOffOut");
    var OffMnOut=document.getElementById(strGrid+ LNO +"_ddlMnOffOut");
    if(OffhrOut.value!='NA')
    {
        OffMnOut.options.selectedIndex=1;
    }
    else
    {
       OffMnOut.options.selectedIndex=0;
    }
 }
 
 function ChangeBusInMn(obj)
 {
    var LNO=GetLineNumber(obj);
     var BushrIN=document.getElementById(strGrid+ LNO +"_ddlhrBusIn");
     var BusMnIN=document.getElementById(strGrid+ LNO +"_ddlMnBusIn");
     if(BushrIN.value!='NA')
     {
        BusMnIN.options.selectedIndex=1;
     }
     else
     {
        BusMnIN.options.selectedIndex=0;
     }

 }
 
 function ChangeOffInMn(obj)
 {
    var LNO=GetLineNumber(obj);
    var OffhrIN=document.getElementById(strGrid+ LNO +"_ddlhrOffIN");   
    var OffMnIN=document.getElementById(strGrid+ LNO +"_ddlMnOffIN");
    if(OffhrIN.value!='NA')
    {
        OffMnIN.options.selectedIndex=1;
    }
    else
    {
        OffMnIN.options.selectedIndex=0;
    }

 }
 
 function SetControlValues()
 {
      if(Page_ClientValidate())
      {
        var EmpName=document.getElementById("txtEmployee");
        var FromDate=document.getElementById("txtFromDate");
        var ToDate=document.getElementById("txtToDate");
        
        var hdEmpName=document.getElementById("hdEmpName");
        var hdFrom=document.getElementById("hdFromDate");
        var hdTo=document.getElementById("hdToDate");
        
        hdEmpName.value=EmpName.value;
        hdFrom.value=FromDate.value;
        hdTo.value=ToDate.value;
       }
       else
       {
        return false;
       }
 }

function WorkingHoursTimeValidation(what)
{
    var Ctl = new RegExp("ctl\\d+");
    var LineNumber = "";
    LineNumber = Ctl.exec(what.name.substring(3).toString());
    var NameArray=what.name.toString().split("$");
        for(i=0; i <= NameArray.length-1; i++)
            {
               LineNumber=NameArray[4];
               break;
            }  
    
    var ddlWorking = document.getElementById("ctl00_ContentPlaceHolder1_ctl00_grdWorkingHours_"+ LineNumber +"_ddlWorking");
    var ddlStartTime = document.getElementById("ctl00_ContentPlaceHolder1_ctl00_grdWorkingHours_" + LineNumber + "_ddlStartTime"); 
    var ddlEndTime = document.getElementById("ctl00_ContentPlaceHolder1_ctl00_grdWorkingHours_" + LineNumber + "_ddlEndTime");
    var txtBreak=document.getElementById("ctl00_ContentPlaceHolder1_ctl00_grdWorkingHours_" + LineNumber + "_txtBreak");
    var rqvStartTime= document.getElementById("ctl00_ContentPlaceHolder1_ctl00_grdWorkingHours_" + LineNumber + "_rqvStartTime");
    var rqvEndTime= document.getElementById("ctl00_ContentPlaceHolder1_ctl00_grdWorkingHours_" + LineNumber + "_rqvEndTime");
    var rngvBreak=  document.getElementById("ctl00_ContentPlaceHolder1_ctl00_grdWorkingHours_"+ LineNumber + "_rngvBreak");  
	
    if(ddlWorking!=null)
    {
        var item=what.value;
        if(item == "0" || item =="<--Select-->")
        {
	        ddlStartTime.disabled = true;
	        ddlEndTime.disabled = true;
	        txtBreak.disabled=true;
	        txtBreak.value=0;
	        ddlStartTime.selectedIndex=0
	        ddlEndTime.selectedIndex=0;
	        rqvStartTime.validationGroup='A';
	        rqvEndTime.validationGroup='A';
	        rngvBreak.validationGroup='A';
	        //ValidatorEnable(rqvStartTime,false); 
	        //ValidatorEnable(rqvEndTime,false);
	        //ValidatorEnable(rngvBreak,false);           
        }
        else
        {
	        ddlStartTime.disabled = false;
	        ddlEndTime.disabled = false;
	        txtBreak.disabled=false;
	        ddlStartTime.selectedIndex=0
	        ddlEndTime.selectedIndex=0;
	        txtBreak.value=0;
	        rqvStartTime.validationGroup='AttendanceRoll';
	        rqvEndTime.validationGroup='AttendanceRoll';
	        rngvBreak.validationGroup='AttendanceRoll';
            //ValidatorEnable(rqvStartTime,true); 
            //ValidatorEnable(rqvEndTime,true);
            //ValidatorEnable(rngvBreak,true);

        }
    }
  
}
///Function Used in WorkFlow
function ClearText()
{
document.getElementById('ctl00$ContentPlaceHolder1$ctl00$txtLevel1').value='';
document.getElementById('ctl00$ContentPlaceHolder1$ctl00$txtLevel2').value='';
document.getElementById('ctl00$ContentPlaceHolder1$ctl00$txtLevel3').value='';
document.getelementbyid('ctl00$contentplaceholder1$ctl00$txtlevel4').value='';
document.getelementbyid('ctl00$contentplaceholder1$ctl00$txtlevel5').value='';
document.getelementbyid('ctl00$contentplaceholder1$ctl00$txtlevel6').value='';
document.getElementById('ctl00$ContentPlaceHolder1$ctl00$txtEndPoint1').value='';
document.getElementById('ctl00$ContentPlaceHolder1$ctl00$txtEndPoint2').value='';
document.getElementById('ctl00$ContentPlaceHolder1$ctl00$txtEndPoint3').value='';
return false;
}

/*Validate atleast one item to select form gridview*/
function ValidateGridItems(grv,cl)
 {
    var grv=document.getElementById(grv);
    var isChecked=0;
    for(var i=1;i<grv.rows.length;i++)
    {
//        if(grv.rows[i].cells[6].firstChild.checked)
        if(grv.rows[i].cells[cl].firstChild.checked)
        {
            isChecked=1;
            break;
        }
    }
    if(isChecked==0)
    {
        alert('Please select atleast one item.');
        return false;
    }
    return true;
  }
  
  
  // Changing Visibility 
  
  
function ShowPopUp(DropDownName,ToggleControlName,AssignCtrlName)
{
    if(document.getElementById(DropDownName).selectedIndex==0)
        {
            document.getElementById(ToggleControlName).style.display="none";
            document.getElementById(AssignCtrlName).style.display="none";
            document.getElementById(AssignCtrlName).value="";
        }
        else
        {
             document.getElementById(ToggleControlName).style.display="";
             document.getElementById(AssignCtrlName).style.display="none";
             document.getElementById(AssignCtrlName).value="";
             document.getElementById(AssignCtrlName).disabled=true;
        }
}


function ShowPopUpInChange(DropDownName,ToggleControlName,AssignCtrlName,HiddenFld)
{
        document.getElementById(HiddenFld).value="";
        if(document.getElementById(DropDownName).selectedIndex==0)
        {
            document.getElementById(ToggleControlName).style.display="none";
            document.getElementById(AssignCtrlName).style.display="none";
            document.getElementById(AssignCtrlName).value="";
        }
        else
        {
             document.getElementById(ToggleControlName).style.display="";
             document.getElementById(AssignCtrlName).style.display="none";
             document.getElementById(AssignCtrlName).value="";
             document.getElementById(AssignCtrlName).disabled=true;
        }
}



/*
   Function For User Details Popup
   ------------------------------------
*/
function ShowOtherArea(tblOther,DDL,CtrlValid,txt)
 {
   var tbl_Other=document.getElementById(tblOther);
   var My_DDL=document.getElementById(DDL);
   var Valid=document.getElementById(CtrlValid);
   var Mytxt=document.getElementById(txt);
   if(My_DDL!=null)
   {
     if(My_DDL.value!="--Select An Item--")
     {
        if(tbl_Other!=null)
            tbl_Other.style.display='none';
        if(Valid!=null)
            ValidatorEnable(Valid, false);
     }
     else
     {
        if(tbl_Other!=null)
            tbl_Other.style.display='';
            
        Mytxt.value='';
        Mytxt.focus();
        if(Valid!=null)
            ValidatorEnable(Valid, true);
     }
   }
   return true;
 }
 
 function SetControlValidation(txtNrmlComp,reqvCtrlNrml,chkOther,reqvOtherCtrl)
 {
    var My_txt=document.getElementById(txtNrmlComp);
    var My_reqv=document.getElementById(reqvCtrlNrml);
    var My_Other=document.getElementById(chkOther);
    var My_OtherReqv=document.getElementById(reqvOtherCtrl);
    if(My_txt!=null)
    {
      if(My_Other.checked==false)
      {
        if(My_reqv!=null)
        {
            if(My_txt.value!='')
            {
                ValidatorEnable(My_reqv, false);
                ValidatorEnable(My_OtherReqv, false);
            }
            else
            {
               ValidatorEnable(My_reqv, true);
               ValidatorEnable(My_OtherReqv, false);
            }
        }
      }
      else
      {
        if(My_OtherReqv!=null)
            ValidatorEnable(My_OtherReqv, true);
      }
    }
 }
 
 function ShowOtherCompany(tblOther,ChkBox,btnSel,txt,NrmlValid,CtrlValid)
 {
   var tbl_Other=document.getElementById(tblOther);
   var My_chk=document.getElementById(ChkBox);
   var MyValid=document.getElementById(CtrlValid);
   var Mytxt=document.getElementById(txt);
   var MySelbtn=document.getElementById(btnSel);
   var MyNrmlVald=document.getElementById(NrmlValid);
   if(My_chk!=null)
   {
     if(My_chk.checked)
     {
        tbl_Other.style.display='';
        Mytxt.value='';
        Mytxt.focus();     
        document.getElementById('ctl00_ContentPlaceHolderContent_txtCompany').value=''
        MySelbtn.style.display='none';
        if(MyValid!=null)
        {
//            MyValid.disabled=false;
            MyValid.style.display='';
            ValidatorEnable(MyValid, true);
        }
        if(MyNrmlVald!=null)
        {
           ValidatorEnable(MyNrmlVald, false);
           MyNrmlVald.style.display='none';
        }
     }
     else
     {
        tbl_Other.style.display='none';
        Mytxt.value='';
//        document.getElementById('ctl00_ContentPlaceHolderContent_txtCompany').value=''
        MySelbtn.style.display='';
        if(MyValid!=null)
        {
            //MyValid.disabled=true;
            ValidatorEnable(MyValid, false);
            MyValid.style.display='none';
        }
        if(MyNrmlVald!=null)
        {
           MyNrmlVald.style.display='';
           ValidatorEnable(MyNrmlVald, true);
        }

     }
   }
   return true;
 }

/*--------------------------------------*/

 function ClearField(lbl)
 {
   var mylbl=document.getElementById(lbl);
   if(mylbl!=null)
   {
     mylbl.value='';
     mylbl.style.display='none';
   }
 }



function disableListView(lstview,boolValue)
{
    var listViewRef = document.getElementById(lstview);
    var inputElementArray = listViewRef.getElementsByTagName('input');
    for (var i=0; i<inputElementArray.length; i++)
    {
         var elementRef = inputElementArray[i];
         elementRef.disabled = boolValue;
         elementRef.style.cursor='Text';
    }

     var selectElementArray = listViewRef.getElementsByTagName('select');
     for (var i=0; i<selectElementArray.length; i++)
     {
        var elementRef = selectElementArray[i];
        elementRef.disabled = boolValue;
        elementRef.style.cursor='Text';
     }

     var anchorElementArray = listViewRef.getElementsByTagName('a');
     for (var i=0; i<anchorElementArray.length; i++)
     {
        var elementRef = anchorElementArray[i];
        elementRef.disabled = boolValue;
        elementRef.style.cursor='Text';
     }
}


function SetHiddenFiled(hdnId,Val)
{
    document.getElementById(hdnId).value=Val;
}

function ClearMailContent(subject,content)
{
    document.getElementById(subject).value='';
    document.getElementById(content).value='';
}

/*-------------------------------------------------------------------------
 Function for checking CheckboxList item selection (Atleast one selection)                                  --------------------------------------------------------------------------*/
 function ValidateChk(chk)
 {
   if(Page_ClientValidate())
   {
        var els = document.getElementsByTagName('input');
        var Count=0;
        var inx=0;
        for (var i=0; i < els.length; ++i)
        {
            var e = els[i];
            var MyCtrl='';
            if(e.type == 'checkbox')
            {
                MyCtrl=chk+"_"+inx;
                inx++;
            }
            if(e.type == 'checkbox'&& e.id ==MyCtrl && e.checked)
                Count++;
        }
        if(Count==0)
        {
         alert("Please Select Atleast one Role.");
         return false;
        }
        else
         return true; 
     }
     else
        return false;  
 }

function CheckAnswerSelected()
{
    var InputLst=document.getElementsByTagName('input');
    for(var i=0;i<InputLst.length-1;i++)
    {
        if(InputLst[i].type=='radio' && InputLst[i].checked==true)
        {
            return true;
        }
    }
    alert('Select one answer');
    return false;
}


function CloseOrNotClose()
{
    //if(window.document.activeElement==null)
    if((window.event.clientX<0) || (window.event.clientY<0)) 
    {
        event.returnValue = "You will lose the current status of exam and you have to reappear for it,Do you want to continue?";
    }
}

function ChangeViibility(tblNotOk,ValidatorRequired,validatorRegx,flag,txtGrammerComment)
{
    var tblID=document.getElementById(tblNotOk);
    var ValidID=document.getElementById(ValidatorRequired);
    var ValidRegx=document.getElementById(validatorRegx);
    var txt=document.getElementById(txtGrammerComment);
    if(flag==1)
    {
        tblID.style.display='';
        ValidatorEnable(ValidID, true);
        ValidatorEnable(ValidRegx, true);
        txt.value='';
    }
    else 
    {
        tblID.style.display='none';
        ValidatorEnable(ValidID, false);
        ValidatorEnable(ValidRegx, false);
        txt.value='';
    }
}


function VisibleEnableHallOfFame(tblHallOfFame,txtHallOfFame,reqvHalloffame,rngvHalloffame,cmpHallOFFame,chkHallOFFame)
{
    var chk=document.getElementById(chkHallOFFame);
    var table=document.getElementById(tblHallOfFame);
    var reqv=document.getElementById(reqvHalloffame);
    var rngv=document.getElementById(rngvHalloffame);
    var cmpr=document.getElementById(cmpHallOFFame);
    var txt=document.getElementById(txtHallOfFame);
    if(chk!=null)
    {
        if(chk.checked && table.style.display=='none')
            table.style.display='';
        else if(chk.checked==false && table.style.display!='none')
        {
            table.style.display='none';
            txt.value='';
        }
        ValidatorEnable(reqv,chk.checked);
        ValidatorEnable(rngv,chk.checked);
        ValidatorEnable(cmpr,chk.checked);
        
    } 
}

/*-----------------------------------------------------------------------*/ 

function CheckBoxSingleSelect(chkId) 
{
   
    var all = document.getElementsByTagName("input");

    for (i = 0; i < all.length; i++) 
    {

        if (all[i].type == "checkbox") 
        {
            all[i].checked = false;
        }

    }
    chkId.checked = true;
}
/*-Top Menu scroll--*/
var scrolling=null ;
function scroll_left(scrollobj) 
{ 
        var d = document.getElementById(scrollobj); 
        
        if(d !=null)
            d.scrollLeft= d.scrollLeft - 5;
  
        scrolling = window.setTimeout(function() { 
            scroll_left(scrollobj); 
        }, 500); 
    } 
  
    function scroll_right(scrollobj)  
    { 
        var d = document.getElementById(scrollobj); 
       
        if(d !=null)
            d.scrollLeft = d.scrollLeft + 5;
  
        scrolling = window.setTimeout(function() { 
            scroll_right(scrollobj); 
        }, 500); 
    } 
  
    function stop_scroll() 
    { 
        window.clearTimeout(scrolling); 
    } 
    /*-Top Menu scroll--*/
    
    function isValidKey(evt)
    {
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode == 32 || charCode == 59 || (charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123))
            return true;
        else
            return false;
    }
    
     function AppAndAudience(App,Aud,Det)
     {
         if(Page_ClientValidate('Action'))
           {     
             var chkApp=document.getElementById(App);
             var chkAud=document.getElementById(Aud);
             var txtDet=document.getElementById(Det);
             var chkBoxCount=chkApp.getElementsByTagName("input");
             var chkBoxCount1=chkAud.getElementsByTagName("input");
             var AlertMessage='';
             var AlertMessage1='';
             for(var i=0;i<chkBoxCount.length;i++) 
                {           
                   if(chkBoxCount[i].checked == true)
                   {
                       AlertMessage='';
                       break;
                   }           
                   AlertMessage = "Please select atleast one application.";
                }
             for(var i=0;i<chkBoxCount1.length;i++) 
                {           
                   if(chkBoxCount1[i].checked == true)
                   {
                       AlertMessage1='';
                       break;
                   }           
                   AlertMessage1 = "Please select atleast one audience.";           
                }
                if(AlertMessage!='')
                {
                    alert(AlertMessage);
                    return false;
                }   
                else if(AlertMessage1!='')
                {
                    alert(AlertMessage1);
                    return false;
                }     
                else
                {
                    return true;
                }
                return false;
            }
     }
     
     
     
function CheckBoxSingleSelectWithinGrid(chkId,grdId) 
{
    var grd=document.getElementById(grdId);
    if(grd !=null)
    {
        var all =grd.getElementsByTagName("input");
        if(all !=null && all.length>0)
        {
            for (i = 0; i < all.length; i++) 
            {
                if (all[i].type == "checkbox") 
                {
                    all[i].checked = false;
                }
            }
        }
    }    
    chkId.checked = true;    
}


function PrintPartOfWebPage(PartID)
{   
    var divToPrint=document.getElementById(PartID);  
    var uniqueName = new Date();
    var newWin= window.open('about:blank',uniqueName.getTime(),'left=3000,top=3000,width=0,height=0');  
    newWin.document.write(divToPrint.outerHTML);  
    newWin.document.close();
    newWin.focus();
    newWin.print();  
    newWin.close();
}

function SelectAtleastOne(lstID)
{
    var lst = document.getElementById(lstID);
    if(Page_ClientValidate('Report'))
    {
        if(lst!=null && lst.options.length>0)
        {
            for(i=0;i<lst.options.length;i++)
            {
                if(lst.options[i].selected) 
                    return true;
            }
        }
        alert('Select atleast one item from the list');
        return false;
    }
    else
        return false;
}

function ClearReportItems(txtyourNameReport,txtComments,txtYourEmailReport,lblReportMessage,val,lst)
{
    var Label=document.getElementById(lblReportMessage);
    document.getElementById(txtyourNameReport).value='';
    document.getElementById(txtComments).value='';
    document.getElementById(txtYourEmailReport).value='';
    if(Label!=null && val==1)
        Label.innerText='';
    document.getElementById(lst).selectedIndex=-1;
}

function ClearShareItems(txtyourName,txtMessage,txtRname,txtEmail,lblShareMessage,val)
{
    var Label=document.getElementById(lblShareMessage);
    document.getElementById(txtyourName).value='';
    document.getElementById(txtMessage).value='';
    document.getElementById(txtRname).value='';
    document.getElementById(txtEmail).value='';
    if(Label!=null && val==1)
        Label.innerText='';
}

function addBookmark(PageTitle,Url)      
{           
    if (document.all)            
    {                      
        window.external.AddFavorite(Url,PageTitle);           
    }           
    else if (window.sidebar)          
    {                      
        window.sidebar.addPanel(PageTitle, Url, "");           
    }      
}   
/* FOR Google Map*/
function Cordinates()
{
    if (GBrowserIsCompatible())
    {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(25.248888,55.500000), 15);
        map.setUIToDefault();
        map.setMapType(G_NORMAL_MAP);
        //var point=new GLatLng(25.244153,55.319789)
        var point=new GLatLng(25.244715,55.315089)
        var marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml('<img src="../../images/adminimages/etlogo.gif" width="170" height="70" />');
       GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml('<img src="../../images/adminimages/etlogo.gif" width="177" height="79" />');});
       
    }
}
//---------------------------------------------
//For Partner Registration

function CheckEmailandName(txtone, txttwo)
{
    var TxtOne = document.getElementById(txtone);
    var TxtTwo = document.getElementById(txttwo);
    
    if(Page_ClientValidate('Partner'))
    {
        if(TxtOne!=null && TxtTwo!=null)
        {
            if((TxtOne.value!='' && TxtTwo.value=='') || (TxtOne.value=='' && TxtTwo.value!=''))
            {
                alert('Enter both name and email for delegate 2');
                return false;
            }
        }
    }
    else
        return true;
}

//For Partner Registration Ends Here