/*  ***************** MasterJS01.js ********************* */

/*  *** 
Replaces BobMainTest02.js
Replaces Functions in 
	Features0212.js
	AVMaster01.js
	

*** */

/*  ***************** Post specific Control Arrays ********************* */
var RunIndex = new Array();
var RunIndex2 = new Array();
var RI2 = new Array();
var QPRx = new Array();
var MaxPages = new Array();
var Mrgb = new Array();
var curPage = new Array();
var curArticle = new Array();
var Row1Index = new Array();
var oldRow1Index = new Array();
var PIndex = new Array();
var oldPIndex = new Array();
var isNewArticle = new Array();
var LeadPostID = new Array();
var curPages = new Array();
var curRowbox = new Array();
var curArtID = new Array();
var DateNode = new Array();
var TA = new Array();
var Wrap0 = new Array();
var Wrap1 = new Array();
var Table = new Array();
var Prow1 = new Array();
var Rrow1 = new Array();
var BAddress = new Array();
var Articles = new Array();
var Images =  new Array();
var AVPlay  =  new Array();
var AVPos  =  new Array();

/*  ***************** Global Variables ********************* */
var SHValue;
var IF_Src;
var IF_CSrcA;
var IF_MFolder = "GTest/Menus/";
var IF_CFolder;

 /*  ***************** UpdateRunIndex ********************* */
 
var SWFplayer = 'http://www.thegrandoldgame.com/SWF/player.swf'; 
var player = null;
var currentState = "NONE"; 
var previousState = "NONE"; 

/*  ***

Functions
	AV(x, b, k)
	AVM(x1, x2, x3, x4, x5)
	ChangeBanner(z, PicName, SrcIndex)
	DXAV(b, k)
	getVars()
	handleResponse()
	HideAVObject(ObjectID)
	HideObject(ObjectID)
	HideUTube(ObjectID)
	function IF_H(x0, x1, x2)
	IHtml(x1)
	RVMJR()
	ScrollHeightTest(a)
	ScrollHeightValue(a)
	SetAVMaster()
	SetLP(oldLP, newLP)
	SF_Display(x1, x2)
	SF_FixObject()
	ShowFBVideo(ObjectID)
	ShowOldStory(x1, x2)
	ShowStory(x1, x2)
	SP_AV(x, b, k)
	stateListener(obj)
	ToggleAV(ObjectID)
	TogglePoll(ObjectID)
 	UpdateRunIndex(x)
	ZRowBox(z, x)
	ZSLP(z, zIndex)
	ZSSP(z, XX)
	
*** */

function AV(x, b, k) {

/* Modified AV(x, b, k) version 01/13/2009 FOR POSTS ONLY ... is now in BobMainTest01.js 

For Posts, x has a range of 0-99 ... for Features, x has a range of 100 - 199 */

 if(x < 100) {
	var AVPlayX = AVPlay[x];
    var ZQPR = QPRx[x];
	var Z = ZQPR[1];
	}
 else {
 	x = x - 100;
	var Z = FeatureID[x];
	AVPlayX = Z + 'AVplayer';
 }   
	
	/* Remaining Code IDENTICAL, regardless of x  */

	var var1 =  eval(Z + 'AVurl');
	var AVurlvar = var1[b]; 
	var PlayerID = Z + 'AV1'; 
	if(k == 0) {
		var SWFh = 20;
		var SWFw = 250;
		var fileValue = '&file=http://www.thegrandoldgame.com/Audio/' + AVurlvar + '&backcolor=FFFFCC&frontcolor=0000CC&lightcolor=FFFF00&screencolor=EEEEEE&autostart=true';
	}
	else if (k == 2) {
		var SWFh = 252;
		var SWFw = 306;
		var fileValue = '&file=http://video.google.com/googleplayer.swf?docid=' + AVurlvar + '&hl=en&fs=1&autostart=true';
	 }	

	else {
		var fileValue = '&file=http://www.youtube.com/v/' + AVurlvar + '&hl=en&fs=1 &backcolor=FFFFCC&frontcolor=0000CC&lightcolor=FFFF00&screencolor=EEEEEE&autostart=true';
		if (k == 3) { 
			var SWFh = 20;
			var SWFw = 250;
		}
		else {
		var SWFh = 252;
		var SWFw = 306;
		}
	}
	
		var so = new SWFObject( SWFplayer,PlayerID,SWFw,SWFh,'9');
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','false');
		so.addParam('flashvars', fileValue);
		so.addParam('id', PlayerID);
		so.addParam('name', PlayerID);
		
		so.write(PlayerID);
		obj = document.getElementById(AVPlayX);
		obj.style.display = "inline";
	 }


function AVM(x1, x2, x3, x4, x5) {
/*  Args 
	x1 = Shop_ID index
	x2 = File Number
	x3 = Media Type
		0 = audio
		1 = U-Tube, show video
		2 = U-Tube, audio only
		3 = Google, show video
		4 = Google. audio only 
	 
	x4 = File Group Number - default = '00', 

	x5 = 0 when x1 = ShopID, 1 when x1 = FeatureID */

 if (x4 == 'undefined') x4 = '00';
 else if (x4 < 10) x4 = '0' + x4;
 
 if (x5 != 'undefined') {} 
 
 var AVurlvar = eval(Shop_ID[x1] + '_' + x4)[x2];
 var PlayerID = 'Master_PID'; 

	if (x3 == 0) {
		var SWFh = 20;
		var SWFw = 250;
		var fileValue = '&file=http://www.thegrandoldgame.com/Audio/' + AVurlvar + '&backcolor=FFFFCC&frontcolor=0000CC&lightcolor=FFFF00&screencolor=EEEEEE&autostart=true';
	}
	
	else if (x3 < 3){
		var fileValue = '&file=http://www.youtube.com/v/' + AVurlvar + '&hl=en&fs=1 &backcolor=FFFFCC&frontcolor=0000CC&lightcolor=FFFF00&screencolor=EEEEEE&autostart=true';
		if (x3 == 2) { 
			var SWFh = 20;
			var SWFw = 250;
		}
		else {
		var SWFh = 252;
		var SWFw = 306;
		}
	}
	
	else if (x3 = 3){
		var SWFh = 20;
		var SWFw = 250;
		var fileValue = '&file=http://www.snuhfiles.com/sound/' + AVurlvar + '&hl=en&fs=1&backcolor=FFFFCC&frontcolor=0000CC&lightcolor=FFFF00&screencolor=EEEEEE&autostart=true';
	}
	
	else {
		var fileValue = '&file=http://video.google.com/googleplayer.swf?docid=' + AVurlvar + '&hl=en&fs=1&autostart=true';
		if (x3 == 4) { 
			var SWFh = 20;
			var SWFw = 250;
		}
		else {
		var SWFh = 252;
		var SWFw = 306;
		}
	}

		var so = new SWFObject( SWFplayer,PlayerID,SWFw,SWFh,'9');
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','false');
		so.addParam('flashvars', fileValue);
		so.addParam('id', PlayerID);
		so.addParam('name', PlayerID);
		so.write(PlayerID);
		MAVobj.style.display = "inline";
		MAVPlayer = document.getElementById(PlayerID);
 }

	 
function ChangeBanner(z, PicName, SrcIndex)  {
 var Pics = Images[z];
 var PicSrc  =  'http://www.thegrandoldgame.com/' + Pics[SrcIndex];
 document[PicName].src=PicSrc;
 
}
	 
function DXAV(b, k) {
    var AVurlvar = eval('D_AVurl[b]');
	var PlayerID = 'XAV1';
	if(k == 0) {
		var SWFh = 20;
		var SWFw = 250;
		var fileValue = '&file=http://www.thegrandoldgame.com/Audio/' + AVurlvar + '&backcolor=FFFFCC&frontcolor=0000CC&lightcolor=FFFF00&screencolor=EEEEEE&autostart=true';
	}
	else if (k == 2) {
		var SWFh = 252;
		var SWFw = 306;
		var fileValue = '&file=http://www.thegrandoldgame.com/Flash/' + AVurlvar + '&backcolor=FFFFCC&frontcolor=0000CC&lightcolor=FFFF00&screencolor=AAAA00&autostart=true';
 
	}	
	else {
		var fileValue = '&file=http://www.youtube.com/v/' + AVurlvar + '&hl=en&rel=0&border=1&backcolor=FFFFCC&frontcolor=0000CC&lightcolor=FFFF00&screencolor=EEEEEE&autostart=true';
		var SWFh = 252;
		var SWFw = 306;
	}
		var so = new SWFObject(SWFplayer,PlayerID,SWFw,SWFh,'9');
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','false');
		so.addParam('flashvars', fileValue);
		so.addParam('id', PlayerID);
		so.addParam('name', PlayerID);
		so.write(PlayerID);
	    obj = document.getElementById(PlayerID); 
		obj.style.display="inline";
				
 }


 /* ****************** Function getVars ()********************* */
/* *** retrieves variables brought in href from theclipjoint (backroom) *** */

function getVars() {
SetAVMaster();
if (document.referrer == 'http://theclipjoint.blogspot.com/'){
varArray = document.location.href.split('?')[1].split('&');
	for(var x=0; x<varArray.length; x++)
	{
		var tmp = varArray[x].split('=');
		eval(unescape(tmp[0]) + '="' + unescape(tmp[1]) + '"');
	}
	


/* change Backroom to http: www.theoldbarbershop.com/index.html#FeatureTop?SFX1='1'&SFX2='1';" Row = SFX1, Cell = SFX2

Also ... create general discussion comment update proceedure for Backroom

###### Change from SF_Display(SFX1, SFX2) to IFrames version IF_H(x0, x1, x2)
 
*/	
	if(SFX1 != 0){
	SF_Display(SFX1, SFX2);
	}
	
}

}

function ShowStory(x, x0) {

if(x <= RowLength) IF_H(x0, 1, x);
else { 
	x = x - RowLength;
 	if(x <= RowLength) IF_H(x0, 2, x);
	else { 
		x = x - RowLength;
		IF_H(x0, 3, x);
 	 }
}

}

function handleResponse() {
  alert('this function is called from server.html')
}


function HideAVObject(ObjectID) {
  if (!document.getElementById) return;
    obj = document.getElementById(ObjectID);
    obj.style.display = "none";
 }
  
 /* Never successful in stopping video using JavaScript ... tried 
 
 MAVPlayer.sendEvent('STOP'); 
 or
 MAVPlayer.Stop()
 or
 function HideAVObject(ObjectID) {
 
    obj = document.getElementById(ObjectID);
    obj.stopVideo();
    obj.style.display = "none";
 }
 
 	MAVPlayer.sendEvent(''STOP'', ''true''); 
*/

 
function HideObject(ObjectID) {
  if (!document.getElementById) return;
    obj = document.getElementById(ObjectID);
    obj.style.display = "none";
 }
 
function HideUTube(ObjectID) {
  if (!document.getElementById) return;
    obj = document.getElementById(ObjectID);
    obj.style.display = "none";
   
 }


function IHtml(x1){
	alert(x1);
	var var1 = 'NPPTest';
	var var2 = 'AskMissCarol01';
	var  obj1 = document.getElementById(var1);
	var var3 = obj1.height;
	alert(obj1.firstChild);
	var  obj2 = document.getElementById(var2);
	alert(obj2.firstChild);
 	var  obj2 = document.getElementById(var2).innerHTML;
	alert(obj2);
    NPP01.innerHTML = obj2;
}    


function RVMJR() {
 alert('debug function');
   }

function ScrollHeightFile(a) {
	
	var testObject1 = document.getElementById(a);
    
	if (testObject1.clientHeight < testObject1.scrollHeight) 
    alert("The element has a vertical scrollbar!"); 
   else 
    alert("The element doesn't have a vertical scrollbar."); 
 
	alert(document.scrollwidth);
	alert(document.height);
	document.scrollwidth = document.width - 20;
	alert(document.scrollwidth);
	alert(document.height);
	 
	if(IsIE) {
		var Hdelta = 0;
		testObject1.style.height = testObject.scrollHeight + Hdelta + 'px'; 
	}	
	else {
	testObject1.style.width = document.width - 20 + 'px'; 
		var Hdelta = 0;
		alert(testObject1.clientHeight);
		testObject1.style.height = testObject1.scrollHeight + Hdelta + 'px';
		
	}
	
	alert(testObject1.offsetHeight); /*  2793 ff   IE */
	alert('document.body.offsetHeight ' + document.body.offsetHeight); /*  2969 ff   IE */ 	
	alert(document.body.parentNode.clientHeight); /*  2985ff   IE */    
	alert(testObject1.scrollHeight);	 /*  2793 ff   IE */
	alert(testObject1.style.height); 	 /*  2793 ff   IE */
}

function ScrollHeightObject(a) {
	var testObject1 = document.getElementById(a);
	
	if (testObject1.clientHeight < testObject1.scrollHeight) 
    alert("The element has a vertical scrollbar!"); 
   else 
    alert("The element doesn't have a vertical scrollbar."); 
	
	var TO1 = testObject1.scrollHeight;
	if(IsIE) {
		var Hdelta = 20;
		var testObject = testObject1.getElementById('SF_010B');
		testObject1.style.height = testObject.scrollHeight + Hdelta + 'px'; 
	}	
	else {
		var Hdelta = 0;
		var testObject = testObject1;
		alert('document.body.offsetHeight ' + document.body.offsetHeight);
		/*  ff 1787 */ 
		alert('testObject ' + testObject);
		testObject1.style.height = document.body.parentNode.clientHeight + Hdelta + 'px';
		
	}
	
	alert(testObject1.offsetHeight); /*  ff 837 */ 	
	alert(document.body.parentNode.clientHeight); /*  ff 1803   */    
	alert(testObject1.parentNode.clientHeight);	 /*  ff client 837 */
	alert(testObject1.style.height); 	
}
   
function ScrollHeightTest(a) {

		var testObject = document.getElementById(a);
		var Hdelta = 92; 
		NewWinHeight = testObject.scrollHeight + Hdelta;
		var MaxHeight = .92 * window.screen.height;
		if(NewWinHeight > MaxHeight) NewWinHeight = MaxHeight;
		self.resizeTo(760, NewWinHeight);
}

function calcObjectHeight(a,b) {
	var iframeEl = document.getElementById(a);
	

var x=iframeEl.contentDocument;
alert(x.getElementsByTagName('table')[0].childNodes[0].nodeValue);
	
alert('hi');

	if ( iframeEl.contentWindow ) { // IE
	alert('IE');
    	var ContentElement = iframeEl.contentDocument.getElementById(b);
	} 
	else if ( iframeEl.contentDocument ) { // DOM
	alert('DOM');
    	var ContentElement = iframeEl.contentWindow.document.getElementById(b);
	}
	
	// Set height of the Object  =  height of the internal page
	iframeEl.height = ContentElement.scrollHeight;
 alert(ContentElement.style.nodeValue);
 alert(ContentElement.parentNode.clientHeight);	 
 alert(ContentElement.scrollHeight);
 alert(ContentElement.offsetHeight);
 
/*  
and in the body create the iframe tag:

<iframe width="100%" id="ObjectID" 
	onLoad="calcObjectHeight(a,b);" 
	src="testing_page.shtml" 
	scrolling="NO" 
	frameborder="1" 
	height="0">
</iframe>

*/

}


function ScrollHeightValue(a) {
	var testObject1 = document.getElementById(a);
	alert(testObject1.parentNode.id);
	alert(testObject1.parentNode.clientWidth);
	alert(testObject1.clientWidth);
	var TO1 = testObject1.scrollHeight;
	if(IsIE) {
		var Hdelta = 20;
		var testObject = testObject1.getElementById('SF_010B');
		testObject1.style.height = testObject.scrollHeight + Hdelta + 'px'; 
	}	
	else {
	var FileHeight = 2816;
		var Hdelta = 20;
		var testObject = testObject1;
		alert('document.body.offsetHeight ' + document.body.offsetHeight);
		/*  ff 1787 */ 
		alert('testObject ' + testObject);
		testObject1.style.height = FileHeight + Hdelta + 'px';
		
	}
	if (testObject1.parentNode.clientWidth < testObject1.parentNode.scrollWidth) 
    alert("The element has a vertical scrollbar!"); 
   else 
    alert("The element doesn't have a vertical scrollbar."); 

	alert(testObject1.offsetHeight); /*  ff 837 */ 	
	alert(document.body.parentNode.clientHeight); /*  ff    */    
	alert(testObject1.parentNode.clientHeight);	 /*  ff client 837 */
	alert(testObject1.style.height); 	
}
	
function ScrollIFrameHV(a) {
	var testObject1 = document.getElementById(a);
	alert(testObject1.scrollHeight + 'px');
	alert(testObject1.attributes.length);
	alert(testObject1.attributes[0].nodeValue);
	alert(testObject1.attributes[1].nodeValue);
	alert(testObject1.attributes[2].nodeValue);
	alert(testObject1.attributes[3].nodeValue);
	alert(testObject1.attributes[4].nodeValue);
	/* attributes[0].value = object's id 
		attributes[1].value = object's style
		attributes[2].value = object's source */
	alert(testObject1.childNodes[0].nodeValue);
	alert(testObject1.height);
	var b = 'SF_010B';
	var testObject2 = testObject1.getElementById('SF_010B');
	alert(testObject2.id);
	
	var testObject = testObject1.getElementById('SF_010B');
	testObject1.style.height = testObject.scrollHeight + 'px';
	alert('style.height ' + testObject.style.height);
}

function SetAVMaster() {
	MAVobj = document.getElementById('Master_AVX');
}
 
function SetLP(oldLP, newLP){ 
/* "SetLP" resets the background color, font color, and cursor for the selected and deselected menu items. */

     obj1 = document.getElementById(oldLP);
     obj1.style.backgroundColor = "purple";
     obj1.style.color = "white";
     obj1.style.cursor = "pointer";
     obj1.style.border = "2px ridge rgb(0, 128, 0)"
     obj2 = document.getElementById(newLP);
     obj2.style.backgroundColor = "transparent";
     obj2.style.color = "red";
     obj2.style.cursor="default";
     obj2.style.border = "0"
   }


	
/* ****************** SF_Display ********************* */

/* The title rows below the Feature Rows are navigational bars.  When a specific Feature is selected, its title in the Bar is changed to "Exit" and provides for closing of the currently selected Feature. 

Features can be referenced by either their "call letters" (SJA) or matrix position [(1,2) = row 1, cell 2].  

The default "displayed feature" SFX='SF_010'

*** Note: Funtion was Called HelloThere(x)

*** */

function SF_Display(x1, x2) {

var z1 = x1 - 1;  
var x = z1 * RowLength + x2;
var FTop = '#FTop' + x;
var xx = 10 * x;
var z = (DisplayedRow - 1) * RowLength + DisplayedRowCell;
var zz = 10 * z;  
var FRZ = 'FR' + DisplayedRow + DisplayedRowCell; // old FRX
var FRX = 'FR' + x1 + x2; // new FRX

if(zz < 100) var SFZ = 'SF_0' + zz; // old SFX
else var SFZ = 'SF_' + zz;
if(xx < 100) var SFX = 'SF_0' + xx; // old SFX
else var SFX = 'SF_' + xx;

DisplayedRow = x1;
DisplayedRowCell = x2; 

if(DisplayedIndex != 0) {
	var obj1 = document.getElementById(FRZ);
	var FTopLink = '<a href=' + FTop + '>' + FeatureTitles[DisplayedIndex] + '</a>';
	obj1.innerHTML = FTopLink;
	obj1 = document.getElementById(SFZ);
	obj1.style.display = "none";
	}

	if(x != DisplayedIndex){
		var FTopLink = '<a href=#FTop0>Exit Feature</a>';
		var obj1 = document.getElementById(FRX);
		obj1.innerHTML = FTopLink;
		DisplayedIndex = x;
		var obj1 = document.getElementById(SFX);
		obj1.style.display = "block"; 
	}
}


function SF_FixObject() {
	if(Fixed_MissCarol_obj1 != 1) {
	MissCarol_obj1 = document.getElementById('AskMissCarol01').innerHTML;
	Fixed_MissCarol_obj1 = 1; 
	}
}


function ShowFBVideo(ObjectID) {
  if (!document.getElementById) return;
    obj = document.getElementById(ObjectID);
    obj.style.display = "inline";
 
 }
 
function ShowOldStory(x1, x2) {
	alert('Article Not Currently Available');
}


function Old_ShowStory(x1, x2) {

	Fid = FeatureID[x1];
	var OldStoryUrl = eval(Fid + '_File')[x2];
	FUrl = Fhref + Fid + '/' + OldStoryUrl;
	var WinFeatures =  'width=760, height=700, scrollbars=1';
	PopUpWin = window.open(FUrl, WinName, WinFeatures);
}

/* here */

function SP_AV(x, b, k) {
	var x = x + 100;
	alert('x ' + x);
	alert('b ' + b);
	alert('k ' + k);
	AV(x, b, k);
}
 
function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
 	currentState = obj.newstate; 
	previousState = obj.oldstate;
	var playerID = obj.id;
	
	var AVDiv = playerID.charAt(0) + '_AVplayer';
	alert(currentState);
	if ((currentState == "COMPLETED") || (currentState == "IDLE")){
	
	document.getElementById(AVDiv).style.display = "none";
	}
}

function ToggleAV(ObjectID) {
  if (!document.getElementById) return;
    obj = document.getElementById(ObjectID);
	if(obj.style.display != 'none') obj.style.display="none";
	else obj.style.display="inline";
 }
 
function TogglePoll(ObjectID) {
  if (!document.getElementById) return;
    obj = document.getElementById(ObjectID);
	if(obj.style.display != 'none') obj.style.display="none";
	else obj.style.display="inline";
 }
 
function UpdateRunIndex(x) { 
  z = RunIndex.length;
  RunIndex[z] = x;
  return z;
}   

function ZRowBox(z, x){
 var var1 = curPages[z];
  if(curRowbox[z] != var1) {
  curRowbox[z] = var1;
  var rowbox = x + '_RowBox';
   for (i = 1; i <= 2; i++) {
   Obj1 = document.getElementById(rowbox + i);
   if(var1 == 1) {
   	Obj1.style.display = "none";
   }
    else { 
   /* show row 2 (pages) at top and bottom of post page and set attributes for page 1*/
    var ZQPR = QPRx[z];
	Obj1.style.display = "inline";
	
	 var v0 = parseFloat(var1);
	 var v1 = 5.0 + 1.0 * v0;
	 var v2 = v1 + 'em';
	 Obj1.style.width = v2;
	 var x= ZQPR[i] + 'td4';
	 var Obj2 = document.getElementById(x + 1);
	 Obj2.style.display = "inline";
     Obj2.style.backgroundColor = "transparent";
     Obj2.style.color = "red";
     Obj2.style.cursor="default"; 
	 
	  for (t = 2; t <= MaxPages[z]; t++) {
	  var Obj2 = document.getElementById(x + t);
	  if(t <= var1) { 
	   Obj2.style.display = "inline";
       Obj2.style.backgroundColor = "purple";
       Obj2.style.color = "white";
       Obj2.style.cursor = "pointer";
	  } 
	  
      else Obj2.style.display = "none";
	  
	  	 } /*  End for (t = 2; t <= MaxPages; t++) */  
    } /*  End else (curPages != 1) */
	
  } /*  End for (i = 1; i <= 2; i++) */
 
 } /*  End if(curRowbox != curPages) */

 } /*  End RowBox(x) Function */

function ZSLP(z, zIndex){
  var ZQPR = QPRx[z];
 
   for (ii = 1; ii <= 2; ii++) {
   var SP = ZQPR[ii] + 'td4';
   var oldSP = SP + PIndex[z];
   var newSP = SP + zIndex;
   SetLP(oldSP, newSP);
  }
  
  curPage[z].style.display = "none";
  isNewArticle[z] = 0;
  curPage[z] = document.getElementById(curArtID[z] + zIndex);
  curPage[z].style.display = "inline";  
  oldPIndex[z] = zIndex;
    
 /* 'R_row1', the bottom table supporting article menu bar, is first shown when the last page of the lead post is selected ... with the lead post selection shown as "Home" */
var DebugX = 0;
if(DebugX){
alert('z ' + z); 
alert('RunIndex ' + RunIndex[z]);
alert('RunIndex2 ' + RunIndex2[z]);
alert('RI2 ' + RI2[z]);
alert('QPRx ' + QPRx[z]);
alert('MaxPages ' + MaxPages[z]);
alert('Mrgb ' + Mrgb[z]);
alert('curPage ' + curPage[z]);
alert('curArticle ' + curArticle[z]);
alert('Row1Index ' + Row1Index[z]);
alert('oldRow1Index ' + oldRow1Index[z]);
alert('PIndex ' + PIndex[z]);
alert('oldPIndex ' + oldPIndex[z]);
alert('isNewArticle ' + isNewArticle[z]);
alert('LeadPostID ' + LeadPostID[z]);
alert('curPages ' + curPages[z]);
alert('curRowbox ' + curRowbox[z]);
alert('curArtID ' + curArtID[z]);
alert('DateNode ' + DateNode[z]);
alert('TA ' + TA[z]);
alert('Wrap0 ' + Wrap0[z]);
alert('Wrap1 ' + Wrap1[z]);
alert('Table ' + Table[z]);
alert('Prow1 ' + Prow1[z]);
alert('Rrow1 ' + Rrow1[z]);
alert('BAddress ' + BAddress[z]);
alert('Articles ' + Articles[z]);
alert('Images ' + Images[z]);
alert('AVPlay ' + AVPlay[z]);
alert('AVPos ' + AVPos[z]);
}

 if(Articles[z] > 1) {
  if((LeadPostID[z] == curArtID[z]) && (zIndex = curPages[z])){
  var zRowBox = RunIndex[z] + '_RowBox2';
  var ztd0 = RunIndex2[z] + '_td0';
    
  document.getElementById(zRowBox).style.position ="absolute";
  Obj1 = document.getElementById(Rrow1[z]);
  Obj1.style.display = "inline";
  obj2 = document.getElementById(ztd0);
  obj2.style.backgroundColor = "transparent";
  obj2.style.color = "red";
  obj2.style.cursor = "default"; 
  obj2.style.border = "0";
 }
 }
PIndex[z] = zIndex;
}


/*  until a supporting article is selected, (TA = 0) ... top menu bar is displayed with TA set = 1.  When "Home" is selected, is reset = 0. */

function ZSSP(z, XX){
 var zk = Row1Index[z];
 var obj1 = null;
 var obj2 = null;
if(XX == 0) {
	var rowbox = RunIndex[z] + '_RowBox2'; 
	document.getElementById(rowbox).style.position ="relative";
	}

if(LeadPostID[z] == curArtID[z]){
  Obj1 = document.getElementById(Prow1[z]);
  Obj1.style.display = "inline";
  var td0 = RunIndex[z] + '_td0';
  obj2 = document.getElementById(td0);
  obj2.style.backgroundColor = "transparent";
  obj2.style.color = "red";
  obj2.style.cursor = "default"; 
  obj2.style.border = "0";
	}

/*  use "SetLP" to reset row 2 values ... page 1 selected both tables*/
  var ZQPR = QPRx[z];
  for (ii = 1; ii <= 2; ii++) {
  
   var oldSSP = ZQPR[ii] + 'td4' + oldPIndex[z];
   var newSSP = ZQPR[ii] + 'td41';
   SetLP(oldSSP, newSSP);
   if(TA[z] == 0) {
      document.getElementById(Prow1[z]).style.display = "block";
	TA[z] = 1;
   }
   var oldSSP = ZQPR[ii] + 'td' + zk;
   var newSSP = ZQPR[ii] + 'td' + XX;
   SetLP(oldSSP, newSSP);
  }

  /*  hide (display:none) for old article and active page and reveal (display:block) for new article ... (display:inline) for page one of the article*/

  curArticle[z].style.display = "none";
  curPage[z].style.display = "none";
  oldRow1Index[z] = zk;
  Row1Index[z] = XX;
  
/* ...................... Selected Article's variables ........................
  sk[0] = Titles (article title)
  sk[1] = Js (Author)
  sk[2] = Ds (article date)
  sk[3] = IDs (id of containing element)
  sk[4] = gs (pages in article)
  sk[5] = On (1= active article, 0 = inactive)
  sk[6] = Size (font size of article title)
  sk[7] = TitleRow (name of title containing element) 
  sk[8] = cIDs (name of Organization i.e. The Shop)    
*/ 

  var BURL = BAddress[z] + '(XX, z)';
  eval(BURL);
  sk = RI2[z];
 
 var ObjTitle = sk[0] + " - " + sk[1];
 
 curPages[z] = sk[4];
 curArtID[z] = sk[3];
 var CAID = sk[3] 
 
 /* ...................End Post Specific Block ........................ */  
   
 /* ...................... Article Title ........................ */

 obj2 = document.getElementById(sk[7]);
 obj2.style.display = "block";
 obj2.firstChild.nodeValue = ObjTitle;
 curArticle[z] = document.getElementById(CAID);
 curArticle[z].style.display = "block";
 curPage[z] = document.getElementById(CAID + 1);
 curPage[z].style.display = "inline";
 for (i = 2; i <= sk[4]; i++) {
  document.getElementById(CAID + i).style.display = "none"; 
 }
 
obj2.style.fontSize = sk[6]; 
 
 /* ....................... End Article Title ........................ */
 
  oldPIndex[z] = PIndex[z];
  
  PIndex[z] = 1;
Obj1 = document.getElementById(Wrap0[z]);
Obj2 = document.getElementById(Table[z]);

 if (XX == 0) {
   	Obj1.style.backgroundColor = "transparent";
	Obj1.style.border = "0";
	Obj2.style.backgroundColor = "transparent";
 	}
 else if (oldRow1Index[z] == 0)  {
    Obj1.style.border = '2px solid red';
	Obj1.style.backgroundColor = Mrgb[z];
 	Obj2.style.backgroundColor = Mrgb[z];
 	}

  if(TA[z] == 0){
  TA[z] = 1;
  }	  
  else if(XX == 0) {
  /*  If "home" is selected, user is returned to "lead post"  */
  document.getElementById(Rrow1[z]).style.display = "none";
  document.getElementById(Prow1[z]).style.display = "none";
  }
 else {
  var ZQPR = QPRx[z];
  var DNx = ZQPR[1] + 'DN' + XX;
   	obj1 = document.getElementById(DNx);
    obj1.style.display = "block";
    obj1.firstChild.nodeValue = sk[2];
 	}
 
 /*  If the number of pages in the selected article (curpages) is different from the number in the previously selected article (oldCurrentPages), run the "Rowbox" module. */

 ZRowBox(z, RunIndex[z]);
 document.getElementById(Wrap1[z]).style.display = "inline";
}
 
function AlertTest() {
alert('test alert 01');
}





