var prnwindow;
function resizeText(sizeIn) {
alert('Coming soon!');
}

function setFontCookie(name, value) {
  //var curCookie = name + "=" + escape(value) + "; path=/; domain=atypica.com";
  var curCookie = name + "=" + escape(value) + "; path=/; domain=interfaithfamily.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('fontsize') == null) {
	var fontsize = 12;
} else {
	var fontsize = getFontCookie('fontsize');
}

function changeFontSize (fontsize) {
    if (fontsize<=0) {
        if (getFontCookie('fontsize') == 16)
    	    fontsize = 12;
        else fontsize=16;
    }
	setFontCookie('fontsize',fontsize);
}


function writeRSS () {

      if(!(window.L3RSS==undefined))
      if(!(window.rssURL==undefined))
      if (L3RSS) {
      //var str2 = '<a href="' + rssURL + '?format=html" class="tools"><img border="0" src="/IFF_Prototype/images/rss.gif" alt="RSS Feed" width="16" height="16" align="absMiddle"></a>&nbsp;<A class="tools" href="' + rssURL + '?format=html">' + L3Descr + '</a> |';
      var str2 = '<a href="' + rssURL + '?format=html" class="tools"><img border="0" src="/images/rss.gif" alt="RSS Feed" width="16" height="16">&nbsp;' + L3Descr + '</a> |';
      document.write(str2);
      }
}

function writeRSS2 () {

      if(!(window.L3RSS==undefined))
      if(!(window.rssURL==undefined))
      if (L3RSS) {
      //var str2 = '<a href="' + rssURL + '?format=html" class="tools"><img border="0" src="/IFF_Prototype/images/rss.gif" alt="RSS Feed" width="16" height="16" align="absMiddle"></a>&nbsp;<A class="tools" href="' + rssURL + '?format=html">' + L3Descr + '</a> |';
      var str2 = '<a href="' + rssURL + '?format=html" class="rss"><img border="0" src="/images/rss.gif" width="16" height="16" alt="RSS Feed - ' + L3Descr + '" title="RSS Feed - ' + L3Descr + '">';
      document.write(str2);
      }
}

function saveToProfile (urlIn, titleIn) {
var logcookieValue=getCookie("iffusername");
//if (logcookieValue == null) {
//    //alert('You must be logged in to save to your profile.');
//    iff_notloggedin_msg();
//    return;
//    }
//else {
    var str = 'address=' + encodeURIComponent(urlIn) + '&title=' + encodeURIComponent(titleIn);
    var redir = '/elgg/mod/bookmarks/add.php?' + str;
    //alert(redir);
    //document.location.href=redir;
    window.open(redir);
//    }
} // function


function popWin(page,w,h) {
prnwindow=window.open(page,'prnwindow','width=' + w + ',height=' + h + ',left=300,top=150,location=no,resizable=yes,menubar=no,status=no,toolbar=yes,scrollbars=yes');
prnwindow.opener=self;
prnwindow.focus();
}

var ratewindow;

function popWin2(page,w,h) {
ratewindow=window.open(page,'ratewindow','width=' + w + ',height=' + h + ',left=300,top=150,location=no,resizable=yes,menubar=no,status=no,toolbar=no,scrollbars=yes');
ratewindow.opener=self;
ratewindow.focus();
}

var emailwindow;

function popWinEmail(page,w,h) {
emailwindow=window.open(page,'emailwindow','width=' + w + ',height=' + h + ',left=300,top=150,location=no,resizable=yes,menubar=no,status=no,toolbar=no,scrollbars=yes');
emailwindow.opener=self;
emailwindow.focus();
}


function fltWgt_rateStarHover(rating) {
document.fltWgt_rateStarsBtn0.src = '/templates/images/rating/' + rating + 'stars.new.gif';
}

function fltWgt_rateStarsReset() {
document.fltWgt_rateStarsBtn0.src = '/templates/images/rating/0stars.new.gif';
}
function fltWgt_rateSet(docidIn,ratingIn) {

if (docidIn==0) {
    alert('This page cannot be rated.');
    return;
}

//alert('Docid: ' + docidIn + '\nRating: ' + ratingIn + '\n' + 'Ratings coming soon!');
popWin2('/rating.php?d=' + docidIn + '&r=' + ratingIn,325,225);

}

function emailArticle(urlIn,descr) {
//urlIn = (urlIn.replace(".shtml", ".js"));
popWinEmail('/emailarticle.php?i=' + urlIn,450,400);

}

function commentArticle(urlIn,descr) {
//urlIn = (urlIn.replace(".shtml", ".js"));

if(window.location.href.indexOf("thanks.php")==-1){
//        alert('Setting Timer');
        createCookie('Comment','0',0);
        window.setTimeout('Check_Refresh()',9000);
    }
    else {
        createCookie('Comment','1',0);
    }
    popWinEmail(urlIn,450,420);
}

var crefresh=0;
function Check_Refresh (){
crefresh=Get_Cookie('Comment');
// alert("crefresh="+crefresh);
window.setTimeout('Check_Refresh()',1000);
if (crefresh==1) {
   if(window.location.href.indexOf("?Scr")=="-1"){
      location.replace(window.location.href);
      createCookie('Comment','0',0);
   }
   else {
   location.replace(window.location.href);
   }


}
}
function Get_Cookie( name ) {
var stat = '';
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
// alert("len="+len);
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;
// alert(name+' Cookieval=' + unescape( document.cookie.substring( len, end )));
// if(name=='Comment')window.setTimeout('status=Get_Cookie(\'Comment\')',2000);
return unescape( document.cookie.substring( len, end ) );
}


// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function dispTopics () {
if (topicsArr.length > 0) {
    var topicsStr = '<h3>Topics</h3><ul class="spbullet2">';
	for (var i=0;i<topicsArr.length;i++){
		topicsStr += '<li class="spbullet2_text"><a href="' + topicsArr[i].url + '">' + topicsArr[i].tag + '</a></li>';
	}
    topicsStr += '</ul><p class="spacer3px">&nbsp;</p>';
    document.write(topicsStr);
    }
}

function dispIFFresources () {
if (iffRsrcArr.length > 0) {
    var iffRsrcStr = '<h3>Topics</h3><ul class="spbullet2">';
	for (var i=0;i<iffRsrcArr.length;i++){
        if (i < 5)
		iffRsrcStr += '<li class="spbullet2_text"><a href="' + iffRsrcArr[i].url + '">' + iffRsrcArr[i].tag + '</a></li>';
	}
    iffRsrcStr += '</ul><p class="spacer3px">&nbsp;</p>';
    document.write(iffRsrcStr);
    }
}


function dispDiscussions () {
if (discArr.length > 0) {
    var discStr = '<h3>Discussions</h3><ul class="spbullet2">';
	for (var i=0;i<discArr.length;i++){
		discStr += '<li class="spbullet2_text"><a href="' + discArr[i].url + '">' + discArr[i].tag + '</a></li>';
	}
    discStr += '</ul><p class="spacer3px">&nbsp;</p>';
    document.write(discStr);
    }
}

function dispCommunities () {
if (communityArr.length > 0) {
    var communityStr = '<h3>Communities</h3><ul class="spbullet2">';
	for (var i=0;i<communityArr.length;i++){
		communityStr += '<li class="spbullet2_text"><a href="http://www.interfaithfamily.com/community.php?aid=' + communityArr[i].url + '">' + communityArr[i].tag + '</a></li>';
	}
    communityStr += '</ul><p class="spacer3px">&nbsp;</p>';
    document.write(communityStr);
    }
}


function dispBlogs () {
if (blogArr.length > 0) {
    var blogStr = '<h3>From the Blogs</h3><ul class="spbullet2">';
	for (var i=0;i<blogArr.length;i++){
		blogStr += '<li class="spbullet2_text"><a href="' + blogArr[i].url + '">' + blogArr[i].tag + '</a></li>';
	}
    blogStr += '</ul><p class="spacer3px">&nbsp;</p>';
    document.write(blogStr);
    }
}

function dispMjl () {
if (mjlArr.length > 0) {
    var mjlStr = '<h3>MyJewishLearning.com</h3><ul class="spbullet2">';
	for (var i=0;i<mjlArr.length;i++){
		mjlStr += '<li class="spbullet2_text"><a href="' + mjlArr[i].url + '">' + mjlArr[i].tag + '</a></li>';
	}
    mjlStr += '</ul><p class="spacer3px">&nbsp;</p>';
    document.write(mjlStr);
    }
}

function dispOtherAuthors () {
//alert(authors.length);
if (authors.length > 0)
{
    var authStr = '<h3>Other Articles By...</h3><ul class="spbullet2">';

    for (var i=0;i<authors.length;i++)
    {

          authStr += "<li class=\"spbullet2_text\">";
          authStr += "<a href=\"/ix_author.php?aid=" + authors[i].authId + "\">";

          if (authors[i].fn != 'null') {
          authStr += authors[i].fn;
          authStr += "&nbsp;";
          }

          authStr += authors[i].ln;
          authStr += "</a></li>";
    }
    authStr += "</ul><p class=\"spacer3px\">&nbsp;</p>";
    document.write(authStr);
}

} // disp other authors

//////////////////////////

function initAllTopics () {}

//////////////////////////

function NewWin600(url) {
    newwindow = window.open(url , "New600","toolbar=no,resizable=yes,status=no,width=700,height=400,scrollbars=yes");
    if (window.focus) {newwindow.focus()}
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// TALKBACK Vars + Functions

var tbCnt = 0;
var tbArray = new Array ();
var tbObj = new Object ();
// first rec is a dummy rec
tbObj.title = '';
tbObj.username = '';
tbObj.date_added = '';
tbObj.time_added = '';
tbObj.url = '';
tbArray[tbCnt++] = tbObj;


function writeTalkback () {

    if (threadID <= 0) return;

    //alert('in tb 1');

    //document.write('<table align=center bgcolor="#FFFFFF" width=400><tr><td height="27"><h2 id="tbh"><a name="talkback">&nbsp;</a></h2>');
    //document.write('<div id="tb">');
    //document.write('<hr><B>' +  (tbCnt - 1) + ' talkback record(s)</B><BR>');

    document.write('<br><table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">');
    document.write('<tr><td><h3>Article Discussions</h3></td></tr>');
    document.write('<tr><td><table width=100% border=0 align=left><tr><td>');

    for (var i=1;i<tbCnt; i++) {
        var dispTBobj = tbArray[i];
        document.write('<p><a href="' + dispTBobj.url + '">' + dispTBobj.title + '</a><br>');
        document.write('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>' + dispTBobj.username + '</b> ' + dispTBobj.date_added + ' ' + dispTBobj.time_added + '</p>');
    }

    if (tbCnt > 1) { // Only display this link if someone has already posted to thread
        //document.write('<p>&nbsp;</p>');
        //document.write('<p><a href="' + discPath + 'showthread.php?t=' + threadID + '">View All Posts</a></p>');
    }

} // End write talkback function


function writeTalkback () {

    var secID2= "IF";
    //alert(thisTopicId==undefined);
    if (!(thisTopicId==undefined)) secID2 = thisTopicId.substring(0,5);

    if (threadID <= 0) return;

    document.write('<a name="comments"></a><br><br><div id="commentsList" class="tBorderBold"><div class="resultsPaging wrapper"><br><span class="author-bio-content">Comments</span><br></div>');

    for (var i=1;i<tbCnt; i++) {
        var dispTBobj = tbArray[i];
        document.write('<div class="clr"></div>');
        document.write('<div class="comment">');
        document.write('<p class="first">' + dispTBobj.title + '</p></div>');
        document.write('<div class="comment">');
        document.write('<p class="author"><strong>Posted by ' + dispTBobj.username + '</strong> ' + dispTBobj.date_added + ' ' + dispTBobj.time_added + '<br><br></p></div>');

    }

    if (tbCnt > 1) { // Only display this link if someone has already posted to thread
    //document.write('<p>&nbsp;</p>');
    //document.write('<p><a href="' + discPath + 'showthread.php?t=' + threadID + '">View All Posts</a></p>');
    }


    document.write('<div class="clr"></div>');
    document.write('<div class="comment2">');
    document.write('<p class="author2"><b><a href="javascript:commentArticle(\'http://iff1.atypica.com/verify/comment.php?d=\' + thisDocId + \'&sid=\' + thisTopicId,\'\');">Click here to post a comment on this article</a></b></p>');
    document.write('</div>');
    document.write('</div>');



} // END TB WRITE FUNCTION

function writeTalkback09 () {
    //alert(threadID);
    if (threadID <= 0) return;

    var strOut = '<iframe width="708" id="myframe" src="/iffcms/iff_display_article_comments.php?topicid=' + threadID + '" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:hidden; width:708px; display:none"></iframe>';

    //alert(strOut);
    document.write(strOut);


} // END TB WRITE FUNCTION

function Set_Cookie( name, value, expires, path, domain, secure )
{
// alert('Setting Cookie to '+value);
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function doWelcome () {
//return; // remove if making live
// displays welcome message for IFF login cookie
var ckTID = "IF";
//alert(thisTopicId==undefined);
if (!(thisTopicId==undefined)) ckTID = thisTopicId.substring(0,5);

var fn = readCookie("fn");
var uname = readCookie("uname");
var txt = "&nbsp;";
var mytry=0;
if ( (ckTID == 'IF.J2') && (fn == null) ) {
    var url = window.location.href;
    var ixparams = '123';
    //alert(readCookie("fn"));
    //alert(url.indexOf('login.phtml'));
    //alert(window.location);
    if ((url.indexOf('login.phtml')==-1 || (url.indexOf('login.php')==-1) || (url.indexOf('loginjk.phtml')==-1) || (url.indexOf('loginjk.php')==-1))  && mytry==0) {
     ++mytry;
      window.location ="/rcjc2/login.phtml?r=" + mytry + "&url=" + url;
    }
    return;
}

if (fn != null) {
    fn = fn.replace("+"," ");
    txt = 'Welcome, ' + fn + ' | ';
    txt +='<a href="javascript:logout();">Logout</a>';
}
else {
    txt +='<a href="http://iff1.atypica.com/rcjc2/login.phtml">Login123</a>';
    // we no longer display a login link  as this is handled by file/dir protection
    txt = '&nbsp;';
}
txt = "<span style=\"color:#31456d;\">" + txt + "</span>";
//txt = '&nbsp;'; // remove this live when it goes live
document.write('<p class="gap">' + txt + '</p>');
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function logout () {
    eraseCookie('fn');
    eraseCookie('tenor');
    eraseCookie('__utma');
    eraseCookie('__utmb');
    eraseCookie('utmcsr');
    window.location ="/rcjc/Resource_Center_for_Jewish_Clergy.shtml";
    return;

}

var popToCheck = "IF.JC.AA";
var popUPtid = "IF.JC.AF";

function popRCJC () {

    var cut_off_date=new Date(2008,3,1);
    var now=new Date();
    var today_date=new Date(2008,now.getMonth(),now.getDate());
    if (today_date > cut_off_date) return;

    var ckTID = "IF";
    if (!(thisTopicId==undefined)) ckTID = thisTopicId.substring(0,5);
    // if we're ont he RCJC index page then we need to check the popup window Topicid cookie - if we dont have any then do the popup
    if (thisTopicId==popToCheck) {
        var fn = readCookie(popUPtid);
        if (fn == null) popWin2('/rcjc/CCAR_Announcement.shtml',500,350);
    }
}

function close_rcjc_pop () {

if (document.mypopform.hideme.checked)
    createCookie(thisTopicId,'1',20);
window.close();

}

function subscriber(promo,fname) {
popWinEmail('/subscribe.php?p=' + promo + "&f=" + fname,450,350);
}

var h2fontsize = fontsize;
h2fontsize++;
h2fontsize++;
document.write('<style type="text/css">');
document.write('#artmain, .artmain {font-size:'+fontsize+'px; line-height: 160%}');
document.write('#artmain a, .artmain a {font-size:'+fontsize+'px; line-height: 160%}');
document.write('.artmain p a {font-size:'+fontsize+'px; line-height: 160%}');
document.write('#artmain h2 a, .artmain h2 a {font-size:'+h2fontsize+'px; line-height: 160%}');
document.write('#brdcrmbs {font-size:10px;}');
document.write('<\/style>');

