﻿                                   
        var div;
        var objMediaPlayer;
        var objFlashPlayer;
        var objSource;
        var divClose;
        var divLogo;
        var divPlayer;       
        var ts;
        var i = 0;                
        var stat;  
        var DivTitle;
        var DivSummary;
        var imgObj;
        var objTitle;
        var mediaTitle;
           


//        function showMovieTab(id)
//        {
//            var boxOffice = document.getElementById('boxOffice').style;
//            var reviews = document.getElementById('reviews').style;
//            var tabBoxOffice = document.getElementById('tabBoxOffice').style;
//            var tabReviews = document.getElementById('tabReviews').style;            
//                                    
//            tabBoxOffice.backgroundColor="white";
//            tabReviews.backgroundColor="white";
//           
//            if(id == "reviews")
//            {
//                reviews.display = "block";
//                boxOffice.display = "none";
//                tabReviews.backgroundColor="gray";
//            }
//            else
//            {
//                boxOffice.display = "block";
//                reviews.display = "none";
//                tabBoxOffice.backgroundColor="gray";
//            }
//        }
        
        function downloadme(x)
        {    
            myTempWindow = window.open(x,"","left=10000,screenX=10000");
            alert(x);    
            myTempWindow.document.execCommand("SaveAs","null",x);
            myTempWindow.close();
        }

        function closeMedia()
        {
             divClose = document.getElementById('divClose').style; 
             divLogo = document.getElementById('videopiologo').style;
             divPlayer = document.getElementById('videoplayer').style;
             div = document.getElementById('mediaContainer');
             objSource = document.getElementById('sourcepath');
           
             objSource.value = '';  
                                      
             divLogo.display = 'none';
             divPlayer.display = 'none';
             divClose.display = 'none';
             
             div.style.backgroundColor="white";
          
             objFlashPlayer = document.getElementById('objFlashPlayer');                      
                                                   
             objFlashPlayer.style.display = 'none';  
             objFlashPlayer.style.width = '0px';
             objFlashPlayer.style.height = '0px'; 
             objFlashPlayer.innerHTML = '';         
              
             $find('modalMedia').hide();                                                                                                 
        }

        function grow()
        {   
             div.backgroundColor="";                             
             div.top="0px";
             div.left="0px";   
             
             divClose = document.getElementById('divClose').style; 
             divLogo = document.getElementById('videopiologo').style;
             divPlayer = document.getElementById('videoplayer').style;
             
             divLogo.display = 'block';
             divPlayer.display = 'block';
             divClose.display = 'block';                                       
                                          
             if(stat=='Video')
             {
                 showVideo();

             } 
        }                       
                           
        function showMedia(objbutton,status,title) {        
           var mediaMain = document.getElementById('mediaMain').style;                                                                  
           div = document.getElementById('mediaContainer').style;

           objSource = document.getElementById('sourcepath');
           objSource.value = objbutton.title;         
           objTitle = title;
           
           //alert(objbutton.title);                                      
           mediaMain.display = 'block';                    
           
           div.height ='0px';
           div.width = '0px';   
           div.top = '169px';   
           div.left ='340px';    
           stat = status;
           if (stat == 'Audio') {
               window.open('/pio/layouts/AudioPlayer.aspx?title=' + objTitle, 'audio', 'width=484,height=30,top=820,left=0,scrollbars=no,titlebar=no,resizable=no,status=no,toolbar=no,menubar=no,location=no');               
            }
            else
            {
                $find('modalMedia').show();
                grow(); 
            }
        }

        function showRSSMedia(source, title) {
            var mediaMain = document.getElementById('mediaMain').style;
            div = document.getElementById('mediaContainer').style;

            objSource = document.getElementById('sourcepath');
            objSource.value = source;
            objTitle = title;

            //alert(objbutton.title);                                      
            mediaMain.display = 'block';

            div.height = '0px';
            div.width = '0px';
            div.top = '169px';
            div.left = '340px';
            window.open('/pio/layouts/AudioPlayer.aspx?title=' + objTitle, 'audio', 'width=484,height=30,top=820,left=0,scrollbars=no,titlebar=no,resizable=no,status=no,toolbar=no,menubar=no,location=no');
            
        }
        
        function showMediaPodCast(objbutton, status, title) {
           var selected = $('#dateDropdown').val();
           var array = selected.split("~|~");
           var selected = array[0];
           var selectedtitle = array[1];
           var stitle = selectedtitle;
           //alert(selectedtitle);
           //var selectedtitle = document.getElementById('optionId').title;
           var mediaMain = document.getElementById('mediaMain').style;                                                                  
           div = document.getElementById('mediaContainer').style;
           
           objSource = document.getElementById('sourcepath');
           objSource.value = selected;
           objbutton.title = selected;
           //var dropdownlisten = document.getElementById('dropDownListen');
           var dropdowndownload = document.getElementById('dropDownDownload');
           dropdowndownload.href = selected;

           mediaMain.display = 'block';                    
           
           div.height ='0px';
           div.width = '0px';   
           div.top = '169px';   
           div.left ='340px';    
           stat = status;
                                    
            if(stat=='Audio')
            {
                window.open('/pio/layouts/AudioPlayer.aspx?title=' + stitle, 'audio', 'width=484,height=30,top=820,left=0,scrollbars=no,titlebar=no,resizable=no,status=no,toolbar=no,menubar=no,location=no');
            }
            else
            {

                window.location = selected;
//                alert("!");
//                document.execCommand("SaveAs");
////                window.location.replace('download.asp'); 

//               document.execCommand("SaveAs");
//                grow(); 
//                document.execCommand("SaveAs",false,window.location);
//                popdocument(selected,objSource);
            }
        }

        function updateTitle(obj) 
        {
            var selected = $('#dateDropdown').val();
            var array = selected.split("~|~");
            var selectedUrl = array[0];

            var dropdownlisten = document.getElementById('dropDownListen');
            var dropdowndownload = document.getElementById('dropDownDownload');
            dropdownlisten.title = selectedUrl;
            dropdowndownload.href = selectedUrl;
            dropdowndownload.title = selectedUrl;
            
        }
        
        function popdocument(itemCode,dir) 
        { 
            document.execCommand("SaveAs",false,itemCode) 
        }


        function redirectCultureClipsArchive()
        {
            var selected = $('#archiveIssues').val();
            window.location = selected;
        }
                
        function showVideoBABAndBO(status)
        {
            var selected = $('#bobandBillEpisodes').val();
            
            if(selected == '1')
                return;
            
            var mediaMain = document.getElementById('mediaMain').style;                                                                  
            div = document.getElementById('mediaContainer').style;
           
           objSource = document.getElementById('sourcepath');
           objSource.value = selected;
           
           mediaMain.display = 'block';                    
           
           div.height ='0px';
           div.width = '0px';   
           div.top = '169px';   
           div.left ='340px';    
            stat = status;  
            $find('modalMedia').show();
            grow(); 
        }

        function showVideo()
        {      
                                  
              objFlashPlayer = document.getElementById('objFlashPlayer');
              var vars = "&ControlPanelColor=0xffffff&buttonColor=0x000000&ControlPanelPosition=0&showControlPanel=1&ShowtimeColor=0xffffff&autostart=true&bAutoRepeat=0&BufferTime=1&tmeColor=0xffffff&loaColor=0x666666&GroundColor=0x000000&conNum=5&bShowtime=1&startvolume=100";             

              objSource = document.getElementById('sourcepath');                                                                             
                                                 
              var video = objSource.value + vars;

              var s1 = new SWFObject("/pio/scripts/player.swf", "single", "484", "221", "9", "#003399");
              objFlashPlayer.style.display = 'block'; 
              objFlashPlayer.style.top = '17px';              
              objFlashPlayer.style.left = '16px';  
                 s1.addVariable('displayheight','221');
                 s1.addParam('allowfullscreen','true');
                 s1.addParam('menu','false');
                 s1.addVariable('file',video);                 
                 s1.write('objFlashPlayer');  
                 
                                                                                                                                                                                                
                     
        }
             
             
        function showAudios()
        {
            var vars = "&ControlPanelColor=0xffffff&buttonColor=0x000000&ControlPanelPosition=0&showControlPanel=1&ShowtimeColor=0xffffff&autostart=true&bAutoRepeat=0&BufferTime=1&tmeColor=0xffffff&loaColor=0x666666&GroundColor=0x000000&conNum=5&bShowtime=1&startvolume=100";             
            var browser = navigator.appName;   
                       
            objSource =  opener.document.getElementById('sourcepath');
                 
            objMediaPlayer = document.getElementById('objMediaPlayer');
            
            var video = objSource.value + vars;
            //var video = path + vars;

            //var s1 = new SWFObject("/pio/scripts/player.swf", "single", "484", "100", "9", "#003399");
            var s1 = new SWFObject("/pio/scripts/player15.swf", "single", "484", "100", "9", "#003399");//player15 have no full screen button
           //alert(s1);
            objMediaPlayer.style.display = 'block';
              objMediaPlayer.style.top = '0px';
              objMediaPlayer.style.left = '0px';
              s1.addVariable('displayheight', '0');
              s1.addVariable('allowfullscreen', 'false');
              s1.addParam('wmode', 'opaque');
              s1.addVariable('type', 'sound');
             s1.addParam('menu', 'false');
             s1.addVariable('file', video);
             s1.write('objMediaPlayer');
        }
                
        function changePath(btnVideo,btnAudio,audiopath,videopath,strtitle)
        {                                                                                  
           var video = document.getElementById(btnVideo);
           var audio = document.getElementById(btnAudio);

           video.title = videopath;
           audio.title = audiopath;

           //video.onclick = function() { addEvent('Video', strtitle); }
           //audio.onclick = function() { addEvent('Audio', strtitle); }

        }

        function addEvent(type,mediatitle) 
        {
            if (type == 'Video') 
            {
                showMedia(this, 'Video', mediatitle); return false;
            }
            else if (type == 'Audio') 
            {
                showMedia(this, 'Audio', mediatitle); return false;
            }
        }

        function loadTitle(obj, type) 
        {
            DivTitle = document.getElementById(DivTitle);
            mediaTitle = obj.title;
            
            if (type == 'Video') 
            {
                showMedia(obj, 'Video', mediaTitle); return false;
            }
            else if (type == 'Audio') 
            {
                showMedia(obj, 'Audio', mediaTitle); return false;
            }
            
            //audio.onclick = showMedia(this, 'Audio', strtitle); return false;
            //video.onclick = showMedia(this, 'Video', strtitle); return false;
            //load(obj);
        }
        
        function convertQuotes(string){
          var text = string.replace(/&qte/g,"\'");
          text = text.replace(/&dqte/g,"\"");
          text = text.replace(/&comma/g,",");
          return text;
        }

        function changeDisplay(obj,btnVideo, btnAudio, strTitle, strSummary, img, imgObj, DivTitle, DivSummary, audiopath, videopath, source, readURL, readLink)
        {
            DivTitle = document.getElementById(DivTitle);
            DivSummary = document.getElementById(DivSummary);
            hrefReadLink = document.getElementById(readLink);
            hrefMainImage = document.getElementById(imgObj + 'Link');
            imgObj = document.getElementById(imgObj);

            load(obj);
            
            hrefMainImage.href = readURL;       
            hrefReadLink.href = readURL;
            DivTitle.href = readURL;                    
            DivTitle.innerHTML = convertQuotes(strTitle);
            DivSummary.innerHTML = convertQuotes(strSummary);    
                       
            imgObj.src = img;

            toggleWatchListenLink(audiopath, videopath, source);
            changePath(btnVideo,btnAudio,audiopath,videopath,strTitle);                         
                                                                                                                                                                                                                                         
        }
        
        function toggleWatchListenLink(audiopath,videopath,source)
        {
            if(source == 'movie')
            {
                var lnkWatch = document.getElementById('watchLinkHrefMovie'); 
                var lnkListen = document.getElementById('listenLinkHrefMovie');    
            }
            else if(source == 'video')
            {
                var lnkWatch = document.getElementById('watchLinkHrefVideo');    
                var lnkListen = document.getElementById('listenLinkHrefVideo');    
            }
            
            if(videopath != '')
            {
                lnkWatch.style.display = 'block';    
            }
            else
            {
                lnkWatch.style.display = 'none';    
            }   
            
            if(audiopath != '')
            {
                lnkListen.style.display = 'block';    
            }
            else
            {
                lnkListen.style.display = 'none';    
            }
            
        }
        
        function toggleWatchListenLinkForLandingPages(audiopath,videopath,watchrcid,listenrcid)
        {
            
            var lnkWatch = document.getElementById(watchrcid); 
            var lnkListen = document.getElementById(listenrcid);    
            
            if(videopath != '')
            {
                lnkWatch.style.display = 'block';    
            }
            else
            {
                lnkWatch.style.display = 'none';    
            }
            
            if(audiopath != '')
            {
                lnkListen.style.display = 'block';    
            }
            else
            {
                lnkListen.style.display = 'none';    
            }
        }

        function display(obj, btnVideo, btnAudio, strTitle, strSummary, img, imgObj, DivTitle, DivSummary, audiopath, videopath, source, readURL, readLink,listId)
        {
            if (listId == 1) {
                DivTitle = document.getElementById(DivTitle);
                DivSummary = document.getElementById(DivSummary);
                hrefMainImage = document.getElementById(imgObj + 'Link');
                imgObj = document.getElementById(imgObj);
                hrefReadLink = document.getElementById(readLink);

                //browserVal(obj, true);
                //fadeObject(obj);
                imgObj.src = img;
                
                hrefMainImage.href = readURL;
                hrefReadLink.href = readURL;
                DivTitle.href = readURL;
                DivTitle.innerHTML = convertQuotes(strTitle);
                DivSummary.innerHTML = convertQuotes(strSummary);

               

                toggleWatchListenLink(audiopath, videopath, source);
                changePath(btnVideo, btnAudio, audiopath, videopath, strTitle);
            }
            else {
                browserVal(obj, true);
                //fadeObject(obj);
            }        
                                                   
        }
                              
        function load(obj)
        {                        
            browserVal(obj,false);           
            fadeObject(obj);                   
        }
        
        function browserVal(obj,isFaded)
        {
            var opacityVal = 100;  
            var browser = navigator.appName;   
            if(browser == "Microsoft Internet Explorer")
            {              
                if(isFaded)
                {
                    opacityVal = 40;
                }               
                obj.style.filter = 'alpha(opacity=' + opacityVal.toString() + ')';                               
            }
            else
            {      
                if(isFaded)
                {
                    opacityVal = 0.40;
                }          
                obj.style.opacity = opacityVal;              
            }                   
        }
     
        function fadeObject(obj)
        {                              
            var container = document.getElementById(obj.parentNode.parentNode.id);
            var obj2;
            var isSelected = false;    
            var nodelength = container.childNodes.length;
            var browser = navigator.appName;   
           // obj.onmouseout = function mouseOut(e)            
           // {                                                                                                                                                            
           //      browserVal(obj,false);
            // }

            obj.onmousemove = function mouseMove(e) {
                if (browser == "Microsoft Internet Explorer") {
                    for (i = 0; i < nodelength; i++) {
                        obj2 = container.childNodes[i].childNodes[0];
                        browserVal(obj2, true);
                    }
                    browserVal(obj, false);
                }
                else {
                    for (var i = 0; i < nodelength; i++) {
                        //alert(container.childNodes[i].childNodes[1].nodeName);
                        if (container.childNodes[i].nodeName == "#text") continue;
                        for (var j = 0; j < container.childNodes[i].childNodes.length; j++) 
                        {
                            if (container.childNodes[i].childNodes[j].nodeName == "#text") continue;
                            obj2 = container.childNodes[i].childNodes[j];
                        }                       
                        browserVal(obj2, true);
                        //alert(obj3.name);

                        //alert(i + container.childNodes[i].childNodes[1].id);

                    }
                    browserVal(obj, false);

                }
            }                                  
                                                                                                                                                                        
        }
        
// Print current date function

var d_names = new Array("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday");

var m_names = new Array("January", "February", "March", 
"April", "May", "June", "July", "August", "September",
"October", "November", "December");

var d_names_spanish = new Array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado");
var m_names_spanish = new Array("Enero", "Febrero", "Marzo",
"Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre",
"Octubre", "Noviembre", "Diciembre");

var d = new Date();
var curr_day = d.getDay();
var curr_date = d.getDate();
var sup = "";
if (curr_date == 1 || curr_date == 21 || curr_date ==31)
   {
   sup = "st";
   }
else if (curr_date == 2 || curr_date == 22)
   {
   sup = "nd";
   }
else if (curr_date == 3 || curr_date == 23)
   {
   sup = "rd";
   }
else
   {
   sup = "th";
   }
var curr_month = d.getMonth();
var curr_year = d.getFullYear();

function getSendItInfo() {
    return parent.location = "mailto:?body=" + window.location;
}

function postdata(IDString,isSearch) {
    var theForm = document.getElementById("aspnetForm");
    var inputInfo = document.getElementById(IDString).value;   
    if (isSearch) {
        //theForm.action = "http://search.pluggedinonline.com/search";
        //theForm.method = "POST";
        document.location.href="http://172.17.101.41/search?q="+inputInfo+"&btnG=Search&filter=&entqr=0&output=xml_no_dtd&sort=date%3AD%3AL%3Ad1&client=dev_pluggedinonline_com&filter=&ud=1&oe=UTF-8&ie=UTF-8&proxystylesheet=dev_pluggedinonline_com";
    }
    else {
        var eNewsletterUrl = document.getElementById("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_eNewsLetterUrl").value;
        //theForm.action = "https://www.family.org/email-profile/index.cfm";
        //theForm.action = "http://www.focusonthefamily.com/enewsletter/layouts/AccountManagement.aspx?EmailAddressFromLogin="+emailAddress;
        var email = document.getElementById("enewsletterText").value;
        if (email == 'Enter e-mail address') {
            email = '';
        }
        document.location.href = eNewsletterUrl + "&EmailAddress=" + email;
        
    }
    
    return false;    
}




