// Copyright (c) 2010. Fabrice Menoyot - http://freeEducationCenter.com.
// All rights reserved.
function translateNow() {
	var Url = location.href;
	var pageLang = "en";
	if (navigator.appName == 'Netscape')
    	var language = navigator.language;
	else
    	var language = navigator.browserLanguage;
	var 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://menoyot.com/center/indexeng.html";
	var pageLang = "en";
	
	if (userLang == "en"){
		var dest = "http://menoyot.com/center/indexeng.html";
	} else if  (userLang == "fr") {
		var dest = "http://menoyot.com/center/indexfr.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 seeasianettv() {
	var URLStr = "asianet/index.html";
	var myWidth = 740;
	var myHeight = 600;
	var myPosX = Number((screen.availWidth - myWidth)/2);
	var myPosY = Number((screen.availHeight - myHeight)/2);
	myWin = window.open(URLStr,'Reportage','resizable=no,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,directories=no,height=' + myHeight + ',width=' + myWidth + ',top=' + myPosY + ',left=' +myPosX);
	myWin.focus();
	
	
}
function openLiteracy() {
	var URLStr = "literacy.html";
	var myWidth = 950;
	var myHeight = 540;
	var myPosX = Number((screen.availWidth - myWidth)/2);
	var myPosY = Number((screen.availHeight - myHeight)/2);
	myWin = window.open(URLStr,'Literacy','resizable=no,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,directories=no,height=' + myHeight + ',width=' + myWidth + ',top=' + myPosY + ',left=' +myPosX);
	myWin.focus();
	
}
function goIlletrisme() {
	var URLStr = "illetrisme/index.html";
	var myWidth = 740;
	var myHeight = 500;
	var myPosX = Number((screen.availWidth - myWidth)/2);
	var myPosY = Number((screen.availHeight - myHeight)/2);
	myWin = window.open(URLStr,'Reportage','resizable=no,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,directories=no,height=' + myHeight + ',width=' + myWidth + ',top=' + myPosY + ',left=' +myPosX);
	myWin.focus();

}
function goFrenchSite(){
	window.location="indexFr.html";
}

//===========================================================
function sendEmailNow(){
	// WARNING: Must redirect to http://menoyot.com (NOT www.menoyot.com) for FLASH Security Policy
	var URLStr = "http://menoyot.com/center/sendEmail.html";
	var myWidth = 600;
	var myHeight = 450;
	var myPosX = Number((screen.availWidth - myWidth)/2);
	var myPosY = Number((screen.availHeight - myHeight)/2);
	myWin = window.open(URLStr,'Send Email','resizable=no,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,directories=no,height=' + myHeight + ',width=' + myWidth + ',top=' + myPosY + ',left=' +myPosX);
	myWin.focus();
	
	//alert("The demo is currently under maintenance. Please try later. Sorry for the inconvenience.");
}


//===========================================================
function sendBugReport(){
	// WARNING: Must redirect to http://menoyot.com (NOT www.menoyot.com) for FLASH Security Policy
	var URLStr = "http://menoyot.com/center/sendReport.html";
	var myWidth = 600;
	var myHeight = 500;
	var myPosX = Number((screen.availWidth - myWidth)/2);
	var myPosY = Number((screen.availHeight - myHeight)/2);
	myWin = window.open(URLStr,'Send Report','resizable=no,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,directories=no,height=' + myHeight + ',width=' + myWidth + ',top=' + myPosY + ',left=' +myPosX);
	myWin.focus();
	
	//alert("The demo is currently under maintenance. Please try later. Sorry for the inconvenience.");
}

//===========================================================
function openAllPlayer(){
	// WARNING: Must redirect to http://menoyot.com (NOT www.menoyot.com) for FLASH Security Policy
	
	
	if (window.location.hostname == "localhost") {
		var URLStr = "http://localhost/EducationCenter/loadAll.html";
	} else {
		var URLStr = "http://menoyot.com/EducationCenter/loadAll.html";
	}
	var myWidth = 906.7;
	var myHeight = 680;
	var myPosX = Number((screen.availWidth - myWidth)/2);
	var myPosY = Number((screen.availHeight - myHeight)/2);
	myWin = window.open(URLStr,'LearningNow','resizable=yes,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,directories=no,height=' + myHeight + ',width=' + myWidth + ',top=' + myPosY + ',left=' +myPosX);
	myWin.focus();
	
	//alert("The demo is currently under maintenance. Please try later. Sorry for the inconvenience.");
}

//===========================================================
function openCleanSO(){
	var URLStr = "../EducationCenter/cleanSO.html";
	//var URLStr = "http://localhost/ESv1/Tools/cleanSO.html";
	//var URLStr = "../ESv1/cleanSO.html";
	var myWidth = 620;
	var myHeight = 560;
	var myPosX = Number((screen.availWidth - myWidth)/2);
	var myPosY = Number((screen.availHeight - myHeight)/2);
	//myWin = window.open(URLStr,'EasySkankingPlayer','resizable=yes,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,directories=no,height=' + myHeight + ',width=' + myWidth + ',top=' + myPosY + ',left=' +myPosX);
	//myWin.focus();
	alert("The demo is currently under maintenance. Please try later. Sorry for the inconvenience.");
}
//----------------------------------------------------------------
// FAVORITE SCRIPTS
//----------------------------------------------------------------
// Copyright (c) 2011. Fabrice Menoyot  - http://freeEducationCenter.com
// All rights reserved.
//===========================================================
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 listenToShow(showURL,showName) {
	var myWebHost = window.location.hostname;
	var myWeb = "http://" + myWebHost + "/";
	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 + "/";
	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 + "/";
	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 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();
}
//===========================================================
// 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);
}
//============================================================================
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 the News List and display in from 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 myTitles = xmlDoc.getElementsByTagName("title");
	var myDesc = xmlDoc.getElementsByTagName("description");
	var myBars = xmlDoc.getElementsByTagName("bar");
	var myLinks = xmlDoc.getElementsByTagName("link");
	var myTargets = xmlDoc.getElementsByTagName("target");
	var myImages = xmlDoc.getElementsByTagName("img");
	var myAlign = xmlDoc.getElementsByTagName("imgAlign");
	
	var myText = "";
	for (i=0;i<myTitles.length;i++)
	  { 
	  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;
	  }
	  if (myImages[i].childNodes[0]) {
		 var myImage =  '<img src="' + myImages[i].childNodes[0].nodeValue + '">';
		 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 {
	  
		  if (myTitles[i].childNodes[0]) {
			if (theLink != "") {
				myText += '<p><a href="' + theLink + '"target="' + theTarget + '">' + '<span class="newsTitle">' + myTitles[i].childNodes[0].nodeValue + '</span></a><br>';
			} else {
				myText += '<p><span class="newsTitle">' + myTitles[i].childNodes[0].nodeValue + '</span></a><br>';
			}
			if (myDesc[i].childNodes[0]) {
				myText += '<span class="newsDescription">' + myDesc[i].childNodes[0].nodeValue + '</span></a></p>';
			} else {
				myText +='</p>';
			}
			var myBar = "";
			if ( myBars[i].childNodes[0]) {
				myBar = myBars[i].childNodes[0].nodeValue;
				if (myBar != "") {
					myText += '<p><img src="' + myBar +'" width="100%" height="1" /></p>';
				}
			}
		  }
	  }
		
	 }
	return myText;
}
//-----------------------------------------------------------
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 listenBlogSound(myAudio) {
	var myArray = myAudio.split("|x|");
	var mySound = myArray[0];
	var myTitle = myArray[1];
	listenToShow(mySound,myTitle);
	
}

