﻿var nowPlaying = 0;

function isChecked(source,args)
{	try 
	{	var chkListaTipoModificaciones= document.getElementById ('chkRegion');
		var chkLista= chkListaTipoModificaciones.getElementsByTagName("input");
		for(var i=0;i<chkLista.length;i++)
		{   if(chkLista[i].checked)
			{	args.IsValid = true;
				return;	}
		}
	} catch (e) {}
	args.IsValid = false;
}
function closeME()
{	alert('You are now subscribed to our PodCast via "' + document.getElementById('txtEmail').value + '" email account.');
	self.close();
}

function showAuth()
{ popHlp(document.getElementById("hdnOthInfoID").value);   }

function initFlashObject()
{	AC_FL_RunContent( 'codebase'
						,'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'
						,'id','FLVPlayer'
						,'name','FLVPlayer'
						,'width','320'
						,'height','256'
						,'src','FLVPlayer.swf'
						,'allowScriptAccess','sameDomain'
						,'allowFullScreen','true'
						,'bgcolor','#000000'
						,'align','middle'
						,'quality','high'
						,'pluginspage','http://www.macromedia.com/go/getflashplayer'
						,'movie','FLVPlayer' ); 
	tryInitNxtVDO();
}
	
function tryInitNxtVDO()
{	window.setTimeout("getNextVideo(0)", 1000);	}

function playVDO(wpid, oid)
{   document.getElementById("hdnOthInfoID").value = oid;
    document.getElementById("hdnWPID").value = wpid;
    document.getElementById("lblAuthor").innerHTML = document.getElementById("auth" + wpid).innerHTML + " ";
    document.getElementById("lblLength").innerHTML = '[' + document.getElementById("dur" + wpid).innerHTML + '] ';
    document.getElementById("lblTitle").innerHTML = document.getElementById("tit" + wpid).innerHTML ;
    document.getElementById("lblUplDt").innerHTML = document.getElementById("upldt" + wpid).innerHTML;
    document.getElementById("lbldesc").innerHTML = document.getElementById("hdnDesc" + wpid).value + "  ";
    playFLV('http://podcasts.am.joneslanglasalle.com/videos/' + wpid + '.flv##' + wpid);   
}

function getFlashMovieObject()
{	var movieName = "FLVPlayer";
	if(document.embeds[movieName])
		return document.embeds[movieName];
	if(window.document[movieName])
		return window.document[movieName];
	if(window[movieName])
		return window[movieName];
	if(document[movieName])
		return document[movieName];
	return null;
}

function onPlayVideo(value) 
{	var oFlv = getFlashMovieObject();
	oFlv.onPlayVideo(value);  }

function onNextVideo(value) 
{	var oFlv = getFlashMovieObject();
	oFlv.onNextVideo(value);	}

function getNextVideo(wpid) 
{	try {	var nxtVDO = 0;
			var allVDOs = document.getElementById("hdnAllWPIDs").value.split(',');
			var i;
			for (i=0; i<allVDOs.length; i++)
			{	if (allVDOs[i] == wpid) 
				{   if (i!=0)
						nxtVDO = allVDOs[i-1];
					else
						nxtVDO = allVDOs[0];
					break;    }
			}
			if (nxtVDO == 0)
				nxtVDO = allVDOs[i-2];
			var nxtVideoData= document.getElementById("auth" + nxtVDO).innerHTML + "##<b>" + document.getElementById("tit" + nxtVDO).innerHTML + '</b>\n' + document.getElementById("hdnDesc" + nxtVDO).value + "##http://podcastfiles.am.joneslanglasalle.com/u/Images/s" + nxtVDO + ".jpg##http://podcasts.am.joneslanglasalle.com/videos/" + nxtVDO+ ".flv##" + nxtVDO;
			onNextVideo(nxtVideoData);	}
	catch (e)
		{	tryInitNxtVDO();	}
}

function playFLV(args)
{   var playVideoData=args;
    onPlayVideo(playVideoData); }

function mTo(id)
{   var tempFolder = '/';
    window.location.href="mailto:?cc=OneViewPodcasts@am.jll.com&subject=Insights from Jones Lang LaSalle: " + document.getElementById('tit' + id).innerHTML.replace(/"/g,'*') + "&body=" + document.getElementById('hdnDesc' + id).innerHTML.replace(/"/g,'*') + ' - ' + document.getElementById('auth' + id).innerHTML + "     - To view this Podcast, please visit http://" + document.domain + tempFolder + "?id=" + id  ; 
}

function mToPC(id,rgn)
{	var rgnNm = 'AM';
	if (rgn!=1)
		rgnNm = 'AP';
	var tempFolder = '/';
    window.location.href="mailto:" + document.getElementById('auth' + id).innerHTML.replace(' ','.') + "@" + rgnNm + ".jll.com?cc=OneViewPodcasts@am.jll.com&subject=About your Podcast: " + document.getElementById('tit' + id).innerHTML.replace(/"/g,'*') + "&body=" + document.getElementById('hdnDesc' + id).innerHTML.replace(/"/g,'*') + ' - ' + document.getElementById('auth' + id).innerHTML + "     - To view this Podcast, please visit http://" + document.domain + tempFolder + "?id=" + id  ; 
}


function CreateBookmarkLink() 
{   if (window.sidebar) { 
		// Mozilla Firefox Bookmark		
		window.sidebar.addPanel(document.title, location.href,"");	
	} else if( window.external ) { 
		// IE Favorite
		window.external.AddFavorite(location.href, document.title); 
	} else if(window.opera && window.print) { 
		// Opera Hotlist		
		return true; 
	}
}
	
/*
{   alert(location.href);
    alert(document.title);
    var url = location.href;
    var title = document.title;
    var ua=navigator.userAgent.toLowerCase();
    var isKonq=(ua.indexOf('konqueror')!=-1);
    var isSafari=(ua.indexOf('webkit')!=-1);
    var isMac=(ua.indexOf('mac')!=-1);
    var buttonStr=isMac?'Command/Cmd':'CTRL';
    
    if(window.external && (!document.createTextNode ||
      (typeof(window.external.AddFavorite)=='unknown'))) {
        // IE4/Win generates an error when you
        // execute "typeof(window.external.AddFavorite)"
        // In IE7 the page must be from a web server, not directly from a local 
        // file system, otherwise, you will get a permission denied error.
        window.external.AddFavorite(url, title); // IE/Win
    } else if(isKonq) {
      alert('You need to press CTRL + B to bookmark our site.');
    } else if(window.opera) {
      void(0); // do nothing here (Opera 7+)
    } else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab
      alert('You need to press '+buttonStr+' + D to bookmark our site.');
    } else if(!window.print || isMac) { // IE5/Mac and Safari 1.0
      alert('You need to press Command/Cmd + D to bookmark our site.');    
    } else {
      alert('In order to bookmark this site you need to do so manually '+
        'through your browser.');
}
*/	
	
function subsNow(readerHref) 
{   if (iTunesInstalled())
    {   eFURL = readerHref;
	    //strip current URL; replace with {feed} for posterity
	    var reURL = /(.+)http.+$/
	    //handle the itpc protocol case as well
	    var reITPC = /(itpc:\/\/).+$/;
	    if (reURL.test(readerHref)) {
		    eFURL = eFURL.replace(reURL,'$1{feed}')
	    } else if (reITPC.test(readerHref)) {
		    eFURL = eFURL.replace(reITPC,'$1{feed}')
	    }
	    //send location.href off to that loc'n	
	    return readerHref;
	}
	else
	{  alert('You must install iTunes first.');
	   popHlp(9);
	   return '#'; }
}

function emailSub()
{
	window.open("subscribe.aspx","PodCast","location=no,menubar=no,titlebar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,directories=no,width=500,height=400,left=200,top=150", true);	
}

function emailSubOld(defaultEmail)
{   if (defaultEmail==null)
        defaultEmail = 'Your Email Address here..';
    var email = prompt("Please enter your email address to notify when new PodCasts are published:",defaultEmail);
    if (email!= null)
    {   var rx  = new RegExp("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$");
	    var matches = rx.exec(email);
        if (matches !=null)
        {   document.forms[0].txtEmail.value = email; 
            document.forms[0].btnEmail.click();  }
        else
        {  alert('Please Enter a valid Email Address');
           emailSub(email); }
     }
}

function emailFriend(defaultEmail)
{   if (defaultEmail==null)
        defaultEmail = "Your Colleague's Email Address here..";
    var email = prompt("Please enter your Colleague's email address:",defaultEmail);
    if (email!= null)
    {   var rx  = new RegExp("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$");
	    var matches = rx.exec(email);
        if (matches !=null)
        {   document.forms[0].txtEmail.value = email; 
            document.forms[0].btnFriend.click();  }
        else
        {  alert('Please Enter a valid Email Address');
           emailFriend(email); }
     }
}

function popHlp(x)
{  window.open("podHelp.aspx?id=" + x,"PodCast","location=no,menubar=no,titlebar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,directories=no,width=610,height=400,left=200,top=150", true);	}

function iTunesInstalled()
{
    return(true);
}

/*
function iTunesInstalled() 
{   try
    {   var searchNameStr = '';
    	searchNameStr = 'QuickTime';	
        var detected = 0;
	    if (navigator.plugins && navigator.plugins.length) 
	        {
		        for (var i=0; i < navigator.plugins.length; i++ ) 
		            {   var currentPlugin = navigator.plugins[i];
		                if (currentPlugin.name.toLowerCase().substring(0,searchNameStr.length) == searchNameStr.toLowerCase()) 
		                    {   detected = 1;
			                    break;  }
	                }
	        } 
	        else 
	        {   searchNameStr = 'QuickTimeCheckObject.QuickTimeCheck'; 
		        axo = new ActiveXObject(searchNameStr);
		        if (axo) 
		            {     detected = 1;   }
	            else 
	                {   detected = 0;   }
			    axo = null;
			    
			    // For now assume that all Internet Explorer users have iTunes - Security on IE prevents creating ActiveX ]
			    \s and hence can't check
			    detected = 1;
	        }
	    return (detected);
	}
	catch (e)
	{  return(0); }
}
*/

function showMap(x)
{   
    document.getElementById('wmap').src = 'images/world' + x + '.gif';
}
