﻿// Added By : Amrik Goswami
// Added On : 22-10-08
// Page : Presentation.aspx

var strURL = new String();
strURL = location.href;     
if(strURL.indexOf("www",0) == -1)
{     
      var subURL = new String(strURL.substring(7,strURL.length));
      var domain = strURL.substring(7, 23)
      if(domain=="authorstream.com" || domain=="authorstream.com/")
      {
        var strFullURL = "http://www."+subURL;
        location.replace(strFullURL);  
      }
}
/* Featured Audio Div */
function ShowAudioDiv(Filter)
{
    document.getElementById("divAudioAjax").innerHTML="<div style='padding-top:10px;'><img src='" + m_strServerURL + "Images/loader.gif'/>&nbsp;<span>Loading...</span></div>";
    oXMLHTTP1=GetXmlHttpObject();
    var url=m_strServerURL + 'FeaturedPresentationDiv.aspx?vType=Audio&vFilter='+Filter;
    oXMLHTTP1.onreadystatechange=stateChangedAudio;
    oXMLHTTP1.open ('GET',url,true);
    oXMLHTTP1.send (null);
}
function stateChangedAudio()
{
    if (oXMLHTTP1.readyState==4 || oXMLHTTP1.readyState=="complete")
    {
         var txt = oXMLHTTP1.responseText;
         var sIndex = txt.indexOf("<div1");
         var LIndex = txt.indexOf("</form>")-1;
         txt = txt.substring(sIndex,LIndex);             
         document.getElementById("divAudioAjax").innerHTML="";
         document.getElementById("divAudioAjax").innerHTML=txt;
    }
}

/* Featured Animated Div */
function ShowAnimatedDiv(Filter)
{
    document.getElementById("divAnimatedAjax").innerHTML="<div style='padding-top:10px;'><img src='" + m_strServerURL + "Images/loader.gif'/>&nbsp;<span>Loading...</span></div>";
    oXMLHTTP2=GetXmlHttpObject();
    var url=m_strServerURL + 'FeaturedPresentationAnimatedDiv.aspx?vType=Animated&vFilter='+Filter;
    oXMLHTTP2.onreadystatechange=stateChangedAnimated;
    oXMLHTTP2.open ('GET',url,true);
    oXMLHTTP2.send (null);
}
function stateChangedAnimated()
{
    if (oXMLHTTP2.readyState==4 || oXMLHTTP2.readyState=="complete")
    {
         var txt = oXMLHTTP2.responseText;
         var sIndex = txt.indexOf("<div1");
         var LIndex = txt.indexOf("</form>")-1;
         txt = txt.substring(sIndex,LIndex);
         document.getElementById("divAnimatedAjax").innerHTML="";
         document.getElementById("divAnimatedAjax").innerHTML=txt;
    }
}
function GetXmlHttpObject()
{
    return (window.XMLHttpRequest)?(new XMLHttpRequest()):(new ActiveXObject("Microsoft.XMLHTTP"));
}
function openWindow()
{
    window.open(m_strServerURL + "ImportContacts.aspx",'',"left=0,top=0,width=700,height=600,status=1");
}
function ShowAroundUsDiv(Filter)
{    
    isPath1InUse = 1;        
    isPath2InUse = 0;        
    var imagePathToUseInIt;
    imagePathToUseInIt = 1;
   
    
    document.getElementById("divAroundUsAjax").innerHTML="<div style='padding-top:10px;'><img src='" + m_strServerURL + "Images/loader.gif'/>&nbsp;<span style='color:black'>Loading...</span></div>";
    oXMLHTTP4=GetXmlHttpObject();
    var url=m_strServerURL + 'AroundUsPresentationsDivDash.aspx?vType=ARoundUs&vFilter='+Filter+'&TotPages=5&PathToUse='+imagePathToUseInIt+'&ForDash=1';
    oXMLHTTP4.onreadystatechange=stateChangedShowAroundUsDiv;
    oXMLHTTP4.open ('GET',url,true);
    oXMLHTTP4.send (null); 
    
    if(imagePathToUseInIt == 2)
    {
        isPath2InUse = 0;
    }
    else
    {
        isPath1InUse = 0;            
    }
}
function stateChangedShowAroundUsDiv()
{
    if (oXMLHTTP4.readyState==4 || oXMLHTTP4.readyState=="complete")
    {
         var txt = oXMLHTTP4.responseText;
         var sIndex = txt.indexOf("<div1");
         var LIndex = txt.indexOf("</form>")-1;
         txt = txt.substring(sIndex,LIndex);
         document.getElementById("divAroundUsAjax").innerHTML="";
         document.getElementById("divAroundUsAjax").innerHTML=txt;
    }
}

var divName=null;
var divNameOld=null;
var divNameTopOld=null;
if (!document.all) document.onmousemove=MousePosition;
var mX;
var mY;

function MousePosition(e)
 {
    if (!document.all) {
	    mX = e.pageX + 10;
	    mY = e.pageY + 20;
    }			
}	    

function ShowProfileDiv(UserId,divNam,divTop)
{
    try{
        if (divNameOld != undefined)
            document.getElementById(divNameOld).style.display = "none";
    }catch(err){}
    try{
        if (divNameTopOld != undefined)
            document.getElementById(divNameTopOld).className = "";
    }catch(err){}
    
    divName = divNam;
    divNameOld = divNam;
    divNameTopOld = divTop;
    document.getElementById(divName).innerHTML="<div class='PopUpDiv'><img src='" + m_strServerURL + "Images/loader.gif'/>&nbsp;Loading...</div";
    var objDiv= document.getElementById(divName);
    objDiv.style.display="block";
    document.getElementById(divTop).className = "newcatdivyellowTop";
    var vn = getIEVersionNumber();
    if ( vn == 6)
        document.getElementById(divNam).className = "newcatdivmail6";

    oXMLHTTP=GetXmlHttpObject();
    var url=m_strServerURL + 'UserProfileDiv.aspx?Uid=' + UserId;
    oXMLHTTP.onreadystatechange=stateChanged;
    oXMLHTTP.open ('GET',url,true);
    oXMLHTTP.send (null);
}

function stateChanged()
{
    if (oXMLHTTP.readyState==4 || oXMLHTTP.readyState=="complete")
    {
         var txt = oXMLHTTP.responseText;                
         var sIndex = txt.indexOf("<div1>");
         var LIndex = txt.indexOf("</form>")-1;                 
         txt = txt.substring(sIndex,LIndex);   
         document.getElementById(divName).innerHTML=txt;
    }
}
function GetXmlHttpObject()
{
    return (window.XMLHttpRequest)?(new XMLHttpRequest()):(new ActiveXObject("Microsoft.XMLHTTP"));
}

function HideProfileDiv()
{
    try{
        if (divNameTopOld != undefined)
            document.getElementById(divNameTopOld).className = "newcatdivTop";
    }catch(err){}
    try{
        if (divName != undefined)
            document.getElementById(divName).style.display = "none";	
    }catch(err){}
}

   
function getIEVersionNumber() 
{
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    if (MSIEOffset == -1) 
        return 0;
    else 
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
}   
    
document.onclick = function(e)
{
    if (window.event) e = window.event; 
    var srcEl = e.srcElement? e.srcElement : e.target; 
    if(srcEl.id.indexOf('lnkProfile')==-1)
        HideAllDivs();   
    if(srcEl.id.indexOf('aHrefMoreActions')==-1 && srcEl.id.indexOf('lnkMarkAsGreeting')==-1 
        && srcEl.id.indexOf('divMoreActions')==-1)
        document.getElementById('divMoreActions').style.display='none';
}
function HideAllDivs()
{
    for(var i=0;i<5;i++)
    {
        if(document.getElementById('dlst_ctl0' +i + '_divProfile')!=undefined)
        {
            document.getElementById('dlst_ctl0' +i + '_divProfile').style.display = 'none';
        }    
        if(document.getElementById('dlstAnimated_ctl0' +i + '_divProfile')!=undefined)
        {
            document.getElementById('dlstAnimated_ctl0' +i + '_divProfile').style.display = 'none';
        }
    }
    HideProfileDiv();
}

/*//#A 052005 AP: To get the top position of the object*/
function TopPos(obj, pos)
{
    var topCoord = 0;
	while(obj)
	{
	   topCoord += obj.offsetTop;
	   obj = obj.offsetParent;
	}
	return topCoord + pos + 'px';
}

/*// #A 052005 AP: To get the left position of the object*/
function LeftPos(obj, pos)
{
    var leftCoord = 0;    
    while(obj)
	{
	   leftCoord += obj.offsetLeft;
	   obj = obj.offsetParent;	   
	}	
	return leftCoord + pos + 'px';
}

// Set More Actions
function DissLive()
{
    var m_strPresentationDetails = document.getElementById('hdnPresentationID').value;
    var m_strSplit = m_strPresentationDetails.split(",");
    var pun = m_strSplit[1];    
    pun = pun.replace('.','');
    window.open(m_strServerURL +"PresentLive/"+pun,'','top=0,left=0,status=no,resizable=no');
} 
var xy=null;
function openShare()
{      
    var m_strPresentationDetails = document.getElementById('hdnPresentationID').value;
    var m_strSplit = m_strPresentationDetails.split(",");    
    var PUN=m_strSplit[1];
    if(xy!=null)
    {   
        if(!xy.closed)
        {
            xy.close();
        }
    }        
    xy=window.open(m_strServerURL + "presentation-share.aspx?pun="+PUN,'',"left=0,top=0,width=600,height=560,status=1,scrollbars=yes");
    xy.focus();
} 

function ShowGreetingPopup()
{
    PopupShow('DivMarkAsGreetings','modalBackground');
    document.getElementById('divLoaderPassCode').style.display='none';
    document.getElementById('divEdit').style.display='block';
    document.getElementById('divUpdating').style.display='none';    
}

function HideGreetingPopup()
{
    document.getElementById('divLoaderPassCode').style.display='none';
    document.getElementById('divEdit').style.display='none';
    document.getElementById('divUpdating').style.display='block';
}

// previous items deleted because creating problem while selecting first option again clicking on Create Video link...
function FillNewItems(ctlID)
{
    document.getElementById(ctlID).length = 0;        
    var outupttypes_array=document.getElementById('hdnOutputTypes').value.split(",");        
    
    for(var i=0;i<outupttypes_array.length;i++)
        document.getElementById(ctlID).options[i]= new Option(outupttypes_array[i],outupttypes_array[i])
}

function fnSetDDL(ctlDDL,txtText)
{
    for(var i=0;i<=document.getElementById(ctlDDL).length-1;i=i+1)
    {
        var ddlText=document.getElementById(ctlDDL).options[i].value;
        if(ddlText==txtText)
        {
            document.getElementById(ctlDDL).selectedIndex=i;
            break;
        }
    }
}

/* Premium Flow : show create video popup (less than 5 mins) */
function ShowCreateVideoLessThan5mins()
{
//    FillNewItems('ddlOutputFormatsVideoLessThan5Mins');        
//    fnSetDDL('ddlTargetPlatformVideoLessThan5Mins',document.getElementById('hdnTargetPlatform').value);
//    fnSetDDL('ddlOutputFormatsVideoLessThan5Mins',document.getElementById('hdnOutputFormat').value);
//    fnSetDDL('ddlVideoSizeLessThan5Mins',document.getElementById('hdnVideoSize').value);    
    document.getElementById('ddlOutputFormatsVideoLessThan5Mins').setAttribute("AutoPostBack","true");
    
    document.getElementById('divVideoOptions').style.display = 'none';
    
    document.getElementById('rdoVideoWithWMark').checked = true;    
    document.getElementById('pptVideoOptions').style.display = 'none';
    document.getElementById('spnZoomSizeVideoLessThan5Mins').style.visibility = 'visible';
    document.getElementById('spnZoomSizeVideoMoreThan5Mins').style.visibility = 'visible';

    PopupShow('divVideoOptionLessThan5Mins','modalBackground');
    document.getElementById('hdnVideoFormatDefault').value = 0;
    
    document.getElementById("divMoreActions").style.display = "none";
    
    document.getElementById('divLoaderVideoOption').style.display='none';
    document.getElementById('divEditVideoOption').style.display='block';
    document.getElementById('divUpdatingVideoOption').style.display='none';
}

function HideVideoLessThan5minsPopup()
{
    document.getElementById('divLoaderVideoOption').style.display='none';
    document.getElementById('divEditVideoOption').style.display='none';
    document.getElementById('divUpdatingVideoOption').style.display='block';
    setTimeout("UpdateImg();",5);
}

/* Premium Flow : show create video popup (more than 5 mins) */
function ShowCreateVideoMoreThan5mins(iTotalPendingCredits)
{
//    FillNewItems('ddlOutputFormatsVideoMoreThan5Mins');    
//    fnSetDDL('ddlTargetPlatformVideoMoreThan5Mins',document.getElementById('hdnTargetPlatform').value);
//    fnSetDDL('ddlOutputFormatsVideoMoreThan5Mins',document.getElementById('hdnOutputFormat').value);
//    fnSetDDL('ddlVideoSizeMoreThan5Mins',document.getElementById('hdnVideoSize').value);
    
    document.getElementById('divVideoOptionsMore').style.display = 'none';
    
    document.getElementById('spnZoomSizeVideoMoreThan5Mins').style.visibility = 'visible';        
    document.getElementById('spnZoomSizeVideoLessThan5Mins').style.visibility = 'visible';
    document.getElementById('ddlOutputFormatsVideoMoreThan5Mins').setAttribute("AutoPostBack","true");
    if(iTotalPendingCredits > 0)
    {
        PopupShow('divVideoOptionMoreThan5Mins','modalBackground');    
        document.getElementById('hdnVideoFormatDefault').value = 0;
        document.getElementById('spnReededm').style.display='inline';
        document.getElementById('hdnRedeem').value = '1';
        document.getElementById('divLoaderVideoOptionMoreThan5Mins').style.display='none';
        document.getElementById('divEditVideoOptionMoreThan5Mins').style.display='block';
        document.getElementById('divUpdatingVideoOptionMoreThan5Mins').style.display='none';
    }
    else if(iTotalPendingCredits == -1)
    {
        document.getElementById('hdnRedeem').value = '0';
        PopupShow('divVideoOptionMoreThan5Mins','modalBackground');    
        document.getElementById('hdnVideoFormatDefault').value = 0;
        document.getElementById('spnReededm').style.display='none';
        document.getElementById('divLoaderVideoOptionMoreThan5Mins').style.display='none';
        document.getElementById('divEditVideoOptionMoreThan5Mins').style.display='block';
        document.getElementById('divUpdatingVideoOptionMoreThan5Mins').style.display='none';
    }
    else
    {
        PopupShow('divNoVideoOption','modalBackground');
    }
    document.getElementById("divMoreActions").style.display = "none";
}

function HideVideoMoreThan5minsPopup()
{
    document.getElementById('divLoaderVideoOptionMoreThan5Mins').style.display='none';
    document.getElementById('divEditVideoOptionMoreThan5Mins').style.display='none';
    document.getElementById('divUpdatingVideoOptionMoreThan5Mins').style.display='block';
    setTimeout("UpdateImg();",5); 
}

// Show Hide More Options and set the parameters value through hidden fields accordingly...
function ShowHideMoreOptions(ctlID,ctlDivID, presentationID,iPodEligible, conversionAPIId, featured,videoID, finalConversionStatus, 
    youtubeStatus, Job1Status, Job2Status, externalVideoUrl, isMovGenerated, totalFarmes, minFrames, FreeVideoFrames, serviceName, totalPendingCredits,ShowCreateVideoMinValue,ConversionInProgress, ConversionError,AccountID, VideoFormatID)
{
    /* Premium Flow : Create Video related... */
    var iTotalframes = eval(totalFarmes);
    var iMinFrames = eval(minFrames);
    var iFreeVideoFrames = eval(FreeVideoFrames);
    var iTotalPendingCredits = eval(totalPendingCredits);
    
    document.getElementById('spnMsg').style.display='none';
    document.getElementById('hdnPresentationID').value = presentationID;
    document.getElementById('hdnConversionAPIId').value = conversionAPIId;
    document.getElementById('hdnFeatured').value = featured;
    
    document.getElementById('spnVideoInProgress').style.display='none';
    document.getElementById('spnVideoFailed').style.display='none';
    document.getElementById('spnCreateVideo').style.display='none';
    document.getElementById('spnCreateVideoEnabled').style.display='none';
    
    // You tube related divs
    document.getElementById('spnYouTubeInProgress').style.display='none';
    document.getElementById('spnViewOnYouTube').style.display='none';
    document.getElementById('spnYouTubeSend').style.display='none';
    document.getElementById('aHrefSendToYouTube').style.display='none';    
    document.getElementById('spnYouTubeFailed').style.display='none';    
    
    // Replace Presentation
    if(ConversionInProgress=='True' && ConversionError=='')
    {
        document.getElementById('lnkReplacePresentation').style.display='none';
        document.getElementById('spnReplacePresentation').style.display='inline';
        document.getElementById('spnReplacePresentation').title = "Replace PowerPoint is in progress. Please check back after some time.";
    }
    else if(ConversionInProgress=='False' && ConversionError!='')
    {
        document.getElementById('lnkReplacePresentation').style.display='inline';
        document.getElementById('spnReplacePresentation').style.display='none';
        //document.getElementById('lblReplacePresentationMsg').innerHTML = "Your last attempt to Replace PowerPoint failed due to the reason:" + ConversionError;
    }
    else
    {
        document.getElementById('lnkReplacePresentation').style.display='inline';
        document.getElementById('spnReplacePresentation').style.display='none';
    }
    if(AccountID == '1' || AccountID == '2')
        document.getElementById('liReplacePresentation').style.display='none';
    else
        document.getElementById('liReplacePresentation').style.display='inline';
    
    // Premium Flow : new divs
    document.getElementById('spnCreateVideoLessThan5Min').style.display='none';
    document.getElementById('spnCreateVideoMoreThan5Min').style.display='none';
    var m_strText = 'Presentations set to play automatically (either rehearsed or narrated) and of duration less than 100 minutes can be converted in video.';
    m_strText = m_strText + ' If your presentation is set to play on click or total duration of presentation is greater than 100 minutes then you cannot convert presentation in video.';
    m_strText = m_strText + ' As video plays on some time line so you need to create a presentation which advances at its own as per timings set which can be achieved either';
    m_strText = m_strText + ' using add rehearse timing or narration feature of PowerPoint.';
    document.getElementById('lblCreateVideoMsg').innerHTML = m_strText;
    
    var mySplitResult = presentationID.split(',');
    if(eval(mySplitResult[0])<=eval(ShowCreateVideoMinValue))
    {
        document.getElementById('spnCreateVideoEnabled').style.display='none';
        document.getElementById('spnCreateVideo').style.display='inline';
        document.getElementById('lblCreateVideoMsg').innerHTML = 'Video of this presentation cannot be created.';
    }
    else
    {            
        // When there is no entry into tblPPtVideos table
        if(videoID=='0')
        {
            if(iPodEligible=='1' && ConversionInProgress=='False')
            {
                // to check if the video is less than 100 mins
                if(iTotalframes <= minFrames)
                {
                    // to check if the member subscribed for Premium Plus
                    if(serviceName.toUpperCase() == 'PP')
                    {
                        //document.getElementById('spnCreateVideoEnabled').style.display='inline';
                        //document.getElementById('spnCreateVideo').style.display='none';
                        
                        document.getElementById('aHrefCreateVideoMoreThan5min').onclick = function() {ShowCreateVideoMoreThan5mins(-1);}
                        document.getElementById('spnCreateVideoMoreThan5Min').style.display='inline';
                    }
                    else
                    {
                        // to check if the video is less than 5 mins than free
                        if(iTotalframes <= iFreeVideoFrames)
                        {
                            document.getElementById('aHrefCreateVideoLessThan5min').onclick = function() {ShowCreateVideoLessThan5mins();}
                            document.getElementById('spnCreateVideoLessThan5Min').style.display='inline';
                        }
                        else
                        {
                            document.getElementById('aHrefCreateVideoMoreThan5min').onclick = function() {ShowCreateVideoMoreThan5mins(iTotalPendingCredits);}
                            document.getElementById('spnCreateVideoMoreThan5Min').style.display='inline';
                        }
                    }
                }
                else
                {
                    document.getElementById('spnCreateVideoEnabled').style.display='none';
                    document.getElementById('spnCreateVideo').style.display='inline';
                }
            }
            else
            {
                document.getElementById('spnCreateVideoEnabled').style.display='none';
                document.getElementById('spnCreateVideo').style.display='inline';
            }
        }
        // When there is the entry into tblPPtVideos table
        else
        {
            if(finalConversionStatus=='0' && isMovGenerated == "0")
            {
                // to check if the video is less than 100 mins
                if(iTotalframes <= minFrames && ConversionInProgress=='False')
                {
                    // to check if the member subscribed for Premium Plus
                    if(serviceName.toUpperCase() == 'PP')
                    {
                        //document.getElementById('spnCreateVideoEnabled').style.display='inline';
                        //document.getElementById('spnCreateVideo').style.display='none';
                        
                        document.getElementById('aHrefCreateVideoMoreThan5min').onclick = function() {ShowCreateVideoMoreThan5mins(-1);}
                        document.getElementById('spnCreateVideoMoreThan5Min').style.display='inline';
                    }
                    else
                    {
                        // to check if the video is less than 5 mins than free
                        if(iTotalframes <= iFreeVideoFrames)
                        {
                            document.getElementById('aHrefCreateVideoLessThan5min').onclick = function() {ShowCreateVideoLessThan5mins();}
                            document.getElementById('spnCreateVideoLessThan5Min').style.display='inline';
                        }
                        else
                        {
                            document.getElementById('aHrefCreateVideoMoreThan5min').onclick = function() {ShowCreateVideoMoreThan5mins(iTotalPendingCredits);}
                            document.getElementById('spnCreateVideoMoreThan5Min').style.display='inline';
                        }
                    }
                }
                else
                {
                    document.getElementById('spnCreateVideoEnabled').style.display='none';
                    document.getElementById('spnCreateVideo').style.display='inline';
                }
            }
            else
            {
                var boolYouTube = 0;
                // Removed to check only if finalConversionStatus = 2
                if(Job2Status == '1' && Job1Status == "1")
                {
                    if(VideoFormatID.toUpperCase() =='ASIPOD')
                    {
                        document.getElementById('imgInProgress').src = m_strServerURL + 'images/uploadedipod.gif';
                        while(document.getElementById('spnConvertInVideo').innerHTML.indexOf('video')!=-1)
                        {
                            document.getElementById('spnConvertInVideo').innerHTML = document.getElementById('spnConvertInVideo').innerHTML.replace('video','ipod');
                        }
                        document.getElementById('spnInProgressTitle').innerHTML = document.getElementById('spnInProgressTitle').innerHTML.replace('video','ipod');
                    }
                    else
                    {
                        document.getElementById('imgInProgress').src = m_strServerURL + 'images/uploadedvidoe.gif';
                        while(document.getElementById('spnConvertInVideo').innerHTML.indexOf('ipod')!=-1)
                        {
                            document.getElementById('spnConvertInVideo').innerHTML = document.getElementById('spnConvertInVideo').innerHTML.replace('ipod','video');
                        }
                        document.getElementById('spnInProgressTitle').innerHTML = document.getElementById('spnInProgressTitle').innerHTML.replace('ipod','video');
                    }
                
                    document.getElementById('spnVideoInProgress').style.display='inline';
                    
                    document.getElementById('spnVideoFailed').style.display='none';
                    
                    setTimeout("UpdateImg();",5);
                    
                    // to disable the replace presentation link while video conversion 
                    document.getElementById('lnkReplacePresentation').style.display='none';
                    document.getElementById('spnReplacePresentation').style.display='inline';
                    document.getElementById('spnReplacePresentation').title='Replace PowerPoint will be enabled after video conversion success.';
                }
                else if(Job2Status == '2' || Job1Status == "2")
                {
                    SetYouTubeDetails(youtubeStatus, externalVideoUrl, ConversionInProgress, ConversionError);
                }
                else if(Job2Status == '3' || Job1Status == "3")
                {
                    document.getElementById('spnVideoFailed').style.display='inline';
                    document.getElementById('spnVideoInProgress').style.display='none';            
                }
                
                // To check if Job2Status = 2 then no need to check the final conversion = 2 for iPods
    //            if(boolYouTube==0)
    //            {
    //                if(finalConversionStatus=='1')
    //                {
    //                    document.getElementById('spnVideoInProgress').style.display='inline';
    //                    document.getElementById('spnVideoFailed').style.display='none';
    //                    
    //                    setTimeout("UpdateImg();",5);
    //                }
    //                else if(finalConversionStatus=='2')
    //                    boolYouTube = 1;
    //                else if(finalConversionStatus=='3')
    //                {
    //                    document.getElementById('spnVideoFailed').style.display='inline';
    //                    document.getElementById('spnVideoInProgress').style.display='none';            
    //                }
    //            }        
    //            if(boolYouTube==1)
    //                SetYouTubeDetails(youtubeStatus, externalVideoUrl);
            }
        }
    }
    document.getElementById(ctlDivID).style.display='inline';
    document.getElementById(ctlDivID).style.top=TopPos(document.getElementById(ctlID),-58);
    document.getElementById(ctlDivID).style.left=LeftPos(document.getElementById(ctlID),80);   
}

function UpdateImg()
{
    document.getElementById('gif_image').src=m_strServerURL + 'images/YoutubeloadingIcon.gif';
    document.getElementById('gif_image_transferring').src=m_strServerURL + 'images/YoutubeloadingIcon.gif';    
    
    document.getElementById('imgLoaderGreeting').src=m_strServerURL + 'images/loader.gif';
    document.getElementById('imgLoaderVideoOption').src=m_strServerURL + 'images/loader.gif';
    document.getElementById('imgLoaderVideoOptionMoreThan5Mins').src=m_strServerURL + 'images/loader.gif';
}

function SetYouTubeDetails(youtubeStatus, externalVideoUrl, ConversionInProgress, ConversionError)
{
    if(youtubeStatus=='0' || youtubeStatus == '1')
    {    
        document.getElementById('spnYouTubeInProgress').style.display='inline';
        setTimeout("UpdateImg();",5);
        //In Progress
        
        document.getElementById('lnkReplacePresentation').style.display='none';
        document.getElementById('spnReplacePresentation').style.display='inline';
        document.getElementById('spnReplacePresentation').title = "Send to YouTube is in progress. Please check back after some time.";
    }
    else if(youtubeStatus=='2')
    {
        document.getElementById('spnViewOnYouTube').style.display='inline';
        document.getElementById('anchorYouTubeView').href = externalVideoUrl;
        document.getElementById('anchorYouTubeViewImg').href = externalVideoUrl;        
        //view on u tube        
    }
    else if(youtubeStatus=='4')
    {
        document.getElementById('spnYouTubeFailed').style.display='inline';
        //Failed
    }
    else if(youtubeStatus=='-1' || youtubeStatus == '3')
    {
        if(ConversionInProgress=='True' && ConversionError=='')
            document.getElementById('aHrefSendToYouTube').style.display='inline';
        else
            document.getElementById('spnYouTubeSend').style.display='inline';
            //Send to You Tube --Enable that span.        
    }    
    document.getElementById('spnVideoInProgress').style.display='none';
    document.getElementById('spnVideoFailed').style.display='none';
}

/********** You Tube Related Methods - Starts Here... ************/
function ShowYoutubeInfo()
{
    PopupShow('divYoutube','modalBackground');
    
    document.getElementById("txtUsername").value = "";
    document.getElementById("txtPwdYouTube").value = "";
        
    document.getElementById("divLoaderYoutube").style.display = "none";
    document.getElementById("divYoutubeEdit").style.display = "block";
    document.getElementById("txtUsername").focus();
    document.getElementById("divYoutubeUpload").style.display = "none"; 
}

function YoutubeAfterLoginSettings()
{
    var varYs = document.getElementById("hdnYoutubeStatus").value;        
    if ( varYs == "1")
    {
        PopupShow('divYoutube','modalBackground');
        document.getElementById("divLoaderYoutube").style.display = "none";
        document.getElementById("divYoutubeUpload").style.display = "block";            
        document.getElementById("btnSendYoutube").focus();           
    }
    else
    {
        PopupShow('divYoutube','modalBackground');
        document.getElementById("divLoaderYoutube").style.display = "none";
        document.getElementById("divYoutubeEdit").style.display = "block";
        document.getElementById("lblYoutubeMsg").innerHTML  ="Sorry, your login was incorrect.";
        document.getElementById("tblYoutube").className  ="redbardiv";
    }
}

function ValidateYoutubeLogin()
{
    var Validation = true;
    var Error = true;
    var varUsername = document.getElementById("txtUsername");
    var varPassword = document.getElementById("txtPwdYouTube");
    if (varUsername.value == "")
    {
       Validation = false;
       varUsername.style.border = "2px solid #D00B0B";
       varUsername.focus();
    }
    else
    {            
       varUsername.style.border = "2px solid #DFDFDF";                
    } 
    if (document.getElementById("txtPwdYouTube").value.length==0)
    {
       Validation = false;
       varPassword.style.border = "2px solid #D00B0B";
       varPassword.focus();
    }
    else
    {            
       varPassword.style.border = "2px solid #DFDFDF";                
    } 
     
    if (Validation == false)
    {   
        document.getElementById("lblYoutubeMsg").innerHTML  ="*Some fields were missed.";
        document.getElementById("tblYoutube").className  ="redbardiv";
    }
    if(Validation == true)
    {          
       document.getElementById("divLoaderYoutube").style.display = "block";
       document.getElementById("divYoutubeEdit").style.display = "none";
       document.getElementById("lblYoutubeLoader").innerHTML = "Processing...";
    }
    return Validation;
} 
/********** You Tube Related Methods - Ends Here... ************/

function ShowToolTipDIv(e,id,ctlPlaceID,ctlType)
{
    document.getElementById(id).style.display='block';
    if(ctlType==1)
    {
        document.getElementById(id).style.top=TopPos(document.getElementById(ctlPlaceID),-270);
        document.getElementById(id).style.left=LeftPos(document.getElementById(ctlPlaceID),-160);        
    }
    else if(ctlType==0)
    {
        document.getElementById(id).style.top=TopPos(document.getElementById(ctlPlaceID),-205);
        document.getElementById(id).style.left=LeftPos(document.getElementById(ctlPlaceID),-163);
    }
    else if(ctlType==2)
    {
        document.getElementById(id).style.top=TopPos(document.getElementById(ctlPlaceID),-145);
        document.getElementById(id).style.left=LeftPos(document.getElementById(ctlPlaceID),-160);
    }
    else if(ctlType==3) // for no video credits left popup
    {
        document.getElementById(id).style.top=TopPos(document.getElementById(ctlPlaceID),25);
        document.getElementById(id).style.left=LeftPos(document.getElementById(ctlPlaceID),-170);
    }
    else if(ctlType==4)
    {
        document.getElementById(id).style.top=TopPos(document.getElementById(ctlPlaceID),-180);
        document.getElementById(id).style.left=LeftPos(document.getElementById(ctlPlaceID),-160);
    }
}

function HideToolTipDIv(id)
{
    document.getElementById(id).style.display='none';
}

function ShowHideVideoOptions(ctlMoreOptions, spnShowVideoOptions)
{
    document.getElementById('hdnVideoFormatDefault').value='1';
    document.getElementById(ctlMoreOptions).style.display='block';
    document.getElementById(spnShowVideoOptions).style.display='none';
}

function VideoFormatsChanged(primaryDropDown,spanIdToHideForIpod,destinationDropDownIdNormal,destinationDropDownIdForWeb,dropDownIdOfZoom,spnShowVideoOptionsLess5)
{    
    operation = document.getElementById(primaryDropDown).selectedIndex;
    document.getElementById(dropDownIdOfZoom).selectedIndex = 0;//1 index is of FLV in this case
    
    if(spnShowVideoOptionsLess5!='')
    {
        document.getElementById(spnShowVideoOptionsLess5).style.display='inline';
    }
    if(operation == '1')
    {
        document.getElementById(spanIdToHideForIpod).style.display='none';
    }
    else
    {
        document.getElementById(spanIdToHideForIpod).style.display='inline';
        if(operation == '2')
        {
            document.getElementById(destinationDropDownIdForWeb).style.display='inline';
            document.getElementById(destinationDropDownIdNormal).style.display='none';
            document.getElementById(destinationDropDownIdForWeb).selectedIndex = 1;//1 index is of FLV in this case
            document.getElementById(dropDownIdOfZoom).selectedIndex = 1;//1 index is of 2x
        }
        else if(operation == '0')
        {
            document.getElementById(destinationDropDownIdForWeb).style.display='none';
            document.getElementById(destinationDropDownIdNormal).style.display='inline';
            document.getElementById(destinationDropDownIdNormal).selectedIndex = 1; //1 index is of MPEG in this case            
        }
    }    
}