// must be loaded AFTER file-specific .js file which defines thisTopicId
// and AFTER at_<SECTION_NAME>.js which defines array of topic objects
var pathtoroot = getPathToRoot(); //save function calls throughout module
var indentPixels = 6;
var levelWidth = 189;
var maxIndent = 6; //8
var thisTopicObj = null;
var maxATcolumns=15;
var coDom = false;
var coDomImage = "";
//var dbgWindow = null;
//alert('in at.js');
function NewWin(u){
	// inaptly named but... this function used by Phorum SLS to create reply
	if (u==null) { alert ("Sorry, we cannot open new window at this time. Please report this error (code=0003). Thank you."); }
	else {
		var newwin=window.open(u,"SLSREPLYWIN","height=500,width=500,resizable=yes,scrollbars=yes,status=yes");
	}
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {

var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}


// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function getLogoImages(p2root){
	var retStr='<div align="left">';
	if (arguments.length == 1 || arguments[1] == true) {
		retStr += '<a href="' + getPathToRoot() + '/index.htm"><img src="';
	}
	else {
		retStr += '<img src="';
	}
	if  (p2root.indexOf('www.myjewishlearning.com') > -1) {
		retStr += '/common/images/logo.gif" width="325" height="63" border=0"></a>';
	}
	else if (p2root.indexOf('jewishla.myjewishlearning.com') > -1) {
		retStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images/jewishlalogo.gif" width="114" height="63" >';
	}
	else if (p2root.indexOf('hillel.myjewishlearning.com') > -1) {
		retStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images/hillel.jpg" width="114" height="63" >';
	}
	else if (p2root.indexOf('hadassah.myjewishlearning.com') > -1) {
		retStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><a href="www.hadassah.org" target="_blank"><img src="/common/images/hadassah.jpg" width="114" height="63" alt="Go to Hadassah.org Web site"></a>';
	}
	else if (p2root.indexOf('jcc.myjewishlearning.com') > -1) {
		retStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images/jcc.jpg" width="114" height="63" >';
	}
	else if (p2root.indexOf('bbyo.myjewishlearning.com') > -1) {
		retStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images/bbyo.jpg" width="114" height="63" >';
	}
	else if (p2root.indexOf('star.myjewishlearning.com') > -1) {
		retStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images/star.jpg" width="114" height="63" >';
	}
	// catch all case
	else {
		retStr += '/common/images/logo.gif" width="325" height="63" border="0" ></a>';
	}
	return retStr ;
}



function getPageContext(){
	var ctx = getParamVal("GL");
	if (ctx == null && typeof(thisPageTemplate) != 'undefined') {
		// for Index pages don't burden caller to specify GL parameter
		//alert('at.js: thisPageTemplate='+thisPageTemplate);
		return thisPageTemplate ;
	}
	else if (ctx != null && ctx.toLowerCase() == 'true') {
		return 'GL';
	}
	else if (ctx != null && ctx.toLowerCase() == 'idx') {
		// in case caller wants to force the "index" style left hand panel
		// even though page doesn't declare it's an Index page
		return 'IDX';
	}
	else {
		// the most common case
		return 'AT';
	}
}
function isSibling(t1,t2){
	// t1 is topic being tested
	// t2 is the selected topic for article
	// if t1 differs from t2 only in last element then they are siblings
	if (chopTopic(t1,1)==chopTopic(t2,1)) { return true; }
	else {return false;}
}
function topicDepth(key){
	// count dots in key
	var count = 0;
	for (var i=0;i < key.length;i++) {
		if (key.charAt(i) == ".") { count++ ; }
	}
	return count;
}
function trimTopic(str,count){
	// cut off "count" leading topic identifiers from string
	var dotloc=-1;
	for (var i=0; i > count; i++){
		if ((dotloc=str.indexOf('.',dotloc+1)) == -1) { return null ; }
	}
	return str.substring(dotloc+1) ;
}
function chopTopic(str,count){
	// cut off "count" trailing path elements
	var dotloc=-1;
	for (var i=0; i < count; i++){
		dotloc=str.lastIndexOf('.');
		if (dotloc == -1) { return null; }
		str = str.substring(0,dotloc);
	}
	return str ;
}

function initAllTopics(){
	// go through array of topics and set items menustate
	for (var i=0; i < allTopicsElements.length; i++) {
		// set up object's own index field
		allTopicsElements[i].arrayIndex=i;
		if (allTopicsElements[i] != null )
			initTopic(allTopicsElements[i]) ;
	}
}
function initTopic(topicObj){
/*
summer 2003:
We compare thisTopicId with the topicid of topicObj:
-we set hasChildren attribute
-we set state for ancestor/sibling/child of current topic:
STATES:
0. default state (do not display at all)
1. display as OPEN in bold using ">" since this is the current item!
2. diplay as OPEN in normal since this is ancestor of current item
3. display as CLOSED in normal since thie is child of current item
3. display as CLOSED in normal since this is sibling of current item
3. display as CLOSED in normal since this is sibling of ancestor current item
3. display as CLOSED in normal since this is first level item (non-ancestral)
*/
	//NOTE: Do not change the order of the following if...else if...else structure!!
	topicObj.menustate = 0;
	// special cases first: this page does not appear in AT and so
	// if we are looking at it we are in GL context or some other context
	if (thisTopicId == null ) { return; }
	else if (topicObj.topicId == thisTopicId) {
		// this is the current topic!
		topicObj.menustate=1;
		hasChildren(topicObj);
		thisTopicObj = topicObj; // save it for later
	}
	else if (thisTopicId.indexOf(topicObj.topicId) == 0) {
		// ancestor of current topic at some level
		topicObj.menustate=2;
		hasChildren(topicObj);
	}
	else if (topicObj.indent == 0) {
		// first level item but not ancestor
		topicObj.menustate=3;
		hasChildren(topicObj);
	}
	else if (topicObj.topicId.indexOf(thisTopicId) == 0 &&
			topicDepth(topicObj.topicId) == (topicDepth(thisTopicId) + 1) ){
		// direct child
		topicObj.menustate=3;
		hasChildren(topicObj);
	}
	else if (chopTopic(topicObj.topicId,1) == chopTopic(thisTopicId,1)){
		// sibling -- show it
		topicObj.menustate=3;
		hasChildren(topicObj);
	}
	else {
		// handle the siblings of each ancestor!
		for (var j=0;j < topicDepth(thisTopicId)-1;j++){
			if (isSibling(topicObj.topicId,chopTopic(thisTopicId,j))){
				topicObj.menustate=3;
				hasChildren(topicObj);
			}
		}
	}
}
function hasChildren(tObj){
	// set tObj.hasChildren to true or false acc. to whether tObj has any children
	tObj.hasChildren = false; // simplifies the ELSE case below
	// note that we need only check the NEXT item but since it might be null we use a strange for loop
	for (var i=tObj.arrayIndex+1;i<allTopicsElements.length; i++) {
		if (allTopicsElements[i] == null) { continue; }
		else if (allTopicsElements[i].topicId.indexOf(tObj.topicId)>-1){
			tObj.hasChildren = true;
			return;
		}
		else {
			return;
		}
	}
}

function chooseTag(i){
	var tObj=allTopicsElements[i];
	//var colspan = maxATcolumns - (tObj.indent+1);
    // bug fix MAF 0805
    var colspan = maxATcolumns - 1;
    //if (tObj.indent > 0) colspan = maxATcolumns - (tObj.indent+2);
    colspan = maxATcolumns - (tObj.indent+1);


	var retStr = '<td colspan="'+ colspan + '" valign="top">';

	//if (tObj.menustate != 1) {
	//	retStr += '<p><a class="lhsnav" href="' + tObj.url + '">';
	//}
	//else {
	//	retStr += '<p class="current"><span class="current">123<a class="current" href="' +	tObj.url + '">';
	//}
	//retStr += tObj.tag + '</a><br></p></td>';

    if (tObj.menustate != 1) {
		retStr += '<p><a class="lhsnav" href="' + tObj.url + '">' + tObj.tag + '</a></p></td>';;
	}
	else {
		retStr += '<p class="current">' + tObj.tag + '</p></td>';;
	}
	//retStr += tObj.tag + '</a><br></p></td>';

    //alert(retStr);

	return retStr;
}
function choosePMA(idx){
	// usual case: has children and is not opened
	var retStr = null;
	var tObj=allTopicsElements[idx];
	if (tObj.menustate==1) {
		retStr = '<p class="current"><a class="current" href="' + tObj.url + '">';
		retStr += '<img border="0" src="/common/images/treebits/arrow.gif" width="9" height="9" align="texttop">';
	}
	else if (tObj.menustate==2 || !tObj.hasChildren) {
		retStr = '<p class="black"><a class="lhsnav" href="' + tObj.url + '">';
		retStr += '<img border="0" src="/common/images/treebits/minus.gif" width="9" height="9" align="texttop">';
	}
	else {
		retStr = '<p class="black"><a class="lhsnav" href="' + tObj.url + '">';
		retStr += '<img border="0" src="/common/images/treebits/plus.gif" width="9" height="9" align="texttop">';
	}
	retStr += '</a>';
    //alert(retStr);
	return retStr;
}
function fixupDetailLineItemArray(arr){
	// forward traverse array to set branchlast property
	var i=0;
	while (i<arr.length){
		// no branchlast for indent 0 items!
		//20030808 no vertstretch at all
		arr[i].needVertStretch = false;
		if (arr[i].indent==0) {	arr[i].branchlast=null; }
		else {
			//if no next node or next node is less indented, then this node is LAST
			if (i==(arr.length-1) || arr[i+1].indent < arr[i].indent) {
				arr[i].branchlast='last';
			}
			else {
				arr[i].branchlast='branch';
			}
		}
		i++;
	}
	/*
	var dbgStr='Following are array elements \n';
	for (var i=10;i<arr.length;i++){
		dbgStr += '   VSTRETCH:' + arr[i].needVertStretch  + '\n'+
			// 'INDENT:' + arr[i].indent  + '\n'+
			// '   PMA:' + arr[i].pma  + '\n'+
			  '   TAG:' +  arr[i].detail + '\n';
	}
	alert(dbgStr);
	*/
}
function AllTopics(){
	var root= null;

	var thisSec = thisTopicId;
    if (thisSec.length >=5) thisSec = thisSec.substring(0,5); // set current XX.XX section
    else thisSec = ""; // should not ever be blank

    //displayMainIx ();

    document.write('<table class="topicsborder" align="right" width="100%" border="0" cellspacing="1" cellpadding="0">');
    //remove this line MF FOR MRJ
    //document.write('<tr><th align=left><p class="menutitle">' + ixTitle + '</p></th></tr>');
    for (var i=0;i<allixObj.length;i++){ // NEW DISPLAY OF ALL HOMETOPICS IN SECTION


        //alert(allixObj[i].topicId + ' : ' + thisSec);
        if (thisSec != allixObj[i].topicId) // do section index links ??DONT NEED FOR MRJ MF
        {
            //document.write('<tr><td><p class="lhsnav"><a class="lhsnav" href="' + allixObj[i].url + '">' + allixObj[i].tag + '<a></p></td></tr>');
        }
        else
        {  // write topcid nav for this (sub section
        	if (arguments.length > 1 ) { root = arguments[1];}
        	var glCtxt=getPageContext();
            // DISPLAY CURRENT SECTION TITLE MF
            document.write('<tr><td style="background-color:#ffa63f"><p class="lhsnav">&nbsp;<a class="lhsnavTitle" href="' + allixObj[i].url + '"><strong>' + allixObj[i].tag + '</strong><a></p></td></tr>');
            document.write('<tr><td>');
        	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="2">');
        	if (glCtxt == 'GL' || glCtxt == 'IDX') {
        		// just show top level nodes
        		collapseAllTopics(root);
        	}
        	else {
        		// open tree to correct node, showing ancestors, siblings, direct children, and siblings of ancestors
        		showAllTopics(false,root);
        	}
            document.write('</table>');
            //document.write('<b>GL HERE</b>');
            document.write('</td></tr>');
            //showReadability();
        }

    }
    document.write('</table>');


}
function collapseAllTopics(r){
	showAllTopics(true,r);
}

function showAllTopics(top,r){
    // new if Feb 05, 2004 - don't display this info for links pages
    //if (allTopicsMainTopicId!='LI') {
    if (allTopicsMainTopicId=='XYZ') { // DO NOT DISPLAY AT ALL FOR NEW DESIGN
    //if (allTopicsMainTopicId!='XYZ') { // PUT BACK IN FOR TESTING FEB 08 (MRJ)
    	document.write('<tr><th colspan="'+(maxATcolumns)+'"><p class="menutitle">1.');
	    document.write(allTopicsSectionTitle +' (');
    	document.write(allTopicsElements.length +')</p></th></tr>');
    }

    //alert("top:" + top);
    //alert("TID: " + thisTopicId);

	if (top == true) {
		// handle special collapsed case quickly
		var tmpidx=0;
		var detailline='';
		var detailline2='';
		for (var i=0;i<allTopicsElements.length;i++){
			if (allTopicsElements[i].indent==0){
				// show all first level items (menustate always 3)
				if ((tmpidx++)>0){
					//end previous item unless first time through
					document.write(detailline + detailline2);
				}
				//20030808 no vertstretch anymore
				//detailline='<tr><td align="left" class="vertstretch" valign="top">';
				detailline='<tr><td align="left" valign="middle">';
				detailline+='<a class="lhsnav" href="'+allTopicsElements[i].url + '">';
				if (allTopicsElements[i].hasChildren) {
					detailline2='<img border="0" src="/common/images/treebits/plus.gif" width="9" height="9"></a></td>';
				}
				else {
					detailline2='<img border="0" src="/common/images/treebits/minus.gif" width="9" height="9"></a></td>';
				}
                  		detailline2+='<td colspan="'+(maxATcolumns-1)+' valign="middle">';
				detailline2+='<p ><a class="lhsnav" href="';
				detailline2+=allTopicsElements[i].url + '">';
				detailline2+=allTopicsElements[i].tag;
				detailline2+='</a></p></td></tr>';
			}
		}
		//20030808 no vertstretch anymore
		// last line does not get a vertstretch!
		//detailline='<tr><td align="left" valign="top">';
		document.write(detailline + detailline2);
        //alert(detailline + detailline2);
		//alert('showAllTopics at end of loop for top==true--wrote out:\n ' + detailline + detailline2);
	}
	else {
		// show each node at appropriate depth and open/closed/invisible state
		// using object state and hasChildren attributes
		// make sure the current node is shown in bold red(?)
		// following set up inside loop for each item
		var detailLineItemArray=new Array();

		var arrayIdx=0;
		var colspan=0;
		var lineItem=null;
		// create array of line item objects
		for (var i=0;i<allTopicsElements.length;i++){
			if (allTopicsElements[i]==null || allTopicsElements[i].menustate == 0) {continue;}
			lineItem = new Object();
			lineItem.indent=allTopicsElements[i].indent;
			lineItem.idx=i;
			lineItem.detail= chooseTag(i);
			lineItem.pma = choosePMA(i);
			lineItem.branchlast='branch'; // default value
			//20030808 no vertstretch anymore
			lineItem.needVertStretch=false; // default value
			// save item
			detailLineItemArray[arrayIdx++]=lineItem;
		}
		// fixup array by setting the "needVertStretch" flag
		fixupDetailLineItemArray(detailLineItemArray);

		// now we go through array and write out the detail lines appropriately
		//030808
		// eliminate these images and use spacers!!!!!!
		//var branchImg ='<img src="/common/images/treebits/branch.gif" width="9" height="9">';
		//var lastImg ='<img src="/common/images/treebits/last.gif" width="9" height="9">';
		var branchImg ='<img src="/common/images/spacer.gif" width="1" height="9">';
		var lastImg ='<img src="/common/images/spacer.gif" width="1" height="9">';

		var thisLineItem=null;

		for (var i=0;i<detailLineItemArray.length;i++){
			document.write('<tr>');
			thisLineItem=detailLineItemArray[i];
			// special case for indent 0

			if (detailLineItemArray[i].indent==0){
				//20030808 no vertstretch anymore
				document.write('<td align="left" valign="middle">');
				document.write(thisLineItem.pma + '</td>');
				document.write(thisLineItem.detail + '</tr>' );
				continue; // do next item
			}
			// handle all non-0 indents...
			// construct each TD
			for (var j=0;j<=thisLineItem.indent;j++){
				// if any later item at this indent level then write out vertstretch
				//20030808 get rid of vertstretch
				/*
				this algorithm won't work!!! only draw vertical lines in those TDs that need them!!
				this means that we need to know if some earlier node at indent N needs to be connected to node later in the array at indent N
				must complicate the array in which we keep this info: let each item remember what tab indents need a vertstretch
				complicate the fixup logic a lot
				MEANTIME try turning off the stretch
				if (thisLineItem.needVertStretch) {document.write('<td align="left" class="vertstretch" valign="top">');}
				else { document.write('<td align="left" valign="top">');  }
				*/
				//document.write('<td align="left" colspan="' + thisLineItem.indent + '"valign="top">x4');
				//terminate all but the last TD before the pma etc
				if (j<thisLineItem.indent)
				{
				//document.write('1</td>');
				}
				else if (thisLineItem.branchlast == 'branch'){
					//document.write(branchImg + '2</td>');
				}
				else if(thisLineItem.branchlast == 'last'){
					//document.write(lastImg + '3</td>');
				}
			}
			// now do the rest of the line
			//030808 eliminate vertstretch
			//document.write('<td class="vertstretch" valign="top">' + thisLineItem.pma + '</td>');
			//document.write('<td valign="top">x5' + thisLineItem.pma + '</td>');
            //if (thisLineItem.indent != 0) {
                document.write('<td valign="top" colspan="' + thisLineItem.indent + '">&nbsp;</td>');
            //}
            document.write('<td valign="middle" align="center" colspan="1">' + thisLineItem.pma + '</td>');
            //alert(thisLineItem.detail);
			document.write(thisLineItem.detail);
            //alert(this.colspan);
			document.write('</tr>');
 		}

	}

}


function displayMainIx () {

alert(ixcnt);

}



function choosePartnerLogo(){
	// this function is here only for backwards compatibility for Quizzes.
	// Its sole job is to return the file for the partner and/or a background image.
	return getPartnerLogoString();
}
function padspaces(indentlevel){
	//alert('inside padspaces with indentlevel='+indentlevel);
	//var retStr="";
	if (indentlevel == 0) { return ""; }
	var retStr = '<img src="/common/images/space4.gif" border=0 hspace=0 vspace=0 width=1>';
	while (indentlevel > 0) {
		retStr += '<img src="/common/images/space4.gif" border=0 hspace=0 vspace=0 width=5>';
		indentlevel-- ;
	}

	return retStr ;
}


function getBreadCrumbs(){
    //alert('in crumbs');
    //return;
	//return (getSignInUpOut());
	//*
	//var retStr =  '<a href="javascript:signinupout();"><img border="2" ' +
	//	'src="' + getPathToRoot()+ '/common/images/headlines/signinupout.gif" valign="bottom" width="98" height="15" vspace="2"></a>';
	//var retStr = '<b><i>Site Preview. Launch: Chanukah 2002 </i><b>';
    var retStr = '';
	if (thisTopicObj == null || arguments.length>0 ) {
        return '';
		// might be Index Page or GL page
		retStr += allTopicsTitle;
		if (arguments.length>0){ retStr += "&gt;" + arguments[0] ; }
	}
	else {
		retStr += thisTopicObj.crumbs;
	}
    //retStr = replace(retStr,'&gt;',' | ').toUpperCase();
    retStr = replace(retStr,'&gt;',' | ');
    retStr = '<table width="100%"><tr><td valign="top" class="crumbs">' + retStr + '</td>';

    if (currenttalkback)
        retStr += '<td valign="top"><a href="#tb"><img src="/common/images/tback_sm.gif" alt="Discuss This Article" width="107" height="60" border="0"></a></td>';

    retStr += '</tr></table>';


	return retStr;
}


function getBreadCrumbsTBonly(){
    var retStr = '';
    if (currenttalkback)
        retStr += '<a href="#tb"><img src="/common/images/tback_sm.gif" alt="Discuss This Article" width="107" height="60" border="0"></a>';
	return retStr;
}


function getJoinLine(){
	return (getSignInUpOut());
	/*
	var retStr =  '<a href="javascript:signinupout()"><img border="2" ' +
		'src="' + getPathToRoot()+ '/common/images/headlines/referthissite.gif" valign="bottom" width="73" height="23" vspace="2"></a>' +
		'<a href="javascript:survey();"><img border="2" ' +
		'src="' + getPathToRoot()+ '/common/images/headlines/wewantyour.gif" valign="bottom" width="73" height="23" vspace="2"></a>';
	return retStr ;
	*/
}

function TwoLogosLarge(){
	return "";
	/*
	var retStr = '<table width="200" border="0" cellspacing="0" cellpadding="0">';
	retStr += '<tr><td align="center"><br><a href="http://www.hebrewcollege.edu"><img src="/common/images/hebrew_college.gif" border=0 width="200" height="80"></a></td></tr><tr><td><br><a href="http://www.jflmedia.com"><img src="/common/images/jfl_logo.gif" border=0 width="200" height="80"></a></td></tr>';
	retStr += '</table>';
	document.write(retStr);
	*/
}
function TwoLogos(){
	return "";
	/*
	var retStr = '<table width="200" border="0" cellspacing="0" cellpadding="0">';
	retStr += '<tr><td align="center"><br><a href="http://www.hebrewcollege.edu"><img src="/common/images/hebrew_edu_logo_sm.gif" border=0 width="132" height="50"></a></td></tr><tr><td><br><a href="http://www.jflmedia.com"><img src="/common/images/jfl_logo_sm.gif" border=0 width="132" height="50"></a></td></tr>';
	retStr += '</table>';
	document.write(retStr);
	*/
}
function help(key){
	var locStr = getPathToRoot() + '/Help/help.html';
	if (key==null || key=='help') {locStr= getPathToRoot() + '/Help/help.html';}
	else if (key=='browsers') {locStr= getPathToRoot() +'/Help/browsers.html';}
	else if (key=='printer') {locStr= getPathToRoot() +'/Help/printer.html';}
	else if (key=='mlt') {locStr= getPathToRoot() +'/Help/mlt.html';}
	else if (key=='gloss') {locStr= getPathToRoot() +'/Help/glossary.html';}
	else if (key=='glearn') {locStr=getPathToRoot() +'/Help/glearning.html';}
	else if (key=='prnsnd') {locStr=getPathToRoot() +'/Help/printsend.html';}
	else if (key=='join') {locStr= getPathToRoot() + '/Help/join.html';}
	else if (key=='persp') {locStr= getPathToRoot() +'/Help/perspectives.html';}
	else if (key=='disc') {locStr= getPathToRoot() +'/Help/discussions.html';}
	else if (key=='alltopics') {locStr= getPathToRoot() +'/Help/alltopics.html';}
	else if (key=='search') {locStr= getPathToRoot() +'/Help/search.html';}
	else if (key=='journal') {locStr= getPathToRoot() +'/Help/journal.html';}
	else if (key=='print') {locStr= getPathToRoot() +'/Help/print.html';}
	else if (key=='email') {locStr= getPathToRoot() +'/Help/email.html';}
	//alert('locStr is ' + locStr );
	var winprops="height=475,width=530,directories=no,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
	if (arguments.length == 1) {
		win = window.open(locStr, "HELPWIN", winprops);
	}
	else if (arguments[1] == 'SELF'){
		location = locStr;
	}
	else {
		alert('at.js: Error. help() called with unrecognized extra argument');
	}
}
function eletter(){
	var sname = getScreenNameCookie();
	if (sname == null) {
        window.location = '/User/signup.jsp';
		//alert('You will need to login or register in order to take advantage of this and many other Members-only features.\nMembership is free and private.\nThank you.');
		return;
	}
	//var newwin=window.open(getPathToRoot() + "/eletter/launchEletter.htm","ELETTERWIN","height=500,width=650,resizable=yes,scrollbars=yes,status=yes");
    window.location = '/eletter/launchEletter.htm';
}
function jumpMainWindow(pg){
	// this function needs to be made more robust by recursively checking
	// the parent (of parent of...) or opener of top until we find the main
	// window or find that there is none. The main window is the one with
	// window.name='MAINWIN' and this will have to be set in the home.htm page!!
	// For the meantime we can treat the opener as the main window.
	// make sure window is still there
	if (typeof(window.opener)=="undefined" || window.opener == null) {
		//must open new MAIN window for this url
		var mainwin = window.open(pg,"MAINWIN", "height=800,width=600,resizable=yes,scrollbars=yes,status=yes,menubar=yes");
	}
	pg = pathFirstPart + pg ;
	window.opener.location = pg;
}
function heb_eng_date(){
	// First display the Hebrew date
	var now = new Date;
	var tday = now.getDate();
	var tmonth = now.getMonth() + 1;
	var tyear = now.getYear();
	if(tyear < 1900)
		// if date from Netscape, then add 1900
		tyear += 1900;
	var hebDate = civ2heb(tday, tmonth, tyear);
	var hmS = hebDate.substring(hebDate.indexOf(' ')+1, hebDate.length);
	var	hDay = eval(hebDate.substring(0, hebDate.indexOf(' ')));
	var hMonth = eval(hmS.substring(0, hmS.indexOf(' ')));
	var hYear = hmS.substring(hmS.indexOf(' ')+1, hmS.length);
	// Then display the corresponding civil dates
	var day, month, year;
	var today = new Date;
	var yesterday = new Date(today.getTime() - 86400000);
	day   = yesterday.getDate();
	month = yesterday.getMonth() + 1;
	year  = yesterday.getYear();
	if(year < 1900)
		year += 1900; // if date from Netscape, then add 1900
	day   = today.getDate();
	month = today.getMonth() + 1;
	year  = today.getYear();
	if(year < 1900)
		year += 1900; // if date from Netscape, then add 1900
	return('<b>'+hDay + ' ' + hebMonth[hMonth+1] + ' ' + hYear + '/' +
		civMonth[month] + ' ' + day + ', ' + year+'</b>');
}

function SLSjumpMainWindow(pg){
	if (typeof(window.opener)=="undefined" || window.opener  == null) {
		var mainwin = window.open(pg,"MAINWIN",
		"height=800,width=600,resizable=yes,scrollbars=yes,status=yes,menubar=yes");
	}
	else {
		window.opener.location = pg;
	}
}

function discuss(){

    //MAY HAVE TO CHANGE THIS FOR LIVE SEP/OCT 05
    //window.location = 'http://tst.myjewishlearning.com/Vforum/upload/index.php';
    window.location = 'http://www.myjewishlearning.com/forums';
    return;
	/*
	// FOR EMERGENCY (7-6-03)
	alert("We are sorry but at this time Discussions are offline.\nPlease come back and try again later.");
	return;
	*/
	var discURL = getPathToRoot() + "/phorum/index.php3" ;
	if (arguments.length > 0) {
		discURL = getPathToRoot() + arguments[0];
	}
	var newwin=window.open(discURL,"DISCUSSWIN","height=650,width=750,resizable=yes,scrollbars=yes,status=yes");
	/* old code
	var newwin=window.open(getPathToRoot() + "/phorum/index.php3",
"DISCUSSWIN","height=650,width=750,resizable=yes,scrollbars=yes,status=yes");
	*/
}

function discuss2(){
	var thishost = location.hostname.toLowerCase();
    var thisDisc = '/forums/';

	if (pathtoroot.indexOf('tst.myjewishlearning.com') > -1) {
		thisDisc = '/Vforum/upload/';
	}
    if (pathtoroot.indexOf('smyjewishlearning.atypica.com') > -1) {
		thisDisc = 'http://tst.myjewishlearning.com/Vforum/upload/';
	}


    thisDisc += 'forumdisplay.php?f=';
    thisDisc += arguments[0];

	var discURL = getPathToRoot() + "/forums/index.php" ;
	if (arguments.length > 0) {
		//discURL = "http://www.myjewishlearning.com/forums/" + arguments[0];
        discURL = "http://www.myjewishlearning.com" + thisDisc;
	}
    //alert(discURL);
    window.location = discURL;
	//var newwin=window.open(discURL,"DISCUSSWIN","height=650,width=750,resizable=yes,scrollbars=yes,status=yes");
    //var newwin=window.open(thisDisc,"DISCUSSWIN","height=650,width=750,resizable=yes,scrollbars=yes,status=yes");
}

function journal(){
	var sname = getScreenNameCookie();
	if (sname == null) {
        window.location = '/User/signup.jsp';
		//alert('You will need to login or register in order to take advantage of this and many other Members-only features.\nMembership is free and private.\nThank you.');
		return;
	}
	//var newwin=window.open(getPathToRoot() + "/mj/launchJournal.htm","JOURNALWIN","height=650,width=750,resizable=yes,scrollbars=yes,status=yes");
    window.location = '/mj/launchJournal.htm';
}
function glossary(){
	var newwin=window.open(getPathToRoot() + "/Glossary/a_glosslist.htm","GLOSSWIN","height=500,width=700,resizable=yes,scrollbars=yes,status=yes");
}
function showGlossary(fn) {
	var newwin=window.open(getPathToRoot() + "/Glossary/" + fn,"GLOSSWIN","height=500,width=700,resizable=yes,scrollbars=yes,status=yes");
}
function printarticle(){
    	if (typeof(printerfile)=='undefined' || printerfile==null) {
		window.print();
	}
	else {
		var locStr = getPathToRoot() + printerfile;
        window.location = locStr;
		//var winprops="height=600,width=750,directories=no,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
		//var newwin = window.open(locStr, "PRINTARTWIN", winprops);
	}
}
function sendarticle(){
    var locStr = pathToJSP + '/User/send_article.jsp?DOCOWNID=' + thisTopicId ;
    var winprops="height=500,width=500,directories=no,resizable=yes,scrollbars=auto,toolbar=no,menubar=no,status=no,location=no";
	win = window.open(locStr, "SENDARTWIN", winprops);
}
function savetojournal(){
	var winprops="height=500,width=500,directories=no,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
	var newloc = pathToJSP + '/mj/savetojournal.jsp?DOCID=' + thisTopicId +
		'&DOCNAME=' + escape(thisTopicName);
	win = window.open(newloc, "SAVEJOURNALWIN", winprops);
}
function getSignInUp(){
	// for backwards compatibility
	return (getSignInUpOut());
}
function getSignInUpOut(){
	var retStr = 	'<a href="javascript:signinupout();"><img border="2" src="/common/images/headlines/signinupout.gif" valign="bottom" width="148" height="15" vspace="2"></a>';
	if (window.homepage==true && ie55up()) {
		var homepg = getPathToRoot() + "/index.htm" ;
		retStr += '<br><a  href="javascript:void(0)" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'' + homepg + '\');"><font size="-2">Make MyJewishLearning.com your homepage!</font></a>';
	}
	return retStr;
}
function signinupout(){
	var winprops="height=500,width=650,directories=no,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
	var newloc = pathToJSP + '/User/SignInUpOut.jsp'; // used to go directly to htm but now we ask user
 //   var newloc =  'http://www.myjewishlearning.com:90/logincheck';
	win = window.open(newloc, "SAVEJOURNALWIN", winprops);
}
function register(){
	// if user is currently logged in, ask user to log out and THEN register as new user
	var sname = getScreenNameCookie();
	if (sname != null) {
		alert('Dear ' + sname + ',\n' +
			'If you are ' + sname + ', click on the Discussions button above to participate in the MyJewishLearning.com community. You do not need to re-register.\n'+
			'If you are NOT ' + sname + ', please logout by clicking the Logout link in the top left-hand corner of the page and then Login or Register (if you haven\'t done so already). '+
			'Once logged in, click on the Discussions button to enjoy all the benefits of being part of our community.');
		return;
	}
    var SS = getRefererCookie();
	var winprops=
"height=650,width=650,directories=no,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
	//var newloc = pathToJSP + '/User/SignInUpOut.jsp';
	//win = window.open(newloc, "LOGINREGISTERWIN", winprops);
    var newloc = pathToJSP + '/User/signup.jsp';
	//win = window.open(newloc, "LOGINREGISTERWIN", winprops);
    window.location = newloc;
}
function showBanner555(TopicId){
//    alert('in showbanner555');
	// all cases show MJL logo ...
	document.write('<td width="231px"><a href="/index.php"><img src="/common/images/mjl_logo.gif" width="231" height="73" border="0"></a></td>');
	var dom = getPartnerDomain();
	// staging only

	if (dom.toLowerCase().indexOf('smyjewishlearning')>-1){ dom ='www' ;}
    if (dom.toLowerCase().indexOf('tst')>-1){ dom ='www' ;}

	if (dom.toLowerCase() == 'www') {
		// handle no partner case
        //document.write('<td width="153px" background="/common/images/grad_bkgnd.gif" height="73px"></td>');
        document.write('<td width="153px" bgcolor="#ffffff" height="73px"></td>');
	}
	else {
	// if partner
		//document.write('<td background="/common/images/grad_bkgnd.gif" width="153px" height="73px">' + getPartnerLogoImage(dom) + '</td>');
        document.write('<td bgcolor="#ffffff" width="153px" height="73px">' + getPartnerLogoImage(dom) + '</td>');
	}
	document.write('<td width="171px" background="/common/images/grad_bkgnd.gif" valign="top">');
	if (TopicId != 'PF') { showBannerNav(TopicId); }
}
function showBanner(){
//    alert('in showbanner');
	var pathtoroot = getPathToRoot();
	if (arguments.length >= 2) {
		pathtoroot = getPathToRoot(arguments[1]);
	}
	var bannerStr = '<div align="left">';
	if (arguments.length == 0 || arguments[0] != 'prn') {
		bannerStr += '<a href="' + pathtoroot + '/index.htm">';
	}
	bannerStr += '<img src="';
	var thishost = location.hostname.toLowerCase();
	if  (pathtoroot.indexOf('www.myjewishlearning.com') > -1) {
		bannerStr += '/common/images/logo.gif" width="325" height="63" border=0"></a>';
	}
	else if (pathtoroot.indexOf('hillel.myjewishlearning.com') > -1) {
		bannerStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images//hillel.jpg" width="114" height="63" >';
	}
	else if (pathtoroot.indexOf('jewishla.myjewishlearning.com') > -1) {
		bannerStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images//jewishlalogo.gif" width="114" height="63" >';
	}
	else if (pathtoroot.indexOf('hadassah.myjewishlearning.com') > -1) {
		bannerStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><a href="http://www.hadassah.org" target="_blank"><img alt="Go to Hadassah.org Web site" src="/common/images//hadassah.jpg" width="114" height="63" border="0"></a>';
	}
	else if (pathtoroot.indexOf('jcc.myjewishlearning.com') > -1) {
		bannerStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images//jcc.jpg" width="114" height="63" >';
	}
	else if (pathtoroot.indexOf('bbyo.myjewishlearning.com') > -1) {
		bannerStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images//bbyo.jpg" width="114" height="63" >';
	}
	else if (pathtoroot.indexOf('star.myjewishlearning.com') > -1) {
		bannerStr += '/common/images/mjl_logo_partners.jpg"  width="211" height="63" border=0" ></a><img src="/common/images//star.jpg" width="114" height="63" >';
	}
	// catch all case
	else {
		bannerStr += '/common/images/logo.gif" width="325" height="63" border="0" ></a>';
	}
	bannerStr += '<img src="/common/images/space/trans.gif" width="50" height="63" border=0">';
	if (arguments.length == 0 || arguments[0] != 'prn') {
		bannerStr += '<a href="javascript:journal();"><img src="/common/images//buttons/journal.gif" border="0" width="67" height="63"></a>';
		bannerStr += '<a href="javascript:discuss();"><img src="/common/images//buttons/discussions.gif" border="0" width="96" height="63"></a>';
      		bannerStr += '<a href="javascript:glossary();"><img src="/common/images/buttons/glossary.gif" border="0" width="62" height="63"></a>';
	}
	else if (arguments[0] == 'prn') {
      		bannerStr += '<a href="javascript:window.print();"><img src="/common/images//buttons/printbig.gif" border="0" width="132" height="63"></a>';
	}
	bannerStr += '<a href="javascript:help(\'help\');"><img src="/common/images/buttons/help.gif" border="0" width="83" height="63"></a>';
	bannerStr += '</div>';
	alert('at.js: bannerStr=' + bannerStr);
	document.write(bannerStr);
}


function getCoDomain(){
	var bannerStr = '<p class="pGap">&nbsp;</p>';

	var thishost = location.hostname.toLowerCase();
	if (pathtoroot.indexOf('hillel.myjewishlearning.com') > -1) {
		bannerStr += '<img src="/common/images/hillel.jpg" width="114" height="63" >';
        coDom = true;
	}
	else if (pathtoroot.indexOf('jewishla.myjewishlearning.com') > -1) {
		bannerStr += '<img src="/common/images/jewishlalogo.gif" width="114" height="63" >';
        coDom = true;
	}
	else if (pathtoroot.indexOf('hadassah.myjewishlearning.com') > -1) {
		bannerStr += '<a href="http://www.hadassah.org" target="_blank"><img alt="Go to Hadassah.org Web site" src="/common/images//hadassah.jpg" width="114" height="63" border="0"></a>';
        coDom = true;
	}
	else if (pathtoroot.indexOf('jcc.myjewishlearning.com') > -1) {
		bannerStr += '<img src="/common/images/jcc.jpg" width="114" height="63" >';
        coDom = true;
	}
	else if (pathtoroot.indexOf('bbyo.myjewishlearning.com') > -1) {
		bannerStr += '<img src="/common/images/bbyo.jpg" width="114" height="63" >';
        coDom = true;
	}
	else if (pathtoroot.indexOf('star.myjewishlearning.com') > -1) {
		bannerStr += '<img src="/common/images/star.jpg" width="114" height="63" >';
        coDom = true;
	}

    //coDom = true;
    //bannerStr += '<img src="/common/images/bbyo.jpg" width="114" height="63" >';

	return(bannerStr);
}

function feedback(){
	// call the shamoffer() function in user.js
	shmaoffer();
	/*
    	var locStr = getPathToRoot() + '/User/contact_us.html';
	var winprops="height=500,width=500,directories=no,resizable=yes,scrollbars=auto,toolbar=no,menubar=no,status=no,location=no";
	win = window.open(locStr,"CONTACTWIN",winprops);
	*/
}
function showILG(u){
    	var locStr = getPathToRoot() + '/ilg/' + u;
	var winprops="height=500,width=500,directories=no,resizable=yes,scrollbars=auto,toolbar=no,menubar=no,status=no,location=no";
	win = window.open(locStr,"ILGWIN",winprops);
}


function setFontCookie(name, value) {
  //var curCookie = name + "=" + escape(value) + "; path=/; domain=atypica.com";
  var curCookie = name + "=" + escape(value) + "; path=/; domain=myjewishlearning.com";
  document.cookie = curCookie;
  self.location.href = self.location.href;
}

function getFontCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


if (getFontCookie('fontfamily') == null) {
	var fontfamily = 'Verdana';
} else {
	var fontfamily = getFontCookie('fontfamily');
}
if (getFontCookie('fontsize') == null) {
	var fontsize = 12;
} else {
	var fontsize = getFontCookie('fontsize');
}

function changeFontFamily (fontfamily) {
	setFontCookie('fontfamily',fontfamily);
}


function changeFontSize (fontsize) {
	setFontCookie('fontsize',fontsize);
}

function showReadability() {


  	 document.write('<tr><td><table cellspacing="0" cellpadding="3"><form><tr><td><span class="p1">Font Type:</span><\/td></tr>');
	 document.write('<tr><td><select name="fontfamily" onChange="changeFontFamily(this.options[selectedIndex].value);">');
	 if (fontfamily == "Verdana") {
	 document.write('<option value="Verdana" selected>Verdana<\/option>');
	 } else {
	  document.write('<option value="Verdana">Verdana<\/option>');
	 }
	 if (fontfamily == "Arial") {
	 document.write('<option value="Arial" selected>Arial<\/option>');
	 } else {
	  document.write('<option value="Arial">Arial<\/option>');
	 }
	  if (fontfamily == "Courier") {
	 document.write('<option value="Courier" selected>Courier<\/option>');
	 } else {
	  document.write('<option value="Courier">Courier<\/option>');
	 }
	  if (fontfamily == "Lucida Grande") {
	 document.write('<option value="Lucida Grande" selected>Lucida Grande<\/option>');
	 } else {
	  document.write('<option value="Lucida Grande">Lucida Grande<\/option>');
	 }
	  if (fontfamily == "Times") {
	 document.write('<option value="Times" selected>Times<\/option>');
	 } else {
	  document.write('<option value="Times">Times<\/option>');
	 }
	 document.write('<\/select>');
	 document.write('<\/td><\/tr></table></td></tr>');


     document.write('<tr><td><span class="p1">&nbsp;Font Size: </span><select name="fontsize" onChange="changeFontSize(this.options[selectedIndex].value);">');

	 for ( var x=9; x <= 24; x++) {
	 	var sel;
	 	if (Number(x) == Number(fontsize)) {
		sel = "selected";
	 	} else {
		sel = "";
	 	}
		document.write('<option value="'+x+'" '+sel+'>'+x+'<\/option>');
	 }
	 document.write('<\/select><br><br></td></tr>');
	 //document.write('<\/form>');

}

document.write('<style type="text/css">');
document.write('.bodycopy, p {font-family:"'+fontfamily+'"; font-size:'+fontsize+'px; line-height: 160%}');
document.write('<\/style>');


function showSiteNav () {

document.write('<tr valign="bottom">');
document.write('<td nowrap valign="bottom" class="sitenavsize" colspan="3">');
document.write('    <a href="/blog" class="sitenav">Blog</a> | ');
document.write('    <a href="/xcommon/Hot_Topics/primers_index.htm" class="sitenav">Judaism 101</a> | ');
document.write('    <a href="javascript:discuss();" class="sitenav">Discussions</a> | ');
document.write('    <a href="/resources/rsindex.htm" class="sitenav">Resources</a> | ');
document.write('    <a href="javascript:journal();" class="sitenav">My Learning</a> | ');
document.write('    <a href="http://www.myjewishlearning.com/hebcal/index.cgi" class="sitenav">Jewish Calendar</a> | ');
document.write('    <a href="javascript:eletter();" class="sitenav">Newsletters</a> | ');
document.write('    <a href="/links/lindex/majorpartners.htm" class="sitenav">Links</a> | ');
document.write('    <a href="/links/lindex/communities.htm" class="sitenav">Local Opportunities</a>');
document.write('</td>');
document.write('</tr>');

}


function showTopNav () {

var sname = null;
sname=getScreenNameCookie();

document.writeln('<form action="/logincheck" method="POST" name="LogoutForm" >');
document.writeln('<input type="hidden" name="PMETHOD" value="POST">');
document.writeln('<input type="hidden" name="PURL" value="/User/SignOutOK.jsp">');
document.writeln('</form');

document.write('<tr>');
document.write('    <td colspan="3" align="right" valign="top" class="topnavsize">');

if (sname==null) {
    document.write('    <a href="/User/relogin.jsp" class="topnav">login</a> | ');
    document.write('    <a href="javascript:register_info();" class="topnav">free membership</a> | ');
}
else
if (sname=='') {
    document.write('    <a href="javascript:logoutuser0805();" class="topnav">Login Reset</a> | ');
}
else {
    //document.write('    <a href="/User/UpdatePwdSname.jsp" class="topnav">manage profile (<b>' + sname + '</b>)</a> | ');
    document.write('    <a href="http://www.myjewishlearning.com/blog/wp-admin/profile.php?s=mjl" class="topnav">manage profile (<b>' + sname + '</b>)</a> | ');
    document.write('    <a href="javascript:logoutuser0805();" class="topnav">logout</a> | ');
}

document.write('    <a name="top" href="/index.htm" class="topnav">home</a> | ');
document.write('    <a href="/aboutus/abindex.htm" class="topnav">about us</a> | ');
document.write('    <a href="/survey/intro.html" class="topnav">feedback</a> | ');
document.write('    <a href="javascript:contactus();" class="topnav">contact us</a> | ');
document.write('    <a href="/Help/hpindex.htm" class="topnav">site help</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>');
document.write('</tr>');

}

function showLHS1 () {

//document.write('<P>&nbsp;</P>');
document.write('<DIV align="left">');
document.write('<table width="100%" border="0">');
document.write('<tr valign="middle">');
document.write('<td height="30">&nbsp;&nbsp;<a href="/rss/mjl.xml"><img src="/rss/images/rss.gif" width="32" height="15" border="0" alt="Subscribe to &quot;This Week on MJL&quot;"></a></td>');
document.write('<td height="30"><a href="/Help/hpindex/rss.htm">What is RSS?</a>&nbsp;&nbsp;&nbsp;&nbsp;</td>');
document.write('</tr>');
document.write('<tr><td colspan="2">');
document.write('&nbsp;&nbsp;<a href="http://add.my.yahoo.com/rss?url=http://www.myjewishlearning.com/rss/mjl.xml"><img class="subImage" src="/rss/images/addmyyahoo.gif" border="0" alt="Add to My Yahoo" /></a><br>');
//document.write('&nbsp;&nbsp;<a href="http://www.google.com/reader/preview/*/feed/http://www.myjewishlearning.com/rss/mjl.xml"><img src="/rss/images/addgoogle.gif" alt="Add to Google" border="0"/></a><br>');
//document.write('&nbsp;&nbsp;<a href="http://my.msn.com/addtomymsn.armx?id=rss&amp;ut=http://www.myjewishlearning.com/rss/mjl.xml&amp;tt=CENTRALDIRECTORY&amp;ru=http://rss.msn.com"><img class="subImage" border="0" src="/rss/images/addmymsn.gif" alt="Add to My MSN" /></a>');
document.write('<p class="pGap">&nbsp;</p>');
document.write('</td></tr>');
document.write('</tr></table>');


document.write('</DIV>');

//document.write('<P>&nbsp;</P>');

document.write('<DIV align="center">');
document.write('<P><a href="http://www.myjewishlearning.com/redirect/redir.php?U=https://survey.qstation.com/cgi-shl/public/cgiip.exe/WService=Panel/qform/public/MJL/630-1/form.p"><img src="/common/images/aug05/supportmjl.gif" border="0" width="167" height="50" border="0"></a>');
//document.write('<P><a href="https://survey.qstation.com/cgi-shl/public/cgiip.exe/WService=Panel/qform/public/MJL/630-1/form.p"><img src="/common/images/aug05/supportmjl.gif" border="0" width="167" height="50" border="0"></a>');
//document.write('<P><a href="https://survey.qstation.com/cgi-shl/public/cgiip.exe/WService=Panel/qform/public/MJL/630-1/form.p"><img src="/images/support/support.jpg" border="0" width="180" height="100" border="0"></a>');
//document.write('<P><a href="https://survey.qstation.com/cgi-shl/public/cgiip.exe/WService=Panel/qform/public/MJL/630-1/form.p"><img src="/common/images/aug07/support_mini.jpg" border="0" width="167" height="143" border="0"></a>');
document.write('<br><a href="javascript:register_info();"><img src="/common/images/aug05/jointhemjl.gif" border="0" width="167" height="50" border="0"></a></P>');
document.write('</DIV>');
//document.write('<P><br></P>');

if (typeof(thisPageTemplate) != 'undefined') {
    var mobileimg = '<table>';
        mobileimg += '      <tr><td>';
        mobileimg += '      <div align=center>';
        mobileimg += '          <a href="/xcommon/mobilemjl.htm"><img src="/common/images/ad/mobilead.gif" border="0"></a>';
        mobileimg += '      </div>';
        mobileimg += '      </td></tr>';
        mobileimg += '      </table>';
        mobileimg += '<p class="pGap">&nbsp;</p>';
        document.write(mobileimg);
}

}

function showArtFooter () {

document.write('<P>&nbsp;</P>');
document.write('<DIV align="left">');
document.write('<P><a href="#top">Back To Top</a></P>');
document.write('</DIV>');
}

function manageprofile0805(){
    window.location = '/User/SignInUpOut.jsp';
}
function logoutuser0805(){
    //newWin = window.open('','subWindow','top=0,left=0,directories=no,height=650,width=500,location=no, menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=750');
    Delete_Cookie('MJLCookie', '/', '');
    Delete_Cookie('MJLSnameCookie', '/', '');
    document.LogoutForm.submit();
}

function mjlHead () {
var retStr = '<td valign="top" width="391" align="left">';
retStr += '<p class="pGap">&nbsp;</p>';
retStr += '<a href="/index.htm"><img src="/common/images/aug05/mjl_logo.gif" alt="My Jewish Learning" border="0" width="391" height="44"></a><br>';
retStr += '</td>';
return(retStr);
}
function mjlCoHead () {
var retStr = '<td valign="top" width="350" align="left">';
retStr += '<p class="pGap">&nbsp;</p>';
retStr += '<a href="/index.htm"><img src="/common/images/aug05/mjl_logo_2.gif" alt="My Jewish Learning" border="0" width="350" height="44"></a><br>';
retStr += '</td>';
return(retStr);
}


function showHeader0805() {

coDomImage = getCoDomain();

document.write('<table align="center" width="760" border="0" cellspacing="0" cellpadding="0">');

showTopNav();

document.write('  <tr valign="bottom">');

if (!(coDom))
    document.write(mjlHead());
else
    document.write(mjlCoHead());

//document.write('    <td valign="top" width="391" align="left">');
//document.write('    <p class="pGap">&nbsp;</p>');
//document.write('    <a href="/index.htm"><img src="/common/images/aug05/mjl_logo.gif" alt="My Jewish Learning" border="0" width="391" height="44"></a><br>');
//document.write('    </td>');

document.write('    <td valign="top" border="0" width="114">');
document.write(coDomImage);
document.write('    </td>');

document.write('    <form name="gs" method="GET" action="http://srchm.myjewishlearning.com/search" name="SearchForm" >');
document.write('      <td rowspan="1" valign="bottom">');
document.write('      <table align="right" border="0" cellpadding="0" cellspacing="0">');
document.write('        <tr>');
document.write('        <td colspan=2 width="50%">');
document.write('                  <input type="hidden" name="client" value="X">');
document.write('                  <input type="hidden" name="output" value="xml_no_dtd">');
document.write('                  <input type="hidden" name="proxystylesheet" value="http://www.myjewishlearning.com/xsl/style1.xsl">');
document.write('                  <input type="hidden" name="restrict" value="MJL_MAIN"/>');
document.write('                  <input type="hidden" name="site" value="MJL">');
document.write('        <img src="/common/images/aug05/search_top.gif" alt="Search" width="42" height="17">');
document.write('        </td></tr>');
document.write('        <tr><td>');
document.write('        <input name="q" type="text" onKeyPress="checkEnterS(event)" onfocus="clearFLD();" value="search our site" size="16">&nbsp;');
document.write('        </td><td align="left" width="50%">');
document.write('        <a href="javascript:searchsubmit();">');
document.write('        <input name="GO" type="image" id="GO" src="/common/images/aug05/search_go.gif" alt="Go" align="middle" width="28" height="25" border="0">');
document.write('        </a>');
document.write('        </td>');
document.write('        </tr>');
document.write('        <tr><td colspan=2 nowrap>');
document.write('        <span class ="sitenav">Looking for a specific term? Try the <a href="javascript:glossary();">glossary</a></span>');
document.write('    <p class="pGap">&nbsp;</p>');
document.write('    </td>');
document.write('      </table>');
document.write('    </form>');;
document.write('  </tr>');

showSiteNav();

document.write('</table>');

//temporary for october 2007 survey

    var showsurvey2007 = true;
    var cookieValue=getCookie("showsurvey2007");

    if (cookieValue == null) {
    	var now = new Date();
	    now.setTime(now.getTime() + 30 * 24 * 60 * 60 * 1000);
        //setCookie("showsurvey2007","true", now, "/");
        //document.write(dropdowndivReg);
        //window.onload=initbox;
    }

//temporary for march 2007 raffle
//updated for aug 2008 the forward promo
//if (showPop0307()){
//  NewWin0307();
//}

} // showHeader0805

function showHeader0805b () {

coDomImage = getCoDomain();

document.write('<table align="center" width="760" border="0" cellspacing="0" cellpadding="0">');

showTopNav();

document.write('  <tr valign="bottom">');

if (!(coDom))
    document.write(mjlHead());
else
    document.write(mjlCoHead());

//document.write('    <td valign="top" width="391" align="left">');
//document.write('    <p class="pGap">&nbsp;</p>');
//document.write('    <a href="/index.htm"><img src="/common/images/aug05/mjl_logo.gif" alt="My Jewish Learning" border="0" width="391" height="44"></a><br>');
//document.write('    </td>');

document.write('    <td valign="top" border="0" width="114">');
document.write(coDomImage);
document.write('    </td>');

document.write('    <form name="gs" method="GET" action="http://srchm.myjewishlearning.com/search" name="SearchForm" >');
document.write('      <td rowspan="1" valign="bottom">');
document.write('      <table align="right" border="0" cellpadding="0" cellspacing="0">');
document.write('        <tr>');
document.write('        <td colspan=2 width="50%">');
document.write('                  <input type="hidden" name="client" value="X">');
document.write('                  <input type="hidden" name="output" value="xml_no_dtd">');
document.write('                  <input type="hidden" name="proxystylesheet" value="http://www.myjewishlearning.com/xsl/style1.xsl">');
document.write('                  <input type="hidden" name="restrict" value="MJL_MAIN"/>');
document.write('                  <input type="hidden" name="site" value="MJL">');
document.write('        <img src="/common/images/aug05/search_top.gif" alt="Search" width="42" height="17">');
document.write('        </td></tr>');
document.write('        <tr><td>');
document.write('        <input name="q" type="text" onKeyPress="checkEnterS(event)" onfocus="clearFLD();" value="search our site" size="16">&nbsp;');
document.write('        </td><td align="left" width="50%">');
document.write('        <a href="javascript:searchsubmit();">');
document.write('        <input name="GO" type="image" id="GO" src="/common/images/aug05/search_go.gif" alt="Go" align="middle" width="28" height="25" border="0">');
document.write('        </a>');
document.write('        </td>');
document.write('        </tr>');
document.write('        <tr><td colspan=2 nowrap>');
document.write('        <span class ="sitenav">Looking for a specific term? Try the <a href="javascript:glossary();">glossary</a></span>');
document.write('    <p class="pGap">&nbsp;</p>');
document.write('    </td>');
document.write('      </table>');
document.write('    </form>');;
document.write('  </tr>');

showSiteNav();

document.write('</table>');

//temporary for october 2007 survey

    var showsurvey2007 = true;
    var cookieValue=getCookie("showsurvey2007");

    if (cookieValue == null) {
    	var now = new Date();
	    now.setTime(now.getTime() + 30 * 24 * 60 * 60 * 1000);
        //setCookie("showsurvey2007","true", now, "/");
        //document.write(dropdowndivHome);
        ////visibilityToggle('jtalyr','hidden');
        //window.onload=initbox;
    }

}


function showJTA () {

document.write('<DIV id="jtalyr" style="visibility: visible">');
document.write('<applet codebase="http://www.jta.org/ticker/" code="yavs.class" width=400 height=27>');
document.write('<param name="MSGTEXT" value="http://www.jta.org/ticker/ShowTickers.asp?referid=MJLearn">');
document.write('<param name="BGCOLOR" value="#FFFFFF">');
document.write('<param name="FGCOLOR" value="#000000">');
document.write('<param name="HREFCOLOR" value="#0000FF">');
document.write('<param name="LINKCOLOR" value="#FF0000">');
document.write('<param name="FONTNAME" value="VERDANA">');
document.write('<param name="FONTSIZE" value="13">');
document.write('<param name="SPEED" value="200">');
document.write('<param name="WAITTEXT" value="YES">');
document.write('<param name="PAUSE" value="0">');
document.write('</applet>');
document.write('</DIV>');

}


function visibilityToggle(id,onoff) {

 if (id =='jtalyr') {
    var cookieValue=getCookie("showsurvey2007");
    if (cookieValue == null) {
        onoff = 'hidden';
    }
 }

 var el = document.getElementById(id).style;
 el.visibility = onoff;
}

function displayDate() {
var curDate = new Date();
var myMonths= ["January","February","March","April","May","June","July","August","September","October","November","December"]
var thisMM = curDate.getMonth();
var thisYYYY = curDate.getFullYear();
var thisDD = curDate.getDate();
var thisMonth = myMonths[thisMM];
return (thisMonth + " " + thisDD + ", " + thisYYYY);
}

// NEW MF TESTING APRIL 12 2007
// ALREADY IN ANOTHER INCLUDE
function clearFLD () {
    if (document.gs.q.value == "search our site")
        document.gs.q.value = "";
}

//function for forcing form submission
function checkEnterS(e){
var characterCode;
	 if(e && e.which){
	 e = e;
	 characterCode = e.which;
	 }
	 else{
	 e = event;
	 characterCode = e.keyCode;
	 }
	 if(characterCode == 13){
 	 searchsubmit();
 	 return false;
	 }
return true;

}
