﻿// JavaScript Document 041911 6:30pm

var i, inxt, p, theImages = new Array(), whichImage, rimage, nxtImage = new Image(), ldngImages=0, d=document, obj, scrh, scrw, gwin = null, path;

function VPpopwin(wdt,hgt,pad,content,wintype) {
	
	if (wintype == 'doc') {
		wdt = 840;
		hgt = 575;
	}
	
	if (wintype == 'txt') {
		wdt = document.getElementById(content).scrollWidth;if (wdt > 525) {wdt = 525;};
		hgt = document.getElementById(content).scrollHeight;if (hgt > 575) {hgt = 575;};
	}
	
	var params = wdt + "XZX" + hgt + "XZX" + pad + "XZX" + content + "XZX" + wintype; /* XZX is delimiter for calling parameters to be passed to vpop in window NAME */
	if (gwin && wintype!='mfi') {gwin.close();} /* close a pop-up if one is open (see note for case ext below) */
	wdt = wdt + (2*pad);
	var result = null;
	var ref = null;
	/* add height room for button(s) */
		switch (wintype) {
			case 'gal': result = 25; break;
			case 'img': result = 25; break;
			case 'txt': result = 25; break;
			case 'mfi': result = 25; break;
			case 'map': result = 25; break;
			case 'doc': result = 25; break;
			default: result = 0;
		}
	hgt = hgt + (2*pad) + result;
	scrh = ((window.screen.height - hgt)/2);
	scrw = (((window.screen.width - wdt)/2) - 16);
	
		switch (wintype) {
			case 'pdf': gwin = window.open('Pdf/' + content + '.pdf',content,'width=' + wdt + 'px,height=' + hgt + 'px' + ',left=' + scrw + ',top=' + scrh + ',resizable=yes,scrollbars=yes'); gwin.focus();break;
			case 'ext': /* NB: IE will not return a window reference/handle (gwin) to external site (e.g. virtuesshop) - so cannot focus or close these windows - they will be left open until closed by the IE user. Also note that external links windows from a pop-up has no handle, so will be left open by all browsers.
For full window controls, specify:  gwin = window.open(ref,content,'width=' + wdt + 'px,height=' + hgt + 'px' + ',left=' + scrw + ',top=' + scrh + ',directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes');}  */
			
if (content == "buycards") {
ref = encodeURI("https://virtuesshop.com/index.php?option=com_virtuemart&page=shop.product_details&flypage=flypage.tpl&product_id=45&Itemid=53"); }
if (content == "buypog") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=117&category_id=1&option=com_virtuemart&Itemid=61"); }
if (content == "buyevg") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=96&category_id=17&option=com_virtuemart&Itemid=98"); }
if (content == "buyilb") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=104&category_id=3&keyword=booklet&option=com_virtuemart&Itemid=64"); }
if (content == "buyFVG") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=26&category_id=2&option=com_virtuemart&Itemid=63"); }
if (content == "lookL") {
ref = encodeURI("http://www.nationalpost.com/Angels+workplace+virtue+enhances+productivity/3390154/story.html"); }
if (content == "buy5strat") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=123&category_id=8&option=com_virtuemart&Itemid=67"); }
if (content == "buyVAC") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=86&category_id=10&option=com_virtuemart&Itemid=55"); }
if (content == "buySM") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=41&category_id=1&option=com_virtuemart&Itemid=61"); }
if (content == "buyEVC") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=97&category_id=17&option=com_virtuemart&Itemid=98"); }
if (content == "buyBroc") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=75&category_id=8&option=com_virtuemart&Itemid=67"); }
if (content == "buyFP") {
ref = encodeURI("https://virtuesshop.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=118&category_id=8&option=com_virtuemart&Itemid=67"); }
if (content == "buyFC") {
ref = encodeURI("https://virtuesshop.com/index.php?option=com_virtuemart&Itemid=90"); }
if (content == "searchvp") {
var stext = d.getElementById("srchtxt").value;
if (stext == "") {return;}
ref = encodeURI("http://www.google.com/search?q=" + stext + "&sitesearch=virtuesproject.com/&as_qdr=m3"); }

gwin = window.open(ref,content,'width=' + wdt + 'px,height=' + hgt + 'px' + ',left=' + scrw + ',top=' + scrh + ',location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes');

			return; break;

			default: gwin = window.open('virtuespopup.html',params,'width=' + wdt + 'px,height=' + hgt + 'px' + ',left=' + scrw + ',top=' + scrh + ',resizable=yes,scrollbars=yes');gwin.focus();
		} /*end wintype*/
} /*end popwin*/

function VPvpop() {
	
	var vparms = window.name;
	/*window.name = "VirtuesFeature";  NB - this would be a bit more secure, but it will eliminate the user from refreshing the pop-up */
	var vparmsAR = new Array();
	vparmsAR = vparms.split("XZX");  /* vparmsAR[0]=width, vparmsAR[1]=height, vparmsAR[2]=padding, vparmsAR[3]=content, vparmsAR[4]=type */
	var vwdt = vparmsAR[0];
	var vhgt = vparmsAR[1];
	var vpad = vparmsAR[2];
	var vcont = vparmsAR[3];
	var vtyp = vparmsAR[4];

		switch (vtyp) { /* could bring all getElementByID up here */
			case 'gal': 
				d.getElementById('para').innerHTML='<img id=\"galpic\" src=\"\" />';
				d.getElementById('ncb').style.display = "inline-block";
				d.getElementById('ncb').innerHTML='<br /><input value=\"Next\" type=\"submit\" onclick=\"nextphoto();\" /><input value=\"Close\" type=\"submit\" onclick=\"self.close();\" />';
				d.getElementById('ncb').style.bottom = "0px";
				var addtop = '25';
				d.getElementById('photodiv').style.marginTop = addtop + 'px';
				d.getElementById('para').style.height = "667px";
				photogallery(vcont);
				return; break;
			
			case 'img':
				d.getElementById('para').innerHTML='<img id=\"galpic\" src=\"\" />';
				d.getElementById('ncb').style.display = "inline-block";
				d.getElementById('ncb').innerHTML='<br /><input value=\"Close\" type=\"submit\" onclick=\"self.close();\" />';
				var addtop = '25';
				d.getElementById('photodiv').style.marginTop = addtop + 'px';
				virpick(vcont);
				return; break;
			
			case 'mfi':
				d.getElementById('para').innerHTML='<img id=\"galpic\" src=\"\" />';
				d.getElementById('ncb').style.display = "inline-block";
				d.getElementById('ncb').innerHTML='<br /><input value=\"Close\" type=\"submit\" onclick=\"self.close();\" />';
				var addtop = '25';
				d.getElementById('photodiv').style.marginTop = addtop + 'px';
				mfishow(vcont); 
				return; break;
			
			case 'map':
				var para = d.getElementById("para");
				var content = window.opener.d.getElementById(vcont).innerHTML;
				para.innerHTML = content;
				d.getElementById('ncb').style.display = "inline-block";
				d.getElementById('ncb').innerHTML='<br /><input value=\"Close\" type=\"submit\" onclick=\"self.close();\" />';
				var addtop = '25';
				d.getElementById('photodiv').style.marginTop = addtop + 'px';
				return; break;
			
			case 'aud':
				d.getElementById('para').innerHTML='<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"' + vwdt + '\" height=\"' + vhgt + '\" id=\"FlashID\" title=\"Hear the Virtues Project in Action\"><param name=\"movie\" value=\"Audio/Vaudio.swf\" /><param name="flashVars" value=\"audioname=' + vcont + '.flv\"><param name=\"quality\" value=\"high\" /><param name=\"swfversion\" value=\"6.0.65.0\" /><param name=\"expressinstall\" value=\"Video/expressInstall.swf\" /><param name=\"wmode\" value=\"transparent\" /><!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"Audio/Vaudio.swf\" width=\"' + vwdt + '\" height=\"' + vhgt + '\"><param name="flashVars" value=\"audioname=' + vcont + '.flv\"><!--<![endif]--><param name=\"quality\" value=\"high\" /><param name=\"swfversion\" value=\"6.0.65.0\" /><param name=\"expressinstall\" value=\"Video/expressInstall.swf\" /><param name=\"wmode\" value=\"transparent\" /><!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object>';
			 return; break;
			
			case 'vid':
				d.getElementById('para').innerHTML='<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"' + vwdt + '\" height=\"' + vhgt + '\" id=\"FlashID\" title=\"See the Virtues Project in Action\"><param name=\"movie\" value=\"Video/Vvideo.swf\" /><param name="flashVars" value=\"moviein=' + vcont + '.flv\"><param name=\"quality\" value=\"high\" /><param name=\"swfversion\" value=\"6.0.65.0\" /><param name=\"expressinstall\" value=\"Video/expressInstall.swf\" /><param name=\"wmode\" value=\"transparent\" /><!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"Video/Vvideo.swf\" width=\"' + vwdt + '\" height=\"' + vhgt + '\"><param name="flashVars" value=\"moviein=' + vcont + '.flv\"><!--<![endif]--><param name=\"quality\" value=\"high\" /><param name=\"swfversion\" value=\"6.0.65.0\" /><param name=\"expressinstall\" value=\"Video/expressInstall.swf\" /><param name=\"wmode\" value=\"transparent\" /><!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object>';
			return; break;
			 
			case 'txt':
				if (vcont == "involve" || vcont == "testimonials" || vcont == "involveVPRN")
				{
				var para = d.getElementById("para");
				para.innerHTML=window.opener.document.getElementById(vcont).innerHTML;
				para.style.width = vwdt + 'px';
				d.getElementById('ncb').style.display = "inline-block";
				d.getElementById('ncb').innerHTML='<br /><input value=\"Close\" type=\"submit\" onclick=\"self.close();\" />';
				var alink = new Array();
				alink = d.getElementsByTagName("a");
				for(i=0; i < alink.length ; i++) {alink[i].style.color = "#000000";};
				var addtop = '25';
				d.getElementById('photodiv').style.marginTop = addtop + 'px';
				}
			
			return; break;
		
			case 'fix':
				if (vcont == "ContactUs")
				{
				window.location = 'contact.html';
				}

			return; break;
		
			case 'doc':
				var gdoc = "";
				var para = d.getElementById("para");
				var sects =  'oneG|twoG|threeG|fourG|fiveG|sixG|sevenG|eightG|nineG|tenG';
				theImages = sects.split("|");
				for (i=0;i<=9;i++)
				{
				var docpar = window.opener.d.getElementById(theImages[i]).innerHTML;
				gdoc = gdoc + '<div id="' + theImages[i] + '" style=\"background-color:#FFFFFF;color:#000000;padding:10px;text-align:left;font-size:15px;width:800px;margin-left:auto;margin-right:auto;\">' + docpar+ '</div>';
					if (i<9) {
					gdoc = gdoc + '<div style="height:25px;width:100%;"><input value=\"Close\" type=\"submit\" onclick=\"self.close();\" /></div>';
					}
				}
				para.innerHTML=gdoc;
				d.getElementById('ncb').style.display = "inline-block";
				d.getElementById('ncb').innerHTML='<br /><input value=\"Close\" type=\"submit\" onclick=\"self.close();\" />';
				var alink = new Array();
				alink = d.getElementsByTagName("a");
				for(i=0; i < alink.length; i++) {alink[i].style.color = "#000000";};
				var addtop = '25';
				d.getElementById('photodiv').style.marginTop = addtop + 'px';
				window.scrollTo(0,document.getElementById(vcont).offsetTop);

				return; break;
		
			case 'ytv':
				if (vcont == "kenya")
				{
				d.getElementById("para").innerHTML='<object width=\"480\" height=\"385\"><param name=\"movie\" value=\"http://www.youtube.com/v/R4Roxd_BM4g?fs=1&amp;hl=en_US\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/R4Roxd_BM4g?fs=1&amp;hl=en_US\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"480\" height=\"385\"></embed></object>';
				}

				if (vcont == "strat")
				{
				d.getElementById("para").innerHTML='<object width=\"640\" height=\"385\"><param name=\"movie\" value=\"http://www.youtube.com/v/XC1I-g0vAN0?fs=1&amp;hl=en_US&amp;rel=0\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/XC1I-g0vAN0?fs=1&amp;hl=en_US&amp;rel=0\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"640\" height=\"385\"></embed></object>';
				}
			return; break;
				
			default: return;

		} /*end switch*/
		
} /*end vpop()*/

function virpick(vcont) {
theImages.length = 0;
rimage = d.getElementById('galpic');
path = 'http://virtuesproject.com/Image/Vpicks/';
/* all faiths picks images are the same filenames*/
var picks = 'Accountability.jpg|Assertiveness.jpg|Caring.jpg|Cleanliness.jpg|Compassion.jpg|Confidence.jpg|Consideration.jpg|Cooperation.jpg|Courage.jpg|Courtesy.jpg|Creativity.jpg|Detachment.jpg|Determination.jpg|Discernment.jpg|Enthusiasm.jpg|Excellence.jpg|Faith.jpg|Faithfulness.jpg|Flexibility.jpg|Forgiveness.jpg|Friendliness.jpg|Generosity.jpg|Gentleness.jpg|Gratitude.jpg|Helpfulness.jpg|Honesty.jpg|Honor.jpg|Humility.jpg|Idealism.jpg|Joyfulness.jpg|Justice.jpg|Kindness.jpg|Love.jpg|Loyalty.jpg|Mercy.jpg|Moderation.jpg|Modesty.jpg|Obedience.jpg|Orderliness.jpg|Patience.jpg|Peacefulness.jpg|Prayerfulness.jpg|Purposefulness.jpg|Reliability.jpg|Respect.jpg|Responsibility.jpg|Reverence.jpg|Righteousness.jpg|Self-Discipline.jpg|Service.jpg|Steadfastness.jpg|Tact.jpg|Tolerance.jpg|Trust.jpg|Trustworthiness.jpg|Truthfulness.jpg|Unity.jpg|Wonder.jpg';
switch (vcont) {
case 'getrandomimage': path = path + "Random/";
var picks = 'Acceptance.jpg|Accountability.jpg|Appreciation.jpg|Assertiveness.jpg|Awe.jpg|Beauty.jpg|Caring.jpg|Certitude.jpg|Charity.jpg|Cheerfulness.jpg|Cleanliness.jpg|Commitment.jpg|Compassion.jpg|Confidence.jpg|Consideration.jpg|Contentment.jpg|Cooperation.jpg|Courage.jpg|Courtesy.jpg|Creativity.jpg|Decisiveness.jpg|Detachment.jpg|Determination.jpg|Devotion.jpg|Dignity.jpg|Diligence.jpg|Discernment.jpg|Empathy.jpg|Endurance.jpg|Enthusiasm.jpg|Excellence.jpg|Fairness.jpg|Faith.jpg|Faithfulness.jpg|Friendliness.jpg|Fidelity.jpg|Flexibility.jpg|Forbearance.jpg|Forgiveness.jpg|Fortitude.jpg|Generosity.jpg|Gentleness.jpg|Grace.jpg|Gratitude.jpg|Helpfulness.jpg|Honesty.jpg|Honor.jpg|Hope.jpg|Humanity.jpg|Humility.jpg|Idealism.jpg|Independence.jpg|Initiative.jpg|Integrity.jpg|Joyfulness.jpg|Justice.jpg|Kindness.jpg|Love.jpg|Loyalty.jpg|Mercy.jpg|Mindfulness.jpg|Moderation.jpg|Modesty.jpg|Nobility.jpg|Openess.jpg|Optimism.jpg|Orderliness.jpg|Patience.jpg|Peacefulness.jpg|Perceptiveness.jpg|Perseverance.jpg|Prayerfulness.jpg|Purity.jpg|Purposefulness.jpg|Reliability.jpg|Resilience.jpg|Respect.jpg|Responsibility.jpg|Reverance.jpg|Righteousness.jpg|Sacrifice.jpg|Self-Discipline.jpg|Serenity.jpg|Service.jpg|Simplicity.jpg|Sincerity.jpg|Steadfastness.jpg|Strength.jpg|Tact.jpg|Thankfulness.jpg|Thoughtfulness.jpg|Tolerance.jpg|Trust.jpg|Trustworthiness.jpg|Truthfulness.jpg|Understanding.jpg|Unity.jpg|Wisdom.jpg|Wonder.jpg|Zeal.jpg';break;

case 'getrandomimagee': path = path + "Randome/";
var picks = 'Assertiveness.jpg|Caring.jpg|Cleanliness.jpg|Commitment.jpg|Compassion.jpg|Confidence.jpg|Consideration.jpg|Cooperation.jpg|Courage.jpg|Courtesy.jpg|Creativity.jpg|Detachment.jpg|Determination.jpg|Diligence.jpg|Enthusiasm.jpg|Excellence.jpg|Friendliness.jpg|Flexibility.jpg|Forgiveness.jpg|Generosity.jpg|Gentleness.jpg|Helpfulness.jpg|Honesty.jpg|Honor.jpg|Humility.jpg|Idealism.jpg|Integrity.jpg|Joyfulness.jpg|JusticeB.jpg|Kindness.jpg|Love.jpg|Loyalty.jpg|Moderation.jpg|Modesty.jpg|Orderliness.jpg|Patience.jpg|Peacefulness.jpg|Perseverance.jpg|Purposefulness.jpg|Reliability.jpg|Respect.jpg|Responsibility.jpg|Self-Discipline.jpg|Service.jpg|Tact.jpg|Thankfulness.jpg|Tolerance.jpg|Trust.jpg|Trustworthiness.jpg|Truthfulness.jpg|Understanding.jpg|Unity.jpg';break;

case 'getrandomimageFVC': path = path + "RandomFVC/";
var picks = 'Assertiveness.jpg|Caring.jpg|Cleanliness.jpg|Compassion.jpg|Confidence.jpg|Consideration.jpg|Courage.jpg|Courtesy.jpg|Creativity.jpg|Detachment.jpg|Determination.jpg|Enthusiasm.jpg|Excellence.jpg|Faithfulness.jpg|Friendliness.jpg|Flexibility.jpg|Forgiveness.jpg|Generosity.jpg|Gentleness.jpg|Helpfulness.jpg|Honesty.jpg|Honor.jpg|Humility.jpg|Idealism.jpg|Joyfulness.jpg|Justice.jpg|Kindness.jpg|Love.jpg|Loyalty.jpg|Mercy.jpg|Moderation.jpg|Modesty.jpg|Obedience.jpg|Orderliness.jpg|Patience.jpg|Peacefulness.jpg|Prayerfulness.jpg|Purposefulness.jpg|Reliability.jpg|Respect.jpg|Responsibility.jpg|Reverence.jpg|Self-Discipline.jpg|Service.jpg|Steadfastness.jpg|Tact.jpg|Thankfulness.jpg|Tolerance.jpg|Trust.jpg|Trustworthiness.jpg|Truthfulness.jpg|Unity.jpg';break;
case 'getrandomimageA': path = path + "RandomA/";break;
case 'getrandomimageB': path = path + "RandomB/";break;
case 'getrandomimageBF': path = path + "RandomBF/";break;
case 'getrandomimageCB': path = path + "RandomCB/";break;
case 'getrandomimageCC': path = path + "RandomCC/";break;
case 'getrandomimageKJV': path = path + "RandomCKJV/";break;
case 'getrandomimageFN': path = path + "RandomFN/";break;
case 'getrandomimageH': path = path + "RandomH/";break;
case 'getrandomimageJ': path = path + "RandomJ/";break;
case 'getrandomimageLDS': path = path + "RandomLDS/";break;
case 'getrandomimageM': path = path + "RandomM/";break;
case 'getrandomimageS': path = path + "RandomS/";break;
case 'getrandomimageZ': path = path + "RandomZ/";break;

	default: return;break;
	} /* end switch */
theImages = picks.split("|");
p = theImages.length;
whichImage = Math.round(Math.random()*(p-1));
rimage.src = path + theImages[whichImage];
}

