// Copyright (c) 2010. Fabrice Menoyot - http://freeEducationCenter.com.
// All rights reserved.
function sendEmailNow(){
	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();
}

function openTimeWeather(){
	var myWidth = 600;
	var myHeight = 620;
	var myPosX = Number((screen.availWidth - myWidth)/2);
	var myPosY = Number((screen.availHeight - myHeight)/2);
	var URLStr = "timeSmall.html";
	myWin = window.open(URLStr,'Time and Weather','resizable=yes,menubar=no,titlebar=no,toolbar=no,scrollbars=no,status=no,directories=no,height=' + myHeight + ',width=' + myWidth + ',top=' + myPosY + ',left=' +myPosX);
	myWin.focus();
}


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()}

 }
//----------------------------------------------------------------
// 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 ){
	var flashvars = {};
	flashvars.xml_file = myXML_file;
	flashvars.sound_file = mySoundFile;
	flashvars.shortTitle = myShortTitle;
	flashvars.bgColor = myBGColor;
	flashvars.autoPlay = myAutoPlay;
	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;
}

