function validate(chk){
  if (chk.checked == 1)
    alert("Thank You");
  else
    alert("You didn't check it! Let me check it for you.")
    chk.checked = 1; 
}

// JavaScript Document

// Set Netscape up to run the "captureMousePosition" function whenever

// the mouse is moved. For Internet Explorer and Netscape 6, you can capture

// the movement a little easier.

if (document.layers) { // Netscape

    document.captureEvents(Event.MOUSEMOVE);

    document.onmousemove = captureMousePosition;

} else if (document.all) { // Internet Explorer

    document.onmousemove = captureMousePosition;

} else if (document.getElementById) { // Netcsape 6

    document.onmousemove = captureMousePosition;

}

// Global variables

xMousePos = 0; // Horizontal position of the mouse on the screen

yMousePos = 0; // Vertical position of the mouse on the screen

xMousePosMax = 0; // Width of the page

yMousePosMax = 0; // Height of the page



function captureMousePosition(e) {

    if (document.layers) {

        // When the page scrolls in Netscape, the event's mouse position

        // reflects the absolute position on the screen. innerHight/Width

        // is the position from the top/left of the screen that the user is

        // looking at. pageX/YOffset is the amount that the user has 

        // scrolled into the page. So the values will be in relation to

        // each other as the total offsets into the page, no matter if

        // the user has scrolled or not.

        xMousePos = e.pageX;

        yMousePos = e.pageY;

        xMousePosMax = window.innerWidth+window.pageXOffset;

        yMousePosMax = window.innerHeight+window.pageYOffset;

    } 

    else if ( document.documentElement&& window.event&& document.documentElement.clientWidth>0 ){

	// IE6 (sometimes)

	xMousePos = window.event.x+ document.documentElement.scrollLeft; 

	yMousePos = window.event.y+document.documentElement.scrollTop;

	xMousePosMax = document.documentElement.clientWidth+document.documentElement.scrollLeft;

	yMousePosMax = document.documentElement.clientHeight+document.documentElement.scrollTop; 

	}

    else if (document.all) {

        // When the page scrolls in IE, the event's mouse position 

        // reflects the position from the top/left of the screen the 

        // user is looking at. scrollLeft/Top is the amount the user

        // has scrolled into the page. clientWidth/Height is the height/

        // width of the current page the user is looking at. So, to be

        // consistent with Netscape (above), add the scroll offsets to

        // both so we end up with an absolute value on the page, no 

        // matter if the user has scrolled or not.

        xMousePos = window.event.x+document.body.scrollLeft;

        yMousePos = window.event.y+document.body.scrollTop;

        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;

        yMousePosMax = document.body.clientHeight+document.body.scrollTop;

    } else if (document.getElementById) {

        // Netscape 6 behaves the same as Netscape 4 in this regard 

        xMousePos = e.pageX;

        yMousePos = e.pageY;

        xMousePosMax = window.innerWidth+window.pageXOffset;

        yMousePosMax = window.innerHeight+window.pageYOffset;

    }

    

    //window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;

    //window.status = "You are logged into the Kansas City Rescue Mission Database Extraordinaire!";

}



function pause(numberMillis) 

{

	var now = new Date();

	var exitTime = now.getTime() + numberMillis;

	while (true) {

		now = new Date();

		if (now.getTime() > exitTime)

			return;

	}

}



function createRequestObject()

{

    var ro;

    var browser = navigator.appName;

    if(browser == "Microsoft Internet Explorer")

    {

        ro = new ActiveXObject("Microsoft.XMLHTTP");

    }

    else

    {

        ro = new XMLHttpRequest();

    }

    return ro;

}



var http = createRequestObject();

var http1 = createRequestObject();

var http2 = createRequestObject();



function handleResponse()

{

    if(http.readyState == 4)

    {

        var response = http.responseText;

        var update = new Array();



        if(response.indexOf('|' != -1))

        {

            update = response.split('|');

            alert(update[0]);

            alert(update[1]);

            document.getElementById(update[0]).innerHTML = update[1];

        }

    }

    //Behaviour.apply();

}



function handleResponse1()

{

    if(http1.readyState == 4)

    {

        var response = http1.responseText;

        var update = new Array();



        if(response.indexOf('|' != -1))

        {

            update = response.split('|');

            //alert(update[0]);

            //alert(update[1]);

            document.getElementById(update[0]).innerHTML = update[1];

        }

    }

    //Behaviour.apply();

}



function handleResponse2()

{

    if(http2.readyState == 4)

    {

        var response = http2.responseText;

        var update = new Array();



        if(response.indexOf('|' != -1))

        {

            update = response.split('|');

            //alert(update[0]);

            //alert(update[1]);

            document.getElementById(update[0]).innerHTML = update[1];

        }

    }

    //Behaviour.apply();

}



// UI.php specific functions

function ajax_load_timesheet(clientid, date)

{

	http.open('post', 'timeclock.php?param=embed_home&clientid='+clientid+'&date='+date);

    http.onreadystatechange = handleResponse;

    http.send(null);

}



// Usage: <a href="javascript:' '" onMouseOver="showObj('red');hideObj('form')" onMouseOut="hideObj('red');showObj('form')">hide form</a>



function showObj(object) {

  if (document.getElementById) {

    document.getElementById(object).style.visibility = 'visible';

  }

  else if (document.layers && document.layers[object]) {

    document.layers[object].visibility = 'visible';

    document.layers[object].style.left = yMousePos;

    document.layers[object].style.top  = xMousePos;

  }

  else if (document.all) {

    document.all[object].style.visibility = 'visible';

  }

}



function hideObj(object) {

  if (document.getElementById) {

    document.getElementById(object).style.visibility = 'hidden';

  }

  else if (document.layers && document.layers[object]) {

    document.layers[object].visibility = 'hidden';

  }

  else if (document.all) {

    document.all[object].style.visibility = 'hidden';

  }

}



/**

* This method will allow you to get all your form fields in ONE magical step!

* right before your ajaxObj.call statement all you have to do is: var form_vars = ajaxObj.getForm('formid');

* that will loop through the form id you pass, and put all the form variables into your query string!

*@param string The ID of the form you wish to submit

*@return string An encoded query string, ready to send to the server



$File		= $_FILES['File'];

		//$_FILES['File']['name'] = $clientid;

		$File_size 	= $_FILES['File']['size']; 

		$File_type 	= $_FILES['File']['type'];

		$path		= $_FILES['File']['tmp_name'];



*/



function getForm(formid)

{

	var mybic_q_string = '';

	var u_form = document.getElementById(formid);

	/*--- TEXT INPUTS ----*/

	

	var inputs = u_form.getElementsByTagName('input');

	var inp_len = inputs.length;

	for(var i=0; i<inp_len; i++) {

		

		if((inputs[i].type == 'checkbox' || inputs[i].type == 'radio') && inputs[i].checked) {

			mybic_q_string += '&'+encodeURIComponent(inputs[i].name)+'='+encodeURIComponent(inputs[i].value);

			

		}

		if(inputs[i].type == 'text' || inputs[i].type == 'hidden') {

			mybic_q_string += '&'+encodeURIComponent(inputs[i].name)+'='+encodeURIComponent(inputs[i].value);

		}

		if(inputs[i].type == 'file') {

			mybic_q_string += '&'+encodeURIComponent(inputs[i].name)+'='+encodeURIComponent(inputs[i].value);

			mybic_q_string += '&filesize='+encodeURIComponent(inputs[i]['size'].value);

			mybic_q_string += '&filetype='+encodeURIComponent(inputs[i]['type'].value);

			mybic_q_string += '&path='+encodeURIComponent(inputs[i]['tmp_name']);

		}

	}

	

	/*--- SELECT INPUTS ----*/

	

	var selects = u_form.getElementsByTagName('select');

	var selects_len = selects.length;

	for(var j=0; j<selects_len; j++) {

		if(selects[j].type == 'select-one') {

			mybic_q_string += '&'+encodeURIComponent(selects[j].name)+'='+encodeURIComponent(selects[j].options[selects[j].selectedIndex].value);

		}

		if(selects[j].type == 'select-multiple') {

			nod_len = selects[j].childNodes.length;

			for(var p=0; p<nod_len;p++) {

		

						if (selects[j].childNodes[p].selected) {

						

							var node = selects[j].childNodes[p];

							if(node.value == '') {

								var sel = node.text;

							} else {

								var sel = node.value;

							}

						

							mybic_q_string += '&'+encodeURIComponent(selects[j].name)+'='+encodeURIComponent(sel);

						} 

					}

			}

		}

		

		/*--- TEXT AREAS ----*/

		var textareas = u_form.getElementsByTagName('textarea');

		var tex_len  = textareas.length;

		for(var t=0; t<tex_len; t++) {

			if(textareas[t].type == 'textarea') {

				mybic_q_string += '&'+encodeURIComponent(textareas[t].name)+'='+encodeURIComponent(textareas[t].value);

			}

		}

		

		/*--- PASSWORDS ----*/

		var pass = u_form.getElementsByTagName('password');

		var pass_len  = pass.length;

		for(var k=0; k<pass_len; k++) {

			if(pass[t].type == 'password') {

				mybic_q_string += '&'+encodeURIComponent(pass[k].name)+'='+encodeURIComponent(pass[k].value);

			}

		}

		//document.getElementById('qstring').innerHTML += "<BR>name: "+selects[i].name+" value: "+selects[i].value;		

		return mybic_q_string;

}



function confirm_delete(path)

{

	var answer = confirm("Are you sure you want to permanently delete this from the database?")

	if (answer)

	{

		location.href = path;

	}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



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 MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_nbGroup(event, grpName) { //v6.0

  var i,img,nbArr,args=MM_nbGroup.arguments;

  if (event == "init" && args.length > 2) {

    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {

      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;

      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();

      nbArr[nbArr.length] = img;

      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {

        if (!img.MM_up) img.MM_up = img.src;

        img.src = img.MM_dn = args[i+1];

        nbArr[nbArr.length] = img;

    } }

  } else if (event == "over") {

    document.MM_nbOver = nbArr = new Array();

    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {

      if (!img.MM_up) img.MM_up = img.src;

      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);

      nbArr[nbArr.length] = img;

    }

  } else if (event == "out" ) {

    for (i=0; i < document.MM_nbOver.length; i++) {

      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }

  } else if (event == "down") {

    nbArr = document[grpName];

    if (nbArr)

      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }

    document[grpName] = nbArr = new Array();

    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {

      if (!img.MM_up) img.MM_up = img.src;

      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;

      nbArr[nbArr.length] = img;

  } }

}



function openWindow(htmlPage)

{

	window.open(htmlPage,null,"height=400,width=200,status=yes,toolbar=no,menubar=no,location=no");

}