// Copyright (c) 2011. Fabrice Menoyot - http://freeEducationCenter.com
// All rights reserved.
//===========================================================
/*
	 This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */
// Do not touch this line:
var webAdd = "";
function timeSpent() {
	var d = new Date();
	var y = d.getFullYear();
	var x = y - 2000;
	var myDate = new Array();
	myDate[0] = 13 + x; // Reading
	myDate[1] = 8 + x; // Regression
	myDate[2] = 3 + x; // Progression
	
	return myDate;
	
	/*
	var myDate = timeSpent();
	document.write(myDate[0]);
	*/
}
//=====================================================================
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function showdiv(id) {
	//safe function to show an element with a specified id	  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
function showMenuBlog(id) {

	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == 'none') {
			document.getElementById(id).style.display = 'block';
		} else {
			document.getElementById(id).style.display = 'none';
		}
	}
	else {
		if (document.layers) { // Netscape 4
			if (document.id.display == 'none') {
				document.id.display = 'block';
			} else {
				document.id.display = 'none';
			}
		}
		else { // IE 4
				if (document.all.id.style.display == 'none') {
					document.all.id.style.display = 'block';
				} else {
					document.all.id.style.display = 'none';
				}
		}
	}
}
function expand_collapse(cnt) {
	
	var id= "show0"; 
	var myStat = false;
	// check 1st one
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == 'none') {
			myStat = true;
		} else {
			myStat = false;
		}
	}
	else {
		if (document.layers) { // Netscape 4
			if (document.id.display == 'none') {
				myStat = true;
			} else {
				myStat = false;
			}
		}
		else { // IE 4
				if (document.all.id.style.display == 'none') {
					myStat = true;
				} else {
					myStat = false;
				}
		}
	}
	
		

	var mypop = "";
	for(var i=0;i < cnt;i++) {
		mypop = "show" + String(i);
		showMenuBlog2(mypop,myStat);
	}

function showMenuBlog2(id,myStat) {
	var thisStat = "";
	if (myStat) {
		thisStat = "block";
	} else {
		thisStat = "none";
	}
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = thisStat;
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = thisStat;
		}
		else { // IE 4
			document.all.id.style.display = thisStat;
		}
	}
}
			
}
//===========================================================
function listenToShow(showURL,showName) {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	if (!showName) {
		showName = "Listen to show";
	}
	var myPlayer = myWeb + "playSound.html";
	var myShow = myWeb + showURL;
	var myCook = showURL + "|x|" + showName;
	createCookie("soundPlayNow",myCook,1);
	
	var myWidth = 230;
	var myHeight = 110;

	
	var winl = (screen.width - myWidth) / 2;
	var wint = (screen.height - myHeight) / 2;
    var winprop = 'width=' + myWidth +',height=' + myHeight+ ',' + 'top=' + wint + ',left=' + winl + ',location=no,toolbar=no,scrollbars=yes,directories=no,Status=no,copyhistory=no';
	myWin = window.open(myPlayer, '',winprop);
	myWin.focus();

}
//===========================================================
function viewTheShow(showURL,ww,hh) {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var myPlayer = myWeb + "playVideo.html";
	var myShow = myWeb + showURL;
	var myWidth = Number(ww) + 40;
	var myHeight = Number(hh) + 60;
	var myCook = myShow + "|x|" + ww + "|x|" + hh;
	createCookie("videoPlayNow",myCook,1);
	var winl = (screen.width - myWidth) / 2;
	var wint = (screen.height - myHeight) / 2;
    var winprop = 'width=' + myWidth +',height=' + myHeight+ ',' + 'top=' + wint + ',left=' + winl + ',location=no,toolbar=no,scrollbars=yes,directories=no,Status=no,copyhistory=no,resizable=yes';
	myWin = window.open(myPlayer, '',winprop);
	myWin.focus();
}

//===========================================================
function viewYouTubeShow(showID,ww,hh) {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var myPlayer = myWeb + "playVideoYouTube.html";
	var myWidth = Number(ww) + 40;
	var myHeight = Number(hh) + 60;
	var myCook = showID + "|x|" + ww + "|x|" + hh;
	createCookie("videoPlayNow",myCook,1);
	var winl = (screen.width - myWidth) / 2;
	var wint = (screen.height - myHeight) / 2;
    var winprop = 'width=' + myWidth +',height=' + myHeight+ ',' + 'top=' + wint + ',left=' + winl + ',location=no,toolbar=no,scrollbars=yes,directories=no,Status=no,copyhistory=no,resizable=yes';
	myWin = window.open(myPlayer, '',winprop);
	myWin.focus();
}

//===========================================================
function viewPublication(pub) {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var myPub = myWeb + pub;
	window.location = myPub;
	myWin.focus();
}

//===========================================================
function viewPositiveThoughts() {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var myLoc = myWeb + "positiveThoughts.html";
	centerwin(myLoc,330,270);
}

//===========================================================
function centerwin(url,width,height) {
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
    var winprop = 'width=' + width +',height=' + height+ ',' + 'top=' + wint + ',left=' + winl + ',location=no,toolbar=no,scrollbars=yes,directories=no,Status=no,copyhistory=no';
	myWin = window.open(url, '',winprop);
	myWin.focus();
}
//===========================================================
function openPhotoAlbum(myUrl,width,height) {
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
    var winprop = 'width=' + width +',height=' + height+ ',' + 'top=' + wint + ',left=' + winl + ',location=no,toolbar=no,scrollbars=yes,directories=no,Status=no,copyhistory=no';
	myWin = window.open(myUrl,'',winprop);
	myWin.focus();
	
	
}
//===========================================================
function goToShop(where) {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var myURL = myWeb + "myStore/";
	
	//var theWebHost = window.location.hostname.toUpperCase();
	//if (theWebHost != "PETRENE.TLD") {
		//myURL =	"https://secure25.securewebsession.com/petrene.com/myStore/";
	//}
	
	// Use the link below to open the blog or use "//" before the line when closed
	window.location = myURL;
	// Use this alert when the shop is closed. 
	//alert("Sorry... The Store is currently under maintenance. Please come back soon!!");
}
//===========================================================
function goToForums() {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var myURL = myWeb + "forums/"
	// Use the link below to open the blog or use "//" before the line when closed
	//window.location = myURL;
	// Use this alert when the Blog is closed. 
	alert("The forums are currently offline. We'll reopen them when more time is available or when the moderators' team is in place.");
}
//===========================================================
function goToBlog(where) {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var myURL = myWeb + "blog/"
	if (where) {
		myURL = myURL + where;
	}
	// Use the link below to open the blog or use "//" before the line when closed
	window.location = myURL;
	// Use this alert when the Blog is closed. 
	//alert("Sorry... The Blog is currently under maintenance. Come back soon!!");
}
//===========================================================
function goToRooms() {
	// WARNING: Must redirect to http://menoyot.com (NOT www.menoyot.com) for FLASH Security Policy
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var URLStr = myWeb + "rooms.html";
	var myWidth = 940;
	var myHeight = 650;
	var winl = (screen.availWidth - myHeight) / 2;
	var wint = (screen.availHeight - myHeight) / 2;
    var winprop = 'width=' + myWidth +',height=' + myHeight+ ',' + 'top=' + wint + ',left=' + winl + ',location=no,toolbar=no,scrollbars=yes,directories=no,Status=no,copyhistory=no';
	myWin = window.open(URLStr, '',winprop);
	myWin.focus();
}
///////////////////////////////////////////////////////////////////////////////
// NOT USE FOR THE MOMENT
function translatePage(user) {
	var Url = location.href;
	var pageLang = "pt";
	var userLang = user;
	if (userLang == "") {
		if (navigator.appName == 'Netscape')
			var language = navigator.language;
		else
			var language = navigator.browserLanguage;
		userLang = language.substring(0,2);
	}
	
	if (userLang == pageLang) userLang = "es";
	//alert(userLang);
	var dest = "http://translate.google.com/translate?js=y&prev=_t&hl=es&ie=UTF-8&layout=1&eotf=1&u=" + Url + "&sl=" + pageLang + "&tl=" + userLang;
	//alert(dest);
	newwindow = window.open(dest,'Translation');
	if (window.focus) {newwindow.focus()}
 }
 function translateEntrance(userLang) {
	var Url = "http://www.chacaramarabu.com.br/index0.html";
	var pageLang = "pt";
	
	if (userLang == "pt"){
		var dest = "http://www.chacaramarabu.com.br/index0.html";
	} else {
		var dest = "http://translate.google.com/translate?js=y&prev=_t&hl=es&ie=UTF-8&layout=1&eotf=1&u=" + Url + "&sl=" + pageLang + "&tl=" + userLang;
	}
	//alert(dest);
	newwindow = window.open(dest,'Translation');
	if (window.focus) {newwindow.focus()}
 }
  function translateNow() {
	if (navigator.appName == 'Netscape')
			var language = navigator.language;
		else
			var language = navigator.browserLanguage;
	var userLang = language.substring(0,2);
	translatePage(userLang);
 }
//===========================================================
// NTO USED FOR THE MOMENT
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//===========================================================
// RUN THE UNIVERSAL VIDEO PLAYER
function loadUniversalVideoPlayer(videoPlayerURL,videoPlayerBG,myVideoURL,clipWidth,clipHeight,webDomain,YouTubeVideoID,coverImage,playerSkin,playerSkinUnder,playerSkinColor,autoPlay,divID) {
	
	var swfVersionStr = "10.1.52";
	var xiSwfUrlStr = "";
	var flashvars = {};
	flashvars.videoFile = myVideoURL;
	flashvars.videoWidth = clipWidth;
	flashvars.videoHeight = clipHeight;
	flashvars.webDomain = webDomain;
	flashvars.youTubeVideoID = YouTubeVideoID;
	flashvars.screenImage = coverImage;
	flashvars.myPlayerSkin = playerSkin;
	flashvars.myPlayerSkinUnder = playerSkinUnder;
	flashvars.skinColor = playerSkinColor;
	flashvars.autoPlay = autoPlay;
	var params = {};
	params.quality = "high";
	params.bgcolor = videoPlayerBG;
	params.play = "true";
	params.loop = "true";
	params.wmode = "window"; // params.wmode = "transparent"; // params.wmode = "opaque";
	params.scale = "showall";
	params.menu = "true";
	params.devicefont = "false";
	params.salign = "";
	params.allowscriptaccess = "sameDomain";
	params.allowFullScreen = "true";
	var attributes = {};
	attributes.id = "universalVideoPlay";
	attributes.name = "universalVideoPlay";
	attributes.align = "middle";
	finalHeight = Number(clipHeight);
	if ((playerSkinUnder == "YES") || (YouTubeVideoID != "")) {
		finalHeight += 40;
	}
	
	swfobject.embedSWF( videoPlayerURL, divID,clipWidth, finalHeight, swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
}
//=============================================================================
// INSERT THE SINGLE AND MULTIPLE SOUND PLAYER on a WEB page (NOT WordPress)
 function loadSoundPlayer(mySoundPlayer,myPlayerType,myXML_file,mySoundFile,myShortTitle,myBGColor,myAutoPlay,myDivID,disableTextScroll){
	var flashvars = {};
	flashvars.xml_file = myXML_file;
	flashvars.sound_file = mySoundFile;
	flashvars.shortTitle = myShortTitle;
	flashvars.bgColor = myBGColor;
	flashvars.autoPlay = myAutoPlay;
	if (disableTextScroll) {
		flashvars.disableTextScrolling = disableTextScroll;
	}
	var myH = 70;
	if (myPlayerType == "MULTIPLE") { myH = 100; }
	swfobject.embedSWF(mySoundPlayer, myDivID, "190", myH, "9.0.0", false, flashvars);
}
//===========================================================================
// INSERT DISPLAY IMAGE WITH LINK FROM URL OR XML
function loadDisplayImage(maxWidth,maxheight,axml_file,ashowControls,aurl_file,aurl_link,abgColor,adivName,awmode) {

	    //maxWidth // single image url_file or largest width of image from xml list
	    //maxheight  // single image url_file or largest width of image from xml list

		var flashvars = {};
		flashvars.xml_file = axml_file; // multiple image file
		flashvars.url_file = aurl_file; // "assets/images/50wayspic.jpg"; // single image file
		flashvars.url_link = aurl_link; //"shop/"; // single image file
		flashvars.bgColor = abgColor;
		flashvars.showControls = ashowControls;
		var divName = adivName;
		
		flashvars.myWidth = maxWidth;
		flashvars.myHeight = maxheight;
		
		var imageDisplayWidth = maxWidth;
		var imageDisplayHeight =  maxheight;
		if (flashvars.xml_file != "") {
			if (ashowControls.toUpperCase() == "YES") {
				// Must add 40 to 50 px to largest image image of the xml list when displaying more than 1 image to allow room for buttons
				imageDisplayHeight = String(Number(maxheight) + 40);
			}
		}
		
		var params = {};
		params.quality = "high";
		params.play = "true";
		params.loop = "true";
		if (awmode) {
			params.wmode = awmode;
		} else {
			params.wmode = "opaque"; // params.wmode = "transparent"; // params.wmode = "opaque"; //params.wmode = "window";
		}
		params.scale = "showall";
		params.menu = "true";
		params.devicefont = "false";
		params.salign = "";
		params.allowscriptaccess = "sameDomain";
		params.allowFullScreen = "true";
	
		var myWebHost = window.location.hostname;
		var myApp = "http://" + myWebHost + webAdd + "/assets/flash/positiveThoughts.swf";
		
		swfobject.embedSWF(myApp, divName, imageDisplayWidth, imageDisplayHeight, "9.0.0", false, flashvars, params);
}
//===========================================================================
// INSERT DISPLAY IMAGE WITH LINK FROM URL OR XML
function loadPositiveThoughts(maxWidth,maxheight,axml_file,aurl_file,aurl_link,abgColor,adivName,awmode) {

	    //maxWidth // single image url_file or largest width of image from xml list
	    //maxheight  // single image url_file or largest width of image from xml list
		var myWebHost = window.location.hostname;
		
		var flashvars = {};
		flashvars.xml_file = axml_file; // multiple image file
		flashvars.url_file = aurl_file; // "assets/images/50wayspic.jpg"; // single image file
		flashvars.url_link = aurl_link; //"shop/"; // single image file
		flashvars.bgColor = abgColor;
		var divName = adivName;
		
		flashvars.myWidth = maxWidth;
		flashvars.myHeight = maxheight;
		
		var imageDisplayWidth = maxWidth;
		var imageDisplayHeight =  maxheight;
		imageDisplayHeight = String(Number(maxheight) + 40);
		
		var params = {};
		params.quality = "high";
		params.play = "true";
		params.loop = "true";
		
		if (awmode) {
			params.wmode = awmode;
		} else {
			params.wmode = "opaque"; // params.wmode = "transparent"; // params.wmode = "opaque"; //params.wmode = "window";
		}
		params.scale = "showall";
		params.menu = "true";
		params.devicefont = "false";
		params.salign = "";
		params.allowscriptaccess = "sameDomain";
		params.allowFullScreen = "true";
		
		
		var myApp = "http://" + myWebHost + webAdd + "/assets/flash/positiveThoughts.swf";
		
		swfobject.embedSWF(myApp, divName, imageDisplayWidth, imageDisplayHeight, "9.0.0", false, flashvars, params);
}
//============================================================================
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
//============================================================================
// Get an xml file randomly and select a quote randomly
function getMeRandomQuote() {
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  
	var myRand = Math.floor(Math.random()* 12);
	var myFile = "assets/xml/Random_Quotes/myQuotes" + String(myRand) + ".xml";
	xhttp.open("GET",myFile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	
	x=xmlDoc.getElementsByTagName("text");
	y=xmlDoc.getElementsByTagName("author");
	
	var i = Math.floor(Math.random()* x.length);
	//for (i=0;i<x.length;i++)
	  //{ 
	var myQuote = x[i].childNodes[0].nodeValue + "  <br><div align='right'><strong>" + y[i].childNodes[0].nodeValue + "</strong></div>";
	  //}
	return myQuote;
}
//=====================================================================================
// Get a specific xml quote file and return a random quote
function getMeUniqueRandomQuote(myFile) {
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",myFile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	x=xmlDoc.getElementsByTagName("text");
	y=xmlDoc.getElementsByTagName("author");
	var i = Math.floor(Math.random()* x.length);
	//for (i=0;i<x.length;i++)
	  //{ 
	var myQuote = x[i].childNodes[0].nodeValue + "  <br><div align='right'><strong>" + y[i].childNodes[0].nodeValue + "</strong></div>";
	  //}
	return myQuote;
}
//=====================================================================================
// Get a specific xml quote file and return a random quote without author
function getMeUniqueQuoteNoAutor(myFile) {
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",myFile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	x=xmlDoc.getElementsByTagName("text");
	y=xmlDoc.getElementsByTagName("author");
	var i = Math.floor(Math.random()* x.length);
	//for (i=0;i<x.length;i++)
	  //{ 
	var myQuote = x[i].childNodes[0].nodeValue;
	  //}
	return myQuote;
}
//=====================================================================================
// Get the News List and display in front page
function getMeMyNews(myFile) {	
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",myFile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	var textNews = 0;
	var imageNews = 0;
	// Get data
	
	

	var myTitles = xmlDoc.getElementsByTagName("title");
	
	
	
	var myDesc = xmlDoc.getElementsByTagName("description");
	var myImages = xmlDoc.getElementsByTagName("image");
	var myAlign = xmlDoc.getElementsByTagName("imagealign");		
	var myBars = xmlDoc.getElementsByTagName("bar");
	var myLinks = xmlDoc.getElementsByTagName("link");
	var myTargets = xmlDoc.getElementsByTagName("target");
	
	// check to see if we have text and news
	for (y=0;y<myTitles.length;y++)
	  { 
		if (myTitles[y].childNodes[0]) {
			if (myTitles[y].childNodes[0].nodeValue != "") {
			  textNews++;
			}
		}
		if (myImages[y].childNodes[0]) {
			if (myImages[y].childNodes[0].nodeValue != "") {
			  imageNews++;
			}
		}
	}
	if ((textNews + imageNews) < 1) {
		// no news!
		return "";
	}
	// Set the div class according to result
	var myDiv = "";
	if ((textNews > 0) && (imageNews < 1)) {
		myDiv = "centerNewsXMLTEXT";
	}
	if ((textNews > 0) && (imageNews > 0)) {
		myDiv = "centerNewsXMLMIXED";
	}
	if ((textNews < 1) && (imageNews  == 1)) {
		myDiv = "centerNewsXMLONEIMAGE";
	}
		if ((textNews < 1) && (imageNews  > 1)) {
		myDiv = "centerNewsXMLIMAGES";
	}
	var myText = '<div class="' + myDiv + '">'; 
	for (i=0;i<myTitles.length;i++)
	  { 
	  // Get the data available
	  var theLink = "";
	  if (myLinks[i].childNodes[0]) {
	  	theLink = myLinks[i].childNodes[0].nodeValue;
	  }
	  var theTarget = "";
	  if (myTargets[i].childNodes[0]) {
		theTarget = myTargets[i].childNodes[0].nodeValue;
	  }
	  
	  var theAlign = "center";
	  if (myAlign[i].childNodes[0]) {
		  theAlign = myAlign[i].childNodes[0].nodeValue;
	  }
	  var myBar = "";
	  if ( myBars[i].childNodes[0]) {
		myBar = myBars[i].childNodes[0].nodeValue;
	  }
	  var myContent = "";
	  if (myDesc[i].childNodes[0]) {
	  	  myContent = myDesc[i].childNodes[0].nodeValue;
	  }
	  // check if image
	  if (myImages[i].childNodes[0]) {
		 var myImage =  '<img src="' + myImages[i].childNodes[0].nodeValue + '">';
		 if (theAlign == "") { theAlign = "center"; }
		 if (theLink != "") {
				myText += '<p class="newsImage" align="' + theAlign + '"><a href="' + theLink + '"target="' + theTarget + '">' + myImage + '</a></p>';
			} else {
				myText += '<p  class="newsImage" align="' + theAlign + '">' + myImage + '</p>';
			}	
	  } else {
	  	// No image but title
		  if (myTitles[i].childNodes[0]) {
			if (theLink != "") {
				myText += '<p><a href="' + theLink + '"target="' + theTarget + '">' + '<span class="newsTitle">' + myTitles[i].childNodes[0].nodeValue + '</span></a>';
			} else {
				myText += '<p><span class="newsTitle">' + myTitles[i].childNodes[0].nodeValue + '</span>';
			}
		  }
		}
		// Now check if description - Couldhave one even with image
		if (myContent != "") {
			if (myImages[i].childNodes[0]) {
				myText += '<p>';
			} else {
				myText += '<br>';
			}
			myText += '<span class="newsDescription">' + myDesc[i].childNodes[0].nodeValue + '</span></p>';
		} else {
			if (!myImages[i].childNodes[0]) {
				myText +='</p>';
			}
		}
		// Add division bar
		if ( myBar != "") {
			myText += '<p><img src="' + myBar +'" width="100%" height="1" /></p>';
		}
	 }
	 myText += "</div>";
	return myText;
	

}
//====================================================//
// Get the News List and display in front page
function getMeMyNewsBlog(myFile) {	
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var XMLfile = "";
	if (myFile) {
		XMLfile = myFile;
	} else {
		XMLfile = myWeb + "events/newsList.xml";
	}
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",XMLfile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	// Get data
	var myTitles = xmlDoc.getElementsByTagName("title");
	var myDesc = xmlDoc.getElementsByTagName("description");
	var myImages = xmlDoc.getElementsByTagName("image");
	var myAlign = xmlDoc.getElementsByTagName("imagealign");		
	var myBars = xmlDoc.getElementsByTagName("bar");
	var myLinks = xmlDoc.getElementsByTagName("link");
	var myTargets = xmlDoc.getElementsByTagName("target");
	var textNews = 0;
	var imageNews = 0;
	
	
	// check to see if we have text and news
	for (y=0;y<myTitles.length;y++)
	  { 
		if (myTitles[y].childNodes[0]) {
			if (myTitles[y].childNodes[0].nodeValue != "") {
			  textNews++;
			}
		}
		if (myImages[y].childNodes[0]) {
			if (myImages[y].childNodes[0].nodeValue != "") {
			  imageNews++;
			}
		}
	}
	if ((textNews + imageNews) < 1) {
		// no news!
		return "";
	}
	// Set the div class according to result
	var myDiv = "";
	if ((textNews > 0) && (imageNews < 1)) {
		myDiv = "centerNewsXMLTEXTBlog";
	}
	if ((textNews > 0) && (imageNews > 0)) {
		myDiv = "centerNewsXMLMIXEDBlog";
	}
	if ((textNews < 1) && (imageNews  == 1)) {
		myDiv = "centerNewsXMLONEIMAGEBlog";
	}
		if ((textNews < 1) && (imageNews  > 1)) {
		myDiv = "centerNewsXMLIMAGESBlog";
	}
	var myText = '<div class="' + myDiv + '">'; 
	for (i=0;i<myTitles.length;i++)
	  { 
	  // Get the data available
	  var theLink = "";
	  if (myLinks[i].childNodes[0]) {
	  	theLink = myLinks[i].childNodes[0].nodeValue;
	  }
	  var theTarget = "";
	  if (myTargets[i].childNodes[0]) {
		theTarget = myTargets[i].childNodes[0].nodeValue;
	  }
	  
	  var theAlign = "center";
	  if (myAlign[i].childNodes[0]) {
		  theAlign = myAlign[i].childNodes[0].nodeValue;
	  }
	  var myBar = "";
	  if ( myBars[i].childNodes[0]) {
		myBar = myBars[i].childNodes[0].nodeValue;
	  }
	  var myContent = "";
	  if (myDesc[i].childNodes[0]) {
	  	  myContent = myDesc[i].childNodes[0].nodeValue;
	  }
	  // check if image
	  if (myImages[i].childNodes[0]) {
		 if (theAlign == "") { theAlign = "center"; }
		 var myImage =  '<img src="' + myWeb + myImages[i].childNodes[0].nodeValue + '">';
		 if (theLink != "") {
				myText += '<p class="newsImageBlog" align="' + theAlign + '"><a href="' + theLink + '"target="' + theTarget + '">' + myImage + '</a></p>';
			} else {
				myText += '<p  class="newsImageBlog" align="' + theAlign + '">' + myImage + '</p>';
			}
				
	  } else {
	  	// No image but title
		  if (myTitles[i].childNodes[0]) {
			if (theLink != "") {
				myText += '<p><a href="' + theLink + '"target="' + theTarget + '">' + '<span class="newsTitleBlog">' + myTitles[i].childNodes[0].nodeValue + '</span></a>';
			} else {
				myText += '<p><span class="newsTitleBlog">' + myTitles[i].childNodes[0].nodeValue + '</span>';
			}
		  }
		}
		// Now check if description - Couldhave one even with image
		if (myContent != "") {
			if (myImages[i].childNodes[0]) {
				myText += '<p>';
			} else {
				myText += '<br>';
			}
			myText += '<span class="newsDescriptionBlog">' + myDesc[i].childNodes[0].nodeValue + '</span></p>';
		} else {
			if (!myImages[i].childNodes[0]) {
				myText +='</p>';
			}
		}
		// Add division bar
		if ( myBar != "") {
			var myImageBar =  '<img style="width:100%;height:1px;" src="' + myWeb + myBar + '">';
			myText += '<p>' + myImageBar + '</p>';
			
		}
	 }
	 myText += "</div>";
	return myText;
}

//=====================================================================================
// Get the EVENTS List and display in front page
function getMeMyEvents(myFile) {	
	
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",myFile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	// Get data
	var myDates = xmlDoc.getElementsByTagName("date");
	var myTZs = xmlDoc.getElementsByTagName("timezone");
	var myNames = xmlDoc.getElementsByTagName("event_name");
	//var myContNames = xmlDoc.getElementsByTagName("contact_name");	
	//var myContEmails = xmlDoc.getElementsByTagName("contact_email");
	//var myContPhones = xmlDoc.getElementsByTagName("contact_phone");
	
	//var mySponsors = xmlDoc.getElementsByTagName("sponsor");
	var myLocs = xmlDoc.getElementsByTagName("location");
	
	var myURLs = xmlDoc.getElementsByTagName("event_url");
	//var myCosts = xmlDoc.getElementsByTagName("event_cost");
	//var myAudiences = xmlDoc.getElementsByTagName("event_audience");
	//var mySubs = xmlDoc.getElementsByTagName("eventsubject");
	
	var textEvents = 0;
	// check to see if we have any
	for (y=0;y<myNames.length;y++)
	  { 
		if (myNames[y].childNodes[0]) {
			if (myNames[y].childNodes[0].nodeValue != "") {
			  textEvents++;
			}
		}
		
	}
	if (textEvents < 1) {
		// no events!
		return "";
	}
	// Set the div class according to result
	var myText = "";
	if (textEvents < 2) {
		myText += "<div class='displayEventsXML'>";
	} else {
		myText += "<div class='displayEventsXMLMultiple'>";
	}
	 
	for (i=0;i<myNames.length;i++)
	  { 
	  // Get the data available
	  var theDate = "";
	  if (myDates[i].childNodes[0]) {
	  	theDate = myDates[i].childNodes[0].nodeValue;
	  }
	  var theTZ = "";
	  if (myTZs[i].childNodes[0]) {
		theTZ = myTZs[i].childNodes[0].nodeValue;
	  }
	  var theName = "";
	  if (myNames[i].childNodes[0]) {
		  theName = myNames[i].childNodes[0].nodeValue;
	  }
	  var theLoc = "";
	  if ( myLocs[i].childNodes[0]) {
		theLoc = myLocs[i].childNodes[0].nodeValue;
	  }
	  var thisLoc = "";
	  if (theLoc != "") {
		  thisLoc = cleanLocation(theLoc);
	  }
	  var theLink = "";
	  if (myURLs[i].childNodes[0]) {
	  	  theLink = myURLs[i].childNodes[0].nodeValue;
	  }
	  
	  if ((theDate != "") && (theName != "")) {
		  myText += '<p><span class="eventXMLdate"> ' + theDate + '</span><br>';
		  myText += '<span class="eventXMLtimezone"><strong>Time Zone: </strong>' + theTZ + '</span><br>';
		  myText += '<span class="eventXMLname">' + theName + '</span><br>';
		  myText += '<span class="eventXMLlocation">' + thisLoc + '</span><br>';
		  
		 if (theLink == "") { theLink = "events/"; };
		  
		 myText += '<span class="eventXMLlink"><a href="' + theLink + '" target="_blank">More here...</a></span></p>';
	  }
	 }
	 myText += "</div>";
	return myText;
}

//=====================================================================================
// Get the EVENTS List and display in front page
function getMeMyEventsBlog(myFile) {	
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var XMLfile = "";
	if (myFile) {
		XMLfile = myFile;
	} else {
		XMLfile = myWeb + "events/eventsList.xml";
	}
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",XMLfile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	// Get data
	var myDates = xmlDoc.getElementsByTagName("date");
	var myTZs = xmlDoc.getElementsByTagName("timezone");
	var myNames = xmlDoc.getElementsByTagName("event_name");
	//var myContNames = xmlDoc.getElementsByTagName("contact_name");	
	//var myContEmails = xmlDoc.getElementsByTagName("contact_email");
	//var myContPhones = xmlDoc.getElementsByTagName("contact_phone");
	
	//var mySponsors = xmlDoc.getElementsByTagName("sponsor");
	var myLocs = xmlDoc.getElementsByTagName("location");
	
	var myURLs = xmlDoc.getElementsByTagName("event_url");
	//var myCosts = xmlDoc.getElementsByTagName("event_cost");
	//var myAudiences = xmlDoc.getElementsByTagName("event_audience");
	//var mySubs = xmlDoc.getElementsByTagName("eventsubject");
	
	var textEvents = 0;
	// check to see if we have any
	for (y=0;y<myNames.length;y++)
	  { 
		if (myNames[y].childNodes[0]) {
			if (myNames[y].childNodes[0].nodeValue != "") {
			  textEvents++;
			}
		}
		
	}
	if (textEvents < 1) {
		// no events!
		return "";
	}
	// Set the div class according to result
	var myText = "<div class='displayEventsXMLBlog'>";
	//myText += '<h4 class="eventXMLheaderBlog">Upcoming Events</h4>';
	 
	for (i=0;i<myNames.length;i++)
	  { 
	  // Get the data available
	  var theDate = "";
	  if (myDates[i].childNodes[0]) {
	  	theDate = myDates[i].childNodes[0].nodeValue;
	  }
	  var theTZ = "";
	  if (myTZs[i].childNodes[0]) {
		theTZ = myTZs[i].childNodes[0].nodeValue;
	  }
	  var theName = "";
	  if (myNames[i].childNodes[0]) {
		  theName = myNames[i].childNodes[0].nodeValue;
	  }
	  var theLoc = "";
	  if ( myLocs[i].childNodes[0]) {
		theLoc = myLocs[i].childNodes[0].nodeValue;
	  }
	  var thisLoc = "";
	  if (theLoc != "") {
		  thisLoc = cleanLocation(theLoc);
	  }
	  var theLink = "";
	  if (myURLs[i].childNodes[0]) {
	  	  theLink = myURLs[i].childNodes[0].nodeValue;
	  }
	  
	  if ((theDate != "") && (theName != "")) {
		  myText += '<p><span class="eventXMLdate"> ' + theDate + '</span><br>';
		  myText += '<span class="eventXMLtimezone"><strong>Time Zone: </strong>' + theTZ + '</span><br>';
		  myText += '<span class="eventXMLname">' + theName + '</span><br>';
		  myText += '<span class="eventXMLlocation">' + thisLoc + '</span><br>';
		  
		 if (theLink == "") { theLink = "events/"; };
		  
		 myText += '<span class="eventXMLlink"><a href="' + theLink + '" target="_blank">More here...</a></span></p>';
	  }
	 }
	 myText += "</div>";
	return myText;
}
//====================================================//
// Get the audioList.xml file in Events directory and build menulike selector to play audio shows
function getMeMyAudioShows(myFile) {
	if (!myFile) {
		myFile = "events/audioList.xml";
	}
	//var myWebHost = window.location.hostname;
	//var myWeb = "http://" + myWebHost + webAdd + "/";
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",myFile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	// Get data
	var myTitles = xmlDoc.getElementsByTagName("title");
	var mySounds = xmlDoc.getElementsByTagName("soundURL");
	var myCtn = 0;
	var myOutput = "";
	// check to see if we have text and news
	for (y=0;y<myTitles.length;y++)
	  { 
	  	  var theTitle = "";
		  var theSound = "";
		  if (myTitles[y].childNodes[0]) {
			 theTitle = myTitles[y].childNodes[0].nodeValue;
		  }
		  if (mySounds[y].childNodes[0]) {
			 theSound = mySounds[y].childNodes[0].nodeValue;
		  }
		  if ((theTitle != "") && (theSound != ""))  {
			  myCtn++;
			  myOutput += '<option value="' + theTitle + '|x|' + theSound + '">' + theTitle + '</option>';
		  }
	  }
	 if (myCtn > 0) {
		 myOutput += '</select></p></form>';
		// myOutput += '<input type="button" value="   Listen Now   " onClick="javascript:playAudioShowMenu();"></p>';
		myOutput += '<p><img src="assets/images/soundIcon64.png" width="32" height="32" onClick="javascript:playAudioShowMenu();" title="Select show and click here to play"></p>'
		 myOutput += '</div>';
		 var myHeaderForm = '<div class="audioShowMenu"><form method="get" name="audioShow">';
		 myHeaderForm += '<p><select name="audioSelection"><option value="">---- Select Radio Talk Show Extract to Listen ----</option>';
		 myOutput = myHeaderForm + myOutput;
		 
	 }
	 return myOutput;
}	 
//-------------------------------------------------------------------
// This function works with the getMeMyAudioShows() above	 

function playAudioShowMenu() {
	var myID = document.audioShow.audioSelection.selectedIndex;
	var mySelection = document.audioShow.audioSelection.options[myID].value;
	if (mySelection != "") {
		var showURL = mySelection.split("|x|")[1];
		var showName = mySelection.split("|x|")[0];
		listenToShow(showURL,showName);
	} else {
		alert("You must select a Talk Show first!");
	}

}
//=======================================================================
function getMySpecialContent() {
	var myWebHost = window.location.hostname;
	var myFile = "http://" + myWebHost + webAdd + "/specials/specials.xml";
	
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",myFile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	
	var myData = xmlDoc.getElementsByTagName("content");
	
	var myContent = "";
	
	for (y=0;y<myData.length;y++)
	  { 
		if (myData[y].childNodes[0]) {
			if (myData[y].childNodes[0].nodeValue != "") {
			  myContent += myData[y].childNodes[0].nodeValue;
			}
		}
	}
	if (myContent.length < 10) {
		myContent = "";
	}
	return myContent;
}

//=======================================================================
function cleanLocation(theText) {
	return theText.replace(/[\n\r]$/,"<br>");
	//return theText.replace(/\n\r/,"<br>");
}
//=======================================================================
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
//====================================================//
// Get the audioList.xml file in Events directory and build menulike selector to play audio shows
function getMyFees() {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + webAdd + "/";
	var myFile = myWeb + "petreneFees.xml";
	//var myWebHost = window.location.hostname;
	//var myWeb = "http://" + myWebHost + webAdd + "/";
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else // for IE 5/6
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET",myFile,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	// Get data
	var myOutput = "";
	var myFees = xmlDoc.getElementsByTagName("fees");
	
	// check to see if we have text and news
	for (y=0;y<myFees.length;y++)
	  { 
		  if (myFees[y].childNodes[0]) {
			 myOutput = myFees[y].childNodes[0].nodeValue;
		  }

	  }
	 return myOutput;
}	 

