/* Create the htprequest opbect and process the readystate contents */

function createRequestObject() {
	if (window.XMLHttpRequest && !(window.ActiveXObject)) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject){
/*		return new ActiveXObject('Microsoft.XMLHTTP'); */
		try {
			return new ActiveXObject('MSXML2.XMLHTTP');  
		} catch (e) {
			return new ActiveXObject('Microsoft.XMLHTTP');
		}
	} 
}

var http = createRequestObject();

function handleResponse() {
    if(http.readyState == 4){
	var response = http.responseText;
	if (response != 'undefined' && response != '') {
		var update = new Array();
		var up2 = new Array();
		if(response.indexOf('|||' != -1)  ) {
		    update = response.split('|||');
  		    for (var i = 1; i<update.length; i++) {
		        up2 = update[i].split("|:|");
		        if (up2[0] != 'undefined' && up2[0] != '' && document.getElementById(up2[0]) ) {
			    document.getElementById(up2[0]).innerHTML = up2[1];
		        } 
		    }
		}
	}
    }
}

function updateOnlineTime() {
    http.open('GET', 'updateonlinetime.php');
    http.send(null);
    setTimeout("updateOnlineTime()",60000);
}

function updateOnlineCount() {
    http.open('get', 'updateonlinecount.php');
    http.onreadystatechange = handleResponse;
    http.send(null);
    setTimeout("updateOnlineCount()",60000);
}

if ( use_popups == undefined ) {
	var use_popups = true;
}

function isValidEmail( fieldValue ) {
	if ( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(fieldValue) )
		return true;

	return false;
}


function isValidURL(url) {

	if ( url == null )
		return false;

/* space extr */
	var reg='^ *';
/* protocol */
	reg = reg+'(?:([Hh][Tt][Tt][Pp](?:[Ss]?))(?:\:\\/\\/))?';
/* usrpwd */
	reg = reg+'(?:(\\w+\\:\\w+)(?:\\@))?';
/* domain */
	reg = reg+'([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|localhost|([Ww][Ww][Ww].|[a-zA-Z0-9].)[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,6})';
/* port */
	reg = reg+'(\\:\\d+)?';
/* path */
	reg = reg+'((?:\\/.*)*\\/?)?';
/* filename */
	reg = reg+'(.*?\\.(\\w{2,4}))?';
/* qrystr */
	reg = reg+'(\\?(?:[^\\#\\?]+)*)?';
/* bkmrk */
	reg = reg+'(\\#.*)?';
/* space extr */
	reg = reg+' *$';

	return url.match(reg);
}

/* returns true if checkStr contains only characters specified in checkOK
   probably can be replaced with a more efficient regular expression  */

function isValidString( checkStr, checkOK ) {

	if ( !checkOK )
		var checkOK = '';

	var allValid = true;

	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;

		if (j == checkOK.length) {
			allValid = false;
			break;
		}
	}

	return allValid;
}

var alphabeticChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var numericChars = "0123456789";

function isNumeric ( fieldValue ) {
	if ( /[0-9]/.test ( fieldValue ) )
		return true;
	return false;
}

function isNumeric( val, addChars ) {
	return isValidString( val, numericChars + addChars );
}

function isAlphabetic( val ) {
	if ( /[A-Za-z]/.test ( val ) )
		return true;
	return false;
}

function isAlphabetic( val, addChars ) {
	return isValidString( val, alphabeticChars + addChars );
}

function isAlphaNumeric( val ) {
	if ( /\w/.test ( val ) )
		return true;
	return false;
}

function isAlphaNumeric( val, addChars ) {
	return isValidString( val, alphabeticChars + numericChars + addChars );
}

function DispDispHide ( disp1, disp2, hide )
{
    if (hide) hide.style.display = 'none';
    if (disp1) disp1.style.display = 'inline';
    if (disp2) disp2.style.display = 'inline';
}

function DispHideHide ( disp, hide1, hide2 )
{
    if (hide1) hide1.style.display = 'none';
    if (hide2) hide2.style.display = 'none';
    if (disp) disp.style.display = 'inline';
}

function showHide( paramA, paramB)
{
	if (paramA.value == 'US')
		paramB.rows['row_usstates'].style.display ='inline';
	else
		paramB.rows['row_usstates'].style.display = 'none';

	if (paramA.value == 'CA')
		paramB.rows['row_castates'].style.display ='inline';
	else
		paramB.rows['row_castates'].style.display = 'none';

	if (paramA.value == 'AU')
		paramB.rows['row_austates'].style.display ='inline';
	else
		paramB.rows['row_austates'].style.display = 'none';

	if (paramA.value == 'GB')
		paramB.rows['row_gbstates'].style.display ='inline';
	else
		paramB.rows['row_gbstates'].style.display = 'none';

}

function showHide( paramA)
{
	if (paramA == 'US' ) {
		document.getElementById('row_usstates').style.display ='inline';
	} else {
		document.getElementById('row_usstates').style.display = 'none';
	}
	if (paramA == 'CA') {
		document.getElementById('row_castates').style.display ='inline';
	} else {
		document.getElementById('row_castates').style.display = 'none';
	}
	if (paramA == 'AU') {
		document.getElementById('row_austates').style.display ='inline';
	} else {
		document.getElementById('row_austates').style.display = 'none';
	}
	if (paramA == 'GB') {
		document.getElementById('row_gbstates').style.display ='inline';
	} else {
		document.getElementById('row_gbstates').style.display = 'none';
	}
}

function showHidePref( paramA, paramB)
{
	if (paramA.value == 'US') {
		paramB.rows['row_lookusstates'].style.display ='inline';
	} else {
		paramB.rows['row_lookusstates'].style.display = 'none';
	}
	if (paramA.value == 'CA') {
		paramB.rows['row_lookcastates'].style.display ='inline';
	} else {
		paramB.rows['row_lookcastates'].style.display = 'none';
	}
	if (paramA.value == 'AU') {
		paramB.rows['row_lookaustates'].style.display ='inline';
	} else {
		paramB.rows['row_lookaustates'].style.display = 'none';
	}
	if (paramA.value == 'GB') {
		paramB.rows['row_lookgbstates'].style.display ='inline';
	} else {
		paramB.rows['row_lookgbstates'].style.display = 'none';
	}
}

function showHidePref( paramA)
{
	if (paramA == 'US' ) {
		document.getElementById('row_lookusstates').style.display ='inline';
	} else {
		document.getElementById('row_lookusstates').style.display = 'none';
	}
	if (paramA == 'CA') {
		document.getElementById('row_lookcastates').style.display ='inline';
	} else {
		document.getElementById('row_lookcastates').style.display = 'none';
	}
	if (paramA == 'AU') {
		document.getElementById('row_lookaustates').style.display ='inline';
	} else {
		document.getElementById('row_lookaustates').style.display = 'none';
	}
	if (paramA == 'GB') {
		document.getElementById('row_lookgbstates').style.display ='inline';
	} else {
		document.getElementById('row_lookgbstates').style.display = 'none';
	}
}

function openWin(id)
{
	if ( use_popups == false ) {
		window.location.href = 'viewresult.php?pollid=' + id;
		return;
	}

	var width=550;
	var height=378;
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;

	openpopup=window.open('viewresult.php?pollid=' + id ,'','width='+width+',height='+height+',left='+left+',top='+top+',resizable=yes,scrollbars=yes,status=no');
	openpopup.opener.name='abc';
}

function previousPolls(){

	if ( use_popups == false ) {
		window.location.href = 'previouspolls.php';
		return;
	}

	var width=600;
	var height=378;
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;

	openpopup=window.open('previouspolls.php' ,'popupwin','width='+width+',height='+height+',left='+left+',top='+top+',resizable=yes,scrollbars=yes,status=no');
	openpopup.opener.name="abc";
}


function launchTellFriend ()
{
	if ( use_popups == false ) {
		window.location.href = 'tellafriend.php';
		return;
	}

	var left = (screen.width/2) - 400/2;
	var top = (screen.height/2) - 400/2;
	var win = "width=300,height=250,left=" + left + ",top=" + top + ",copyhistory=no,directories=no,menubar=no,location=no,resizable=yes,scrollbars=no";
	window.open("tellafriend.php",'tellfriend',win);
}

function launchTellFriendProfile ( sID )
{
	if ( use_popups == false ) {
		window.location.href = 'tellafriend.php?ID=' + sID;
		return;
	}

	var left = (screen.width/2) - 280/2;
	var top = (screen.height/2) - 280/2;
	var win = "width=280,height=300,left=" + left + ",top=" + top + ",copyhistory=no,directories=no,menubar=no,location=no,resizable=yes,scrollbars=yes";
	window.open("tellfriend.php?ID=" + sID,'tellfriendprofile',win);
}

var popUpWin=0;

<!-- MOD START -->

function popUpWindowMessage(URLStr, align, width, height, msgid)
{

	width = 450;
	height = 450;

	if ( use_popups == false ) {
		window.location.href = URLStr;
		return;
	}

/*	if(popUpWin){

		if(!popUpWin.closed) popUpWin.close();
	}

*/
	if( align == 'center' ){

		var left = (screen.width/2) - width/2;
		var top = (screen.height/2) - height/2;
	} else {

		var left = 0;
		var top = 0;
	}

	popUpWin = open(URLStr, 'popUpWin'+msgid, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

<!-- MOD END -->

function showIM(msgid){
	popUpWindow('showinstantmsg.php?id=' + msgid,'center',320,260,msgid);
}

function popUpWindow(URLStr, align, width, height, msgid)
{
	if ( use_popups == false ) {
		window.location.href = URLStr;
		return;
	}

	if( align == 'center' ){

		var left = (screen.width/2) - width/2;
		var top = (screen.height/2) - height/2;
	} else {

		var left = 0;
		var top = 0;
	}

	popUpWin = open(URLStr, 'popUpWin'+msgid, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	popUpWin.opener.name="abc1"; 
}


function popUpScrollWindow(URLStr, align, width, heightParam)
{
	if ( use_popups == false  ) {
		window.location.href = URLStr;
		return;
	}

	height = screen.height - 150;
	height = Math.min( height, heightParam );

	if( align == 'center' ){

		var left = (screen.width/2) - width/2;
		var top = (screen.height/2) - height/2;
	}else if( align == 'top' ){

		var left = (screen.width/2) - width/2;
		var top = 0;
	}else{

		var left = 0;
		var top = 0;
	}

	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function popUpScrollWindow2 (URLStr, align, width, heightParam)
{
	if ( use_profilepopups == false ) {
		window.location.href = URLStr;
		return;
	}

	height = screen.height - 150;
	height = Math.min( height, heightParam );

/*	if(popUpWin){

		if(!popUpWin.closed) { popUpWin.close(); }
	}
*/
	if( align == 'center' ){

		var left = (screen.width/2) - width/2;
		var top = (screen.height/2) - height/2;
	}else if( align == 'top' ){

		var left = (screen.width/2) - width/2;
		var top = 0;
	}else{

		var left = 0;
		var top = 0;
	}

	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	popUpWin.opener.name="abc1";
}

var prevRow = null;

function toggleRow(rwId, num){

	if( prevRow != null ) {
		prevRow.style.display ='none';
	}
	prevRow = obj = document.getElementById(rwId);
	obj.style.display ='inline';

	for( i=0; i<document.getElementById('tblSelect').length ; i++ ){

		if( i == num ) {
			document.getElementById('tblSelect')[i].className = "s_table_blue";
		} else {
			document.getElementById('tblSelect')[i].className = "s_table_white";
		}
	}
}


function votesubmit(id,curtime)
{
	var width=600;
	var height=378;
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;

	nop = document.frmpoll.rdo.length;
	var i, rdo;
	rdo = '0';
	for (i=0 ; i<nop ; i++)
	{
		if (document.frmpoll.rdo[i].checked)
		{
			rdo = document.frmpoll.rdo[i].value;
		}
	}
	if ( use_popups == false ) {
		if ( rdo == "" ) {
			window.location.href = 'viewresult.php?t=' + curtime + '&pollid=' + id;
		}
		else {
			window.location.href = 'votehere.php?t=' + curtime + '&rdo=' + rdo + '&pollid=' + id;
		}
		return;
	}

	if (rdo=="")
	{
		openpopup=window.open('viewresult.php?t=' + curtime + '&pollid=' + id ,'','width='+width+',height='+height+',left='+left+',top='+top+',resizable=yes,scrollbars=yes,status=no');
		openpopup.opener.name='abc';
	} else {
		openpopup=window.open('votehere.php?t=' + curtime + '&rdo=' + rdo + '&pollid=' + id ,'','width='+width+',height='+height+',left='+left+',top='+top+',resizable=yes,scrollbars=yes,status=no');
		openpopup.opener.name='abc';
	}
}

function selectRdo(form,rdo){

	for( i=0 ; i < form.length ; i++ ) {
		if( form.elements[i].type=='radio' && form.elements[i].name=='searchby'
			&& form.elements[i].value == rdo ) {
			form.elements[i].checked=true;
		}
	}
}

function checkAll(form,name,val){
	for( i=0 ; i < form.length ; i++) {
		if( form.elements[i].type == 'checkbox' && form.elements[i].name == name ) {
			form.elements[i].checked = val;
		}
	}
}

function datefromtovalid(sy,sm,sd,ey,em,ed,msg)
{
	month=new Array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC")
	var syear=sy[sy.selectedIndex].value;
	var smonth=sm[sm.selectedIndex].value;
	var sdays=sd[sd.selectedIndex].value;
	var eyear=ey[ey.selectedIndex].value;
	var emonth=em[em.selectedIndex].value;
	var edays=ed[ed.selectedIndex].value;
	for (var count=0;count<12;count++)
	{
		if ((smonth== month[count]))
		{
			smonth=count;
		}
		if ((emonth== month[count]))
		{
			emonth=count;
		}
	}
	from_date=new Date(syear,smonth,sdays);
	to_date=new Date(eyear,emonth,edays);
	if (from_date > to_date)
	{
	 	alert(msg);
	 	return false;
	}
	return true;
}

function DateCheck(syr, smt, sdt, msg)
{
   hdt=sdt[sdt.selectedIndex].value;
   hmt=smt[smt.selectedIndex].value;
   hyr=syr[syr.selectedIndex].value;

   hms_maxval=31;
   if ((hmt=="APR") || (hmt=="JUN") || (hmt=="SEP") || (hmt=="NOV")){hms_maxval=30;}
   if ((hmt=="FEB") && (hyr%4)==0){hms_maxval=29;}
   if ((hmt=="FEB") && (hyr%4)!=0){hms_maxval=28;}
   if (parseInt(hdt)>hms_maxval)
   {
      alert(msg);
      return false;
   }
   return true;
}



function validateLogin(form)
{
	ErrorMsg = new Array();
	ErrorMsg[0]="------------------------- The Following Errors Occured -------------------------" + String.fromCharCode(13);

	CheckFieldString("noblank",form.txtusername,"{$lang.signup_js_errors.username_noblank}");
	CheckFieldString("noblank",form.txtpassword,"{$lang.signup_js_errors.password_noblank}");

	CheckFieldString("alphanum",form.txtusername,"{$lang.signup_js_errors.username_charset}");
	CheckFieldString("alphanum",form.txtpassword,"{$lang.signup_js_errors.password_charset}");

	/* concat all error messages into one string */
	result="";
	if( ErrorCount > 0)
	{
		alert(ErrorMsg[1]);
		return false;
	}
	return true;
}

// After clicking a link to delete something, pops up a window asking the user to confirm
// If the user clicks ok, it tacks delete=Y to the url.  If the user clicks cancel, 
// it returns false which leaves the user on the page. 
// 
// Ex.  <a href="bloglist.php?id=2&action=delete" onclick="return confirmLink(this, 'Blog Entry')">Delete</a>
// 
function confirmLink(theLink, theMessage) {

      var is_confirmed = confirm(theMessage);
      if (is_confirmed) {
         theLink.href += '&delete=Y';
      }
      
      return is_confirmed;
 }
// After clicking a submit button, pops up a window asking the user to confirm 
// If the user clicks ok, it proceeds.  If the user clicks cancel, it cancels submitting
// the form
// 
// ex.  <input type="submit" class="formbutton" value="Delete" name="delete" onclick="return confirmButton('Blog Entries')" />
// 
function confirmButton(theMessage) {

      var is_confirmed = confirm(theMessage);

      return is_confirmed;
}

// The next two functions comprise the text counting for a text box.  
// 
 function countCheck(countLimit) {
   if(document.frmCmt.comment.value.length > countLimit) {
     alert('Too many characters in the comment box!');
     document.frmCmt.comment.focus();
     return false; }
   else
     return true; }
 function countText(countLimit) {
   var old = document.frmCmt.counter.value;
   document.frmCmt.counter.value=document.frmCmt.comment.value.length;
   if(document.frmCmt.counter.value > countLimit && old <= countLimit) {
     alert('Too many characters in the comment box!');
     if(document.styleSheets) {
       document.frmCmt.counter.style.fontWeight = 'bold';
       document.frmCmt.counter.style.color = '#ff0000'; } }
   else if(document.frmCmt.counter.value <= countLimit && old > countLimit
	   && document.styleSheets ) {
       document.frmCmt.counter.style.fontWeight = 'normal';
       document.frmCmt.counter.style.color = '#000000'; } 
   }
 
function openInParentWindow(url)
{	window.opener.document.location.href=url;
	window.opener.focus();
}


/* To validate the type of input values in the form fields */
function CheckFieldString(type, formField, strMsg) {

	var checkOK;
	var checkStr = formField.value;
  	var allValid = true;
	var flagDot  = false;
	var namestr, domainstr;
	
	if (type == 'noblank')
	{
		if (checkStr == "")
  		{
  			ErrorCount++;
	   	 	ErrorMsg[ErrorCount] = strMsg  ;
  		}
	} else 	{
		if (type == 'integer')	{
  			checkOK = "0123456789";
  		} else if (type == 'decimal'){	
  			checkOK = "0123456789.";
		} else if (type == 'text') {
/*			checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "; */
			checkOK = text_chars;
		} else if (type == 'alphanumeric') {
/*			checkOK = "0123456789.+-_#,/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ()_"; */
			checkOK = alphanumeric_chars;
		} else if (type == 'full') {
/*			checkOK = "0123456789.,[]{}=+-_#,/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ()_:;'\\*^%$@<>?'\"\'"; */
			checkOK = full_chars;
		} else if (type == 'alphanum') {
/*			checkOK = "0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "; */
			checkOK = alphanum_chars;
		} else if (type == 'email'){
			checkOK = "0123456789_-@.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
				if ( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(checkStr) ){
				}else{
					ErrorCount++;
					ErrorMsg[ErrorCount] = strMsg ;
				}
		} else if (type == 'phone') {
			checkOK = "0123456789-+";
		} else if (type == 'URL') {
			checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.:/\\";
		} else if (type == 'path') {
			checkOK = "0123456789.+-_#,/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz () \\ ";
		} else {
			ErrorCount++;
			ErrorMsg[ErrorCount] = "Check Validation one of the mentioned validation type is wrong" ;
			return 1;
		}
		
		/* code for email validation */
		/* if ((type == 'email') && (checkStr != "")) {	
			
			namestr = checkStr.substring(0, checkStr.indexOf("@"));  // everything before the '@'
			domainstr = checkStr.substring(checkStr.indexOf("@")+1, checkStr.length); // everything after the '@'

			// Rules: namestr cannot be empty, or that would indicate no characters before the '@',
			// domainstr must contain a period that is not the first character (i.e. right after
			// the '@').  The last character must be an alpha.
   			if ((namestr.length == 0) || (domainstr.indexOf(".") <= 0) || (domainstr.indexOf("@") != -1)) {
   				ErrorCount++;
				ErrorMsg[ErrorCount] = "Enter a valid Email Address." ;
   			} 
		} */		

  		for (i = 0;  i < checkStr.length;  i++)
  		{
    		ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++) {
	      		if (ch == checkOK.charAt(j)) {
					break; }
				if (j == checkOK.length-1 ){
					
					allValid = false;
					break;
				}
			}
		
			if (type == 'decimal') /* for decimal type */
			{
				for (t = 0;  t < checkStr.length;  t++){	
				
					dot = checkStr.charAt(t)
					if (dot =='.' && flagDot == false) {
						flagDot=true;
					} else if (dot =='.' && flagDot == true){
					
						ErrorCount++;
						ErrorMsg[ErrorCount] = strMsg ;
						break;
					}
				}
			}
				
			if (!allValid){
			
				ErrorCount++;
				ErrorMsg[ErrorCount] = strMsg ;
				break;
			}
     	}
  	}
}

// captcha reload

function reloadCaptcha() {
	now = new Date();
	var capObj = document.getElementById('spam_code_img');
	if (capObj) {
		capObj.src = capObj.src + (capObj.src.indexOf('?') > -1 ? '&' : '?') + Math.ceil(Math.random()*(now.getTime()));
	}
}


// ***
// Added new, brought to you by w3schools to begin with.  -x
// Irritatingly, I have to do this twice, because I can't guarantee it'll work
// with two sections.

var xmlhttp;

function loadXMLDoc() {
        xmlhttp=null;

        if (window.XMLHttpRequest) { // code for IE7, Firefox, Mozilla, etc.
                xmlhttp=new XMLHttpRequest();
        } else if (window.ActiveXObject) { // code for IE5, IE6
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        if (xmlhttp!=null) {
                xmlhttp.onreadystatechange=onResponse;
                xmlhttp.open("GET", "/blog?feed=rss2", true);
                xmlhttp.send(null);
        } else {
                alert("Your browser does not support XMLHTTP.");
        }
}

function onResponse() {
        if(xmlhttp.readyState!=4) return;
        if(xmlhttp.status!=200) {
                alert("Problem retrieving XML data");
                return;
        }

// La la la each item in the feed.
        x=xmlhttp.responseXML.documentElement.getElementsByTagName("item");

//Testing only.
//alert(xmlhttp.responseText);

// Max titles to get.
        var lin = 3;

        var sucText = document.createElement("span"); var sCt = 0;
        var artText = document.createElement("span"); var nCt = 0;
        var blockText = document.createElement("span");

        for (i = 0; i < x.length; i ++) {
                var cat;
                xx = x[i].getElementsByTagName("category");
                {
                        try {
                                cat = xx[0].firstChild.nodeValue;
                        }
                        catch(err) {}
                }

// The link itself.
                xx = x[i].getElementsByTagName("link");
                {
                        try {
                                var newLink = document.createElement("b");
                                var tmp = document.createElement("a");
                                tmp.setAttribute("href", xx[0].firstChild.nodeValue);
                                tmp.setAttribute("target", "_blank");
                        }
                        catch(err) { }
                }

// The text for the link.
                xx=x[i].getElementsByTagName("title");
                {
                        try {
                                tmp.appendChild(document.createTextNode(xx[0].firstChild.nodeValue));
				newLink.appendChild(tmp);
                                if (cat == "Articles" && nCt < lin) {
                                        artText.appendChild(newLink);
                                        artText.appendChild(document.createElement("br"));
				} else if (cat == "Success Stories" && cSt < lin) {
                                        sucText.appendChild(newLink);
                                        sucText.appendChild(document.createElement("br"));
                                }
                        }
// If there's no title, I mean.
                        catch(err) {
                                newLink.appendChild(document.createTextNode("(no subject)"));
                                if (cat == "Articles" && nCt < lin) {
                                        artText.appendChild(newLink);
                                        artText.appendChild(document.createElement("br"));
                                } else if (cat == "Success Stories" && sCt < lin) {
                                        sucText.appendChild(newLink);
                                        sucText.appendChild(document.createElement("br"));
                                }
                        }
                }
// The date the post was published.
                xx=x[i].getElementsByTagName("pubDate");
                {
                        try {
                                var newDate = document.createElement("span");
                                newDate.setAttribute("style", "font-size: 7pt; font-style: italic;");
                                newDate.appendChild(document.createTextNode(xx[0].firstChild.nodeValue.substr(0, 16)));
                                if (cat == "Articles" && nCt < lin) {
                                        artText.appendChild(newDate);
                                        artText.appendChild(document.createElement("br"));
                                        artText.appendChild(document.createElement("br"));
                                } else if (cat == "Success Stories" && sCt < lin) {
                                        sucText.appendChild(newDate);
                                        sucText.appendChild(document.createElement("br"));
                                        sucText.appendChild(document.createElement("br"));
                                }
                        }
                        catch(err) { alert("Date failed!"); }
                }
// The post text la.
                xx = x[i].getElementsByTagName("description");
                {
                        try {
                                if (cat == "Articles" && nCt < lin) {
                                        artText.innerHTML += xx[0].firstChild.nodeValue;
                                        artText.appendChild(document.createElement("br"));
                                        artText.appendChild(document.createElement("br"));
                                } else if (cat == "Success Stories" && sCt < lin) {
                                        sucText.innerHTML += xx[0].firstChild.nodeValue;
                                        sucText.appendChild(document.createElement("br"));
                                        sucText.appendChild(document.createElement("br"));
                                }
                        }
                        catch(err) { }
                }

// POST THIS.
                {
                        try {
                                if (cat == "Articles") {
                                        document.getElementById('newsCopy').appendChild(artText);
					nCt++;
                                } else if (cat == "Success Stories") {
                                        document.getElementById('succCopy').appendChild(sucText);
					sCt++;
                                }
                        }
                        catch(err) { }
                }
        }
}



/* BANNERZ */

function loadAds() {

// Put image/link groups here.
	var adGroups = new Array(
		"coloplast.gif http://www.us.coloplast.com/",
		"ethicon.gif http://www.ethicon.com/",
		"hawaii_bar.png http://www.gohawaii.com/",
		"viagra.png http://www.viagra.com/",
		"sees.gif http://www.sees.com"
	);

        var aLen = adGroups.length;

// Tops first.
        var whichAd = Math.round(Math.random() * (aLen - 1));
        var theAd = adGroups[whichAd].split(" ");
	document.getElementById("banner_main_ad_over").innerHTML = '<a href="' + theAd[1] + '"><img src="/banners/' + theAd[0] + '" border=0></a>';

// Then unders.
        var tmpAd = Math.round(Math.random() * (aLen - 1));
        while (tmpAd == whichAd) {
                tmpAd = Math.round(Math.random() * (aLen - 1));
        }
        var theAd = adGroups[tmpAd].split(" ");
        document.getElementById("banner_main_ad_under").innerHTML = '<a href="' + theAd[1] + '"><img src="/banners/' + theAd[0] + '" border=0></a>';
}


/* QUOTEZ */

function loadQuote() {

// To add a new quote, make a new line somewhere in the middle of all this, then
// have it in this format:
// 	"Quote. %% Author",

	var allQuotes = new Array(
		"Always go to other people's funerals, otherwise they won't come to yours. %% Yogi Berra",
		"It is right that he too should have his little chronicle, his memories, his reason, and be able to recognize the good in the bad, the bad in the worst, and so grow gently old down all the unchanging days, and die one day like any other day, only shorter. %% Samuel Beckett",
		"God is change. %% Octavia Butler",
		"We all have to die some day, if we live long enough. %% Dave Farber",
		"All I know is what the words know, and dead things, and that makes a handsome little sum, with a beginning and a middle and an end, as in the well-built phrase and the long sonata of the dead. %% Samuel Beckett",
		"Birth was the death of him. %% Samuel Beckett",
		"No, I regret nothing, all I regret is having been born, dying is such a long tiresome business I always found. %% Samuel Beckett",
		"Personally I have no bone to pick with graveyards. %% Samuel Beckett",
		"You're on earth. There's no cure for that. %% Samuel Beckett",
		"Death is just nature's way of telling you to slow down. %% Dick Sharples",
		"They say such nice things about people at their funerals that it makes me sad that I'm going to miss mine by just a few days. %% Garrison Keillor",
		"Once the game is over, the king and the pawn go back into the same box. %% Italian Proverb",
		"For days after death hair and fingernails continue to grow, but phone calls taper off. %% Johnny Carson",
		"Alas, I am dying beyond my means. %% Oscar Wilde",
		"If life must not be taken too seriously -- then so neither must death. %% Samuel Butler",
		"I don't want to achieve immortality through my work, I want to achieve it through not dying. %% Woody Allen",
		"I'm not afraid to die, I just don't want to be there when it happens. %% Woody Allen",
		"Death is a low chemical trick played on everybody except sequoia trees. %% J.J. Furnas",
		"At my age I do what Mark Twain did. I get my daily paper, look at the obituaries page and if I'm not there I carry on as usual. %% Patrick Moore",
		"I'm very pleased to be here. Let's face it, at my age I'm very pleased to be anywhere. %% George Burns",
		"Have the courage to live. Anyone can die. %% Robert Cody",
		"Please pardon my levity, I don't see how to take death seriously. It seems absurd. %% Robert Anton Wilson",
		"If you realize that all things change, there is nothing you will try to hold on to. If you are not afraid of dying, there is nothing you cannot achieve.",
		"Dying is a very dull, dreary affair. And my advice to you is to have nothing whatever to do with it. %% W. Somerset Maugham",
		"He had decided to live forever or die in the attempt. %% Joseph Heller",
		"I am ready to meet my Maker. Whether my Maker is prepared for the great ordeal of meeting me is another matter. %% Winston Churchill",
		"The difference between sex and death is that with death you can do it alone and no one is going to make fun of you. %% Woody Allen",
		"Levity is good. It relieves the tension of death. %% Terminator III",
		"Am I lightheaded because I'm not dead or because I'm still alive? %% Heidi Sandige"
	);

	var qLen = allQuotes.length;
	var whichQuote = Math.round(Math.random() * (qLen - 1));
	var theQuote = allQuotes[whichQuote].split(" %% ");

	document.getElementById("q_quote").innerHTML = theQuote[0];
	if (theQuote.length > 1) {
		document.getElementById("q_quote").innerHTML += "&nbsp;-&nbsp;";
		document.getElementById("q_author").innerHTML = theQuote[1];
	}
}