function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	}
	else 
	{
		window.onload = function() 
			{
				oldonload();
				func();
			}
	}
}//function addLoadEvent(func)

function printPage()
{
    //document.getElementById('print').style.visibility = 'hidden';
    // Do print the page
	window.Width=800;
    if (typeof(window.print) != 'undefined') {
        window.print();
    }
    //document.getElementById('print').style.visibility = '';
}
var a_str_windowName="print";
var a_int_windowWidth=800;
var a_int_windowHeight=600;
var a_bool_scrollbars='yes';
var a_bool_resizable='no';
var a_bool_menubar='no';
var a_bool_toolbar='no';
var a_bool_addressbar='no';
var a_bool_statusbar='yes';
var a_bool_fullscreen='no';

function newWindow(a_str_windowURL) 
{
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

//--------------------------------------------------------------------

/*
function checkUnique(fld,val)
{
	if (confirm("Are You sure?"))
	{
		mysend(fld,val);
		//alert("checkUnique  fld=" +fld+", val="+val);
		unique=true;
	}
}//function checkUnique(fld)

*/
function changePass()
{
	frm=document.forms.editprofile;
	frm.mod.value='userpsw';
	frm.action='';
	frm.submit();
}//function changePass()


//self.onerror=function() {return true;}
 //function doNothing() { return true; }
//window.onerror = doNothing;
var alldivs;
alldivs=Array("wholescreen","new_message","iecdata4vup","msgcontent");

function initNM()
{
	if(document.getElementById('wholescreen'))
	{
		//showMesgDiv(0);
		 hideMesgDiv();
	}
}//function initNM()

	//-----------------------
	function _gid(id)
	{
		if (document.getElementById(id))
			return document.getElementById(id);
		else return false;
	}//	function _gid(id)
	//-----------------------
	function _gfrm(frmname)
	{
		if (document.forms[frmname])
			return document.forms[frmname];
		else return false;
	}//	function _gid(id)

	//-----------------------
	function GetLeft(element)
	{
		var curNode = element;
		var left    = 0;
		do {
			left += curNode.offsetLeft;
			curNode = curNode.offsetParent;
		} while(curNode.tagName.toLowerCase() != 'body');
		return left;
	}//	function GetLeft(element)
	//-----------------------
	function GetTop(element)
	{
		var curNode = element;
		var top    = 0;
		do {
			top += curNode.offsetTop;
			curNode = curNode.offsetParent;
		} while(curNode.tagName.toLowerCase() != 'body');
		return top;
	}//	function GetTop(element)
	//-----------------------
	function getGmapLatLng(mapplace)
	{
		var currPrefs=new Array();
		currPrefs['location']=mapplace;
		var latlng = showModalDialog("getlocation.php", currPrefs,"dialogWidth:520px; dialogHeight:340px");
		if (latlng)
		{
			_gid('map_lat').value=latlng['lat'];
			_gid('map_lng').value=latlng['lng'];
			//alert(latlng['lat']+"~~"+latlng['lng']);
		}
		//gmapwindow= window.open ("showlocation.php?location="+mapplace, "gmapwindow","titlebar=1,toolbars=0,location=0,directories=0,top=150,left=50,status=0,menubar=0,scrollbars=1,resizable=1,border=1,width=520,height=320");
	//	gmapwindow.moveTo(50,150);
	}//	function showGmap(mapplace)
	
	function showGmap(mapplace)
	{
		gmapwindow= window.open ("showlocation.php?location="+mapplace, "gmapwindow","titlebar=1,toolbars=0,location=0,directories=0,top=150,left=50,status=0,menubar=0,scrollbars=1,resizable=1,border=1,width=520,height=320");
	//	gmapwindow.moveTo(50,150);
	}//	function showGmap(mapplace)
	//---------------------------
	function age(dob)
	{
		var dt,by,bm,bd,age,res,td,tm,ty;
		if (dob=="" || dob=="0000-00-00" || dob=="0") return 0;
		dt=dob.split("-");
		by=parseInt(dt[0]); bm=parseInt(dt[1]-1); bd=parseInt(dt[2]);
		dt = new Date();
		td=parseInt(dt.getDate()); tm=parseInt(dt.getMonth()); ty=parseInt(dt.getFullYear());
		if((tm > bm)||(tm==bm && td>=bd)) age=by;
		else age=by+1;
		res=ty-age;
		if (age>ty) return 0;
		return res;
	}//function age(dob)


	function makeHeight(o)
	{
		var mama;
		mama=(o.parentElement)?o.parentElement : o.parentNode;
		o.style.height=parseInt(mama.offsetHeight)-18;
	}//	function makeHeight(o)
	//---------------------------- onkeypress='return numbersonly(this,event)' 
	function numbersonly(myfield, e, dec) 
	{
	  var key;
	  var keychar;

	  if (window.event)
		key = window.event.keyCode;
	  else if (e)
		key = e.which;
	  else
		return true;
	  keychar = String.fromCharCode(key);

	  // control keys
	  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
		return true;

	  // numbers
	  else if ((("0123456789").indexOf(keychar) > -1))
		return true;

	  // decimal point jump
	  else if (dec && (keychar == ".")) {
		
		//myfield.form.elements[dec].focus();
		return true;
	  } else
		return false;
	}//function numbersonly(myfield, e, dec) 

//----------------------------
	function alphasonly(myfield, e) 
	{
	  var key;
	  var keychar;

	  if (window.event)
		key = window.event.keyCode;
	  else if (e)
		key = e.which;
	  else
		return true;
	  keychar = String.fromCharCode(key);

	  // control keys
	  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
		return true;
	  // numbers
	  else if ((("ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))
		return true;

	  else
		return false;
	}//function numbersonly(myfield, e, dec) 

//To Erase Cookie set DAYS "-1" to the input   s1..s3  - search values
function saveListPosCookie(id,from,s1,s2,s3,days)
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	from = parseInt(from);
	document.cookie =id+"@from"+"="+from+expires+"; path=/";
	document.cookie =id+"@s1"+"="+s1+expires+"; path=/";
	document.cookie =id+"@s2"+"="+s2+expires+"; path=/";
	document.cookie =id+"@s3"+"="+s3+expires+"; path=/";
//	alert("id="+id+"  top="+top+" /  left="+left+" expires = "+expires);
}//function saveListPosCookie()

function clearListPosCookie(id)
{
	saveListPosCookie(id,0,'','','',-1);
	return true;
}//function saveListPosCookie()
//---------------------------------
function getCookieData(labelName) 
{
	var labelLen = labelName.length;
	// read cookie property only once for speed
	var cookieData = document.cookie;
	var cLen = cookieData.length;
	var i = 0;
	var cEnd;
	while (i < cLen) 
		{
			var j = i + labelLen;
			if (cookieData.substring(i,j) == labelName) 
				{
					cEnd = cookieData.indexOf(";",j);
					if (cEnd == -1) 
						{
							cEnd = cookieData.length;
						}
					return decodeURIComponent(cookieData.substring(j+1, cEnd));
				}
			i++;
		}
	return "";
}//function getCookieData(labelName) 


