﻿// JScript File

//function tbContainerTop_ClientActiveTabIndexChanged(eventTabCtrl,targetTabCtrl,tabIndex)
//{
//    var tabSource=
//}

//function CopyText(sourcetxtCtrl,targettextCtrl)
//{
//try
//{
//var sourcetxt=document.getElementById(sourcetxtCtrl);
//var targettxt=document.getElementById(targettextCtrl);
//if(sourcetxt!=null && targettxt!=null)
//{
//targettxt.innerHTML= sourcetxt.innerHTML;
//}

//}
//catch(e)
//{
//alert(e);
//}
//return false;
//}
function CopyText(sourcetxtCtrl,targettextCtrl,sourcetxtCtrl1,targettextCtrl1,selectedRow,rowIndexCtrl)
{
try
{
var sourcetxt=document.getElementById(sourcetxtCtrl);
var targettxt=document.getElementById(targettextCtrl);
var sorucetxt1=document.getElementById(sourcetxtCtrl1);
var targettxt1=document.getElementById(targettextCtrl1);
var rowIndexTxt=document.getElementById(rowIndexCtrl);
if(sourcetxt!=null && targettxt!=null)
{
if(sourcetxt.value!=null)
{
var val=sourcetxt.value.replace(/<BR>/g,'\n');
val=val.replace(/<br>/g,'\n');
targettxt.value= val;
}
else
{
var val=sourcetxt.innerHTML.replace(/<BR>/g,'\n');
val=val.replace(/<br>/g,'\n');
	targettxt.value= val;
}

}
if(sorucetxt1!=null && targettxt1!=null)
{
if(targettxt1.innerHTML)
{
var val=sorucetxt1.innerHTML.replace(/<BR>/g,'\n');
val=val.replace(/<br>/g,'\n');
targettxt1.innerHTML= val;
}
else
{
var val=sorucetxt1.innerHTML.replace(/<BR>/g,'\n');
val=val.replace(/<br>/g,'\n');
targettxt1.value= val;
}
}
if(rowIndexTxt!=null)
{
rowIndexTxt.value=selectedRow;
}
}
catch(e)
{
//alert(e);
}
return false;
}
function RemoveGridViewRow(gridViewCtrl,rowIndexCtrl,removedRowCtrl)
{
try
{
var gvCtrl=document.getElementById(gridViewCtrl);
var rowIndex=document.getElementById(rowIndexCtrl);
var removedRows=document.getElementById(removedRowCtrl);
if(gvCtrl!=null && rowIndex!=null)
{
if(Math.round(rowIndex.value)>=0)
{
if(gvCtrl.rows.length==Math.round(rowIndex.value))
{
gvCtrl.deleteRow(Math.round(rowIndex.value)-1);
}
else
{
gvCtrl.deleteRow(Math.round(rowIndex.value));
}
if(removedRows!=null)
{
if(removedRows.value>0)
    removedRows.value=removedRows.value+1;
else
    removedRows.value=1;
}
}
}
}
catch(e)
{
alert(e);
}
return false;
}

//------------------ To Check any one of the chek box is selected in grid ------//
function GridcheckSelected(gridid,msg)
{
try
{
var valueselected=false;
var grid=document.getElementById(gridid);
    if(grid!=null && grid.rows.length>0)
    {
    var chkboxes=grid.getElementsByTagName('input');
        if(chkboxes!=null && chkboxes.length>0)
        {
            for(var i=0;i<chkboxes.length;i++)
            {
                if(chkboxes[i].type!=null && chkboxes[i].type=='checkbox' && chkboxes[i].checked==true)
                {
                valueselected=true;
                break;
                }
            }
        }
    }
    if(!valueselected)
    {
        alert(msg);
    }
    return valueselected;
}
catch(e)
{
alert(e);
}
}

function InstaStatusChange(gridId,confirmMsg,errMsg)
{
var result=false;
try
{
    result=GridcheckSelected(gridId,errMsg);
    if(!result)
     return result;
     result=confirm(confirmMsg);
}
catch(e)
{
return false;
}
return result;
}

//------------------End of- Check any one of the chek box is selected in grid ------//


//////////////////////////////////////////////////// Expand Collapse Grid Start\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
function SupplierContractGridViewRowDataBound( hdn  )
{
try
{
    expandcollapse('div' + hdn,'one')
    expandcollapse('div' + hdn,'one')
  }
  catch( exception )
  {
    alert( exception );
  }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
    var PrevDivId = "";
    var PrevImgId = "";
    var PreLebId="";
    function expandcollapse(obj,row)
    {
        
        var div = document.getElementById(obj); 
        var img = document.getElementById('img' + obj);
        //if( hdn
        if (div.style.display == "none")
        {
            div.style.display = "block";
//            if (PrevDivId != "")
//            {
//                PrevDivId.style.display = "none";
//                PrevImgId.src = "/ScolaApp/images/plus-box.gif";
//            }
            //Store the Previous div values
            PrevDivId = div;
            PrevImgId = img;
            if (row == 'alt')
            {
                //alert('1');
                img.src = "/ScolaApp/images/minus.gif";
            }
            else
            {
                //alert('2');
                img.src = "/ScolaApp/images/minus.gif";
            }
            img.alt = "minus";
        }
        else
        {
            div.style.display = "none";
            //Reset the Previous div values
            PrevDivId = "";
            PrevImgId = "";
            if (row == 'alt')
            {
                img.src = "/ScolaApp/images/plus-box.gif";
            }
            else
            {
                img.src = "/ScolaApp/images/plus-box.gif";
            }
            img.alt = "Expand to show languages";
        }
    } 
    
       function expandcollapseNews(obj,row)
    {
       // alert('test');
        try
      {
        var div = document.getElementById(obj); 
        var img = document.getElementById('img' + obj);
        //if( hdn
        if (div.style.display == "none")
        {
       // alert('1');
            div.style.display = "block";
           if (PrevDivId != "")
         {
                PrevDivId.style.display = "none";
                PrevImgId.src = "/ScolaApp/images/plus-box.gif";
            }
            //Store the Previous div values
            PrevDivId = div;
            PrevImgId = img;
            if (row == 'alt')
            {
                //alert('1');
                img.src = "/ScolaApp/images/minus.gif";
            }
            else
            {
                //alert('2');
                img.src = "/ScolaApp/images/minus.gif";
            }
            img.alt = "minus";
        }
        else
        {
          //alert('2');

            div.style.display = "none";
            //Reset the Previous div values
            PrevDivId = "";
            PrevImgId = "";
            if (row == 'alt')
            {
                img.src = "/ScolaApp/images/plus-box.gif";
            }
            else
            {
                img.src = "/ScolaApp/images/plus-box.gif";
            }
            img.alt = "Expand to show languages";
        }
        }
        catch(e)
       {
        //alert(e.message);
        }
    } 
    

     function expandcollapseNew(obj,row)
    {
        
        var div = document.getElementById(obj); 
        var img = document.getElementById('img' + obj);
        //if( hdn
        if (div.style.display == "none")
        {
            div.style.display = "block";
//            if (PrevDivId != "")
//            {
//                PrevDivId.style.display = "none";
//                PrevImgId.src = "/ScolaApp/images/plus-box.gif";
//            }
            //Store the Previous div values
            PrevDivId = div;
            PrevImgId = img;
            if (row == 'alt')
            {
                //alert('1');
                img.src = "/ScolaApp/images/collapse_blueNew.jpg";
            }
            else
            {
                //alert('2');
                img.src = "/ScolaApp/images/collapse_blueNew.jpg";
            }
            img.alt = "collapse  to hide  Search Creteria";
        }
        else
        {
            div.style.display = "none";
            //Reset the Previous div values
            PrevDivId = "";
            PrevImgId = "";
            if (row == 'alt')
            {
                img.src = "/ScolaApp/images/expand_blueNew.jpg";
            }
            else
            {
                img.src = "/ScolaApp/images/expand_blueNew.jpg";
            }
            img.alt = "Expand to show Search Creteria";
        }
    } 
 function expandcollapseHelp(obj,row)
    {
        
        var div = document.getElementById(obj); 
        var img = document.getElementById('img' + obj);       

         var leb = document.getElementById('lbl' + obj);
		
	
        //if( hdn
        if (div.style.display == "none")
        {
            div.style.display = "block";
            if (PrevDivId != "")
            {
                PrevDivId.style.display = "none";
                PrevImgId.src = "/ScolaApp/images/plus-box.gif";
               PreLebId.className="helpheadStyle";
            }
            //Store the Previous div values
            PrevDivId = div;
            PrevImgId = img;
            PreLebId=leb;
            if (row == 'alt')
            {
                //alert('1');
                img.src = "/ScolaApp/images/minus.gif";
                leb.className="helpheadStyleBlue";

            }
            else
            {
                //alert('2');
                img.src = "/ScolaApp/images/minus.gif";
                leb.className="helpheadStyleBlue";

            }
            img.alt = "";
            img.title="";
        }
        else
        {
            //div.style.display = "none";
            //Reset the Previous div values
           // PrevDivId = "";
           // PrevImgId = "";
           // if (row == 'alt')
           // {
             //   img.src = "/ScolaApp/images/plus-box.gif";
           // }
           // else
          //  {
            //    img.src = "/ScolaApp/images/plus-box.gif";
          //  }
           // img.alt = "Expand to show languages";
           
           
            div.style.display = "none";
            //Reset the Previous div values
            PrevDivId = "";
            PrevImgId = "";
            PreLebId = "";
            if (row == 'alt')
            {
                img.src = "/ScolaApp/images/plus-box.gif";
                leb.className="helpheadStyle";

            }
            else
            {
                img.src = "/ScolaApp/images/plus-box.gif";
                leb.className="helpheadStyle";

            }
            img.alt = "";
            img.title="";

        }
        
        
        var inputControls=document.getElementsByTagName('input');
if(inputControls!=null && inputControls.length>0)
{
for(var i=0;i<inputControls.length;i++)
{
if(inputControls[i].type!=null && inputControls[i].type=='hidden')
{

if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnLastHelpDiv')
{
inputControls[i].value=obj;
}
}
}
}

        
    } 

   var PrevDivIdHelpWindow = "";
    var PrevImgIdHelpWindow = "";
 
function expandcollapseHelpWindow(obj,row)
    {
        
        var div = document.getElementById(obj); 
        var img = document.getElementById('img' + obj);
        //if( hdn
        if (div.style.display == "none")
        {
            div.style.display = "block";

            //Store the Previous div values
            PrevDivIdHelpWindow = div;
            PrevImgIdHelpWindow = img;
            if (row == 'alt')
            {
                //alert('1');
                img.src = "/ScolaApp/images/Minimize.jpg";
            }
            else
            {
                //alert('2');
                img.src = "/ScolaApp/images/Minimize.jpg";
            }
            img.alt = "Minimize";
            img.title="Minimize";
            
        }
        else
        {
            div.style.display = "none";
            //Reset the Previous div values
            PrevDivIdHelpWindow = "";
            PrevImgIdHelpWindow = "";
            if (row == 'alt')
            {
                img.src = "/ScolaApp/images/maximize.jpg";
            }
            else
            {
                img.src = "/ScolaApp/images/maximize.jpg";
            }
            img.alt = "Maximize";
            img.title="Maximize";
        }
       
    } 
    
    
   ///////////////////////////////////////////////////////////////////////Expand Collapse Grid End\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
   
   
   function checkGrid(id,gridId,chkEndId)
{
try
{
var _checked=false;
var grid=  document.getElementById(gridId);
var chkheader=document.getElementById(id);
if(chkheader!=null)
    _checked=chkheader.checked;
var chkchilds=grid.getElementsByTagName('input');
if(chkchilds!=null && chkchilds.length>0 )
{
for(i=0;i<chkchilds.length;i++)
{
if(chkchilds[i].type!=null && chkchilds[i].type=='checkbox')
{
if(chkchilds[i].id.indexOf(chkEndId)>0 )
{
chkchilds[i].checked=_checked;
}

}
}
}
}
catch(ex)
{
}
return true;
}

function chkChilds(eventctrlid,headerEndId,gridId,chkEndId)
{
try
{
var _checked=false;
var grid= document.getElementById(gridId);
var chkevent=document.getElementById(eventctrlid);
if(chkevent!=null)
    _checked=chkevent.checked;

if(grid!=null)
{
var firstHeader;
var result1=true;
var chkChilds=grid.getElementsByTagName('input')
if(chkChilds!=null && chkChilds.length>0)
{
for(i=0;i<chkChilds.length;i++)
{
if(chkChilds[i].type!=null && chkChilds[i].type=='checkbox')
 {
if(chkChilds[i].id.indexOf(headerEndId)>0)
 firstHeader=document.getElementById(chkChilds[i].id);

if(chkChilds[i].checked==false)
  {

if(chkChilds[i].id.indexOf(chkEndId)>0)
    {
    firstHeader.checked=false;
    result1=false;
    }

  }
 }
}
if(result1==true && firstHeader!=null)
    firstHeader.checked=true;

}
}
}
catch(ex)
{
}
return true;
}
function chkListChilds(eventctrlid,headerChkId)
{

var Checked=true;
try
{
var eventCtrl=document.getElementById(eventctrlid);
var header=document.getElementById(headerChkId);
    if(eventCtrl!=null)
    {
    var chkList=eventCtrl.getElementsByTagName('input');
        if(chkList!=null && chkList.length>0)
        {
            for(i=0;i<chkList.length;i++)
            {
                if(chkList[i]!=null && chkList[i].type=='checkbox' )
                {
                    if(chkList[i].checked==false)
                    {
                    Checked=false;
                    break;
                    }
                }
            }
        }
    }
    if(header!=null)
        header.checked=Checked;
}
catch(e)
{

}
return true;

}
/////////////////////////////////////////////////validation /////////////////////////////

function AllowOnlyNumeric()
{    
    var key = window.event.keyCode;    
    if ( (key > 47 && key < 58) || key == 46 )
        return;
    else
        window.event.returnValue = null; 
}

function AllowOnlyNumber()
{    
    var key = window.event.keyCode;    
    if  (key > 47 && key < 58) 
        return;
    else
        window.event.returnValue = null; 
}


///----- DA Cookie check-------------------------/
 function IsCookieAvailable(cookieName)
{
try
{
    var strValue=GetCookie(cookieName);
     if(strValue.length ==0)
     {
           
                alert('please add region');
                return false;
           
       }
 }
 catch(e)
 {
// alert(e);
 }
return true;
}


///---------DA Add Text Box Value To List Box------------//
function AddTextBoxValueToListBox(textBoxId,listBoxId)
{
    var alreadyexists=false;
    var tmpTextBox=document.getElementById(textBoxId);
    var tmpListBox=document.getElementById(listBoxId);
    if(tmpTextBox!=null && tmpListBox!=null)
    {
        if(tmpTextBox.value.toString().trim()!="")
        {
            if(tmpListBox.length==0)
            {
               alreadyexists=false;
            }
            else
            {
                for(var i=0;i<tmpListBox.length;i++)
                {
                    if(tmpListBox.options[i].value.toString().trim()==tmpTextBox.value.toString().trim())
                    {
                        alreadyexists=true;
                        break;
                    }
                    else
                    {
                       alreadyexists=false;
                    }   
                }
            }
            if(alreadyexists==false)
            {
                var newOption = new Option();
                newOption.text=tmpTextBox.value.toString().trim();
                newOption.value=tmpTextBox.value.toString().trim();
                tmpListBox.options[tmpListBox.length]=newOption;
                tmpTextBox.value="";
            }
            else
            {
                alert('This word already exists');
            }
        }
    }
    return false;
}
///---------DA Goto Page Validation------------//
function DAGotoPageValidation(tmpGotoText,tmpTotalpageText)
{
try
{
  var txtGotopage = document.getElementById(tmpGotoText).value;
  var txtTotalpage = document.getElementById(tmpTotalpageText).value;
  
if(txtGotopage=="" || txtGotopage==null)
{
 alert("Enter Page No");
 document.getElementById(tmpGotoText).select();
 return false;

}
else if(txtTotalpage=="0" ||txtGotopage=="0" )
   {
    alert("Invalid Page");
   document.getElementById(tmpGotoText).value="";
   document.getElementById(tmpGotoText).select();
   return false;
   }
   else if (Number(txtGotopage) > Number(txtTotalpage))
   {
   alert("Invalid Page");
   document.getElementById(tmpGotoText).value="";
   document.getElementById(tmpGotoText).select();
   return false;
   }
 }
catch(e)
{
}
return true;
}



///---------Back function------------//

function GoBackToPreScreen(postBackValue)
{
try
{
if(window.history!=null && window.history.length>0)
    window.history.go(postBackValue);
 }
catch(e)
{
}
return true;
}

function GoBackToHome()
{
try
{

    window.location="/scola/default.aspx";
 }
catch(e)
{
}
return true;
}


///////////////////////////// Insta Class Admin Page ///////////////////
function ClearText(controlId1,controlId2)
{
try
{
var ctrl1=document.getElementById(controlId1);
var ctrl2=document.getElementById(controlId2);
if(ctrl1!=null)
    ctrl1.value="";
if(ctrl2!=null)
    ctrl2.value="";
return true;
}
catch(e)
{
return true;
}
return true;
}

////////////////
function SetSampleICLession(strMp4File)
	{
		

 if(strMp4File != "")
		 {
		   
		     var response = confirm('Are you sure you want to replace existing sample InstaClass Lession?'); 
            if(response == false) 
            {
          
             return false;

             }
             
        }
        return true;
   }
//------------------------open popup window-------------------------------//
function OpenModelPopup(queryString)
{   
var strWin = window.open(queryString ,"winShow",'toolbar=no,menubar=no,resizable=yes,scrollbars=yes,height=500,status=no');
           strWin.focus();
 

}


function OpenModelPopupVideo(queryString)
{   
var strWin = window.open(queryString ,"winShow",'toolbar=no,menubar=no,resizable=no,scrollbars=no,height=510,status=no,width=500');
           strWin.focus(); 

}

function OpenModelPopupWTO(queryString)
{   
var strWin = window.open(queryString ,"winShow",'toolbar=no,menubar=no,resizable=yes,scrollbars=yes,height=500,status=no');
           strWin.focus();
 

}

function OpenModelPopupHelpVideo(queryString)
{   
var strWin = window.open(queryString ,"winShow",'toolbar=no,menubar=no,resizable=yes,scrollbars=no,height=700,status=no,width=900');
           strWin.focus();
 

}

function OpenModelPopupWindow(queryString)
{   
var strWin = window.open(queryString ,"winShow",'toolbar=no,menubar=no,resizable=yes,scrollbars=yes');
           strWin.focus();
 

}


function OpenModelPopupHelpAudio(queryString)
{   
var strWin = window.open(queryString ,"winShow",'toolbar=no,menubar=no,resizable=yes,scrollbars=no,height=150,status=no,width=550');
           strWin.focus();
 

}
///----------Set the Audio player url - Internationla Radio----------------------//


var servID=null;
var refID=null;
var intRadioID=null;



function setAudioPlayerUrl(playerContainerId,url,fNameLabel,fileName,lanLabel,lanName,bcDateLebel,bcDate,serviceId,referenceId,userId)
{
resetAudioProp();
try
{

servID=serviceId;
refID=referenceId;
intRadioID=null
setrefrenceid();

var pContainer=document.getElementById(playerContainerId);
//if(pContainer)
  //  pContainer.innerHTML=QT_WriteOBJECT('poster.jpg','256','16','','src','');
//var fNameContainer=document.getElementById(fNameLabel);
var lanContainer=document.getElementById(lanLabel);
var bcDateContainer=document.getElementById(bcDateLebel);
var fileUrl=url+"/"+fileName;
//if(fNameContainer!=null)
 //   fNameContainer.innerHTML=fileName;
if(lanContainer!=null)
    lanContainer.innerHTML=lanName;
if(bcDateContainer!=null)
    bcDateContainer.innerHTML=bcDate;
if(pContainer!=null)
{
var objContainer=""
objContainer='<object id="mymovie" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="256" height="16" style="border: 1px solid #aaa;" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
                                      objContainer=  objContainer+'<param name="SRC" value='+"'"+ fileUrl+"'"+'/>'
                                         objContainer=  objContainer+'<param name="AUTOPLAY" value="true" />'
                                         objContainer=  objContainer+'<param name="TARGET" value="QuickTimePlayer" />'
                                         objContainer=  objContainer+'<param name="CONTROLLER" value="true" />'
                                         objContainer=  objContainer+'<param name="BGCOLOR" value="#FFFFFF" />'
                                       objContainer=objContainer+'<param name="ENABLEJAVASCRIPT" value="true" />'
                                        objContainer=  objContainer+'<embed id="mymovie" enablejavascript="true" src='+"'"+fileUrl+"'"+' autoplay="true" target="QuickTimePlayer" width="256" height="16" controller="true" name="mymovie" bgcolor="#FFFFFF" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>'
     
     pContainer.innerHTML= objContainer;
//pContainer.innerHTML=QT_WriteOBJECT('poster.jpg','256','16','','src',fileUrl);//,'autohref','true','target','myself');
//update usage count
//asyncRequestForUsageCount(serviceId,referenceId,userId,fileName,'Play');

}
}
catch(e)
{
//alert(e);
}

}


function setSampleAudioPlayerUrl(playerContainerId,url,fNameLabel,fileName,lanLabel,lanName,bcDateLebel,bcDate,serviceId,referenceId,userId)
{
try
{
var pContainer=document.getElementById(playerContainerId);
//if(pContainer)
  //  pContainer.innerHTML=QT_WriteOBJECT('poster.jpg','256','16','','src','');
//var fNameContainer=document.getElementById(fNameLabel);
var lanContainer=document.getElementById(lanLabel);
var bcDateContainer=document.getElementById(bcDateLebel);
var fileUrl=url+"/"+fileName;
//if(fNameContainer!=null)
 //   fNameContainer.innerHTML=fileName;
if(lanContainer!=null)
    lanContainer.innerHTML=lanName;
if(bcDateContainer!=null)
    bcDateContainer.innerHTML=bcDate;
if(pContainer!=null)
{
var objContainer=""
objContainer='<object id="mymovie" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="256" height="16" style="border: 1px solid #aaa;" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
                                      objContainer=  objContainer+'<param name="SRC" value='+"'"+ fileUrl+"'"+'/>'
                                         objContainer=  objContainer+'<param name="AUTOPLAY" value="true" />'
                                         objContainer=  objContainer+'<param name="TARGET" value="QuickTimePlayer" />'
                                         objContainer=  objContainer+'<param name="CONTROLLER" value="true" />'
                                         objContainer=  objContainer+'<param name="BGCOLOR" value="#FFFFFF" />'
                                       objContainer=objContainer+'<param name="ENABLEJAVASCRIPT" value="true" />'
                                        objContainer=  objContainer+'<embed id="mymovie" enablejavascript="true" src='+"'"+fileUrl+"'"+' autoplay="true" target="QuickTimePlayer" width="256" height="16" controller="true" name="mymovie" bgcolor="#FFFFFF" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>'
     
     pContainer.innerHTML= objContainer;
//pContainer.innerHTML=QT_WriteOBJECT('poster.jpg','256','16','','src',fileUrl);//,'autohref','true','target','myself');
//update usage count
//asyncRequestForUsageCount(serviceId,referenceId,userId,fileName,'Play');

}
}
catch(e)
{
//alert(e);
}

}




function GetServiceid()
{

var inputControls=document.getElementsByTagName('input');
if(inputControls!=null && inputControls.length>0)
{
for(var i=0;i<inputControls.length;i++)
{
if(inputControls[i].type!=null && inputControls[i].type=='hidden')
{
if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnReferenceId')
{
refID=inputControls[i].value;
}
else if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnServiceId')
{
servID=inputControls[i].value;
}
}
}
}

}



function setrefrenceid()
{
if(servID==null)
{
GetServiceid();
}

if(intRadioID==null && servID!=null )
{
var inputControls=document.getElementsByTagName('input');
if(inputControls!=null && inputControls.length>0)
{
for(var i=0;i<inputControls.length;i++)
{
if(inputControls[i].type!=null && inputControls[i].type=='hidden')
{
if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnReferenceId')
{
inputControls[i].value=refID;
intRadioID=refID;
}
else if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnServiceId')
{
inputControls[i].value=servID;
}
}
}
}
}
}


function setRefID()
{
intRadioID='0';
}

function clearrefrenceId()
{

if(intRadioID!=null)
{
intRadioID=null;
var inputControls=document.getElementsByTagName('input');
if(inputControls!=null && inputControls.length>0)
{
for(var i=0;i<inputControls.length;i++)
{
if(inputControls[i].type!=null && inputControls[i].type=='hidden')
{
if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnReferenceId')
{
inputControls[i].value=null;
}

}
}
}
}
}			
			
				
function init() {	
				


				window.setInterval("loop()", 1000);
				
			}
function osvinit() {		
				
				window.setInterval("loop()", 1000);
				
			}


function ICinit() {		
				
				/////window.setInterval("audioloop()", 4000);
				window.setInterval("loop()", 2000);
				
			}




getFormattedTimeString = function(sec) {
	var timeString = "";
    var min = Math.floor(sec / 60);
	var hour = Math.floor(min / 60);
	sec = Math.floor(sec - (min * 60));
	min = Math.floor(min - (hour * 60));
	
    if(min<10){min = "0" + min;}
    if(sec<10){sec = "0" + sec;}
	if(hour > 0) timeString = hour+":";
    timeString += min+":"+sec;
	return timeString;
}





////////////////

function OpenPdf(queryString)
{   

window.open(queryString);
        
 

}

///----------Script for Image Changing in People And Places----------------------//


////////////////
///////////////////image slidehsow///////////////////////
var image;
var num;
var timeDelay;
var imagePreload;
var papList;
var fDir;
var fileDownloadUrl;
var uId;
var preloadedImage=new Array();
function image_array(fielUrl,imgArray,fileNameCtrl,imgCtrlName,currentPhotoIndex,imgNoCtrlId,imgCountCtrlId,papIds,fileDir,handlerUrl,userId)
{
try
{
//creating a array of the image object
image=new Array("");
image=imgArray.split(',');
papList=papIds.split(',');
fDir=fileDir;
fileDownloadUrl=handlerUrl;
uId=userId;
//variable that will increment through the images
num=0;
// set the delay between images


//Preload Images
//Preload the images in the cache so that the images load faster
//create new instance of images in memory 
//if(imagePreload!=null && (imagePreload.length<=0 ||imagePreload.length !=image.length))
//{
imagePreload=new Array()
for (i=0;i<image.length;i++)
{
preloadedImage[i]=fielUrl+image[i];
   imagePreload[i]=new Image()
// set the src attribute
//imagePreload[i].src=fielUrl+image[i]

}
//}
if(currentPhotoIndex>1)
    num=currentPhotoIndex;
clearInterval(timeDelay);
imagePreload[num].src=preloadedImage[num].toString();
if(preloadedImage[Math.round(num)+1])
imagePreload[Math.round(num)+1].src=preloadedImage[Math.round(num)+1].toString();
if(preloadedImage[Math.round(num)+2])
imagePreload[Math.round(num)+2].src=preloadedImage[Math.round(num)+2].toString();
if(preloadedImage[Math.round(num)+3])
imagePreload[Math.round(num)+3].src=preloadedImage[Math.round(num)+3].toString();


//if(autoPlay=='True')
 //timeDelay=setInterval("slideshow_automatic('"+imgCtrlName+"','"+fileNameCtrl+"','"+imgNoCtrlId+"','"+imgCountCtrlId+"')",5000);
 
//hidePreButton();
//hideNextButton();
 

 //slideshow_automatic(imgCtrlName);
}
catch(e)
{
return true;
}
return true;
}

//function for the transition effects
function image_effects()
{
//  var selobj = document.getElementById('slidehow_transition');
//  var selIndex = selobj.selectedIndex;
  //set the transition to the number selected in the list
 var imgCtrl=document.getElementById(imgCtrlName);
 if(imgCtrl!=null)
 {
 imgCtrl.style.filters="revealTrans(duration=2)"; 
// imgCtrl.style.imgCtrl.stylefilters.revealTrans.apply();
// imgCtrl.style.filters.revealTrans.play();
 }
// 
//  document.images.SlideShow.style.filters="revealTrans(duration=2)"; //.Transition=selIndex
//  document.images.SlideShow.filters.revealTrans.apply()
//  document.images.SlideShow.filters.revealTrans.play()
  
}
function previous_image(imgCtrlId,fileNameCtrlId,imgNoCtrlId,imgCountCtrlId,downCtrlId,rbAutoPlayID,lblTopCatID)
{  
  //code to execute only when the automatic slideshow is disabled 
//   if (slideshow.checked==false)
//   {
try
{
var imgCtrl=document.getElementById(imgCtrlId);
var fileNameCtrl=document.getElementById(fileNameCtrlId);
var imgNoCtrl=document.getElementById(imgNoCtrlId);
var imgCountCtrl=document.getElementById(imgCountCtrlId);
var dCtrl=document.getElementById(downCtrlId);
var lblTopCategory=document.getElementById(lblTopCatID);
rbAutoPlayState=false;
var rbAutoPlayCtrl=document.getElementById(rbAutoPlayID);
rbAutoPlayCtrl.checked=rbAutoPlayState;
StopAutoPlay();
if(imgCtrl==null || fileNameCtrl==null)
{
setTimeout("previous_image('"+imgCtrlId+"','"+fileNameCtrlId+"','"+imgNoCtrlId+"','"+imgCountCtrlId+"','"+downCtrlId+"','"+rbAutoPlayID+"','"+lblTopCatID+"')",5000);
//return true;
}
  else
  {
  var numChanged=false;
    if (num>0)
    {
       num--;
       numChanged=true;
    //   image_effects()
       //set the SRC attribute to let the browser load the preloaded images 
      
     }
//    if (num==0)
//    {  //if first image is displayed
//       num=image.length;
//       num--;
//      // image_effects()
//     //  document.images.slideShow.src=image[num] 
//    } 
if(imagePreload[num].src.toString()<=0)
imagePreload[num].src=preloadedImage[num].toString();
     imgCtrl.src=imagePreload[num].src;
    var imgName=image[num].toString().substring(0,image[num].toString().length-4);//remove extension
        fileNameCtrl.innerHTML=PandPDispFileName[num].toString();
        lblTopCategory.innerHTML=PandPTCategory[num].toString();
     imgNoCtrl.innerHTML=Math.round(num)+1;
      imgCountCtrl.innerHTML=image.length;

   dCtrl.href=fileDownloadUrl+"?ServiceId=3&FileDirectory="+fDir+"&ReferenceId="+papList[num].toString()+"&FileName="+image[num].toString()+"&UserId="+uId;
   if(numChanged)
	asyncRequestForUsageCount('3',papList[num].toString(),uId,image[num].toString(),'View');

   // hidePreButton();
    //   aNextImg.disabled=false;
   
  }
   //return true; 
   }
   catch(e)
   {
   }
}
//function to get the next image in the array
function next_image(imgCtrlId,fileNameCtrlId,imgNoCtrlId,imgCountCtrlId,downloadCtrlId,rbAutoPlayID,lblTopCatID)
{ 
  //code to execute only when the automatic slideshow is disabled 
//  if (slideshow.checked==false)
//  {
try
{
var imgCtrl=document.getElementById(imgCtrlId);
var fileNameCtrl=document.getElementById(fileNameCtrlId);
var imgNoCtrl=document.getElementById(imgNoCtrlId);
var imgCountCtrl=document.getElementById(imgCountCtrlId);
var dCtrl=document.getElementById(downloadCtrlId);
var lblTopCategory=document.getElementById(lblTopCatID);
rbAutoPlayState=false;
var rbAutoPlayCtrl=document.getElementById(rbAutoPlayID);
rbAutoPlayCtrl.checked=rbAutoPlayState;
StopAutoPlay();
if(imgCtrl==null || fileNameCtrl==null)
{
setTimeout("next_image('"+imgCtrlId+"','"+fileNameCtrlId+"','"+imgNoCtrlId+"','"+imgCountCtrlId+"','"+downloadCtrlId+"','"+rbAutoPlayID+"','"+lblTopCatID+"')",5000);
//return true;
}
else
{
    if (num<image.length)
    {
var numChanged =false;
       //if last image is reached,display the first image
       if(num!=image.length-1)
       {
       num++;
       numChanged=true;
       }
      
var count=0;
for(i=num;i<image.length;i++)
{
if(preloadedImage[i])
{

if(imagePreload[i].src==null || imagePreload[i].src.length<=0)
{
imagePreload[i].src=preloadedImage[i].toString();
count++;
if(count==2)
break;
}
}
else
{
break;
}
}

        //set the SRC attribute to let the browser load the preloaded images 
        if(imagePreload[num].src.toString()<=0)
		imagePreload[num].src=preloadedImage[num].toString();

      imgCtrl.src=imagePreload[num].src;
      var imgName=image[num].toString().substring(0,image[num].toString().length-4);//remove extension
        fileNameCtrl.innerHTML=PandPDispFileName[num].toString();
       lblTopCategory.innerHTML=PandPTCategory[num].toString();
      imgNoCtrl.innerHTML=Math.round(num)+1;
      imgCountCtrl.innerHTML=image.length;
      dCtrl.href=fileDownloadUrl+"?ServiceId=3&FileDirectory="+fDir+"&ReferenceId="+papList[num].toString()+"&FileName="+image[num].toString()+"&UserId="+uId;
if(numChanged)    
  asyncRequestForUsageCount('3',papList[num].toString(),uId,image[num].toString(),'View');
    }
    // hideNextButton();
   // aPrevImg.disabled=false;
     
 }
 }
 catch(e)
 {
 }
}
function StopAutoPlay()
{
clearInterval(timeDelay);
return true;
}
//for automatic Slideshow of the Images
var rbAutoPlayState=false;
function automatic_Play(rbAutoPlayID,imgCtrlName,fileNameCtrl,imgNoCtrlId,imgCountCtrlId,downloadCtrlId,lblTopCatID)
{
var rbAutoPlayCtrl=document.getElementById(rbAutoPlayID);
    if(rbAutoPlayCtrl)
    {
    
        rbAutoPlayCtrl.checked=!rbAutoPlayState;
        rbAutoPlayState=!rbAutoPlayState;
        if(rbAutoPlayCtrl.checked)
        {
        timeDelay=setInterval("slideshow_automatic('"+imgCtrlName+"','"+fileNameCtrl+"','"+imgNoCtrlId+"','"+imgCountCtrlId+"','"+downloadCtrlId+"','"+lblTopCatID+"')",5000);
        }
        else
        {
        StopAutoPlay();
        }
    }
    else
    {
    StopAutoPlay();
    }
return true;
}
function slideshow_automatic(imgCtrlName,fileNameCtrlId,imgNoCtrlId,imgCountCtrlId,downloadCtrlId,lblTopCatID)
{ 
//if (slideshow.checked)
//   {
try
{
var fileNameCtrl=document.getElementById(fileNameCtrlId);
var imgNoCtrl=document.getElementById(imgNoCtrlId);
var imgCountCtrl=document.getElementById(imgCountCtrlId);
var dCtrl=document.getElementById(downloadCtrlId);
var lblTopCategory=document.getElementById(lblTopCatID);
if(imgNoCtrl==null || fileNameCtrl==null || (imagePreload[Math.round(num)+1] && (!imagePreload[Math.round(num)+1].src.length<=0 && !imagePreload[Math.round(num)+1].complete || imagePreload[Math.round(num)+1].complete==null)))
{
//setTimeout("slideshow_automatic('"+imgCtrlName+"','"+fileNameCtrlId+"','"+imgNoCtrlId+"','"+imgCountCtrlId+"','"+downloadCtrlId+"','"+lblTopCatID+"')",5000);
//return true;
}
else
{
var count=0;
for(i=num;i<image.length;i++)
{
if(preloadedImage[i])
{

if(imagePreload[i].src==null || imagePreload[i].src.length<=0)
{
imagePreload[i].src=preloadedImage[i].toString();
count++;
if(count==2)
break;
}
}
else
{
break;
}
}

    if (num<image.length)
     {
     var imgCtlr=document.getElementById(imgCtrlName);
     if(imgCtlr==null)
        return true;
       num++
       //if last image is reached,display the first image
       if (num==image.length) 
       num=0
     
      if(imagePreload[num].src.toString()<=0)
      {
		imagePreload[num].src=preloadedImage[num].toString();
		if(num==0)
		if(imagePreload[Math.round(num)+1] && imagePreload[Math.round(num)+1].src.length<=0)
		imagePreload[Math.round(num)+1].src=preloadedImage[Math.round(num)+1].toString()
	  }

       if(imgCtlr!=null)
        imgCtlr.src=imagePreload[num].src;
        var imgName=image[num].toString().substring(0,image[num].toString().length-4);//remove extension
        fileNameCtrl.innerHTML=PandPDispFileName[num].toString();
        lblTopCategory.innerHTML=PandPTCategory[num].toString();
         imgNoCtrl.innerHTML=Math.round(num)+1;
      imgCountCtrl.innerHTML=image.length;
      dCtrl.href=fileDownloadUrl+"?ServiceId=3&FileDirectory="+fDir+"&ReferenceId="+papList[num].toString()+"&FileName="+image[num].toString()+"&UserId="+uId;
      asyncRequestForUsageCount('3',papList[num].toString(),uId,image[num].toString(),'View');
     // hideNextButton();
     //  hidePreButton();
        
       //document.images.slideShow.src=image[num]   
     }
   //}  
//   if (slideshow.checked==false)
//   { 
//     //Cancels the time-out that was set with the setTimeout method. 
//      clearTimeout(timeDelay)
//   }
}
}
catch(e)
{
}
}
////////////
function hideNextButton()
{
try
{
if(aNextImg!='undefined' && aPrevImg!='undefined' && aNextImg!=null && aPrevImg!=null)
{
//when currently display image is last in the array hide next button
if (num==image.length-1) 
       {
       aNextImg.disabled=true;
       //prebtnId.style.visible='visible';
       //num=0;
       }
       else
       {
        aNextImg.disabled=false;
       }
       prebtnId.disabled=false;
       //aPrevImg.style.visibility='visible';
  }
  else
  {
  setTimeout("hideNextButton()",5000);
  }
 }
 catch(e)
 {
 
 } 
}

//////////////
function hidePreButton()
{
try
{

if(aNextImg!='undefined' && aPrevImg!='undefined' && aNextImg!=null && aPrevImg!=null)
{
//when currently display image is first image in the array hide preImage btn
 if (num==0) 
       {
       aPrevImg.disabled=true;
        //aPrevImg.style.visibility='hidden';
       //num=0;
       }
       else
       {
       aPrevImg.disabled=false;
        // aPrevImg.style.visibility='visible';
       }
       aPrevImg.disabled=false;
        // aNextImg.style.visibility='visible';
  }
  else
  {
  setTimeout("hidePreButton()",5000);
  }
  }
  catch(e)
  {
  }
}
/////
var serviceId=null;
var referenceId=null;
var oRequest;

function sendAsyncReqToUpateSessionTime()
{
try
{

var urls=window.location;
if(window.XMLHttpRequest)
    oRequest=new XMLHttpRequest();
else if(window.ActiveXObject)
    oRequest=new ActiveXObject("Microsoft.XMLHTTP");
 
 if(oRequest!=null)
 {
 var inputControls=document.getElementsByTagName('input');

if(serviceId==null && referenceId==null)
{
if(inputControls!=null && inputControls.length>0)
{
for(var i=0;i<inputControls.length;i++)
{
if(inputControls[i].type!=null && inputControls[i].type=='hidden')
{
if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnReferenceId')
{

referenceId=inputControls[i].value;

}
else if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnServiceId')
{
serviceId=inputControls[i].value;
}
}
}
}
}

else if(serviceId =='2' || serviceId =='9'|| serviceId =='12')
		{
						if(inputControls!=null && inputControls.length>0)
						{
							for(var i=0;i<inputControls.length;i++)
							{
								if(inputControls[i].type!=null && inputControls[i].type=='hidden')
								{
										if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnReferenceId')
										{										
										referenceId=inputControls[i].value;										
										}									
										
									
								}
							}
						}
						
					

		}



oRequest.onreadystatechange=callback;
  oRequest.open("GET","/Scola/updatesessions.aspx?ServiceId="+serviceId+"&ReferenceId="+referenceId+"&InstaLessonUrl="+urls,true);
 oRequest.send(null);
 }
  
 }
 catch(e)
 {
 //alert(e);
 }
 return true;
}



function UpdateLessonTime(limitedSession)
{

var updateSessionTimeOutId=0;
//For IE
if(document.all)
{
 updateSessionTimeOutId= setInterval("sendAsyncReqToUpateSessionTime()",12000); //milli seconds
 if(limitedSession=='True')
 {
  setTimeout("clearInterval("+updateSessionTimeOutId+")",1200000);
  }
}
else  // Mozilla,...
{
this.updateSessionTimeOutId = setInterval ( function() { sendAsyncReqToUpateSessionTime(); }, 12000);
if(limitedSession=='True')
{
setTimeout(function(){clearInterval(this.updateSessionTimeOutId );},1200000);
}
}
 
return true;
}
function callback()
{


if(oRequest.readyState==4)
{
	if(typeof(oRequest.responseText)!='unknown')
	{
		if(document.getElementById('spnTimeRemaining')!=null)
		{
		//if(oRequest.responseText.getElementById('tmSpan')!=null)
	var str=oRequest.responseText;
	//alert(str);

	str= str.toString().substring(0, str.toString().indexOf("Mins ")+4);//  .length-(str.toString().length-str.toString().index));
//	alert(str);

	document.getElementById('spnTimeRemaining').innerHTML=str;
	}
	}
	//alert('ok');
}
return true;
}


/////////////////////////////Update Usage For Source (BBN and IC MP4/MP3) //////////////////


var sourceUsageServiceId=null;
var sourceUsageReferenceId=null;
var sourceUsageType=null;
var oRequest;

function sendAsyncReqToUpateSessionSourceUsage()
{
try
{

var urls=window.location;
if(window.XMLHttpRequest)
    oRequest=new XMLHttpRequest();
else if(window.ActiveXObject)
    oRequest=new ActiveXObject("Microsoft.XMLHTTP");
 
	 if(oRequest!=null)
	 {
	 		var inputControls=document.getElementsByTagName('input');
			
					if(inputControls!=null && inputControls.length>0)
					{
						for(var i=0;i<inputControls.length;i++)
						{
							if(inputControls[i].type!=null && inputControls[i].type=='hidden')
							{
									if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageReferenceId')
									{
									
									sourceUsageReferenceId=inputControls[i].value;
									
									}
									else if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageServiceId')
									{
									sourceUsageServiceId=inputControls[i].value;
									}
										else if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageType')
									{
									sourceUsageType=inputControls[i].value;
									}
	
									
							}
						}
					
			
			
			}
			
	
	
	
	
			oRequest.onreadystatechange=callback;
			  oRequest.open("GET","/Scola/UpdateSessionSourceUsage.aspx?ServiceId="+sourceUsageServiceId+"&ReferenceId="+sourceUsageReferenceId+"&UsageType="+sourceUsageType+"&InstaLessonUrl="+urls,true);
			 oRequest.send(null);
	 }
  
 }
 catch(e)
 {
 //alert(e);
 }
 return true;
}





function UpdateSessionSourceUsage()
{

	var updateSessionSourceUsageTimeOutId=0;
	//For IE
	if(document.all)
	{
		 updateSessionSourceUsageTimeOutId= setInterval("sendAsyncReqToUpateSessionSourceUsage()",15000); //milli seconds
		
	}
	else  // Mozilla,...
	{
			this.updateSessionSourceUsageTimeOutId= setInterval ( function() { sendAsyncReqToUpateSessionSourceUsage(); }, 15000);
			
	
	}
 
return true;
}






function setSourceReferenceBBN()
{

	var inputControls=document.getElementsByTagName('input');
		
				if(inputControls!=null && inputControls.length>0)
				{
					for(var i=0;i<inputControls.length;i++)
					{
						if(inputControls[i].type!=null && inputControls[i].type=='hidden')
						{
								
								
								if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageType')
								{
								inputControls[i].value="BBN";
								}

								
						}
					}
				}

}

function setSourceReference(sourceType)
{

	var inputControls=document.getElementsByTagName('input');
		
				if(inputControls!=null && inputControls.length>0)
				{
					for(var i=0;i<inputControls.length;i++)
					{
						if(inputControls[i].type!=null && inputControls[i].type=='hidden')
						{
								
								
								if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageType')
								{
								inputControls[i].value=sourceType;
								}

								
						}
					}
				}

}



function ClearSourceReference()
{

	var inputControls=document.getElementsByTagName('input');
		
				if(inputControls!=null && inputControls.length>0)
				{
					for(var i=0;i<inputControls.length;i++)
					{
						if(inputControls[i].type!=null && inputControls[i].type=='hidden')
						{
								if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageReferenceId')
								{
								
								inputControls[i].value="0";
								
								}

								
								else if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageType')
								{
								inputControls[i].value="";
								}

								
						}
					}
				}

}

function setSourceReferenceIdForBBN()
{

	var inputControls=document.getElementsByTagName('input');
		
				if(inputControls!=null && inputControls.length>0)
				{
					for(var i=0;i<inputControls.length;i++)
					{
						if(inputControls[i].type!=null && inputControls[i].type=='hidden')
						{
								
								if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageReferenceId')
								{
								
								inputControls[i].value=sourceUsageReferenceId;
								
								}

								else if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnSourceUsageType')
								{
								inputControls[i].value="BBN";
								}

								
						}
					}
				}

}



function OpenBBNWindow(queryString)
{   

setSourceReferenceBBN();
var strWin = window.open(queryString ,"winShow");
          strWin.focus();
 

}

function OpenBBNWindowWithReference(queryString,DAreferenceId)
{   
sourceUsageReferenceId=DAreferenceId;
setSourceReferenceIdForBBN();
var strWin = window.open(queryString ,"winShow");
          strWin.focus();
 

}







/////////////////////////////Update Usage Completed //////////////////




function LoadPlayer(playerContainerId,fileUrl,autoPlay)
{
try
{
var pContainer=document.getElementById(playerContainerId)
if(pContainer==null)
setTimeout("LoadPlayer('"+playerContainerId+"','"+fileUrl+"','"+autoPlay+"')",5000);
if(pContainer!=null)
{
pContainer.innerHTML="";
var objContainer="";
objContainer='<object id="myAudio" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="256" height="16" style="border: 1px solid #aaa;" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
                                      objContainer=  objContainer+'<param name="SRC" value='+"'"+ fileUrl+"'"+'/>'
                                         objContainer=  objContainer+'<param name="AUTOPLAY" value='+"'"+ autoPlay+"'"+' />'
                                         objContainer=  objContainer+'<param name="TARGET" value="QuickTimePlayer" />'
                                         objContainer=  objContainer+'<param name="CONTROLLER" value="true" />'
                                         objContainer=  objContainer+'<param name="BGCOLOR" value="#FFFFFF" />'
                                       objContainer=objContainer+'<param name="ENABLEJAVASCRIPT" value="true" /> <param name="KIOSKMODE" value="True" />'
                                        objContainer=  objContainer+'<embed id="myAudio" name="myAudio" enablejavascript="true" src='+"'"+fileUrl+"'"+' autoplay='+"'"+autoPlay+"'"+' target="QuickTimePlayer" width="256" height="16" controller="true" bgcolor="#FFFFFF"  KIOSKMODE="True"  pluginspage="http://www.apple.com/quicktime/download/" ></embed></object>'
     
     pContainer.innerHTML= objContainer;

//pContainer.innerHTML=QT_WriteOBJECT('poster.jpg','256','16','','src',fileUrl);//,'autohref','true','target','myself');
}

}
catch(e)
{
}
return true;
}
function ClearTimer(timerId)
{
var timer=document.getElementById(timerId);
if(timer==null)
setTimeout("ClearTimer('"+timerId+"')",5000);
if(timer!=null)
{
setTimeout("disableTimer('"+timer+"')",60000);
}
}
function disableTimer(timer)
{

//timer.disabled=true;
//alert(timer.disabled);
}

function asyncRequestForUsageCount(serviceId,referenceId,userId,fileName,usageType)
{
try
{


var oRequest;
if(window.XMLHttpRequest)
    oRequest=new XMLHttpRequest();
else if(window.ActiveXObject)
    oRequest=new ActiveXObject("Microsoft.XMLHTTP");
 
 if(oRequest!=null)
 {


//oRequest.onreadystatechange=exChange;

//var url="http://devserver2/ScolaFileHandler/default.do?Mode=Play&ServiceId="+serviceId+"&ReferenceId="+referenceId+"&UserId="+userId+"&FileName="+fileName;

oRequest.open("GET","/Scola/FileUsage.aspx?Mode="+usageType+"&ServiceId="+serviceId+"&ReferenceId="+referenceId+"&UserId="+userId+"&FileName="+fileName,true);
//window.open("http://devserver2/ScolaFileHandler/default.do?Mode=Play&ServiceId="+serviceId+"&ReferenceId="+referenceId+"&UserId="+userId+"&FileName="+fileName);
//  oRequest.open("GET","http://devserver2/ScolaFileHandler/default.do?Mode=Play&ServiceId="+serviceId+"&ReferenceId="+referenceId+"&UserId="+userId+"&FileName="+fileName,true);
//  oRequest.setRequestHeader(
//  oRequest.withCredentials="true";
 // oRequest.open("GET",url,true);

  //alert('dd');
 oRequest.send(null);
 
 }
  
 }
 catch(e)
 {
// alert(e.message);
 }
 return true;

}
/////////////////////////////Script for display utc time //////////////////

function GetUtcTime(offsetvalue,DisplayField)
{
var updated_time = "";
	var tag = "";
	
	
	setInterval("time()",1000);
	
	function time(){
	today = new Date();
	
	//process Hours
	hours = today.getUTCHours() - offsetvalue;
	if (hours > 12){
	hours = hours - 12;
	tag = "PM";	
	}//ends hours IF
	else {tag = "AM"}
	
	//process Minutes
	minutes = today.getUTCMinutes();
	if (minutes < 10){
	minutes = "0" + minutes;
	}//ends minutes IF
	
	//process Seconds
	seconds = today.getUTCSeconds();
	if (seconds < 10){
	seconds = "0" + seconds;
	}//ends seconds IF
	
	updated_time = " " + hours + ":" + minutes + ":" + seconds + "  " + tag;
	document.getElementById(DisplayField).value = updated_time;
//	return true;
	}
}
///////////////////////////////////////////////

///////////////////////////////////////////////
//Load the player dynamically
function DynamicPlayer(playerContainerId,fileUrl,autoPlay,width,height)
{
try
{
var pContainer=document.getElementById(playerContainerId)
if(pContainer==null)
setTimeout("DynamicPlayer('"+playerContainerId+"','"+fileUrl+"','"+autoPlay+"','"+width+"','"+height+"')",5000);
if(pContainer!=null)
{
pContainer.innerHTML="";
var objContainer="";
objContainer='<object id="apobj" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+width +'px" height="'+height+'px" style="border: 1px solid #aaa;" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
                                      objContainer=  objContainer+'<param name="SRC" value='+"'"+ fileUrl+"'"+'/>'
                                         objContainer=  objContainer+'<param name="AUTOPLAY" value='+"'"+ autoPlay+"'"+' />'
                                         objContainer=  objContainer+'<param name="TARGET" value="QuickTimePlayer" />'
                                         objContainer=  objContainer+'<param name="CONTROLLER" value="true" />'
                                         objContainer=  objContainer+'<param name="BGCOLOR" value="#FFFFFF" />'
                                       objContainer=objContainer+'<param name="ENABLEJAVASCRIPT" value="true" />'
                                        objContainer=  objContainer+'<embed id="eobj" enablejavascript="true" src='+"'"+fileUrl+"'"+' autoplay='+"'"+autoPlay+"'"+' target="QuickTimePlayer" width='+"'"+width+"px'"+' height='+"'"+height+"px'"+' controller="true" bgcolor="#FFFFFF" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>'
     
     pContainer.innerHTML= objContainer;
//pContainer.innerHTML=QT_WriteOBJECT('poster.jpg','256','16','','src',fileUrl);//,'autohref','true','target','myself');
}

}
catch(e)
{
//alert(e);
//return false;
}
//return false;
}
/*=================== Tab Control Index Change =================*/
function ChangeTabIndex(activeButton,inActiveButton,activeDiv,inActiveDiv)
{
try
{
var activeDv=document.getElementById(activeDiv);
var inactiveDv=document.getElementById(inActiveDiv);
if(activeDv!=null)
{
activeDv.style.visibility='visible';
activeDv.style.display='';
}

if(inactiveDv!=null)
{
   inactiveDv.style.display='none';
inactiveDv.style.visibility='hidden';
}
if(activeDiv && activeDv==null )
{

activeDiv.style.visibility='visible';
activeDiv.style.display='';

}
if(inActiveDiv && inactiveDv==null)
{
inActiveDiv.style.display='none';
inActiveDiv.style.visibility='hidden';

}



}
catch(e)
{
//alert(e);
return false;
}
return false;
}

/*=================== Tab Control Index Change =================*/
function ChangeTabIndex(activeButton,inActiveButton,activeDiv,inActiveDiv,activeBtnImageurl,inactiveBtnImageurl)
{
try
{
var activeDv=document.getElementById(activeDiv);
var inactiveDv=document.getElementById(inActiveDiv);
var activeTab=document.getElementById(activeButton);
var inactiveTab=document.getElementById(inActiveButton);
var activeImg=activeBtnImageurl;
var inactiveImg=inactiveBtnImageurl;

if(activeDv!=null)
{
activeDv.style.visibility='visible';
activeDv.style.display='';
}
if(inactiveDv!=null)
{
   inactiveDv.style.display='none';
inactiveDv.style.visibility='hidden';
}
if(activeDiv && activeDv==null )
{

activeDiv.style.visibility='visible';
activeDiv.style.display='';

}
if(inActiveDiv && inactiveDv==null)
{
inActiveDiv.style.display='none';
inActiveDiv.style.visibility='hidden';

}

if(activeTab!=null)
{
activeTab.src=activeBtnImageurl;
}
if(inactiveTab!=null)
{
inactiveTab.src=inactiveBtnImageurl;
}


}
catch(e)
{

return false;
}

return false;
}


/// Dynamic Flv Player
//function LoadFlashMovie((playerContainerId,fileUrl,autoPlay,width,height)
//{
//try
//{

//var pContainer=document.getElementById(playerContainerId)
//if(pContainer==null)
//setTimeout("DynamicFlashPlayer('"+playerContainerId+"','"+fileUrl+"','"+autoPlay+"','"+width+"','"+height+"')",5000);
//if(pContainer!=null)
//{
//pContainer.innerHTML="";
//var objContainer="";

 //objContainer='<object id="videoPlayerObject" name="videoPlayerObject" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="300" >';
   //                                     objContainer=objContainer+' <param name="movie" value="/ScolaApp/FlashMovie/scolaflvplayermaxi.swf" />';
     //                                        objContainer=objContainer+ ' <param name="flashvars" value= value=""/>';

//                                             objContainer=objContainer+ ' <param name="allowScriptAccess" value="always" />';
  //                                          objContainer=objContainer+  ' <param name="allowFullScreen" value="true" />';
    //                                        objContainer=objContainer+  ' <param name="salign" value="lt" />';
      //                                       objContainer=objContainer+ ' <embed id="videoPlayerEmbed" name="videoPlayerEmbed" src="/ScolaApp/FlashMovie/scolaflvplayermaxi.swf" flashvars="" allowfullscreen="true" width="350" height="300" allowscriptaccess="always" salign="lt" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
                                                
 // pContainer.innerHTML= objContainer;
//pContainer.innerHTML=QT_WriteOBJECT('poster.jpg','256','16','','src',fileUrl);//,'autohref','true','target','myself');
//}

//}
//catch(e)
//{
//alert(e);
//return false;
//}
//return false;
//}

function LoadFlashMovie(playerContainerId,fileUrl,autoPlay,width,height)
{
try
{
var pContainer=document.getElementById(playerContainerId);
if(pContainer==null)
setTimeout("LoadFlashMovie('"+playerContainerId+"','"+fileUrl+"','"+autoPlay+"','"+width+"','"+height+"')",5000);
if(pContainer!=null)
{

pContainer.innerHTML="";
var objContainer="";
var so = new SWFObject("/ScolaApp/FlashMovie/scolaflvplayermaxi.swf", "D27CDB6E-AE6D-11cf-96B8-444553540000", "350", "300", "9", "#FFFFFF");
   so.addParam("quality", "high");
   so.addParam("wmode", "transparent");
   so.addParam("salign", "t");
   so.addParam("flashvars" ,"flv="+fileUrl+"&amp;width=350&amp;height=300");
   so.addParam("play","true");

		//so.addParams("flashvars", fileUrl); // this line is optional, but this example uses the variable and displays this text inside the flash movie
//var flashcontent=document.createElement('div');
so.write(pContainer);
//alert(pContainer.innerHTML);
//alert(flashcontent.innerHTML);
  //var FO = { movie:"/ScolaApp/FlashMovie/scolaflvplayermaxi.swf", width:"350", height:"300", majorversion:"6", build:"40", flashvars:fileUrl };
//alert(FO);
 //   UFO.create(FO, pContainer);

//fileUrl="C:\Documents and Settings\Suresh.GURUSERVER\Desktop\nasatest.flv"

//objContainer='<object id="videoPlayerObject" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width +'px" height="'+height+'px" style="border: 1px solid #aaa;" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0">'
  //                                    objContainer=  objContainer+'<param name="movie" value='+"'"+ fileUrl+"'"+'/>'
    //                                     objContainer=  objContainer+'<param name="movie" value="/ScolaApp/FlashMovie/scolaflvplayermaxi.swf" />'
      //                                   objContainer=  objContainer+'<param name="TARGET" value="QuickTimePlayer" />'
        //                                 objContainer=  objContainer+'<param name="CONTROLLER" value="true" />'
          //                               objContainer=  objContainer+'<param name="BGCOLOR" value="#FFFFFF" />'
            //                           objContainer=objContainer+'<param name="ENABLEJAVASCRIPT" value="true" />'
              //                          objContainer=  objContainer+'<embed id="eobj" enablejavascript="true" src='+"'"+fileUrl+"'"+' autoplay='+"'"+autoPlay+"'"+' target="QuickTimePlayer" width='+"'"+width+"px'"+' height='+"'"+height+"px'"+' controller="true" bgcolor="#FFFFFF" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>'
//objContainer="<object id=\"videoPlayerObject\" name=\"videoPlayerObject\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"350\" height=\"300\" >";
//objContainer=objContainer+" <param name=\"movie\" value=\"/ScolaApp/FlashMovie/scolaflvplayermaxi.swf\" />";
 // objContainer=  objContainer+"<param name=\"flashvars\" value=\"flv="+fileUrl +"&amp;width=350&amp;height=300\"/>";

 //objContainer=objContainer+ " <param name=\"allowScriptAccess\" value=\"always\" />";
  //objContainer=objContainer+  " <param name=\"allowFullScreen\" value=\"true\" />";
  //objContainer=objContainer+  " <param name=\"salign\" value=\"lt\" />";
  //objContainer=objContainer+ "<embed id=\"videoPlayerEmbed\" name=\"videoPlayerEmbed\" src=\"/ScolaApp/FlashMovie/scolaflvplayermaxi.swf\" flashvars=\"flv="+ fileUrl+"&amp;width=350&amp;height=300\" allowfullscreen=\"true\" width=\"350\" height=\"300\" allowscriptaccess=\"always\" salign=\"lt\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed></object>"; 
  //pContainer.innerHTML=objContainer;

//alert(pContainer.innerHTML);
}
}
catch(e)
{
}
}





/////////// Play List/////////////////////////


  function GetCookie(cookieName)
{
var c_value='';
var c_start=0;
try
{
 if(document.cookie!=null && document.cookie.length>0)
 {
 c_start=document.cookie.indexOf(cookieName+ "=") 

 if (c_start!=-1) 
    {  
    c_start=c_start + cookieName.length+1  ;
    c_end=document.cookie.indexOf(";",c_start) ;
    if (c_end==-1) c_end=document.cookie.length;
    c_value=document.cookie.substring(c_start,c_end);
   // alert(userCookie);
    }
 }

 }
 catch(e)
 {
// alert(e);
 }
return c_value;
}
function WriteCookie(cookieName,cookieValue,expireDays)
{

try
{

var exdate='';
if(expireDays!=null && expireDays>0)
{
exdate=new Date();

exdate.setDate(exdate.getDate()+expireDays);
}

document.cookie=cookieName+"="+cookieValue+((expireDays==null) ? "" : ";expires="+exdate.toDateString())+"; path=/";
}
catch(e)
{

}

}
function IsPlayerOf(playerType)
{

var playerOption='';
var result=false;
try
{
playerOption=GetCookie('PlayerOption');
if(playerOption!=null && playerOption.length>0 && playerOption==playerType)
{

result=true;
}

}
catch(e)
{
}
return result;
}

function AddToPlaylist(clipId)
{
try
{
var playlistCookie="Playlist";
var expireDays=30;
var playlist= GetCookie(playlistCookie);

    if(playlist!=null && playlist.length>0 )
    {
        if(!Contains(playlist,clipId))
        {
        playlist=playlist+","+clipId;
        WriteCookie(playlistCookie,playlist,expireDays);
        }
    }
    else
    {
    playlist=clipId;
    WriteCookie(playlistCookie,playlist,expireDays);

    }
}
catch(e)
{
}


}
function Contains(source,value)
{
var result=false;
if(source!=null && source.length>0 && value!=null && value.length>0)
{
source=","+source+",";
if(source.indexOf(","+value+",")==-1)
resutlt=false;
else
result=true;

}
return result;
}

function Disable_TabChanged(sender,e) 
{

try
{
sender._autoPostBackId=null;
if(sender._activeTabIndex!=0)
sender.set_activeTab(sender.get_tabs()[0]);
}
catch(e)
{
return false;
}
return false;

}




function CheckAll(checkHeader,checkChild) 
{
 
              
                  var chkheader=document.getElementById(checkHeader);
                  var chkChilds=document.getElementById(checkChild);
                  var ChkState=false;
                    if(chkheader!=null)
                         ChkState=chkheader.checked;
                         
                           if(chkChilds!=null && chkChilds.rows.length>0)
                            {
                                 var chkboxes=chkChilds.getElementsByTagName('input');
                                if(chkboxes!=null && chkboxes.length>0)
                                {
                                        for(i=0;i< chkboxes.length;i++) 
                                        {  
                                              if(chkboxes[i].type!=null && chkboxes[i].type=='checkbox')
                                              {             
                                                chkboxes[i].checked= ChkState ; 
                                               }
                                        } 
                                }
               
                            } 
}

function CheckChanged(checkHeader,checkChild) 
{
 
              
      var chkheader=document.getElementById(checkHeader);
      var chkChilds=document.getElementById(checkChild);
   
     var boolAllChecked=true; 
     if(chkChilds!=null && chkChilds.rows.length>0)
                            {
                                 var chkboxes=chkChilds.getElementsByTagName('input');
                                if(chkboxes!=null && chkboxes.length>0)
                                {
                                        for(i=0;i< chkboxes.length;i++) 
                                        {  
    
                                             if(chkboxes[i].type!=null && chkboxes[i].type=='checkbox' && chkboxes[i].checked== false) 
                                             { 
                                             boolAllChecked=false; 
                                             break; 
                                             } 
                                        } 
                                        
                                  }
                                  
                                }
   
     if( boolAllChecked==false) 
     chkheader.checked= false ; 
     else 
     chkheader.checked= true; 
     
} 


function CopyTextWithRating(sourcetxtCtrl,targettextCtrl,sourcetxtCtrl1,targettextCtrl1,selectedRow,rowIndexCtrl,ddlControl,selectedValue)
{
try
{
var ratingCtrl=document.getElementById(ddlControl);
if(ratingCtrl)
{
ratingCtrl[selectedValue].selected="1";

CopyText(sourcetxtCtrl,targettextCtrl,sourcetxtCtrl1,targettextCtrl1,selectedRow,rowIndexCtrl);
}
}
catch(e)
{}
return false;
}                





function checkAllWithDirectionOld(checkHeader,checkChild,scriptCtrl,txtCtrl)
{
try
{
defaultDirection="LR";

CheckAll(checkHeader,checkChild);

scriptRList=document.getElementById(scriptCtrl); //radiobuttonlist
txtScript=document.getElementById(txtCtrl); //textbox
txtScript.dir=defaultDirection;
}
catch(e)
{
}
return false;

}

function CheckChangedWithDirectionOld(checkHeader,checkChild,scriptCtrl,txtCtrl)
{
try
{
var count=0;
var defaultDirection="LR";
var textDirection="LR";
CheckChanged(checkHeader,checkChild);
var scriptRList=document.getElementById(scriptCtrl); //radiobuttonlist
var txtScript=document.getElementById(txtCtrl); //textbox
var chkList=document.getElementById(checkChild);
for(var i=0;i<chkList.rows.length;i++)
{
var spn=chkList.rows[i].getElementsByTagName('span');
if(spn)
{
var chkBox=spn[0].getElementsByTagName('input');
if(chkBox && chkBox[0].type && chkBox[0].type=='checkbox' && chkBox[0].checked)
{

				if(spn[0].id && spn[0].id==defaultDirection) //any one of the checked language is ltr(Left To Right) text direction assign ltr and break it.
				{
				textDirection=defaultDirection;
				break;
				}
				else
				textDirection="RL";
}
}
}
if(textDirection!=defaultDirection)
{
var rbList=scriptRList.getElementsByTagName('input');
if(rbList && rbList[1].checked)
{
textDirection=defaultDirection;
}
}
txtScript.dir=(textDirection=="RL")?"RTL":"LTR";
}
catch(e)
{
}
return false;
}
     


function checkAllWithDirection(checkHeader,checkChild,scriptCtrl,txtCtrl,hdnDir)
{
try
{
defaultDirection="LTR";

CheckAll(checkHeader,checkChild);

scriptRList=document.getElementById(scriptCtrl); //radiobuttonlist
txtScript=document.getElementById(txtCtrl); //textbox
hdntxtDir=document.getElementById(hdnDir)
txtScript.dir=defaultDirection;
hdntxtDir.value=defaultDirection;
}
catch(e)
{
}
return false;

}

function CheckChangedWithDirection(checkHeader,checkChild,scriptCtrl,txtCtrl,hdnDir)
{
try
{
var count=0;
var defaultDirection="LR";
var textDirection="LR";
CheckChanged(checkHeader,checkChild);
var scriptRList=document.getElementById(scriptCtrl); //radiobuttonlist
var txtScript=document.getElementById(txtCtrl); //textbox
var chkList=document.getElementById(checkChild);
hdntxtDir=document.getElementById(hdnDir)
for(var i=0;i<chkList.rows.length;i++)
{
var spn=chkList.rows[i].getElementsByTagName('span');
if(spn)
{
var chkBox=spn[0].getElementsByTagName('input');
if(chkBox && chkBox[0].type && chkBox[0].type=='checkbox' && chkBox[0].checked)
{

				if(spn[0].id && spn[0].id==defaultDirection) //any one of the checked language is ltr(Left To Right) text direction assign ltr and break it.
				{
				textDirection=defaultDirection;
				break;
				}
				else if(spn[0].id && spn[0].id=="RL")
				textDirection="RL";
}
}
}
var rbList=scriptRList.getElementsByTagName('input');
if(rbList && rbList[1].checked)
    {
       txtScript.title = "Search on Translation, Vocabulary, Quiz and Topics can be performed";
    }
    else
    {
         txtScript.title = "Search on Transcript, Vocabulary and Quiz can be performed.";        
    }

if(textDirection!=defaultDirection)
{	
    if(rbList && rbList[1].checked)
    {
        textDirection=defaultDirection;       
    }
}
txtScript.dir=(textDirection=="RL")?"RTL":"LTR";
hdntxtDir.value=(textDirection=="RL")?"RTL":"LTR";
}
catch(e)
{
}
return false;
}
    





function ReportValidation(checkOrgName,checkCountry,checkLanguage,checkService,frmDate,toDate) 
{
 
              

 var chkOrgNameChilds=document.getElementById(checkOrgName);
 var boolAllChecked=false; 
 if(chkOrgNameChilds!=null && chkOrgNameChilds.rows.length>0)
    {
        var chkOrgboxes=chkOrgNameChilds.getElementsByTagName('input');
        if(chkOrgboxes!=null && chkOrgboxes.length>0)
        {
                for(i=0;i< chkOrgboxes.length;i++) 
                {  

                     if(chkOrgboxes[i].type!=null && chkOrgboxes[i].type=='checkbox' && chkOrgboxes[i].checked== true) 
                     { 
                     boolAllChecked=true; 
                     break; 
                     } 
                } 
                
          }
          
    }
    if(boolAllChecked==false)
    {
    alert("select any Organization");
    return false;
    }
    
    
    

     var chkCountryChilds=document.getElementById(checkCountry);
  boolAllChecked=false; 
 if(chkCountryChilds!=null && chkCountryChilds.rows.length>0)
    {
        var chkOrgCountryboxes=chkCountryChilds.getElementsByTagName('input');
        if(chkOrgCountryboxes!=null && chkOrgCountryboxes.length>0)
        {
                for(i=0;i< chkOrgCountryboxes.length;i++) 
                {  

                     if(chkOrgCountryboxes[i].type!=null && chkOrgCountryboxes[i].type=='checkbox' && chkOrgCountryboxes[i].checked== true) 
                     { 
                     boolAllChecked=true; 
                     break; 
                     } 
                } 
                
          }
          
    }
    if(boolAllChecked==false)
    {
    alert("select Country");
    return false;
    }
    
     var chkLanguageChilds=document.getElementById(checkLanguage);
 boolAllChecked=false; 
 if(chkLanguageChilds!=null && chkLanguageChilds.rows.length>0)
    {
        var chkLanguageboxes=chkLanguageChilds.getElementsByTagName('input');
        if(chkLanguageboxes!=null && chkLanguageboxes.length>0)
        {
                for(i=0;i< chkLanguageboxes.length;i++) 
                {  

                     if(chkLanguageboxes[i].type!=null && chkLanguageboxes[i].type=='checkbox' && chkLanguageboxes[i].checked== true) 
                     { 
                     boolAllChecked=true; 
                     break; 
                     } 
                } 
                
          }
          
    }
    if(boolAllChecked==false)
    {
    alert("select any Language");
    return false;
    }
    
     var chkServiceChilds=document.getElementById(checkService);
  boolAllChecked=false; 
 if(chkServiceChilds!=null && chkServiceChilds.rows.length>0)
    {
        var chkServiceboxes=chkServiceChilds.getElementsByTagName('input');
        if(chkServiceboxes!=null && chkServiceboxes.length>0)
        {
                for(i=0;i< chkServiceboxes.length;i++) 
                {  

                     if(chkServiceboxes[i].type!=null && chkServiceboxes[i].type=='checkbox' && chkServiceboxes[i].checked== true) 
                     { 
                     boolAllChecked=true; 
                     break; 
                     } 
                } 
                
          }
          
    }
    if(boolAllChecked==false)
    {
    alert("select any Service");
    return false;
    }
    
 
     var SDate = document.getElementById(frmDate).value;    	
    var EDate =  document.getElementById(toDate).value;
    
   
   if(isValidDate(SDate,"From Date")&& isValidDate(EDate,"To Date") )
   {
   
	
    var endDate = new Date(EDate);    	
    var startDate= new Date(SDate);
     	var MinDate=new Date('01/01/2003');
        var MaxDate=new Date();

   if(SDate != '')
        {
            if(SDate != '' && (startDate < MinDate || startDate > MaxDate ) )
            {
                alert("Invalid From Date");
                return false;
            }
            
        }
         if(EDate != '')
        {
               	
             if(EDate != '' && (endDate < MinDate || endDate > MaxDate ) )
            {
                alert("Invalid To Date");
                return false;
            }
        }


       if(SDate != '' && EDate != '' && startDate > endDate)
    {
	    alert("Invalid Date range");
	    return false;
    }
    }
    else
     return false;
    
    
    return true;
}

 
    
    
 
function isValidDate(dateStr,textDiaplay) {
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables

//var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

// To require a 4 digit year entry, use this line instead:
 var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
alert("Enter "+textDiaplay);
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert(textDiaplay+" Invalid Date Formate");
return false;
}
if (day < 1 || day > 31) {
alert(textDiaplay+" Invalid Date Formate");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert(textDiaplay+" Invalid Date Formate");
return false
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert(textDiaplay+" Invalid Date Formate");
return false;
   }
}
return true;  // date is valid
}
                                            
 // Change Report Type
function ChangeReportType(ddlReportType,ddlscolaService,lbltitle)
{

    var rType = "";
    var selectedService = "";
    try 
        {
            var reportType = document.getElementById(ddlReportType);
            
            for(var i=0; i<=reportType.length; i++)
            {
                if(reportType.value == reportType[i].value)
                {
                   rType = reportType[i].text ;
                    break;
                }
            }   
            var scolaService = document.getElementById(ddlscolaService);
            
            for(var i=0; i<=scolaService.length; i++)
            {
                if(scolaService.value == scolaService[i].value)
                {
                   selectedService = scolaService[i].text ;
                    break;
                }
            } 
            if (scolaService.value == 0 || scolaService.value == -1)
            {
                reportType.disabled = false;
                //reportType[0].selected = true;
            }
            else
            {
                reportType.disabled = true;
                reportType[0].selected = true;
            }            
            var title = document.getElementById(lbltitle);     
            title.innerHTML = selectedService+ " - " + rType ;
        }
    catch(e)
        {

        }
}



// Change Report Type
function DisplayReportType(ddlReportType,ddlscolaService,lbltitle)
{

    var rType = "";
    var selectedService = "";
    try 
        {
            var reportType = document.getElementById(ddlReportType);
            
            for(var i=0; i<=reportType.length; i++)
            {
                if(reportType.value == reportType[i].value)
                {
                   rType = reportType[i].text ;
                    break;
                }
            }   
            var scolaService = document.getElementById(ddlscolaService);
            
            for(var i=0; i<=scolaService.length; i++)
            {
                if(scolaService.value == scolaService[i].value)
                {
                   selectedService = scolaService[i].text ;
                    break;
                }
            } 
                
            var title = document.getElementById(lbltitle);     
            title.innerHTML = selectedService+ " - " + rType ;
        }
    catch(e)
        {

        }
} 



function SamplePageAlert()
{
alert("Please Subscribe an account");
return false;

}


function icNewPost(divObj,positionCtrl,txtSubjectId,txtCommentId,ddlRatingId,postId)
{
try
{
var txtSubject= document.getElementById(txtSubjectId);
var txtComment= document.getElementById(txtCommentId);
var ddlRating= document.getElementById(ddlRatingId);
var postCtrl= document.getElementById(postId);
if(postCtrl)
{
postCtrl.value='';
}
if(txtSubject)
{
txtSubject.value='';
}
if(txtComment)
{
txtComment.value='';
}
if(ddlRating)
{
ddlRating[0].selected="1";
}
pop(divObj,positionCtrl);
}
catch(e)
{
}
return false;
}


function getTopLeft(sID){
   var o=document.getElementById(sID);
    //  alert(o);
   if(o==null){return [0,0];}
   var top=o.offsetTop,left=o.offsetLeft;
   o=o.offsetParent;

   while(o){
      if(!document.all){
         if(o.scrollTop)top-=o.scrollTop;
         if(o.scrollLeft)left-=o.scrollLeft;
         // Mozilla bug
         if((o.tagName=='DIV')||(o.tagName=='TABLE'&&navigator.vendor=='Netscape'))
            top+=getAttrPixValue(o,'border-top-width')|0,left+=getAttrPixValue(o,'border-left-width')|0;
      }
      top+=o.offsetTop;
      left+=o.offsetLeft;
      o=o.offsetParent;
   }
   if(navigator.userAgent.indexOf('Mac')!=-1 && typeof(document.body.leftMargin)!='undefined'){
      left+=document.body.leftMargin,top+=document.body.topMargin;   // working?
   }
   return [top,left];
}
function getAttrPixValue(e,a){
   var px=0;
    if(window.getComputedStyle){
        var css,sty=window.getComputedStyle(e,'');
      if(sty&&sty.getPropertyCSSValue){
         css=sty.getPropertyCSSValue(a);
         if((css)&&css.primitiveType<=18){try{px=css.getFloatValue(5)|0;}catch(e){};}
      }
    }
    return px;
}


function pop(divObj,positionCtrl) {
var dv=  document.getElementById(divObj);

var searchbox = document.getElementById(positionCtrl); // add that id, not just class name to html
  // var pos = getPosition(searchbox);
   
dv.style.left = "200px";
   dv.style.top = "200px";
dv.style.position='absolute';

dv.style.display='block';

  return false
}
function hidepopup(divObj) {
  document.getElementById(divObj).style.display='none';
  return false
}

function CopyWithPopup(sourcetxtCtrl,targettextCtrl,sourcetxtCtrl1,targettextCtrl1,selectedRow,rowIndexCtrl,ddlControl,selectedValue,popDivId)
{
CopyTextWithRating(sourcetxtCtrl,targettextCtrl,sourcetxtCtrl1,targettextCtrl1,selectedRow,rowIndexCtrl,ddlControl,selectedValue)
 pop(popDivId,sourcetxtCtrl)
 return false;
}

function getPosition(n,endNode){
    var left = 0;
    var top =0;
    var node = n;
    done=false;
                    
    while(!done){
        if(node.offsetLeft!=null)
                left += node.offsetLeft;
        if(node.offsetTop!=null)
        {
                top += node.offsetTop;
                
         }
        if(node.offsetParent){
                node = node.offsetParent;

        }else{
                done = true;
        }
        if(node == endNode)
                done = true;
    }
    done=false;
    node = n;
    while(!done){
        if(document.all && node.style && parseInt(node.style.borderLeftWidth)){
                left += parseInt(node.style.borderLeftWidth);
        }
        if(document.all && node.style && parseInt(node.style.borderTopWidth)){
                top += parseInt(node.style.borderTopWidth);
        }

        if(node.scrollLeft){
                left -= node.scrollLeft;
        }
        if(node.scrollTop)
                top -= node.scrollTop;
        if(node.parentNode)
                node = node.parentNode;
        else
                done=true;
    }
    return new Array(left, top);
}


function IsBothTextBoxText(txtSearchTerm,txtSearchEngTerm)
{
    try
    {
        var searchTerm=document.getElementById(txtSearchTerm);
        var searchEngTerm=document.getElementById(txtSearchEngTerm);
         if(searchTerm.value !=null && searchEngTerm.value !=null && searchTerm.value !="" && searchEngTerm.value !="")
         {     
            alert('Search can be performed with Native or English text, not both.  Please clear either Native text or English text and click search.');
            return false;           
        }
     }
     catch(e)
     {
    // alert(e);
     }
    return true;
}


//Foreign Text Search Button Validation
function FTSearchValidation(ddlCountry,ddlLanguage,frmDate,toDate,txtSearchTerm,txtSearchEngTerm) 
{ 
    if(IsBothTextBoxText(txtSearchTerm,txtSearchEngTerm))
    {  
        var Countryddl = document.getElementById(ddlCountry);    	
        var Languageddl =  document.getElementById(ddlLanguage);
         if(Countryddl.value == 0 && Languageddl.value == 0)
         {
            alert("Must select a country or language");
            return false;
         }
        var SDate = document.getElementById(frmDate).value;    	
        var EDate =  document.getElementById(toDate).value; 
          var MinDate=new Date('01/01/2003');
        var MaxDate=new Date();
 
        if(SDate != '')
        {
             var startDate= new Date(SDate);
             if(!isValidDate(SDate,"From Date") )
                return false;
        }
        if(EDate != '')
        {
             var endDate = new Date(EDate);    	
            if(!isValidDate(EDate,"To Date") )
                return false;
        }
        
          if(SDate != '')
        {
            if(SDate != '' && (startDate < MinDate || startDate > MaxDate ) )
            {
                alert("Invalid From Date");
                return false;
            }
            
        }
         if(EDate != '')
        {
               	
             if(EDate != '' && (endDate < MinDate || endDate > MaxDate ) )
            {
                alert("Invalid To Date");
                return false;
            }
        }

        
        if(SDate != '' && EDate != '')
        {
           if(SDate != '' && EDate != '' && startDate > endDate)
            {
                alert("Invalid Date range");
                return false;
            }
        }         
    }
    else
    {
     return false;

    }
}                                

function FTSearchValidationOCR(ddlCountry,ddlLanguage,frmDate,toDate,txtSearchTerm,txtSearchEngTerm,frdt) 
{ 
    if(IsBothTextBoxText(txtSearchTerm,txtSearchEngTerm))
    {  
        var Countryddl = document.getElementById(ddlCountry);    	
        var Languageddl =  document.getElementById(ddlLanguage);
         if(Countryddl.value == 0 && Languageddl.value == 0)
         {
            alert("Must select a country or language");
            return false;
         }
        var SDate = document.getElementById(frmDate).value;    	
        var EDate =  document.getElementById(toDate).value; 
        //var MinDate=new Date(frdt);
        var MinDate=new Date('01/01/2003');

        var MaxDate=new Date();
 
        if(SDate != '')
        {
             var startDate= new Date(SDate);
             if(!isValidDate(SDate,"From Date") )
                return false;
        }
        if(EDate != '')
        {
             var endDate = new Date(EDate);    	
            if(!isValidDate(EDate,"To Date") )
                return false;
        }
         if(SDate != '')
        {
            if(SDate != '' && (startDate > MaxDate ) )
            {
                alert("Invalid From Date");
                return false;
            }
             else if (startDate < MinDate)
            {
           // alert('OCRTextSearch can be done from "07/01/2010"');
            alert('Invalid From Date');
            return false;
            }

            
        }
         if(EDate != '')
        {
               	
             if(EDate != '' && (endDate < MinDate || endDate > MaxDate ) )
            {
                alert("Invalid To Date");
                return false;
            }
        }
        
        if(SDate != '' && EDate != '')
        {
           if(SDate != '' && EDate != '' && startDate > endDate)
            {
                alert("Invalid Date range");
                return false;
            }
        }         
    }
      expandcollapse('divT4', 'one');

} 

function ChangeImageByColor(rdbtn,imgCtrl,fileDirectory,labelMsgGotoPage,labelNoMarkMsg)
{
    var labelMsgGotoPages = document.getElementById(labelMsgGotoPage);
    var labelNoMarkMsgs = document.getElementById(labelNoMarkMsg);
    labelMsgGotoPages.innerHTML = "";
    labelNoMarkMsgs.innerHTML = "";
    var imgTag="";
    imgTag=document.getElementById(imgCtrl);  
    rdctrl=document.getElementById(rdbtn);
    imgCtrlSrc = imgTag.src;
    if(rdctrl != null)
    {
        var chkBoxList=rdctrl.getElementsByTagName('input');
        if(chkBoxList[0].checked)
        {
        fileDirectory = fileDirectory + "/ColorImages/";
            if(!Contains(imgCtrlSrc,fileDirectory))
            {
              imgCtrlSrc =  imgCtrlSrc.replace(/GrayImages/,"ColorImages");  
            }  
         }         
        else if(chkBoxList[1].checked)
        {
          fileDirectory = fileDirectory + "/GrayImages/";
            if(!Contains(imgCtrlSrc,fileDirectory))
            {
               imgCtrlSrc =  imgCtrlSrc.replace(/ColorImages/,"GrayImages");     
            }
         }                 
      }
      imgTag.src = imgCtrlSrc;
   }
   
   
   
   function removeItem(originalArray, itemToRemove)
 {
 	var j = 0;
 		while (j < originalArray.length) 
 		{
 			//	alert(originalArray[j]);	
 				if (originalArray[j] == itemToRemove)
 				 {			
 				 originalArray.splice(j, 1);
 				 }
 				 else
 				{
 				    j++;
 		        }
 		}
 		return originalArray;
 } 		



//function ChangeImage(imgCtrl,pageNoControlId,changeDirection,rdbtn,pageNoDisplayControlId,chkBoxMarkPage,chkBoxShowMarkPage,ddlPageNo,fileDirectory)                                                
function ChangeImage(imgCtrl,pageNoControlId,changeDirection,rdbtn,pageNoDisplayControlId,chkBoxMarkPage,chkBoxShowMarkPage,txtGotoPageNo,fileDirectory,lblMsgGotoPages,lblMsgNoMark)                                                
{
setProgressBar();
var currentWidth=0;
var currentHeight=0;
var imgTag="";
imgTag=document.getElementById(imgCtrl);
var pageNoDisplayControl=document.getElementById(pageNoDisplayControlId);
var msgGotoPage = document.getElementById(lblMsgGotoPages);
var msgNoMark = document.getElementById(lblMsgNoMark);
msgGotoPage.innerHTML = "";
msgNoMark.innerHTML = "";
var maxHeight=600;
var maxWidth=500;

//var imgLength = document.getElementById(pageNoControlId);
var rdctrl ="";
var chkctrl ="";
//var gotoPageNo ="";
//ddlCtrl = document.getElementById(ddlPageNo);
var gotoPageNo = document.getElementById(txtGotoPageNo);
chkctrl = document.getElementById(chkBoxMarkPage);
chkshowctrl=document.getElementById(chkBoxShowMarkPage);
rdctrl=document.getElementById(rdbtn);
if(rdctrl != null)
{
var chkBoxList=rdctrl.getElementsByTagName('input');
if(chkBoxList[1].checked)
fileDirectory = fileDirectory + "/GrayImages/";
else if(chkBoxList[0].checked)
fileDirectory = fileDirectory + "/ColorImages/";
}
if(imgTag!=null)
{
currentWidth=imgTag.width;
currentHeight=imgTag.height;
var currentImg=imgTag.src;
var sp = currentImg.split('/');
var file = sp[sp.length-1];
//var chkBox=document.getElementById(checkBoxSaveMarkedPage);
var markedPageslistCookie="MarkedPages";
var markedPageslist= GetCookie(markedPageslistCookie);
//var fileindex = markedPageslist.indexOf(currentPageNo,0);
//var currPageIndex =FTImages.IndexOf(imgTag.src.substring(imgTag.src.lastIndexOf('/')+1,imgTag.src.lastIndexOf('.')));
    var currentFTImageIndex=-1;
    if(FTImages!=null)
    {
        for(var i=0;i<FTImages.length;i++)
        {
            if(FTImages[i].toLowerCase()==file.toLowerCase()) 
            {
            currentFTImageIndex=i; 
            break;
            }
        }
    }
    var currentZoomImageIndex=-1;
    if(ZoomImages!=null)
    {
        for(var i=0;i<ZoomImages.length;i++)
        {
            if(ZoomImages[i].toLowerCase()==file.toLowerCase()) 
            {
            currentZoomImageIndex=i; 
            break;
            }
        }
    }
    if(changeDirection=="Right")
    {
        if(currentFTImageIndex>=0 && currentFTImageIndex<(FTImages.length-1))
        {
            var currPageIndex=FTImages[Math.round(currentFTImageIndex)+1];
            var currentPageNo=currPageIndex.substring(currPageIndex.lastIndexOf('_')+1,currPageIndex.lastIndexOf('.'));
            var fileindex = -1;
            if(markedPageslist!=null)
            	fileindex = markedPageslist.indexOf(currentPageNo,0);
//            ddlCtrl.selectedIndex =currentFTImageIndex+1;
            gotoPageNo.value =currentFTImageIndex+2;
            if (fileindex >= 0)
            {
             if (chkctrl != null)
             {
                chkctrl.checked = true;
             }
            }
            else
            {
             chkctrl.checked = false;
            }
           
             copyResult('',''); //clear the text in ocr textbox and machine translation result text box when change the image;
            
         /////Reload Imge size
       
               


 var oHeight=ZImgHeight[Math.round(currentZoomImageIndex)+1];
 var oWidth=ZImgWidth[Math.round(currentZoomImageIndex)+1];
 var newHeight=oHeight;
 var newWidth=oWidth;
 if(oWidth>oHeight)
 {
 	//Landscape
				 if(oWidth>maxWidth)
				 {
				 newWidth=maxWidth
				// imgTag.width=newWidth;
				
				 newHeight=((((Math.round(maxWidth)/oWidth)*100)*oHeight)/100);
				  // imgTag.height=newHeight;
				 }
				 if(newHeight>maxHeight)
				 {
				 newHeight=maxHeight;
				 //imgTag.height=maxHeight;
					newWidth=((((Math.round(maxHeight)/oHeight)*100)*oWidth)/100);
				 }
 
 }
 else
 {
 if(newHeight>maxHeight)
				 {
				 newHeight=maxHeight;
				 //imgTag.height=maxHeight;
					newWidth=((((Math.round(maxHeight)/oHeight)*100)*oWidth)/100);
				 }
				  if(newWidth>maxWidth)
				 {
				 newWidth=maxWidth
				// imgTag.width=newWidth;
				
				 newHeight=((((Math.round(maxWidth)/oWidth)*100)*oHeight)/100);
				  // imgTag.height=newHeight;
				 }

				 

 				}
// imgTag.src="";
 imgTag.width=newWidth;
 imgTag.height=newHeight;
               
        ClearCordinate();	
        
 	 //imgTag.src ='GetHighlightedFTImage.aspx?FileName='+ fileDirectory+FTImages[Math.round(currentFTImageIndex)+1];  
 imgTag.src =fileDirectory+FTImages[Math.round(currentFTImageIndex)+1];
         pageNoDisplayControl.innerHTML=Math.round(currentFTImageIndex)+2+" Of "+FTImages.length;
        var IE = /*@cc_on!@*/false;
if(IE){    
  playtransitionSubImage();
 }

         
         showDiv();          
         GetCoords(FTImages[Math.round(currentFTImageIndex)+1],newWidth,newHeight);
         HideDiv();
        }
    }
    else if(changeDirection=="Left")
    {
    if(currentFTImageIndex>0)
        {
         var currPageIndex=FTImages[Math.round(currentFTImageIndex)-1];
            var currentPageNo=currPageIndex.substring(currPageIndex.lastIndexOf('_')+1,currPageIndex.lastIndexOf('.'));
            var fileindex = -1;
            if(markedPageslist!=null)
            	fileindex = markedPageslist.indexOf(currentPageNo,0);
//            ddlCtrl.selectedIndex =currentFTImageIndex-1;
            gotoPageNo.value =currentFTImageIndex;
            if (fileindex >= 0)
            {
            if (chkctrl != null)
             {
                chkctrl.checked = true;
             }
            }
            else
            {
             chkctrl.checked = false;
            }
            copyResult('',''); //clear the text in ocr textbox and machine translation result text box when change the image;
                /////Reload Imge size
       
               


 var oHeight=ZImgHeight[Math.round(currentZoomImageIndex)-1];
 var oWidth=ZImgWidth[Math.round(currentZoomImageIndex)-1];
 var newHeight=oHeight;
 var newWidth=oWidth;
 if(oWidth>oHeight)
 {
 	//Landscape
				 if(oWidth>maxWidth)
				 {
				 newWidth=maxWidth
				// imgTag.width=newWidth;
				
				 newHeight=((((Math.round(maxWidth)/oWidth)*100)*oHeight)/100);
				  // imgTag.height=newHeight;
				 }
				 if(newHeight>maxHeight)
				 {
				 newHeight=maxHeight;
				 //imgTag.height=maxHeight;
					newWidth=((((Math.round(maxHeight)/oHeight)*100)*oWidth)/100);
				 }
 
 }
 else
 {
 if(newHeight>maxHeight)
				 {
				 newHeight=maxHeight;
				 //imgTag.height=maxHeight;
					newWidth=((((Math.round(maxHeight)/oHeight)*100)*oWidth)/100);
				 }
				  if(newWidth>maxWidth)
				 {
				 newWidth=maxWidth
				// imgTag.width=newWidth;
				
				 newHeight=((((Math.round(maxWidth)/oWidth)*100)*oHeight)/100);
				  // imgTag.height=newHeight;
				 }

				 

 				}
 imgTag.src="";
 imgTag.width=newWidth;
 imgTag.height=newHeight;
            ClearCordinate();
             showDiv();                 
             GetCoords(FTImages[Math.round(currentFTImageIndex)-1],currentWidth,currentHeight);
             HideDiv();
              imgTag.src =fileDirectory+FTImages[Math.round(currentFTImageIndex)-1];
           // imgTag.src ='GetHighlightedFTImage.aspx?FileName='+ fileDirectory+FTImages[Math.round(currentFTImageIndex)-1];
            pageNoDisplayControl.innerHTML=Math.round(currentFTImageIndex)+" Of "+FTImages.length;            
           var IE = /*@cc_on!@*/false;
if(IE){    
  playtransitionSubImage();
 }

        }
    }
    else
    {
//    var ddlPageNoCtrl=document.getElementById(pageNoControlId);
//    if(ddlPageNoCtrl!=null)
    var selectedValue= gotoPageNo.value;
    
    ClearCordinate();
     showDiv();  
    GetCoords(FTImages[Math.round(selectedValue)+1],currentWidth,currentHeight);
     HideDiv();
       // imgTag.src ='GetHighlightedFTImage.aspx?FileName='+ FTImages[Math.round(selectedValue)-1];
       imgTag.src = FTImages[Math.round(selectedValue)-1];
     //imgTag.src=FTImages[Math.round(selectedValue)-1];
            pageNoDisplayControl.innerHTML=Math.round(selectedValue)+" Of "+FTImages.length;
//            GetCoords(FTImages[Math.round(selectedValue)+1],currentWidth,currentHeight);
    }
}

}



function playtransitionSubImage(oldimage,newimage)
{
var mid=document.getElementById("mdiv")
var val = mid.innerHTML;
mid.innerHTML=val ;//reset DIV to original content (in case demo is run more than once).
mid.filters[0].apply(); //capture initial state of image (showing "castle.gif")
mid.innerHTML=val;
mid.filters[0].play(); //play transition to reveal new image and description
}


function GotoImage(imgControlId,rdbtn,pageNoControlId,pageNoDisplayControlId,chkBoxMarkPage,fileDirectory)
{
try
{

//alert(FTImages);

var imgCtrl=document.getElementById(imgControlId);
var pageNoCtrl=document.getElementById(pageNoControlId);
var pageNoDisplayControl=document.getElementById(pageNoDisplayControlId);
var pageNo=0;
//jai
var rdctrl ="";
var chkctrl ="";
chkctrl = document.getElementById(chkBoxMarkPage);
var markedPageslistCookie="MarkedPages";
var markedPageslist= GetCookie(markedPageslistCookie);
rdctrl=document.getElementById(rdbtn);
if(rdctrl != null)
{
var chkBoxList=rdctrl.getElementsByTagName('input');
if(chkBoxList[1].checked)
fileDirectory = fileDirectory + "/GrayImages/";
else if(chkBoxList[0].checked)
fileDirectory = fileDirectory + "/ColorImages/";
}


//end
if(pageNoCtrl)
pageNo=pageNoCtrl.value;
if(imgCtrl!=null && !isNaN(pageNo) && pageNo>0 && pageNo<=Math.round(FTImages.length))
{
//imgCtrl.src=fileDirectory+FTImages[Math.round(pageNo)-1]
//var img=new Image();
//img.src='GetHighlightedFTImage.aspx?FileName='+ fileDirectory+FTImages[Math.round(pageNo)-1];
  imgCtrl.src = fileDirectory+FTImages[Math.round(pageNo)-1];
 var currPageIndex=FTImages[Math.round(pageNo)-1];
 var currentPageNo=currPageIndex.substring(currPageIndex.lastIndexOf('_')+1,currPageIndex.lastIndexOf('.'));
         var fileindex = markedPageslist.indexOf(currentPageNo,0);
            if (fileindex >= 0)
            {
             if (chkctrl != null)
             {
                chkctrl.checked = true;
             }
            }
            else
            {
             chkctrl.checked = false;
            }           

pageNoDisplayControl.innerHTML=Math.round(pageNo)+" Of "+FTImages.length;
}
}
catch(e)
{
}
//return false;
}

//-------------------------------Goto Page -----------------------//
function GotoPages(imgContId,rdbutton,txtGotoPageControlId,pageNoDisplayId,chkMarkPage,fDirectory,lblMsgGotoPages,noMarkedMesg)
{
    try
    {
        setProgressBar();
        var imgContrl=document.getElementById(imgContId);
        //var pageNoCtrl=document.getElementById(pageNoControlId);
        var pageControlId=document.getElementById(txtGotoPageControlId);
        var pageNoDisplay=document.getElementById(pageNoDisplayId);
        var msgGotoPages = document.getElementById(lblMsgGotoPages);
        var noMarkedMessage = document.getElementById(noMarkedMesg);
        msgGotoPages.innerHTML = "";
        noMarkedMessage.innerHTML = "";
        var pageNum=0;
        var maxWidth=500;
        var maxHeight=600;
        //jai
        var rdctrls ="";
        var chkctrls ="";
        var chkMrkctrls = document.getElementById(chkMarkPage);
        var markedPageslistCookies="MarkedPages";
        var markedPageslst= GetCookie(markedPageslistCookies);
        rdbtnctrl=document.getElementById(rdbutton);
        if(rdbtnctrl != null)
        {
            var chkBoxLst=rdbtnctrl.getElementsByTagName('input');
            if(chkBoxLst[1].checked)
            fDirectory = fDirectory + "/GrayImages/";
            else if(chkBoxLst[0].checked)
            fDirectory = fDirectory + "/ColorImages/";
        }

        //end
        //if(pageNoCtrl)
        pageNum=pageControlId.value;
        if(imgContrl!=null && !isNaN(pageNum) && pageNum > 0 && pageNum <= Math.round(FTImages.length))
        {
        
              copyResult('',''); //clear the text in ocr textbox and machine translation result text box when change the image;
  var oHeight=ZImgHeight[Math.round(pageNum)-1];
 var oWidth=ZImgWidth[Math.round(pageNum)-1];
 var newHeight=oHeight;
 var newWidth=oWidth;
 if(oWidth>oHeight)
 {
 	//Landscape
				 if(oWidth>maxWidth)
				 {
				 newWidth=maxWidth
				// imgTag.width=newWidth;
				
				 newHeight=((((Math.round(maxWidth)/oWidth)*100)*oHeight)/100);
				  // imgTag.height=newHeight;
				 }
				 if(newHeight>maxHeight)
				 {
				 newHeight=maxHeight;
				 //imgTag.height=maxHeight;
					newWidth=((((Math.round(maxHeight)/oHeight)*100)*oWidth)/100);
				 }
 
 }
 else
 {
 if(newHeight>maxHeight)
				 {
				 newHeight=maxHeight;
				 //imgTag.height=maxHeight;
					newWidth=((((Math.round(maxHeight)/oHeight)*100)*oWidth)/100);
				 }
				  if(newWidth>maxWidth)
				 {
				 newWidth=maxWidth
				// imgTag.width=newWidth;
				
				 newHeight=((((Math.round(maxWidth)/oWidth)*100)*oHeight)/100);
				  // imgTag.height=newHeight;
				 }

 }
 imgContrl.src='';
 imgContrl.width=newWidth;
 imgContrl.height=newHeight;
            ClearCordinate();
            showDiv();
            GetCoords(FTImages[Math.round(pageNum)-1],imgContrl.width,imgContrl.height);
            HideDiv();
             // imgContrl.src = 'GetHighlightedFTImage.aspx?FileName='+ fDirectory+FTImages[Math.round(pageNum)-1];
              imgContrl.src = fDirectory+FTImages[Math.round(pageNum)-1];
             var currPgIndex=FTImages[Math.round(pageNum)-1];
             var currentPageNum=currPgIndex.substring(currPgIndex.lastIndexOf('_')+1,currPgIndex.lastIndexOf('.'));
             var fileindexs = -1;
                if(markedPageslst !=null)
                      fileindexs = markedPageslst.indexOf(currentPageNum,0);
                        if (fileindexs >= 0)
                        {
                             if (chkMrkctrls != null)
                             {
                                chkMrkctrls.checked = true;
                             }
                        }
                        else
                        {
                            chkMrkctrls.checked = false;
                        } 
                pageNoDisplay.innerHTML=Math.round(pageNum)+" Of "+FTImages.length;
                
        }
        else
        {
            msgGotoPages.innerHTML = "Invalid Page Number.";
            
         }
    }
    catch(e)
    {
        //alert(e);
    }
    return false;
}
//------------------  Mark Foreign Text Page  -------------------//



//function MarkUnMarkPage(checkBoxSaveMarkedPage,imgControlId,ddlPageNo,checkBoxShowMarkedPage,rdbtn,totpag,pagedis,fileDirectory)
function MarkUnMarkPage(checkBoxSaveMarkedPage,imgControlId,txtGotoPageNum,checkBoxShowMarkedPage,rdbtn,totpag,pagedis,fileDirectory,msgGotoPage,noMarkMsg)
{
    try
    {
        var msgGotoPages = document.getElementById(msgGotoPage);
        var noMarkMsgs = document.getElementById(noMarkMsg);
        msgGotoPages.innerHTML = "";
        noMarkMsgs.innerHTML = "";
        var rdctrl ="";
        rdctrl=document.getElementById(rdbtn);
        if(rdctrl != null)
        {
        var chkBoxList=rdctrl.getElementsByTagName('input');
        if(chkBoxList[1].checked)
        fileDirectory = fileDirectory + "/GrayImages/";
        else if(chkBoxList[0].checked)
        fileDirectory = fileDirectory + "/ColorImages/";
        }
    
        var noOfZero=0;
        var pageNo=0;
        var imgCtrl=document.getElementById(imgControlId);
        var pagecontrol=document.getElementById(totpag);
        var pagedisplay=document.getElementById(pagedis);
        var currentPageNo=imgCtrl.src.substring(imgCtrl.src.lastIndexOf('_')+1,imgCtrl.src.lastIndexOf('.'));
//        var ddlCtrl = document.getElementById(ddlPageNo);     
        var gotoPageNum = document.getElementById(txtGotoPageNum);     
        
       var chkBox=document.getElementById(checkBoxSaveMarkedPage);
       var chkShowBox=document.getElementById(checkBoxShowMarkedPage);
       var markedPageslistCookie="MarkedPages";
       var expireDays=30;
       var markedPageslist= GetCookie(markedPageslistCookie);
        if(chkBox!=null && chkBox.type=='checkbox')
        {
            if(chkBox.checked==true)
            {
                if(markedPageslist!=null && markedPageslist.length>0 )
                {
                    if(!Contains(markedPageslist,currentPageNo))
                    {
                        markedPageslist=markedPageslist+","+currentPageNo;
                        markedPageslist=markedPageslist.replace(",," , ",");  
                  }
                }
                else
                {
                    markedPageslist=currentPageNo;
                }
            }
            else
            {
                if(markedPageslist!=null && markedPageslist.length>0 )
                {
                    if(Contains(markedPageslist,currentPageNo))
                    {
                        markedPageslist=markedPageslist.replace(currentPageNo , "");
                        markedPageslist=markedPageslist.replace(",," , ",");                        
                    }
                    if(chkShowBox.checked == true)
                    {
                     for(var i=0;i<FTImages.length;i++)
                    {
                        var remPageNo=FTImages[i].substring(FTImages[i].lastIndexOf('_')+1,FTImages[i].lastIndexOf('.'));
                        if(!Contains(markedPageslist,remPageNo))
                        {
                            FTImages =removeItem(FTImages, FTImages[i]); 
                            if(FTImages.length == 0)
                            {
                            
                             markedPageslist=SortNumberArray(markedPageslist);  
                             WriteCookie(markedPageslistCookie,markedPageslist,expireDays);                               
                               __doPostBack('__Page', 'FTImageLoad');
                            }
                            else
                            {
                             if(markedPageslist.startsWith(","))
                                {
                                    markedPageslist=markedPageslist.substring(1,(markedPageslist.length));
                                     markedPageslist=SortNumberArray(markedPageslist);  
                                    WriteCookie(markedPageslistCookie,markedPageslist,expireDays);                             
                                     __doPostBack('__Page', 'FTImageReLoad');  
                                }  
                                 if(markedPageslist.endsWith(","))
                                {
                                    markedPageslist=markedPageslist.substring(0,(markedPageslist.length -1));
                                     markedPageslist=SortNumberArray(markedPageslist);  
                                     WriteCookie(markedPageslistCookie,markedPageslist,expireDays);  
                                     __doPostBack('__Page', 'FTImageReLoad'); 
                                }    
                                if(!markedPageslist.startsWith(",") && !markedPageslist.endsWith(","))
                                { 
                                WriteCookie(markedPageslistCookie,markedPageslist,expireDays); 
                                 markedPageslist=SortNumberArray(markedPageslist);  
                                __doPostBack('__Page', 'FTImageReLoad');                                                                                  
                                }                          
                             } 
                        }
                      }
                   }        
                }
            }
        }     
        if(markedPageslist.endsWith(","))
        {
        markedPageslist=markedPageslist.substring(0,(markedPageslist.length -1));
        }  
         markedPageslist=SortNumberArray(markedPageslist);       
        WriteCookie(markedPageslistCookie,markedPageslist,expireDays);        
       // alert(markedPageslist);
        
    }
    catch(e)
    {
        
    }
   // return false;
}

function sortNumber(a,b)
{
    return a - b;
}
function SortNumberArray(CommaSeperatedString)
{
    var tmpArray = CommaSeperatedString.split(',');
    var arr = new Array(tmpArray.length);
    for(var i=0;i<tmpArray.length;i++)
    {
        var tmpString=tmpArray[i];
        arr[i] = tmpString;
    }
    return (arr.sort(sortNumber).toString());
}






function FtRadioButtonValidation(rbColorPDF,rbBWPDF,DownloadType,anchorID,SelectedType)
{
    try
    {
var hrefVal=document.getElementById(anchorID).href;
hrefVal=hrefVal.substring(0,hrefVal.lastIndexOf('PdfType=')+8);
if(SelectedType=='HQ')
{

document.getElementById(DownloadType).value="HQ";
document.getElementById(rbBWPDF).checked=false;
document.getElementById(rbColorPDF).checked=true;
}
else if(SelectedType=='BW')
{

document.getElementById(DownloadType).value="BW";
document.getElementById(rbColorPDF).checked=false;
document.getElementById(rbBWPDF).checked=true;
}
document.getElementById(anchorID).href=hrefVal+document.getElementById(DownloadType).value;
    }
    catch(e)
    {
        
    }
    
    
}

function ChangeFileDownloadHref(txtFromPage,txtToPage,checkBoxSaveMarkedPages,rdbtn)
{
return false;
	var FileDownloadCtrl=document.getElementById('FileDownload');
	var objFromPageCtrl=document.getElementById(txtFromPage);
	var objToPageCtrl=document.getElementById(txtToPage);
	var objSaveMarkedCtrl=document.getElementById(checkBoxSaveMarkedPages);
	var objQualityctrl=document.getElementById(rdbtn);

	if(FileDownloadCtrl!=null)
	{
		var objExistingUrlValue=FileDownloadCtrl.href;
		var objNewUrlValue=objExistingUrlValue.substring(0,objExistingUrlValue.lastIndexOf('PdfRange=')+9)
		if(objFromPageCtrl!=null && objToPageCtrl!=null)
		{
			objNewUrlValue=(objNewUrlValue+objFromPageCtrl.value+'-'+objToPageCtrl.value);
		}
		else
		{
			objNewUrlValue=objNewUrlValue+'-';
		}
		if(objSaveMarkedCtrl!=null)
		{
			if(objNewUrlValue.indexOf('&IncludeMarkedPages=True')>0)
				objNewUrlValue=objNewUrlValue.replace('&IncludeMarkedPages=True','&IncludeMarkedPages='+objSaveMarkedCtrl.checked);
			else if(objNewUrlValue.indexOf('&IncludeMarkedPages=False')>0)
				objNewUrlValue=objNewUrlValue.replace('&IncludeMarkedPages=False','&IncludeMarkedPages='+objSaveMarkedCtrl.checked);
		}
		if(objQualityctrl!= null)
    	{
			var rbtnList=objQualityctrl.getElementsByTagName('input');
			var selectedPDFType='';
			for(var i=0;i<rbtnList.length;i++)
			{
				if(rbtnList[i].checked)
				{
					selectedPDFType=(rbtnList[i].value);
					break;
				}
			}
			if(objNewUrlValue.indexOf('&PdfType=HQ')>0)
			{
				objNewUrlValue=objNewUrlValue.replace('&PdfType=HQ','&PdfType='+selectedPDFType);
			}
			else if(objNewUrlValue.indexOf('&PdfType=Color')>0)
			{
				objNewUrlValue=objNewUrlValue.replace('&PdfType=Color','&PdfType='+selectedPDFType);
			}
			else if(objNewUrlValue.indexOf('&PdfType=BW')>0)
			{
				objNewUrlValue=objNewUrlValue.replace('&PdfType=BW','&PdfType='+selectedPDFType);
			}

		}
		//alert(objNewUrlValue);
		FileDownloadCtrl.href=objNewUrlValue;
	}
}

function ChangeRequest(aCtrl,requestUrl,txtFromId,txtToId,quality,chkIncludeMarkedId,totalPageCtrlId)
{
//&PdfType=" + rdbtnListPDFSize.SelectedItem.Value + "&IncludeMarkedPages=" + checkBoxSaveMarkedPages.Checked +"&PdfRange="+txtFrom.Text+"-"+txtTo.Text 
//alert(GetCookie('MarkedPages'));
aTag=document.getElementById(aCtrl);
var txtFrom=document.getElementById(txtFromId);
var txtTo=document.getElementById(txtToId);
//var rbQuality=document.getElementById(rbQualityId);
var chkIncludeMarked=document.getElementById(chkIncludeMarkedId);
var totalPageCtrl=document.getElementById(totalPageCtrlId);

if(quality==null)
quality="HQ";
if(aTag!=null)
{
var totalPage=0;
if(totalPageCtrl!=null)
{
totalPage=Math.round(totalPageCtrl.value);
}
if (!chkIncludeMarked.checked && txtFrom.value.length<=0 && txtTo.value.length<=0)
{
    aTag.href="#";
    alert("Please enter page number.");
    return false;
}
else if((GetCookie('MarkedPages')==null || GetCookie('MarkedPages').length<=0) && txtFrom.value.length<=0 && txtTo.value.length<=0) 
{
    aTag.href="#";
    alert("No marked page exist.");
    return false;
}
else if(txtFrom.value.length>0 && (Math.round(txtFrom.value)==0 || Math.round(txtFrom.value)>totalPage)) 
{
    aTag.href="#";
    alert("From page number is invalid.");
    return false;
}
else if(txtTo.value.length>0 && (Math.round(txtTo.value)==0 || Math.round(txtTo.value)>totalPage)) 
{
    aTag.href="#";
    alert("To page number is invalid.");
    return false;
}
else if(txtFrom.value.length>0 &&  txtTo.value.length>0 && Math.round(txtFrom.value)>  Math.round(txtTo.value)) 
{
    aTag.href="#";
    alert("From page number is greater than to page number.");
    return false;
}
//if( (!chkIncludeMarked.checked && txtFrom.value.length<=0 && txtTo.value.length<=0) || ((GetCookie('MarkedPages')==null || GetCookie('MarkedPages').length<=0) && txtFrom.value.length<=0 && txtTo.value.length<=0)  ||(txtFrom.value.length>0 && Math.round(txtFrom.value)>totalPage) ||(txtTo.value.length>0 && Math.round(txtTo.value)>totalPage) ||(txtFrom.value.length>0 &&  txtTo.value.length>0 && Math.round(txtFrom.value)>  Math.round(txtTo.value)))
//{
//aTag.href="#";
////aTag.target="_self";
//return false;
//}
        //if(rbQuality!= null)
        //    	{
        //			var rbtnList=rbQuality.getElementsByTagName('input');
        //			var selectedPDFType='';
        //			for(var i=0;i<rbtnList.length;i++)
        //			{
        //				if(rbtnList[i].checked)
        //				{
        //					quality=rbtnList[i].value;
        //					break;
        //				}
        //			}
        //		}
var marked="";
if(chkIncludeMarked.checked)
aTag.href=requestUrl+"&FT=PR&PdfType="+quality+"&IncludeMarkedPages="+chkIncludeMarked.checked+"&PdfRange="+txtFrom.value+"-"+txtTo.value+"&marked="+GetCookie('MarkedPages');
else
aTag.href=requestUrl+"&FT=PR&PdfType="+quality+"&IncludeMarkedPages="+chkIncludeMarked.checked+"&PdfRange="+txtFrom.value+"-"+txtTo.value;

return true;
}
else
return false;
}

function ZoomImage(imgSubPage,zoomOption,animateImage,msgGotoPg,noMarkMesg)
{
    setProgressBar();
    var msgGotoPgs=document.getElementById(msgGotoPg);
    var noMarkMessg=document.getElementById(noMarkMesg);
    var imgClientID=document.getElementById(imgSubPage);
    msgGotoPgs.innerHTML = "";
    noMarkMessg.innerHTML = "";
    var imgWidth  = 0;
    var imgHeight = 0;
    if(imgClientID!=null)
    {
        var currentImg=imgClientID.src;
        var sp = currentImg.split('/');
        var file = sp[sp.length-1];
        var currentFTImageIndex=-1;
        if(ZoomImages!=null)
        {
            for(var i=0;i<ZoomImages.length;i++)
            {
                if(ZoomImages[i].toLowerCase()==file.toLowerCase()) 
                {
                    currentFTImageIndex=i; 
                    break;
                }
            }
            if(ZImgWidth != null)
            {
                imgWidth= ZImgWidth[currentFTImageIndex];
            }
            if(ZImgHeight != null)
            {
                imgHeight = ZImgHeight[currentFTImageIndex]; 
            }
        }
        var wcalPer = 0;
        var widPix = 0;
        var leftcurr_width =0;
        var rightcurr_width =0;
        var heightPix = 0;
        var leftdiv= document.getElementById('leftdiv');  
        // var Rightdiv= document.getElementById('Rightdiv');                 
        var mdiv= document.getElementById('mdiv');
        //Calc ZoomIn Width
        widPer =(100 - ((imgClientID.width /imgWidth) * 100));
        wcalPer = widPer / 5;
        widPix = (imgWidth - imgClientID.width)/ wcalPer; 
        heightPix=(imgHeight-imgClientID.height)/wcalPer;
        if(zoomOption == 'ZoomIn')
        {
            if((Math.round(imgClientID.width) +  widPix<=imgWidth ) && ((Math.round(imgClientID.height)+heightPix) <=imgHeight ))
            {
                var leftdivstylewidth=leftdiv.style.width.replace('px','');
                var mdivstylewidth=mdiv.style.width.replace('px','');
                leftcurr_width = ((parseInt(leftdivstylewidth)/100)* ((wcalPer/parseInt(leftdivstylewidth))* 100));
                if(parseInt(leftdivstylewidth)>=leftcurr_width)
                {
                    leftdiv.style.width =  (parseInt(leftdivstylewidth) - leftcurr_width )+ "px"; 
                }
                //rightcurr_width= ((parseInt(Rightdiv.style.width)/100)* ((wcalPer/parseInt(Rightdiv.style.width))* 100));
                // Rightdiv.style.width =  parseInt(Rightdiv.style.width) - rightcurr_width + "px"; 
                mdiv.style.width =   (parseInt(mdivstylewidth)+ leftcurr_width) + "px"; 
                mdivstylewidth=mdiv.style.width.replace('px',''); 
                if(parseInt(mdivstylewidth) > 700)
                {
                    mdiv.style.width = 700 + "px";
                }              
                imgClientID.width   =Math.round(imgClientID.width) +  widPix;      
                imgClientID.height=Math.round(imgClientID.height)+heightPix;
                ClearCordinate();
                 showDiv();			   
                GetCoords(file,imgClientID.width,0);			  	  	   
                 HideDiv();
            }
        }
        else if(zoomOption == 'ZoomOut')
        {
            if(imgClientID.width > 700 || imgClientID.height > 600)
            {
                if((Math.round(imgClientID.width) - widPix)<700 && (Math.round(imgClientID.height) -  heightPix)<600)
                {
                    leftdiv.style.width = 100 + "px";                                
                    mdiv.style.width =   600 + "px";
                    heightPix=600;
                    wcalPer= (heightPix/Math.round(imgHeight))*100;
                    imgClientID.height= heightPix;
                    imgClientID.width=  Math.round((Math.round(imgWidth)*wcalPer)/100) ;
                    if(imgClientID.width>700)
                    {
                        widPix=700;
                        wcalPer= (widPix/Math.round(imgWidth))*100;
                        imgClientID.width= widPix;
                        imgClientID.height=  Math.round((Math.round(imgHeight)*wcalPer)/100) ;
                    }              
                }
                else
                {
                     var leftdivstylewidth=leftdiv.style.width.replace('px','');
                    var mdivstylewidth=mdiv.style.width.replace('px','');
                    
                    leftcurr_width = ((parseInt(leftdivstylewidth)/100)* ((wcalPer/parseInt(leftdivstylewidth))* 100));
                    leftdiv.style.width =  parseInt(leftdivstylewidth)+ leftcurr_width + "px";                              
                    mdiv.style.width =   parseInt(mdivstylewidth)- leftcurr_width + "px"; 
                    mdivstylewidth=mdiv.style.width.replace('px',''); 
                    if(parseInt(mdivstylewidth) > 700)
                    {
                        mdiv.style.width = 700 + "px";
                    }             
                    imgClientID.width   =Math.round(imgClientID.width) - widPix;
                    imgClientID.height   =Math.round(imgClientID.height) -  heightPix;  
                }
                ClearCordinate();
                showDiv();
                GetCoords(file,imgClientID.width,0);		      
                HideDiv();
            }
        }
        else
        {
            if(Math.round(imgClientID.width)>700 ||  imgClientID.height > 600)
            {
                leftdiv.style.width = 100 + "px";                                
                mdiv.style.width =   600 + "px";
                heightPix=600;
                wcalPer= (heightPix/Math.round(imgHeight))*100;
                imgClientID.height= heightPix;
                imgClientID.width=  Math.round((Math.round(imgWidth)*wcalPer)/100) ;
                if(imgClientID.width>700)
                {
                    widPix=700;
                    wcalPer= (widPix/Math.round(imgWidth))*100;
                    imgClientID.width= widPix;
                    imgClientID.height=  Math.round((Math.round(imgHeight)*wcalPer)/100) ;
                }
                ClearCordinate();
                showDiv();  
                GetCoords(file,imgClientID.width,0);
                HideDiv();           		
            }
        }
    }
}

function showDiv() 
{
if(document.getElementById('popupdiv') != null)
    document.getElementById('popupdiv').style.visibility = 'visible';
}
function HideProgressImage() 
{
if(document.getElementById('popupdiv') != null)
    document.getElementById('popupdiv').style.visibility = 'hidden';
}

function HideDiv() 
{
setTimeout("HideProgressImage()" ,2000);
} 


function GetCoords(fileName,imgWidth,imgHeight)
{
    var xmlRequest;
    if(window.XMLHttpRequest)
    xmlRequest=new XMLHttpRequest();
    else if(window.ActiveXObject)
    xmlRequest=new ActiveXObject("Microsoft.XMLHTTP");

    if(xmlRequest!=null)
    {
    xmlRequest.onreadystatechange=function() 
    {
    if(xmlRequest.readyState==4)
    {
        if(typeof(xmlRequest.responseText)!='unknown')
        {
//            var coordsMap= document.getElementById('map1');
//            if(coordsMap!=null)
//            {
//                var result=xmlRequest.responseText
//                if(result!=null && result.length>0 && result.indexOf('<div id=\'start\' />')>=0)
//                {
//                    coordsMap.innerHTML=result.substring(result.indexOf('<div id=\'start\' />')+20,result.indexOf('<div id=\'end\' />')-1);
//                }
//            }
            var coordsMap= document.getElementById('ZoneTag');
            if(coordsMap!=null)
            {
                var result=xmlRequest.responseText
                if(result!=null && result.length>0 && result.indexOf('<div id=\'start\' />')>=0)
                {
                    coordsMap.innerHTML=result.substring(result.indexOf('<div id=\'start\' />')+20,result.indexOf('<div id=\'end\' />')-1);
                }
            }
        }
    }
    return true;
};
xmlRequest.open("GET","/Scola/GetImageCoords.aspx?fn="+fileName+"&w="+imgWidth+"&h="+imgHeight,true);
xmlRequest.send(null);
}
return true;
}
function ClearCordinate()
{
            var coordsMap= document.getElementById('ZoneTag');
            if(coordsMap!=null)
            {                
             coordsMap.innerHTML='';               
            }
}

function copyResult(mtResult,ocrResult)
{
    var txtmtResult=document.getElementById('txtMTResult');
    var txtocrResult=document.getElementById('txtOcrResult');
        if(txtmtResult!=null && txtocrResult!=null)
        {
            txtmtResult.value=mtResult;
            txtocrResult.value=ocrResult; 
        }
    return false;
}


document.write('<div id="popupdiv" style="position:absolute; visibility:hidden;left:20%;top:30%; z-index:500; border-width: 1px;background-color:white;border-color:black; ;filter: Alpha(Opacity=100);"> <img src=\'/ScolaApp/images/LoadingCircle.GIF\' alt="progress" /></div>')
function setProgressBar()
{
//    var top = 20;
//    var left = 70;
//    var div=document.getElementById('popupdiv')
//	if(div != null)
//	{
//	div.style.visibility=(div.style.visibility=='hidden')?'visible':'hidden';
//	return ;
//	}
//	
//	if (document.documentElement)
//	{
//		left = Math.round(document.documentElement.offsetWidth)/2;
//		top = Math.round(document.documentElement.offsetHeight)/2;
//	}
//	else if (document.body)
//	{
//		left = Math.round(document.body.offsetWidth)/2;
//		top = Math.round(document.body.offsetHeight)/2;
//	}
	try
	{    
	
//	var div = document.createElement('<div id=\'popupDiv\'/>');
//	div.id="popupDiv";
//	div.innerHTML = '<div id=\'popupdiv\' style=\'position: absolute;top='+top+'px;left='+left+'px;padding: 5px;border:1px solid black;background: white;\' ><img src=\'/ScolaApp/images/LoadingCircle.GIF\'/> </div>'	
//	document.body.appendChild(div.firstChild);
	
	}
	catch(e)
	{
	//alert(e);
	}
}
//ToolTip Starts Here



function zoom(page,l,t,w,h,adpo,adpath)
{
   window.open("svww_zoomart.php?file='+page+'ltop='+l+'rtop='+t+'w='+w+'h='+h+'adpos='+l+'adpath='+t+'AN='+selFile+'","StarViewArticle","width=700,height=550,left=50,top=25,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes,titlebar=0,copyhistory=no",target="_new");
}
///////////////////////////////ft zone end/////////////////////////

var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////




var tipWidthFT= 600;
var tipFontFamilyFT= "Arial, Helvetica, sans-serif";
var tipFontSizeFT= "12px";
var tipFontColorFT= "black";
var tipBgColorFT= "white"; 
var tipBorderColorFT= "black";
var tipBorderWidthFT= 1;
var tipPaddingFT= 2;
var tipBorderStyleFT= "solid";


var startStrFT = '<table style="background-color:white" width="600px" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" vertical-align="center" style="width: 570px;height:30px;"></td><td align="right" vertical-align="center" style="width: 20px;"></td></tr>';
var secStrFT='<tr> <td colspan="2" align="left" style="width: 600px"><div style="float: left; width: 290px;font-family:' + tipFontFamilyFT + '; font-size:' + tipFontSizeFT + '; color:' + tipFontColorFT+ ';">';
var secStrendFT=' </div><div style="float: left; width: 290px;font-family:' + tipFontFamilyFT + '; font-size:' + tipFontSizeFT + '; color:' + tipFontColorFT+ ';">';
var endstrdivFT = '</div></td></tr> ';
var endStrFT = '</table>';


var tooltipFT, tipcssFT;
function initTipNew() {
	if (nodyn) return;
	tooltipFT = (ie4)? document.all['tipDivFT']: (ie5||ns5)? document.getElementById('tipDivFT'): null;
	tipcssFT = tooltipFT.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcssFT.width = tipWidthFT+"px";
		tipcssFT.fontFamily = tipFontFamilyFT;
		tipcssFT.fontSize = tipFontSizeFT;
		tipcssFT.color = tipFontColorFT;
		tipcssFT.backgroundColor = tipBgColorFT;
		tipcssFT.borderColor = tipBorderColorFT;
		tipcssFT.borderWidth = tipBorderWidthFT+"px";
		tipcssFT.padding = tipPaddingFT+"px";
		tipcssFT.borderStyle = tipBorderStyleFT;
	}	
}


var t1,t2;	// for setTimeouts
var tipOnFT = false;	// check if over tooltip link
function doTooltipFT(evt,txt,val) {

if(txt.length >0)
{
	if (!tooltipFT) {initTipNew()} else{};
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOnFT = true;	
	var curBgColorFT = '000000';
	curBgColorFT = tipBgColorFT;	
	var curFontColorFT = '000000';//messages[num][3];
	curFontColorFT = tipFontColorFT;
	if (ie4||ie5||ns5) {
		//var tip = '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';"> <span>'+  val + '</span><br/><span>'+ txt +'</span> </span>' + startStr +  midStr + endStr;
		var tipFT = '<div style="text-align:center;background-color:#00365A;border-bottom:solid 1px black; width:600px;height:30px;"><div style="text-align:left;float:left; vertical-align:top;font-family: Verdana;font-size: 10pt; color: #ffffff; font-weight: bold;padding-top:10px">Transcript/ Machine Translation:</div><div style="text-align:left;float:right; vertical-align:bottom;padding-top:10px;padding-right:10px;"><a href="javascript:hideTipFT()"><img src="/scolaapp/images/close.gif" style="border:0px;" alt="close"/></a></div></div><div style="text-align:center;height:300px;overflow:auto;width:600px;font-family:' + tipFontFamilyFT + '; font-size:' + tipFontSizeFT + '; color:' + curFontColorFT + ';">' + startStrFT + secStrFT + val + secStrendFT + txt + endstrdivFT  + endStrFT +'</div>';		  
		tipcssFT.backgroundColor = curBgColorFT;
	 	tooltipFT.innerHTML = tipFT;
	}	
    t1=setTimeout("tipcssFT.visibility='visible'",100);
    playtransition(tipFT);
    showcenterdiv(606,330,'tipDivFT');
}
}

function hideTipFT() {
	if (!tooltipFT) return;
	t2=setTimeout("tipcssFT.visibility='hidden'",100);
	tipOnFT = false;
}

document.write('<div id="tipDivFT" width="606px" style="-ms-filter: \'progid:DXImageTransform.Microsoft.Iris(duration=1,irisStyle=CIRCLE)\';filter:progid:DXImageTransform.Microsoft.Iris(duration=1,irisStyle=CIRCLE);width: 230px;height: 230px;background-color: white;padding: 10px;color: red;position:absolute; visibility:hidden; left:20%; top:30%;  z-index:500; height:330px;  border-width: 1px; background-color:white; border-color:black;"></div>')


function makevisible(cur,which,outorover,opac,mozopac)
{
//strength=(which==0)? 1 : 0
if(which==0)
{
    if (cur.style.MozOpacity)
        cur.style.MozOpacity= mozopac;
    else if (cur.filters)
         cur.filters.alpha.opacity=opac;
}
else if(which==1)
{
    if (cur.style.MozOpacity)
        cur.style.MozOpacity= mozopac;
    else if (cur.filters)
         cur.filters.alpha.opacity=opac;
}
     
}
/////////////////////////////    

function OTSSearchValidation(ddlCountry,ddlLanguage) 
{ 
    
        var Countryddl = document.getElementById(ddlCountry);    	
        var Languageddl =  document.getElementById(ddlLanguage);
         if(Countryddl.value == 0 && Languageddl.value == 0)
         {
            alert("Must select a country or language");
            return false;
         }
         
         return true;
}


function keyPressHandler(e)
    {
      var kC  = (window.event) ?    // MSIE or Firefox?
                 event.keyCode : e.keyCode;
      var Esc = (window.event) ?   
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox
      if(kC==Esc)
         hideTipFT();
   }
////////////////////////////
/////////////////////////////

function playtransition(tipFT){
var sample=document.getElementById("tipDivFT")

sample.innerHTML=tipFT; //reset DIV to original content (in case demo is run more than once).
sample.filters[0].apply() //capture initial state of image (showing "castle.gif")
sample.innerHTML=tipFT;
sample.filters[0].play() //play transition to reveal new image and description
}

//===============================div center of screen script==========
function showcenterdiv(Xwidth,Yheight,divid) {
// First, determine how much the visitor has scrolled

var scrolledX, scrolledY;
if( self.pageYoffset ) {
scrolledX = self.pageXoffset;
scrolledY = self.pageYoffset;
} else if( document.documentElement && document.documentElement.scrollTop ) {
scrolledX = document.documentElement.scrollLeft;
scrolledY = document.documentElement.scrollTop;
} else if( document.body ) {
scrolledX = document.body.scrollLeft;
scrolledY = document.body.scrollTop;
}

// Next, determine the coordinates of the center of browser's window

var centerX, centerY;
if( self.innerHeight ) {
centerX = self.innerWidth;
centerY = self.innerHeight;
} else if( document.documentElement && document.documentElement.clientHeight ) {
centerX = document.documentElement.clientWidth;
centerY = document.documentElement.clientHeight;
} else if( document.body ) {
centerX = document.body.clientWidth;
centerY = document.body.clientHeight;
}

// Xwidth is the width of the div, Yheight is the height of the
// div passed as arguments to the function:
var leftoffset = scrolledX + (centerX - Xwidth) / 2;
var topoffset = scrolledY + (centerY - Yheight) / 2;
// The initial width and height of the div can be set in the
// style sheet with display:none; divid is passed as an argument to // the function
var o=document.getElementById(divid);
var r=o.style;
r.position='absolute';
r.top = topoffset + 'px';
r.left = leftoffset + 'px';
r.display = "block";
} 



function ReportsDateValidation(frmDate,toDate)
 {
  		var SDate = document.getElementById(frmDate).value;    	
        var EDate =  document.getElementById(toDate).value; 
        var MinDate=new Date('01/01/2003');
        var MaxDate=new Date();
 
        if(SDate != '')
        {
             var startDate= new Date(SDate);
             if(!isValidDate(SDate,"From Date") )
                return false;
        }
        if(EDate != '')
        {
             var endDate = new Date(EDate);    	
            if(!isValidDate(EDate,"To Date") )
                return false;
        }
         if(SDate != '')
        {
            if(SDate != '' && (startDate < MinDate || startDate > MaxDate ) )
            {
                alert("Invalid From Date");
                return false;
            }
            
        }
         if(EDate != '')
        {
               	
             if(EDate != '' && (endDate < MinDate || endDate > MaxDate ) )
            {
                alert("Invalid To Date");
                return false;
            }
        }
        
        if(SDate != '' && EDate != '')
        {
           if(SDate != '' && EDate != '' && startDate > endDate)
            {
                alert("Invalid Date range");
                return false;
            }
        } 
        
        hideDiv();
        return true;
 }  


var helpValue="0";
function  setHelpValue(value)
{
helpValue=value;

}

function ShowHelpMenu()
{
helpValue="1";
expandcollapseHelp('divT3', 'one');
setVisible('layer1',true);




}

function ShowHelpMenuNew()
{
helpValue="1";
//expandcollapseHelp('divT3', 'one');




setVisible('layer1',true);



var hdnHelpLastDiv;

var inputControls=document.getElementsByTagName('input');
if(inputControls!=null && inputControls.length>0)
{
for(var i=0;i<inputControls.length;i++)
{
if(inputControls[i].type!=null && inputControls[i].type=='hidden')
{

if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnLastHelpDiv')
{
hdnHelpLastDiv=inputControls[i].value;
}
}
}
}
if(hdnHelpLastDiv!=null && hdnHelpLastDiv!='')
{
expandcollapseHelp(hdnHelpLastDiv,'one');
}
else
{
expandcollapseHelp('divT3', 'one');
}





var hdnHelptextId;

var inputControls=document.getElementsByTagName('input');
if(inputControls!=null && inputControls.length>0)
{
for(var i=0;i<inputControls.length;i++)
{
if(inputControls[i].type!=null && inputControls[i].type=='hidden')
{

if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnHelp')
{
hdnHelptextId=inputControls[i].id;
}
}
}
}

var hdnhlpId=document.getElementById(hdnHelptextId);
    hdnhlpId.value='1';
  


}


function CheckHelpMenu()
{
if(helpValue=="1")
{
setVisible('layer1',true);
}
alert('help text value hit');
alert(helpValue);

}

function CheckHelpMenuNew(value)
{
		if(value=="1")
		{
				setVisible('layer1',true);
				
				var hdnHelpLastDiv;
				
				var inputControls=document.getElementsByTagName('input');
						if(inputControls!=null && inputControls.length>0)
						{
							for(var i=0;i<inputControls.length;i++)
							{
								if(inputControls[i].type!=null && inputControls[i].type=='hidden')
								{
								
									if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnLastHelpDiv')
									{
									hdnHelpLastDiv=inputControls[i].value;
									}
								}
							}
						}
						if(hdnHelpLastDiv!=null && hdnHelpLastDiv!='')
						{
						expandcollapseHelp(hdnHelpLastDiv,'one');
						}
						else
						{
						expandcollapseHelp('divT3', 'one');
						}
				
				}

}



function CheckHelpMenuWindow()
{



		//var width = screen.width;
var width =document.body.clientWidth;
var height = screen.height;
var divtexthelp = document.getElementById('ulhelptext');
var divtextvideo = document.getElementById('ulhelpvideo');
	if(divtexthelp != null)
	{
	
			var IE = /*@cc_on!@*/false;
		if(IE){    
					if( width < 1281)
					{
					   
					   divtexthelp.style.marginLeft='-100px';
					     
					   divtextvideo.style.marginLeft='-235px';
					
					}
					else if( width > 1281 &&  width < 1400)
					{
					  
					   divtexthelp.style.marginLeft='0px';
					   
					   divtextvideo.style.marginLeft='135px';
					
					}
					
					else
					{
					 
					   divtextvideo.style.marginLeft='135px';
					
					}
		}
		else
		{
				if( width < 1281)
				{
				  
				   divtexthelp.style.marginLeft='-100px';
				    
				   divtextvideo.style.marginLeft='-100px';
				
				}
				else if( width > 1281 &&  width < 1400)
				{
				 
				   divtexthelp.style.marginLeft='0px';
					   
					   divtextvideo.style.marginLeft='0px';
				
				}
		
		}
	
	}
	

	


	var divLayer = document.getElementById('layer1'); 
	
	if(divLayer==null)
	return;

		var isShowHelp=GetCookie('Help');
		

		if(isShowHelp=="1")
		{
				setVisible('layer1',true);
				
				var hdnHelpLastDiv;
				
				var inputControls=document.getElementsByTagName('input');
						if(inputControls!=null && inputControls.length>0)
						{
							for(var i=0;i<inputControls.length;i++)
							{
								if(inputControls[i].type!=null && inputControls[i].type=='hidden')
								{
								
									if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnLastHelpDiv')
									{
									hdnHelpLastDiv=inputControls[i].value;
									}
								}
							}
						}
						
						if(hdnHelpLastDiv!=null && hdnHelpLastDiv!='')
						{
						

						expandcollapseHelp(hdnHelpLastDiv,'one');
						}
						else
						{
						expandcollapseHelp('divT3', 'one');
						}
						
					initdragableElements();
				
				}
				else
				{
				CloseHelpWindow('layer1');
				}
				
			
				
		var div = document.getElementById('divHelpBody'); 
		var objHelpWindowSize=GetCookie('HelpWindowSize');
 		if(objHelpWindowSize.length > 0)
    	 {

			div.style.height=objHelpWindowSize;
			var SelectObject=document.getElementById('selectWindowSize'); 
			for(index = 0;index < SelectObject.length;index++) 
			 {
			  	 if(SelectObject[index].value == objHelpWindowSize){
			  	
			     SelectObject.selectedIndex = index;
			     }
	   			}
		}
		
		
		
		
			

}

function ShowHelpMenuWindow()
{
		
		var divLayer = document.getElementById('layer1'); 

		
		if(divLayer==null)
			return;

		
		var isShowHelp=GetCookie('Help');
		if(isShowHelp=="0")
		{
			WriteCookie('Help','1','1');
			
			setVisible('layer1',true);



			var hdnHelpLastDiv;
			
			var inputControls=document.getElementsByTagName('input');
			if(inputControls!=null && inputControls.length>0)
			{
			for(var i=0;i<inputControls.length;i++)
			{
			if(inputControls[i].type!=null && inputControls[i].type=='hidden')
			{
			
			if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='hdnLastHelpDiv')
			{
			hdnHelpLastDiv=inputControls[i].value;
			}
			}
			}
			}
			if(hdnHelpLastDiv!=null && hdnHelpLastDiv!='')
			{
				var div = document.getElementById(hdnHelpLastDiv); 
				 if (div.style.display == "none")
				 {
				  expandcollapseHelp(hdnHelpLastDiv,'one');
				 }
			}
			else
			{
				var div = document.getElementById('divT3'); 
				 if (div.style.display == "none")
				 {

					expandcollapseHelp('divT3', 'one');
				 }
			}
			
			
		}
		
		initdragableElements();
		
		var div = document.getElementById('divHelpBody'); 
		var objHelpWindowSize=GetCookie('HelpWindowSize');
 		if(objHelpWindowSize.length > 0)
    	 {

			div.style.height=objHelpWindowSize;
			
			var SelectObject=document.getElementById('selectWindowSize'); 
			for(index = 0;index < SelectObject.length;index++) 
			 {
			  	 if(SelectObject[index].value == objHelpWindowSize){
			  	
			     SelectObject.selectedIndex = index;
			     }
	   			}

			
		}


}

 
function ChangeHelpWindowSize(divheight)
{

var div = document.getElementById('divHelpBody'); 

div.style.height=divheight;
WriteCookie('HelpWindowSize',divheight,'1');


}

function ChangeMenuOnResizeEvent()
{

	
	//var width = screen.width;
var width =document.body.clientWidth;
var height = screen.height;
var divtexthelp = document.getElementById('ulhelptext');
var divtextvideo = document.getElementById('ulhelpvideo');
	if(divtexthelp != null)
	{
	
			var IE = /*@cc_on!@*/false;
		if(IE){    
					if( width < 1281)
					{
					   
					   divtexthelp.style.marginLeft='-100px';
					     
					  divtextvideo.style.marginLeft='-235px';
					
					}
					else if( width > 1281 &&  width < 1400)
					{
					  
					  divtexthelp.style.marginLeft='0px';
					   
					   divtextvideo.style.marginLeft='135px';
					
					}
					
					else
					{
					 
					   divtextvideo.style.marginLeft='135px';
					
					}
		}
		else
		{
				if( width < 1281)
				{
				  
				   divtexthelp.style.marginLeft='-100px';
				    
				  divtextvideo.style.marginLeft='-100px';
				
				}
				else if( width > 1281 &&  width < 1400)
				{
				 
				 divtexthelp.style.marginLeft='0px';
					   
					   divtextvideo.style.marginLeft='0px';
				
				}
		
		}
	
	}
	




}


function LoginControlDefaultFocus()
{
	var inputControls=document.getElementsByTagName('input');
	

			if(inputControls!=null && inputControls.length>0)
			{
					

					for(var i=0;i<inputControls.length;i++)
					{
					

							if(inputControls[i].type!=null && inputControls[i].type=='text')
							{
							

									if(inputControls[i].id.split('_')[inputControls[i].id.split('_').length-1]=='UserName')
									{
									
									inputControls[i].select();
									
									}
							}
					}
			}
			
			

}

                                            
function SetHelpPanelStartupPosition()
{
var width =document.body.clientWidth;

	WriteCookie('demo','dragableElementClone0'+','+(width-340)+'px,100px,10002','1');
	
}





//Script for LO Popup
function openLOPage(queryString)
{
var objSession=GetCookie('UserSessionId');

var strWin = window.open(queryString+objSession ,"winShow");
        strWin.focus();

}


///add the checked value to hidden field
function AddItem(chkId, hdnFieldId,value) {
    try {

        var chk = document.getElementById(chkId);
         var hdn = document.getElementById(hdnFieldId);
        if (chk != null && hdn!=null) {
            if (chk.checked) {
               
                if (hdn.value.length == 0) {
                    hdn.value=value;
                }
                else {
                    hdn.value = hdn.value +","+ value;
                }
                
            }
            else {
           var items=hdn.value.split(',');
           items = removeItem(items, value)
           hdn.value = items.toString();
            }
        }
       
    }
    catch (e) {
    }
}

function Export(handler,rbtnId,wordValueId,uidCtrl,svcid)
{
try
{

var rbtn=document.getElementById(rbtnId);
var wordId=document.getElementById(wordValueId);
var uid=document.getElementById(uidCtrl);

var buttonList= rbtn.getElementsByTagName('input');


if(buttonList!=null && buttonList.length>0 && buttonList[2].checked)
{

if(wordId.value.length>0)
{

handler=handler+"?FileName="+wordId.value+".zip&UserId="+uid.value+"&ServiceId="+svcid;


window.open(handler);

}
else
{
alert('Please select Word(s).');

}
}
else
{
return true;
}


}
catch(e)
{
//alert(e.Message);
}


try
{

event.returnValue=false;
return false;
}
catch(e)
{
return false;
}
}

function openLOPageWithHelp(queryString)
{
var objSession=GetCookie('UserSessionId');
if(objSession==null)
{
objSession='00000000-0000-0000-0000-000000000000';
}
//alert(queryString+objSession+"&help=text");
var strWin = window.open(queryString+objSession+"&help=text" ,"winShow");
        strWin.focus();

}

function openLOPageWithHelpVideo(queryString)
{
var objSession=GetCookie('UserSessionId');
if(objSession==null)
{
objSession='00000000-0000-0000-0000-000000000000';
}
//alert(queryString+objSession+"&help=video");
var strWin = window.open(queryString+objSession+"&help=video" ,"winShow");
        strWin.focus();

}

