function goto() { 
	goto = document.redirect.viewcontents.options[document.redirect.viewcontents.selectedIndex].value;
	if (goto != "0") {
		location=goto;
	}
}

function openWindow(page_name,width,height) {
	if (width==null) var width=700;
	if (height==null) var height=700;
	
	winStats='toolbar=yes,location=no,directories=yes,menubar=yes,'
	winStats+='scrollbars=yes,resizable=yes,status=yes,width='+width+',height='+height
	if (navigator.appName.indexOf("Microsoft")>=0) {
		winStats+=',left=15,top=20'
	}else{
		winStats+=',screenX=15,screenY=20'
	}
	floater=window.open(page_name,"floater",winStats);
}

function hidealldiv() {
	hidediv('home-submenu');
	hidediv('content-submenu');
	hidediv('subscribe-submenu');
	hidediv('about-submenu');
	hidediv('contact-submenu');
	hidediv('mybpb-submenu');
	hidediv('other-submenu');
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function showhide(id) {
  if (document.getElementById){
	obj = document.getElementById(id);
	if (obj.style.display == "none"){
		obj.style.display = "";
	} else {
		obj.style.display = "none";
	}
  }
}

function changecolor(id,color1,color2) {
	if (!color2) color2 = "#abc";
	obj = document.getElementById(id);
	obj.style.background = color1;
	obj.style.borderBottom = "1px solid "+color2;
}

function hidesearchdivs_old() {
	if (document.getElementById('article')!=null) hidediv('article');
	if (document.getElementById('book')!=null) hidediv('book');
	if (document.getElementById('blog')!=null) hidediv('blog');
	if (document.getElementById('other')!=null) hidediv('other');
	if (document.getElementById('resource')!=null) hidediv('resource');
}
function hidesearchdivs(total) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		for (i=1; i<=total; i++) {
			idname = "type_"+i;
			if (document.getElementById(idname)!=null) hidediv(idname);
		}
	}
}

function changeclass(typenum,total) {
	// make all tabs inactive and then make selected tab active...
	var idbase = "li_";
	var thisid = idbase+typenum;
	if (document.getElementById) { // DOM3 = IE5, NS6
		for (i=0; i<=total; i++) {
			if (document.getElementById(idbase+i)!=null) document.getElementById(idbase+i).className = 'inactive';
		}
		document.getElementById(thisid).className = 'active';
	} else {
		if (document.layers) { // Netscape 4
			var tempid;
			for (i=0; i<=total; i++) {
				tempid = idbase+i;
				if (document.tempid!=null) document.tempid.className = 'inactive';
			}
			document.thisid.className = 'active';
		} else { // IE 4
			var tempid;
			for (i=0; i<=total; i++) {
				tempid = idbase+i;
				if (document.all.tempid!=null) document.all.tempid.className = 'inactive';
			}
			document.all.thisid.className = 'active';
		}
	}
}


/* ====================================================== */
/* The following function allow user to set the font size */
function setFontCookie(name, value) {
  var curCookie = name + "=" + escape(value) + "; expires=Wed, 07-Jun-2023 11:07:25 GMT; path=/; domain=bulletpointbusiness.com";
  /* 
  var curCookie = name + "=" + escape(value) + "; expires=Wed, 07-Jun-2023 11:07:25 GMT; path=/; domain=careerturn.com";
  var curCookie = name + "=" + escape(value) + "; expires=Wed, 07-Jun-2023 11:07:25 GMT; path=/; domain=webmastersherpa.com";
  */
  document.cookie = curCookie;
  window.location.href = window.location.href;
}
function getCookie(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 (getCookie('fontsize') == null) {
	var fontsize = 12;
} else {
	var fontsize = getCookie('fontsize');
}

function changeFontSize (direction) {
	if (direction == "decrease") { fontsize--; fontsize--; }
	if (direction == "increase") { fontsize++; fontsize++; }
	setFontCookie('fontsize',fontsize);
	alert('font size has been set to '+fontsize+'px');
}
document.write('<style type="text/css">');
document.write('.main {font-size:'+fontsize+'px;}');
document.write('<\/style>');
/* ====================================================== */


/* ====================================================== */
/* AJAX stuff */
/* ====================================================== */
//Browser Support Code
function GetXmlHttpObject() {
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}


function ajaxMarkUnread(articleid,memberid) {
  ajaxRequest=GetXmlHttpObject();
  if (ajaxRequest==null) {
	alert ("Your browser does not support AJAX!");
	return;
  } 

  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange=function() {
	if(ajaxRequest.readyState==4) {
		document.getElementById("numviews").innerHTML='<span id="numviews" style="color:red;"> &nbsp; You Have Marked This Article as Unread</span>';
    } else {
		document.getElementById("numviews").innerHTML='<span class="working" style="color:red">Please Wait...</span><br />';
	}
  }
  var url = "/includes/ajax.php?function=markunread&member_id="+memberid+"&id="+articleid;
  ajaxRequest.open("GET",url,true);
  ajaxRequest.send(null);
}

function ajaxPDF(articleid,memberid,size) {
  ajaxRequest2=GetXmlHttpObject();
  if (ajaxRequest2==null) {
	alert ("Your browser does not support AJAX!");
	return;
  } 

  // Create a function that will receive data sent from the server
  ajaxRequest2.onreadystatechange=function() {
	if(ajaxRequest2.readyState==4) {
		if (size==16) document.getElementById("pdf-icon").innerHTML = '<div id="pdf-icon" style="display:inline; cursor: pointer;"><a name="#" onclick="ajaxPDF('+articleid+','+memberid+','+size+');" style="text-decoration:none;"><img src="/images/icons/pdf.png" alt="PDF Version of this Article" align="texttop" width="18" height="18" border="0" /> PDF Created</a></div>';
		if (size!=16) document.getElementById("pdf").innerHTML = '<div id="pdf" style="cursor: pointer;"><a name="#" onclick="ajaxPDF('+articleid+','+memberid+','+size+');" style="text-decoration:none;"><img src="/images/pdf.gif" alt="PDF Version of this Article" align="texttop" width="35" height="35" border="0" /><br /> PDF Created</a></div>';
		openWindow("/pdf/"+articleid+"/");
		//alert("Finished");
    } else {
		if (size==16) document.getElementById("pdf-icon").innerHTML = '<div class="working" style="display:inline;">Creating PDF...Please Wait</div>';
		if (size!=16) document.getElementById("pdf").innerHTML = '<div class="working">Creating PDF<br />...Please Wait</div>';
	}
  }
  var url = "/includes/ajax.php?function=pdf&member_id="+memberid+"&id="+articleid;
  ajaxRequest2.open("GET",url,true);
  ajaxRequest2.send(null);
}


function ajaxPM_read(id) {
  var idquoted = "'"+id+"'";
  var readlink = "readlink"+id;
  var readlinkquoted = "'"+readlink+"'";
  var readid = "read"+id;
  var readidquoted = "'"+readid+"'";
  var replacetext = "'Read'";

  showhide(readid);

  ajaxRequest=GetXmlHttpObject();
  if (ajaxRequest==null) {
	alert ("Your browser does not support AJAX!");
	return;
  } 

  var url = "/includes/ajax.php?function=readpm";
  var parameters = '&messageid=' + id;

  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange=function() {
	if(ajaxRequest.readyState==4) {
		//document.getElementById(readlink).innerHTML = '<span id="'+readlink+'"><a name="#" onclick="ajaxPM_read('+idquoted+','+replacetext+'); showhide('+readidquoted+');" style="cursor:pointer; text-decoration:underline; color:blue;">Show / Hide</a></span>';
		document.getElementById(readlink).innerHTML = '<span id="'+readlink+'"><a name="#" onclick="showhide('+readidquoted+');" style="cursor:pointer; text-decoration:underline; color:blue;">Show / Hide</a></span>';
    } else {
		document.getElementById("contact").innerHTML = '<span class="working">Reading Private Message...Please Wait</span>';
	}
  }

  ajaxRequest.open("POST",url,true);
  ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajaxRequest.setRequestHeader("Content-length", parameters.length);
  ajaxRequest.setRequestHeader("Connection", "close");
  ajaxRequest.send(parameters);
}

function ajaxPM(messageid) {
  var idname = "contact"+messageid;
  var formname ="pm"+messageid;

  ajaxRequest=GetXmlHttpObject();
  if (ajaxRequest==null) {
	alert ("Your browser does not support AJAX!");
	return;
  } 

  var subject = eval("document."+formname+".subject.value");
  var to_member_id = eval("document."+formname+".to_member_id.value");
  var message = eval("document."+formname+".message.value");
  var thread = eval("document."+formname+".thread.value");

  var url = "/includes/ajax.php?function=pm";
  var parameters = '&subject=' + escape(subject) + '&message=' + escape(message) + '&to_member_id=' + to_member_id + '&thread=' + thread;

  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange=function() {
	if(ajaxRequest.readyState==4) {
		document.getElementById(idname).innerHTML = '<div id="'+idname+'"><span style="color:green">Your Private Message Has Been Sent</span></div>';
		alert("Message Sent");
    } else {
		document.getElementById(idname).innerHTML = '<div class="working">Sending Message...Please Wait</div>';
	}
  }

  ajaxRequest.open("POST",url,true);
  ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajaxRequest.setRequestHeader("Content-length", parameters.length);
  ajaxRequest.setRequestHeader("Connection", "close");
  ajaxRequest.send(parameters);
}

function ajaxReportBadLink(sourceid) {
  var idname = "badlink"+sourceid;
  var formname ="reportbadlink"+sourceid;
  ajaxRequest=GetXmlHttpObject();
  if (ajaxRequest==null) {
	alert ("Your browser does not support AJAX!");
	return;
  } 

  var comment = eval("document."+formname+".badlink_comment.value");
  var thispage = eval("document."+formname+".thispage.value");
  var url = "/includes/ajax.php?function=badlink";
  var parameters = '&sourceid=' + escape(sourceid) + '&comment=' + escape(comment) + '&thispage=' + escape(thispage);

  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange=function() {
	if(ajaxRequest.readyState==4) {
		document.getElementById(idname).innerHTML='<div id="'+idname+'" style="border:4px double #ace; background:#f5f5f5; padding:4px; color:green">Thanks for reporting the bad link!</div>';
		alert("Bad Link Message Sent");
    } else {
		//document.getElementById(idname).innerHTML='<div id='+idname+' class="working" style="border:4px double #ace; background:#f5f5f5; padding:4px; color:red">Reporting</div><br />';
		document.getElementById(idname).innerHTML='<div class="working" style="color:red">Saving</div><br />';
	}
  }

  //comment = comment.replace(/\n\r/g,"<br>");
  //comment = comment.replace(/\r\n/g,"<br>");
  //comment = comment.replace(/\n/g,"<br>");
  //comment = comment.replace(/\r/g,"<br>");
  //alert(comment);

  ajaxRequest.open("POST",url,true);
  ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajaxRequest.setRequestHeader("Content-length", parameters.length);
  ajaxRequest.setRequestHeader("Connection", "close");
  ajaxRequest.send(parameters);

  //ajaxRequest.open("GET",url,true);
  //ajaxRequest.send(null);
}


function ajaxSaveFavs(articleid,memberid) {
  ajaxRequest=GetXmlHttpObject();
  if (ajaxRequest==null) {
	alert ("Your browser does not support AJAX!");
	return;
  } 

  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange=function() {
	if(ajaxRequest.readyState==4) {
		document.getElementById("save").innerHTML='<div id="save"><a style="text-decoration:none; cursor: pointer;" href="/mybpb/articles/"><img src="/images/saved.gif" height="40" width="40" /><br />view all saved</a></div>';
    } else {
		document.getElementById("save").innerHTML='<div class="working" style="color:red">Saving</div><br />';
	}
  }
  var url = "/includes/ajax.php?function=save&member_id="+memberid+"&id="+articleid;
  ajaxRequest.open("GET",url,true);
  ajaxRequest.send(null);
}

