// Confirmation Function

function print_confirm($confirm_text) {

	var answer = confirm($confirm_text)

	if (answer){ window.print(); }

}



// Function for Bookmarking

function CreateBookmarkLink() {

title = "Unreached People of the Day";

url = "http://www.unreachedoftheday.org/";

if (window.sidebar) {

// Mozilla Firefox Bookmark

// alert("FIREFOX!");

window.sidebar.addPanel(title, url,"");

} else if( window.external ) {

// IE Favorite

// alert("YES IE");

window.external.AddFavorite( url, title);

}

else if(window.opera && window.print) {

// Opera Hotlist

return true; }

}



// Function to set Home Page

function setasHome(){

document.body.style.behavior='url(#default#homepage)';

document.body.setHomePage('http://www.unreachedoftheday.org');

}



// Function to get URL parameters

function gup( name )

{

name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

var regexS = "[\\?&]"+name+"=([^&#]*)";

var regex = new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results == null )

return "";

else

return results[1];

}



// Day of Year Function 

Date.prototype.getDOY = function() {

var onejan = new Date(this.getFullYear(),0,1);

// Subtract 1 to be the same as PHP Day of Year function

return Math.ceil((this - onejan) / 86400000)-1;

}



function MM_popupMsg(msg) { //v1.0

  confirm(msg);

}



function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}



function foo() {

    ConfirmStatus = confirm("Some listings return several thousand records. \nYou may experience a delay depending on the speed of your internet connection . \n\nDo you want to continue?");

    //py = bar.listing.selectedIndex;

    if (ConfirmStatus == false) {

	//alert(py);

	bar.listing.selectedIndex = 0;

    }

    else {

	document.bar.submit();

	//py = bar.listing.selectedIndex;

	//alert("weve come this far");

    }

}



function MM_callJS(jsStr) { //v2.0

  return eval(jsStr)

}



function MM_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=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function fnClearROG3()

{

   rog3.value='';

}



function fnClearPEO3()

{

   peo3.value='';

}



function ClearForms(p) {

	 var objForm=p;

     for(i=0;i<objForm.elements.length;i++){

          if(objForm.elements[i].type=="text"){

               objForm.elements[i].value = "";

          }

          if(objForm.elements[i].type=="textarea"){

               objForm.elements[i].value = "";

          }

          if(objForm.elements[i].type=="select-one"){

               objForm.elements[i].selectedIndex = 0;

          }

          if(objForm.elements[i].type=="checkbox"){

               objForm.elements[i].checked = false;

          }

          if(objForm.elements[i].type=="radio"){

               objForm.elements[i].checked = false;

          }

     }

}





function targetopener(mylink, closeme, closeonly)

{

if (! (window.focus && window.opener))return true;

window.opener.focus();

if (! closeonly)window.opener.location.href=mylink.href;

if (closeme)window.close();

return false;

}



function open_select()

{

document.dataselect.quickview.focus();

}





function addBookmark(title,url){

if (window.sidebar) // firefox

	window.sidebar.addPanel(title, url, "");

else if(window.opera && window.print){ // opera

	var elem = document.createElement('a');

	elem.setAttribute('href',url);

	elem.setAttribute('title',title);

	elem.setAttribute('rel','sidebar');

	elem.click();

} 

else if(document.all)// ie

	window.external.AddFavorite(url, title);

}



function addEvent(elm, evType, fn, useCapture) {

	if (elm.addEventListener) { 

	elm.addEventListener(evType, fn, useCapture); 

	return true; 

	}

	else if (elm.attachEvent) { 

	var r = elm.attachEvent('on' + evType, fn); 

	EventCache.add(elm, evType, fn);

	return r; 

	}

	else {

	elm['on' + evType] = fn;

	}

}

function getEventSrc(e) {

	if (!e) e = window.event;



	if (e.originalTarget)

	return e.originalTarget;

	else if (e.srcElement)

	return e.srcElement;

}

function addLoadEvent(func) {

var oldonload = window.onload;

	if (typeof window.onload != 'function') {

	window.onload = func;

	} else {

	window.onload = 

		function() {

		oldonload();

		func();

		}

	}

}

var EventCache = function(){

	var listEvents = [];

	return {

		listEvents : listEvents,

	

		add : function(node, sEventName, fHandler, bCapture){

			listEvents.push(arguments);

		},

	

		flush : function(){

			var i, item;

			for(i = listEvents.length - 1; i >= 0; i = i - 1){

				item = listEvents[i];

				

				if(item[0].removeEventListener){

					item[0].removeEventListener(item[1], item[2], item[3]);

				};

				

				/* From this point on we need the event names to be prefixed with 'on" */

				if(item[1].substring(0, 2) != "on"){

					item[1] = "on" + item[1];

				};

				

				if(item[0].detachEvent){

					item[0].detachEvent(item[1], item[2]);

				};

				

				item[0][item[1]] = null;

			};

		}

	};

}();





addEvent(window,'unload',EventCache.flush, false);



var toolTipLib = { 

	xCord : 0,

	yCord : 0,

	obj : null,

	tipElements : ['a','abbr','acronym','form'],

	attachToolTipBehavior: function() {

		if ( !document.getElementById ||

			!document.createElement ||

			!document.getElementsByTagName ) {

			return;

		}

		var i,j;

		addEvent(document,'mousemove',toolTipLib.updateXY,false);

		if ( document.captureEvents ) {

				document.captureEvents(Event.MOUSEMOVE);

		}

		for ( i=0;i<toolTipLib.tipElements.length;i++ ) {

			var current = document.getElementsByTagName(toolTipLib.tipElements[i]);

			for ( j=0;j<current.length;j++ ) {

				if (current[j].getAttribute('title') != null &&

				current[j].getAttribute('title') != '') {

				addEvent(current[j],'mouseover',toolTipLib.tipOver,false);

				addEvent(current[j],'mouseout',toolTipLib.tipOut,false);

				current[j].setAttribute('tip',current[j].title);

				current[j].removeAttribute('title');

				}

			}

		}

	},



	updateXY : function(e) {

		if ( document.captureEvents ) {

			toolTipLib.xCord = e.pageX;

			toolTipLib.yCord = e.pageY;

		} else if ( window.event.clientX ) {

			toolTipLib.xCord = window.event.clientX+document.documentElement.scrollLeft;

			toolTipLib.yCord = window.event.clientY+document.documentElement.scrollTop;

		}

	},

	tipOut: function(e) {

		if ( window.tID ) {

			clearTimeout(tID);

		}

		if ( window.opacityID ) {

			clearTimeout(opacityID);

		}

		var l = getEventSrc(e);

		var div = document.getElementById('toolTip');

		if ( div ) {

			div.parentNode.removeChild(div);

		}

	},

	checkNode : function(obj) {

		var trueObj = obj;

		if ( trueObj.nodeName.toLowerCase() == 'a' || trueObj.nodeName.toLowerCase() == 'acronym' || trueObj.nodeName.toLowerCase() == 'abbr' ) {

			return trueObj;

		} else {

			return trueObj.parentNode;

		}

	},

	tipOver : function(e) {

		toolTipLib.obj = getEventSrc(e);

		tID = setTimeout("toolTipLib.tipShow()",500)

	},

	tipShow : function() {

		var newDiv = document.createElement('div');

		var scrX = Number(toolTipLib.xCord);

		var scrY = Number(toolTipLib.yCord);

		var tp = parseInt(scrY+15);

		var lt = parseInt(scrX+10);

		var anch = toolTipLib.checkNode(toolTipLib.obj);

		var addy = '';

		var access = '';

		if ( anch.nodeName.toLowerCase() == 'a' ) {

			addy = (anch.href.length > 25 ? anch.href.toString().substring(0,25)+"..." : anch.href);

			var access = ( anch.accessKey ? ' <span>['+anch.accessKey+']</span> ' : '' );

		} else {

			addy = anch.firstChild.nodeValue;

		}

		newDiv.id = 'toolTip';

		document.getElementsByTagName('body')[0].appendChild(newDiv);

		newDiv.style.opacity = '.1';

		newDiv.innerHTML = "<p>"+anch.getAttribute('tip')+access+"";

		if ( parseInt(document.documentElement.clientWidth+document.documentElement.scrollLeft) < parseInt(newDiv.offsetWidth+lt) ) {

			newDiv.style.left = parseInt(lt-(newDiv.offsetWidth+10))+'px';

		} else {

			newDiv.style.left = lt+'px';

		}

		if ( parseInt(document.documentElement.clientHeight+document.documentElement.scrollTop) < parseInt(newDiv.offsetHeight+tp) ) {

			newDiv.style.top = parseInt(tp-(newDiv.offsetHeight+10))+'px';

		} else {

			newDiv.style.top = tp+'px';

		}

		toolTipLib.tipFade('toolTip',99);

	},

	tipFade: function(div,opac) {

		var obj = document.getElementById(div);

		var passed = parseInt(opac);

		var newOpac = parseInt(passed+10);

		if ( newOpac < 80 ) {

			obj.style.opacity = '.'+newOpac;

			obj.style.filter = "alpha(opacity:"+newOpac+")";

			opacityID = setTimeout("toolTipLib.tipFade('toolTip','"+newOpac+"')",20);

		}

		else { 

			obj.style.opacity = '.99';

			obj.style.filter = "alpha(opacity:99)";

		}

	}

};

addEvent(window,'load',toolTipLib.attachToolTipBehavior,false);





function openWindow(anchor, options) {



	var args = '';



	if (typeof(options) == 'undefined') { var options = new Object(); }

	if (typeof(options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random()*100000); }



	if (typeof(options.height) != 'undefined' && typeof(options.fullscreen) == 'undefined') {

		args += "height=" + options.height + ",";

	}



	if (typeof(options.width) != 'undefined' && typeof(options.fullscreen) == 'undefined') {

		args += "width=" + options.width + ",";

	}



	if (typeof(options.fullscreen) != 'undefined') {

		args += "width=" + screen.availWidth + ",";

		args += "height=" + screen.availHeight + ",";

	}



	if (typeof(options.center) == 'undefined') {

		options.x = 0;

		options.y = 0;

		args += "screenx=" + options.x + ",";

		args += "screeny=" + options.y + ",";

		args += "left=" + options.x + ",";

		args += "top=" + options.y + ",";

	}



	if (typeof(options.center) != 'undefined' && typeof(options.fullscreen) == 'undefined') {

		options.y=Math.floor((screen.availHeight-(options.height || screen.height))/2)-(screen.height-screen.availHeight);

		options.x=Math.floor((screen.availWidth-(options.width || screen.width))/2)-(screen.width-screen.availWidth);

		args += "screenx=" + options.x + ",";

		args += "screeny=" + options.y + ",";

		args += "left=" + options.x + ",";

		args += "top=" + options.y + ",";

	}



	if (typeof(options.scrollbars) != 'undefined') { args += "scrollbars=1,"; }

	if (typeof(options.menubar) != 'undefined') { args += "menubar=1,"; }

	if (typeof(options.locationbar) != 'undefined') { args += "location=1,"; }

	if (typeof(options.resizable) != 'undefined') { args += "resizable=1,"; }



	var win = window.open(anchor, options.name, args);

	return false;



}

