/*
------------------------------------------
Functions to change the background color on mouse click.
------------------------------------------
*/
function changeBgColor(item, newColor){
	document.getElementById(item).style.backgroundColor=newColor;
}
/*
------------------------------------------
Function to Show / Hide CSS based dialog box
------------------------------------------
*/
		var IE = document.all;
		function showHideDialog(dialogName) {
		var defaultWidth=300;
		var defaultHeight=80;
		var CFD_Layer = document.getElementById(dialogName).style;
		v_status = CFD_Layer.visibility;
		var l_width = CFD_Layer.width.slice(0,-2);	// Remove px from width
		var l_height = CFD_Layer.hight.slice(0,-2);	// Remove px from height
		if (!l_width)
			l_width=defaultWidth;
		if (!l_height)
			l_height=defaultHeight;
		// Capture browser window size
		if (IE) {
			screenWidth = (document.body.clientWidth + 20);
//			screenWidth = (top.document.all.mainFrame.width);
			screenHeight = (top.document.all.mainFrame.height);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}

			// Evaluate left position for the current browser width
			leftPos = (screenWidth/2) -  (l_width/2);
			topPos  = (screenHeight/2) - (l_height/2);
			// Show/Hide layer
			if ((v_status=="hidden") || (v_status==""))
			{
				CFD_Layer.visibility = "visible";
				// Assign new layer position
				CFD_Layer.left = leftPos+'px';
				CFD_Layer.top = (topPos-50)+'px';
			} else {
				CFD_Layer.visibility = "hidden";
			}
		}

		function showHideMenu2(menuName, leftPos, topPos){
		var _menu = document.getElementById(menuName).style;
		var _status = _menu.visibility;
			if ((_status=="hidden") || (_status=="")){
				_menu.left=leftPos+'px';
				_menu.top=topPos+'px';
				_menu.visibility = "visible";
			}else{
				_menu.visibility = "hidden";
			}
		}

		function showHideMenu3(menuName, leftPos, topPos, file){
		var _menu = document.getElementById(menuName).style;
		var _status = _menu.visibility;
			if ((_status=="hidden") || (_status=="")){
				_menu.left=leftPos;
				_menu.top=topPos;
				_menu.visibility = "visible";
				if (file!='')
				self.location.href="popup_add_shortcut.html"
			}else{
				_menu.visibility = "hidden";
			}
		}

		function toggle_submenu(menuName, action){
				document.getElementById(menuName).style.display = action;
		}
		
/*
------------------------------------------
Function to Show / Hide CSS based file/folder menu
------------------------------------------
*/

		var posX;
		var posY;
		function showHideMenu(linkId,menuName,folderid,level,parentid,utyp,fid,cid) {
		var CFD_Layer = document.getElementById(menuName).style;

		var v_status = CFD_Layer.visibility;
			if (IE){
				posX=event.clientX;
				posY=event.clientY;
			}else{
				window.captureEvents(Event.CLICK);
				document.captureEvents(Event.CLICK);
				document.getElementById(linkId).onclick=pos;
			}
                //      setFolder1(folderid,level,parentid,utyp,fid,cid);
//			alert(posX)
		// Capture browser window size
		if (IE) {
			screenHeight = (top.document.all.mainFrame.height);
		} else {
			screenHeight= self.innerHeight;
		}

			// Evaluate left position for the current browser width
			leftPos = posX - 4;
//			alert(screenHeight-posY)
			posYY = screenHeight-posY;
			menuHeight=275;
			if (posYY <= menuHeight)	// Menu height is 240 points
				topPos  = menuHeight-posYY;
			else
				topPos  = posY-4;
//alert(topPos)
			// Show/Hide layer
			if ((v_status=="hidden") || (v_status==""))
			{
				CFD_Layer.visibility = "visible";
				// Assign new layer position
				CFD_Layer.left = leftPos+'px';
				CFD_Layer.top = topPos+'px';
			} else {
				CFD_Layer.visibility = "hidden";
			}


		}
/*
------------------------------------------
Functions to capture mouse click position
------------------------------------------
*/

	  function pos(e){
			posX=e.pageX;
			posY=e.pageY;
		return true;
		}

/*
------------------------------------------
Functions to capture and save Cookies
------------------------------------------
*/

function getexpirydate( nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}

function getcookie(cookiename){
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return "";
		var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length;
		return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function setcookie(name,value,duration){
	cookiestring=name+"="+escape(value); //;+"EXPIRES="+getexpirydate(duration);
	document.cookie=cookiestring;
	if(!getcookie(name)){
		return false;
	}
	else{
		return true;
	}
}

/*
------------------------------------------
Functions to change page/url in the main frame.
------------------------------------------
*/

function changeURL(URL){
	top.mainFrame.location=URL;
}
/*
------------------------------------------
Functions to change page/url in the same frame as the link
------------------------------------------
*/


function goTo(page){
	self.location=page;
}

/*
------------------------------------------
Functions to open a popup window with custom specs
------------------------------------------
*/

function openPopup(varFilename, leftPos, topPos, intWidth, intHeight, binScroll) {

     winParams = " toolbar=no"         // Icon bar
               + ",location=no"      // Location bar
               + ",directories=no"   //
               + ",status=no"       //Status Bar at bottom of window.
               + ",menubar=no"       //Menubar at top of window.
               + ",resizeable=yes"    //Allow resizing by dragging. (Yes - Does not work with Netscape or IE)
               + ",scrollbars="+binScroll   //Displays scrollbars is document is larger than window.
               + ",titlebar=no"     //Enable/Disable titlebar resize capability.
               + ",left="+leftPos             //Offset of windows left edge from screen.
               + ",top="+topPos              //Offset of windows top edge from screen.
               + ",width="+intWidth    //Standard 640,800/788, 800/788
               + ",height="+intHeight  //Standard 480,600/541, 600/566
               + ";"

 		 		 var popwin;
				 popWindow = window.open(varFilename,popwin,winParams)
}




function openCSSPopup(fileName, fwidth, fheight){
	var _pLayer=document.getElementById('popupWin').style;
	var _pFrame=document.getElementById('frmPopup');
	var _pStatus=_pLayer.visibility;
		// Capture browser window size
		if (IE) {
			screenWidth = (document.body.clientWidth + 20);
//			screenWidth = (top.document.all.mainFrame.width);
			screenHeight = (top.document.all.mainFrame.height);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}

			// Evaluate left position for the current browser width
			leftPos = (screenWidth/2) -  (fwidth/2);
			topPos  = (screenHeight/2) - (fheight/2)-30; //30 value draws the display up

		if (_pStatus=="hidden") {
			if(IE)
			document.getElementById('container').style.filter="Alpha(Opacity=40)";
			else
			document.getElementById('container').setAttribute("style","-moz-opacity:.4;");
			_pLayer.left=leftPos+'px';
			_pLayer.top=topPos+'px';
			_pFrame.src=fileName;
			_pFrame.width=fwidth;
			_pFrame.height=fheight;
			_pLayer.visibility="visible";
		}else{
			if(IE)
			document.getElementById('container').style.filter="Alpha(Opacity=100)";
			else
			document.getElementById('container').setAttribute("style","-moz-opacity:1;");
			_pLayer.visibility="hidden";
		}
}




/*  CSS windoow and iframe to be used in pages for the popup window*/
cHTML='<div id="popupWin" style="position: absolute; visibility: hidden; background-color: #ffffff; z-index: 20;">\
	<iframe name="frmPopup" id="frmPopup" frameborder="0" src="">Please wait...</iframe><br>\
	<div style="text-align: right;"> \
		<a href="javascript://" onClick="javascript:openCSSPopup(1,1,1);">Close</a>\
	</div>\
</div>'
document.write(cHTML)

// Create DIVs for each level of CSS POP-UP Window
document.write('<div id="jsHTML0"></div>')
document.write('<div id="jsHTML1"></div>')
document.write('<div id="jsHTML2"></div>')
document.write('<div id="jsHTML3"></div>')
document.write('<div id="jsHTML4"></div>')

function openCSSPopupByName(fileName, fLeft, fTop, fwidth, fheight, wName, depth){
	
	if (!depth) { depth=0; }
	jsDiv 	= wName + 'xCSS';
	jsFrame = wName + 'xFRM';
	// Create dynamic DIV
	createPopUpDiv(jsDiv, jsFrame, wName, depth, fileName);

	// Initialize DIV variables 
	var _pLayer=document.getElementById(jsDiv).style;
	var _pFrame=document.getElementById(jsFrame);
	if (_pLayer.display == "none") 
	{
		// Capture browser window size
		if (IE) {
			screenWidth = (document.body.clientWidth + 20);
			screenHeight = (document.body.clientHeight);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}
		// Evaluate left position for the current browser width
			if (fLeft != 0) {
				leftPos = fLeft;
			} else {
				leftPos = ((screenWidth/2) -  (fwidth/2));
			}
			if (fTop != 0) {
				topPos = fTop;
			} else {
				topPos  = ((screenHeight/2) - (fheight/2)-30); //30 value draws the display up
			}
		// Create opaque page background
			if(IE){
				document.getElementById('container').style.filter="Alpha(Opacity=10)";
			} else {
				document.getElementById('container').setAttribute("style","-moz-opacity:.1;");
			}
		// Draw pop-up DIV & call file in IFRAME
			_pLayer.left=leftPos+'px';
			_pLayer.top=topPos+'px';
			_pFrame.src=fileName;
			_pFrame.width=fwidth;
			_pFrame.height=fheight;
			_pLayer.display="block";
			document.getElementById('jsHTML'+depth).style.display='block';
			//document.location.href="#top";
	} else {
			if(IE)
				document.getElementById('container').style.filter="Alpha(Opacity=100)";
			else
				document.getElementById('container').setAttribute("style","-moz-opacity:1;"); 
			document.getElementById('jsHTML'+depth).innerHTML = '';
			document.getElementById('jsHTML'+depth).style.display='none';
			_pLayer.display="none";
	}
}

//----------------------------Open the window where u click ur mouse button--------------


function openCSSPopupByName1(e,fileName, fLeft, fTop, fwidth, fheight, wName, depth){

  
  
     /* ----Reading the co-oridinate--------------- */
      if (window.ActiveXObject)
       {

         e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
      }
     if (e)
      { 
        if (e.pageX || e.pageY)
            {  // this doesn't work on IE6!! (works on FF,Moz,Opera7)
               x = e.pageX;
               y = e.pageY;
               algor = '[e.pageX]';
               if (e.clientX || e.clientY) 
                   algor += ' [e.clientX] '
            }
        else if (e.clientX || e.clientY)
          { 
            // works on IE6,FF,Moz,Opera7
              x = e.clientX + document.body.scrollLeft;
              y = e.clientY + document.documentElement.scrollTop;
          } 
     } 
 
     //y=y-280;
     //x=x-150;
    
     //alert("the position of y="+y); 
     //fLeft =x+12;
     fTop = y + 20;
     
	if (!depth) { depth=0; }
	jsDiv 	= wName + 'xCSS';
	jsFrame = wName + 'xFRM';
	// Create dynamic DIV
	createPopUpDiv(jsDiv, jsFrame, wName, depth, fileName);

	// Initialize DIV variables 
	var _pLayer=document.getElementById(jsDiv).style;
	var _pFrame=document.getElementById(jsFrame);
	if (_pLayer.display == "none") 
	{
		// Capture browser window size
		if (IE) {
			screenWidth = (document.body.clientWidth + 20);
			screenHeight = (document.body.clientHeight);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}
		// Evaluate left position for the current browser width
			if (fLeft != 0) {
				leftPos = fLeft;
			} else {
				leftPos = ((screenWidth/2) -  (fwidth/2));
			}
			if (fTop != 0) {
				topPos = fTop;
			} else {
				topPos  = ((screenHeight/2) - (fheight/2)-30); //30 value draws the display up
			}
		// Create opaque page background
			if(IE){
			//	document.getElementById('container').style.filter="Alpha(Opacity=50)";
			} else {
				document.getElementById('container').setAttribute("style","-moz-opacity:.6;");
			}
		// Draw pop-up DIV & call file in IFRAME
			_pLayer.left=leftPos+'px';
			_pLayer.top=topPos+'px';
			_pLayer.width=fwidth+'px';
			_pLayer.height=fheight+'px';
			_pFrame.width=fwidth;
			_pFrame.height=fheight;
			_pFrame.src=fileName;
			_pLayer.display="block";
			document.getElementById('jsHTML'+depth).style.display='block';
			//document.location.href="#top";
	} else {
			if(IE)
			{
			//	document.getElementById('container').style.filter="Alpha(Opacity=100)";
			}else{
				document.getElementById('container').setAttribute("style","-moz-opacity:1;"); 
			}
			document.getElementById('jsHTML'+depth).innerHTML = '';
			document.getElementById('jsHTML'+depth).style.display='none';
			_pLayer.display="none";
	}
}





//-----------------------------End opening css window when open the window---------------


function createPopUpDiv(jsDiv, jsFrame, divName, depth, fName) {
	if (fName != "1"){   // File Name MUST be 1 to close the CSS Window 
	popupHTML='<div id="' + jsDiv + '" style="position: absolute; border: 4px double #3c99d4; display: none; background-color: #ffffff; z-index:20;"> \
		<iframe name="' + jsFrame + '" id="' + jsFrame + '" frameborder="0" src="">Please wait...</iframe><br>\
		<div style="background-color: #3c99d4; text-align: right;"><a href=javascript:openCSSPopupByName(1,1,1,1,1,"'+ divName +'",'+ depth +'); style="color: #fff;font-family:Arial;">Close this window</a></div>\
		</div>'
	document.getElementById('jsHTML'+depth).innerHTML = popupHTML;
	}
}


function validateRemove(){
        return confirm("REMOVE!\n\nPlease confirm")
    }



//----------- for creating a book------------------------------------

var xmlHttp
function kbsearch(url,ddlDept,ddInitial,lstemp)
       {
       //alert(ddlDept);
       //alert(ddInitial);
            
             xmlHttp=GetXmlHttpObject();
              if (xmlHttp==null)
                 {
                    alert ("Your browser does not support AJAX!");
                    return;
                  } 
                                   
                 
                    var dept= document.getElementById("ctl00_mainContent_Create_group1_ddldept");      //Create_group1_ddldept  , new =ctl00_mainContent_Create_group1_ddldept
                    var initial = document.getElementById("ctl00_mainContent_Create_group1_ddlInitial"); // Create_group1_ddlInitial, new= ctl00_mainContent_Create_group1_ddlInitial
                    //alert (" selectd value="+  ddlselectedValue(dept));
                    
                    
                    //if (parseInt(ddlselectedValue(dept))!=0)
                     // {
                        //alert("Department is selected="+ parseInt(ddlselectedValue(dept)) );
                         url="showuser.aspx?dept_id="+ddlselectedValue(dept)+"&initial="+ddlselectedValue(initial);
                         //alert ( url);
                         xmlHttp.onreadystatechange=kbstateChanged;
                         xmlHttp.open("GET",url,true);
                         xmlHttp.send(null);
                       //}
        }

        function kbstateChanged() 
            { 
                if (xmlHttp.readyState==4)
                    { 
                         //document.getElementById("lstemployee").innerHTML=xmlHttp.responseText;
                         var uservalue= xmlHttp.responseText;
                         operation(uservalue);
                    }
             }

        function GetXmlHttpObject()
                {
                      var xmlHttp=null;
                      try
                        {
                            // Firefox, Opera 8.0+, Safari
                            xmlHttp=new XMLHttpRequest();
                        }
                      catch (e)
                         {
                             // Internet Explorer
                            try
                             {
                                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                              }
                           catch (e)
                              {
                                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                               }
                   }
             return xmlHttp;
   }
    
    function ddlselectedValue(ddllist)
      {
          //alert ("hello");
          //alert("hello"+ddllist.selectedIndex);
          
          
          for(var i=0;i<(ddllist.options.length);i++)
              {
                 if(ddllist.options[i].selected)
                  {
                   // alert(ddllist.options[i].value);
                    return ddllist.options[i].value; 
                  }
              }  
              //alert(ddllist.Value);
          
          return ddllist.Value;
      }
    
    
    function operation(uservalue)
      {
         //alert(" user value =" + uservalue);
         var arr =uservalue.split("|");
         var lstemployee=document.getElementById("ctl00_mainContent_Create_group1_lstEmployee");   // Create_group1_lstEmployee,new=ctl00_mainContent_Create_group1_lstEmployee  
         removeAllOptions(lstemployee); // clear the lstemployee value         
         //alert ("Array Lenght" + arr.length);
         if (arr.length >1)
         {
            for ( var i=0;i< (arr.length) ;i++)
                {
                     var record=arr[i].split(",");  // value[0]=uid, value[1]=empcode,value[2]=firstname value[3]=middle name value[4]=last name
                     var optn = document.createElement("OPTION");                                        
                     optn.value = record[0]; 
                     optn.text = record[5]; 
                     lstemployee.options.add(optn);
                 //alert("legnth="+arr[i]);  for checking purpose it displays records of employee
                }
          }
      }
      
      // Removing all the option from the list box
    function removeAllOptions(selectbox)
       {
         var i;
         for(i=selectbox.options.length-1;i>=0;i--)
           {
              selectbox.remove(i);
           }
       }      
      
   function AddUser()
      { 
         //this function will add value from one list to another list box 
         // and will remove the value form first one 
         // Process it will first check lstemployee has any values is selected or not
         // if selected then it will transfer that value form one side to another side
         // and remove it  
            var lstemployee=document.getElementById("ctl00_mainContent_Create_group1_lstEmployee"); //  Create_group1_lstEmployee , new=
            var lstSemployee= document.getElementById("ctl00_mainContent_Create_group1_lstSEmployee");  //Create_group1_lstSEmployee, new= ctl00_mainContent_Create_group1_lstSEmployee 
             //alert ("Moving  the value" + IsSelected(lstemployee));
             if (IsSelected(lstemployee))
               {
                  MovingValue(lstemployee,lstSemployee);
               }
      }
      
  function IsSelected(lstbox)
     {
          // This function will return the value true if 
          // any value is selected otherwise it will return the false
          
             //alert("the optin length" + lstbox.options.length);
           
            for(var i=0;i<(lstbox.options.length);i++)
              {
                 if(lstbox.options[i].selected)
                    //alert(lstbox.options[i].text);
                    return true; 
              }  
            return false; 
     }     
      
 function MovingValue(lstSource,lstdestination)
   {
      
              
          for(var i=0;i<(lstSource.options.length);i++)
              {
                    //alert("Yes i m going to transfer value" + lstSource.options.length);
                 if(lstSource.options[i].selected)
                   {
                      // here add the value in destination list
                       var optn = document.createElement("OPTION");                                        
                       optn.text = lstSource.options[i].text; 
                       optn.value = lstSource.options[i].value; 
                       // here check desitination has this value
                        lstdestination.options.add(optn);
                        //lstSource.remove(i);  // it should be change for multiple selection beacuse it re
                        //alert("selected value="+ lstSource.options[i].text+" and value="+lstSource.options[i].value );
                    }
               } 
            // for removing the selected data
            
                for(var i=0;i<(lstSource.options.length);i++)
                 {
                    //alert("Yes i m going to transfer value" + lstSource.options.length);
                  if(lstSource.options[i].selected)
                     {
                       lstSource.remove(i);  
                     }
                 } 
          }     
    
    
    // to removing the value from destination 
    
    
    function Removeuser()
      {
            var lstemployee=document.getElementById("ctl00_mainContent_Create_group1_lstEmployee"); //  Create_group1_lstEmployee
            var lstSemployee= document.getElementById("ctl00_mainContent_Create_group1_lstSEmployee");  //Create_group1_lstSEmployee 
             //alert ("Moving  the value" + IsSelected(lstemployee));
             if (IsSelected(lstSemployee))
               {
                  MovingValue(lstSemployee,lstemployee);
               }
      }
      
    function hiddenValue()
     {
          
          var userid=document.getElementById("ctl00_mainContent_Create_group1_hdnValue")
          var lstbox= document.getElementById("ctl00_mainContent_Create_group1_lstSEmployee");
          userid.value="";
          var flag=0;
          for(var i=0;i<(lstbox.options.length);i++)
              {
                   
                           userid.value=userid.value +","+lstbox.options[i].value;
                           //userid.value=userid.value +","+lstbox.options[i].text; 
              }  
          
          //alert(" test value="+ userid.value); 
     }
      
    function reloadCancel() 
      {
               window.location.href="addbook.aspx";   // To move on previos window 
      } 
      
// For page Layout

  function AddField()
       {
          
           var div_no = document.getElementById("ctl00_mainContent_hdnFieldid");  // Booklayout1_hdnFieldid new=ctl00_mainContent_hdnReference  //ctl00_mainContent_hdnFieldid
           //alert("the value of hidden field=" + div_no.value);
           var divname="lbl"+div_no.value;
           var div_value ="val" + div_no.value; 
           //alert("the value=" + div_no.value);
           if (parseInt(div_no.value)< 6)
             {    
               document.getElementById(divname).style.display="block";  
               document.getElementById(div_value).style.display="block";
               div_no.value = parseInt(div_no.value) +1;     
             }
             else
             {
               alert("You can not add fields"); 
             }
           }
           
           
         //Booklayout1_txtReference
         //Booklayout1_lstReferences
 //--------------------------------------------Access url Reference--------------------------------        
         function kbAddReference()
           {
           
           
              xmlHttp=GetXmlHttpObject();
              if (xmlHttp==null)
                 {
                    alert ("Your browser does not support AJAX!");
                    return;
                  } 
                                   
                 
                    var ref= document.getElementById("ctl00_mainContent_txtReference");  // TO Access txtReferenceValue     
                    var lstReference = document.getElementById("ctl00_mainContent_lstReferences"); // Create_group1_ddlInitial, new= ctl00_mainContent_Create_group1_ddlInitial
                    //alert (" reference value="+  ref.value);
                    
                    
                   if (ref.value!="")
                      {
                         //alert("refrenec value is not null" );
                         url="acesstitle.aspx?ref="+ref.value;
                         
                        // alert (" ref" +url); 
                         xmlHttp.onreadystatechange=kbrefstateChanged;
                         xmlHttp.open("GET",url,true);
                         xmlHttp.send(null);
                                   
                       }
                                       
          }
          
          function kbrefstateChanged() 
            { 
                
                if (xmlHttp.readyState==4)
                    { 
                         //document.getElementById("lstemployee").innerHTML=xmlHttp.responseText;
                        
                         var urltitle= xmlHttp.responseText;
                        // alert ("yes value= " + urltitle);  
                         kbrefoperation(urltitle);
                    }
             }
          
          function kbrefoperation(urltitle)
        {
         //alert(" url value =" + urltitle);
         var arr =urltitle.split("|");
         var lsturl=document.getElementById("ctl00_mainContent_lstReferences");   // Create_group1_lstEmployee,new=ctl00_mainContent_Create_group1_lstEmployee  
         removeAllOptions(lsturl);     // clear the lstemployee value         
        // alert ("test");
         for ( var i=0;i< (arr.length) ;i++)
         {
                 var record=arr[i].split(",");  // value[0]=uid, value[1]=empcode,value[2]=firstname value[3]=middle name value[4]=last name
                var optn = document.createElement("OPTION");                                        
                 optn.value = record[0]; 
                 optn.text = record[0]; 
                 lsturl.options.add(optn);
               //  alert("legnth="+arr[i]);  // for checking purpose it displays records of employee
          }
      }
          

           
         function  kbRemoveReference()
           {
              var references = document.getElementById('ctl00_mainContent_lstReferences');
               // alert("hello");
              for(var i=0;i<(references.options.length);i++)
               {
                  if(references.options[i].selected)
                     references.remove(i);;
               }  
           }
// ------------------------- for KB show document------------------------
         
//        function kbshowdocument(folder_id)
//         {
//            
//            xmlHttp=GetXmlHttpObject();
//            if (xmlHttp==null)
//                 {
//                    alert ("Your browser does not support AJAX!");
//                     return;
//                  } 
//                //var value=document.forms[0]['city'].value
//                var url="documentlist.aspx?folderid=" + folder_id + "";
//                // alert("url=" + url);
//                xmlHttp.onreadystatechange=kbshowstateChanged;
//                xmlHttp.open("GET",url,true);

//                //document.getElementById(pid).innerHTML=xmlHttp.responseText;
//                xmlHttp.send(null);
//                        
//            
//         }         
        
        
         function kbshowdocument(folder_id,chapter_id)
         {
            
            xmlHttp=GetXmlHttpObject();
            if (xmlHttp==null)
                 {
                    alert ("Your browser does not support AJAX!");
                     return;
                  } 
                //var value=document.forms[0]['city'].value
                var url="documentlist.aspx?folderid=" + folder_id + "&chapid="+chapter_id+"";
                // alert("url=" + url);
                xmlHttp.onreadystatechange=kbshowstateChanged;
                xmlHttp.open("GET",url,true);

                //document.getElementById(pid).innerHTML=xmlHttp.responseText;
                xmlHttp.send(null);
                        
            
         }        
      function kbshowstateChanged() 
            { 
               //alert (' I m in Kb show state change');
               
                if (xmlHttp.readyState==4)
                 { 
                     // alert("It is in ready state");
                      var text=xmlHttp.responseText;
                      //alert('the value' +text);
                      var ret_data=text.split("|");
                      //alert('the value' +ret_data[0]);
                     document.getElementById(ret_data[1]).innerHTML=ret_data[0];
                      //return xmlHttp.responseText;

                 }
             }   
 // hiding the document lis
 
// function kbhidedocument (folder_id)
//  {
//         xmlHttp=GetXmlHttpObject();
//            if (xmlHttp==null)
//                 {
//                    alert ("Your browser does not support AJAX!");
//                     return;
//                  } 
//                //var value=document.forms[0]['city'].value
//                var url="rootdocument.aspx?bookid=" + folder_id + "";
//                // alert("url=" + url);
//                xmlHttp.onreadystatechange=kbshowstateChanged;
//                xmlHttp.open("GET",url,true);
//                //document.getElementById(pid).innerHTML=xmlHttp.responseText;
//                xmlHttp.send(null);
//    
//  }


function kbhidedocument (folder_id,chapter_id)
  {
         xmlHttp=GetXmlHttpObject();
            if (xmlHttp==null)
                 {
                    alert ("Your browser does not support AJAX!");
                     return;
                  } 
                //var value=document.forms[0]['city'].value
                var url="rootdocument.aspx?folderid=" + folder_id + "&chapid="+chapter_id +"";
                // alert("url=" + url);
                xmlHttp.onreadystatechange=kbshowstateChanged;
                xmlHttp.open("GET",url,true);
                //document.getElementById(pid).innerHTML=xmlHttp.responseText;
                xmlHttp.send(null);
    
  }
 
 function closePopWindow(url)
  {
       var x= confirm ("Do you want to continue");
         if (x)
          {
            //alert("You have choosed" +x); 
            openCSSPopupByName(url, 0, 0, 300, 200,"checkoutwarninh",2);
          }
          else
           {
              //alert ("you have choose" +x); 
           }
      
  }
function ShowHistory()
  {
     var minus=document.getElementById("minus");
     minus.style.display="block";
     document.getElementById("plus").style.display="none";
     var hist= document.getElementById("history");
     hist.style.display="block";
  }
function HideHistory()
  {
     var minus=document.getElementById("minus");
     minus.style.display="none";
     document.getElementById("plus").style.display="block";
     var hist= document.getElementById("history");
     hist.style.display="none";
  }
function ChangeAccess(controld,value,newrdo)
{
   //alert("contolid=" + controld+" and value=" +value);
   if (parseInt(value)==0)
   {
     ddl=document.getElementById(controld);
     ddl.options[0].selected=true;
      
   }
   else
   {
      //alert("newRdo=" +newrdo );
      rdo=document.getElementById(controld);
      rdo.checked=false;
      rdo1=document.getElementById(newrdo);
      rdo1.checked=true;
      //alert("dropdownlist"); 
   }
   
} 









function openCSSPopupByName4UControls(fileName, fLeft, fTop, fwidth, fheight, wName, depth){
	if (!depth) { depth=0; }
	jsDiv 	= wName + 'xCSS';
	jsFrame = wName + 'xFRM';
	// Create dynamic DIV
	createPopUpDiv(jsDiv, jsFrame, wName, depth, fileName);

	// Initialize DIV variables 
	var _pLayer=document.getElementById(jsDiv).style;
	var _pFrame=document.getElementById(jsFrame);
	if (_pLayer.display == "none") 
	{
		// Capture browser window size
		if (IE) {
			screenWidth = (document.body.clientWidth + 20);
			screenHeight = (document.body.clientHeight);
		} else {
			screenWidth = self.innerWidth;
			screenHeight= self.innerHeight;
		}
		// Evaluate left position for the current browser width
			if (fLeft != 0) {
				leftPos = fLeft;
			} else {
				leftPos = ((screenWidth/2) -  (fwidth/2));
			}
			if (fTop != 0) {
				topPos = fTop;
			} else {
				topPos  = ((screenHeight/2) - (fheight/2)-30); //30 value draws the display up
			}
		// Create opaque page background
			if(IE){
				document.getElementById('container').style.filter="Alpha(Opacity=10)";
			} else {
				document.getElementById('container').setAttribute("style","-moz-opacity:.1;");
			}
		// Draw pop-up DIV & call file in IFRAME
			_pLayer.left=leftPos+'px';
			_pLayer.top=topPos+'px';
			_pFrame.src=fileName;
			_pFrame.width=fwidth;
			_pFrame.height=fheight;
			_pLayer.display="block";
			document.getElementById('jsHTML'+depth).style.display='block';
			//document.location.href="#top";
	} else {
			if(IE)
				document.getElementById('container').style.filter="Alpha(Opacity=100)";
			else
				document.getElementById('container').setAttribute("style","-moz-opacity:1;"); 
			document.getElementById('jsHTML'+depth).innerHTML = '';
			document.getElementById('jsHTML'+depth).style.display='none';
			_pLayer.display="none";
	}
}

function pointcord(e,cid,url_id,uid)
{
  if (window.ActiveXObject)
   {
      e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
   }
   
  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      x = e.pageX;
      y = e.pageY;
      algor = '[e.pageX]';
      if (e.clientX || e.clientY) algor += ' [e.clientX] '
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      x = e.clientX + document.body.scrollLeft;
      y = e.clientY + document.documentElement.scrollTop;
     
   } 
 } 
 
  y=y-280;
  x=x-90;

   openCSSPopupByName('/dforum/dforumreply.aspx?commid='+ cid +'&urlid='+ url_id +'&usrid='+ uid ,x,y,450,250,'post_comment', 0);
   //openCSSPopupByName('/dforum/dforumreply.aspx?commid=5&urlid=2&usrid=3',0,600,450,250,'post_comment', 0);
}



 function showMypost(uid,urlid)
         {
            
            xmlHttp=GetXmlHttpObject();
            if (xmlHttp==null)
                 {
                    alert ("Your browser does not support AJAX!");
                     return;
                  } 
                //var value=document.forms[0]['city'].value
                var url = "viewpost.aspx?uid="+uid+"&urlid="+urlid;
                 //alert(urlid);
                xmlHttp.onreadystatechange=showMypostChanged;
                xmlHttp.open("GET",url,true);

                //document.getElementById(pid).innerHTML=xmlHttp.responseText;
                xmlHttp.send(null);
                        
            
         }         
        
      function showMypostChanged() 
            { 
               //alert (' I m in Kb show state change');
               
                if (xmlHttp.readyState==4)
                 { 
                     // alert("It is in ready state");
                      var text=xmlHttp.responseText;
                     //alert('the value' +text);
                      var ret_data=text.split("|");
                     // alert('the value' +ret_data[1]);
                      document.getElementById(ret_data[1]).innerHTML=ret_data[0];
                      //return xmlHttp.responseText;

                 }
            }   

function hideMypost(uid,urlid)
  {
         xmlHttp=GetXmlHttpObject();
            if (xmlHttp==null)
                 {
                    alert ("Your browser does not support AJAX!");
                     return;
                  } 
                  var url = "rootpost.aspx?uid="+uid+"&urlid="+urlid;
                  xmlHttp.onreadystatechange=showMypostChanged;
                  xmlHttp.open("GET",url,true);
                  xmlHttp.send(null);
    
  }

