   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
      else
      	document.getElementById('myspan').innerHTML="<img src='/cms/common/ajax/ajax_spinner.gif'> Processing ..., please wait, may take some time"
  
   }
   
   function get(obj) {
      var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) +
                    "&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );
      makePOSTRequest('post.php', poststr);
   }
   
   function get_all(obj) {
      var poststr = "?";
     
      for (i=0; i<obj.childNodes.length; i++) {
      	 //alert(obj.childNodes[i].tagName);
         if (obj.childNodes[i].tagName == "INPUT") {
         	alert("INPUT "+obj.childNodes[i].type);
            if (obj.childNodes[i].type == "text") {
               poststr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  poststr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else {
                  poststr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  poststr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
           poststr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         
      }
      //makeRequest('get.php', getstr);
      alert(poststr);
      makePOSTRequest('post.php', poststr);
}

function get_fld(fn,url) {
	var f     		= document.forms[fn];
 	var qstr 		= "";
 	var ename 	= '';
 	for(var i = 0; i < f.length; i++) {
		var e = f.elements[i];
		if ((e.type == "text") 
     		|| (e.type == "select-one") 
     		|| (e.type == "select-multiple") 
     		|| (e.type == "textarea") 
     		|| (e.type == "password") 
     		|| (e.type == "radio") 
     		|| (e.type == "file") 
     		|| (e.type == "checkbox")
     		|| (e.type == "hidden")) {

			if(e.type == "text" || e.type == "textarea" || e.type == "password" || e.type == "file" || e.type == "hidden")
				qstr	+= e.name + "=" + escape(e.value) + "&";
     		if(e.type == "checkbox" || e.type == "radio") {
     			if(e.type == "checkbox")
     				qstr	+= e.checked ? e.name + "=" +  escape(e.value) + "&" : "";
				else
					qstr	+= e.checked ? e.name + "=" +  escape(e.value) + "&" : "";
			}
    		if(e.type == "select-one" || e.type == "select-multiple") 
    			for (n = 0; n < e.options.length; n++) 
					if (e.options[n].selected && e.value != null && e.value != "")
						qstr 	+=  e.type == "select-multiple" ? e.name + "[] =" + e.options[n].value + "&" :  e.name + "=" + e.options[n].value + "&";
    	}
	}
    makePOSTRequest(url, qstr);
}

timedouturl = "./index.php?timeout=1";
var newWin = null;
var version4 = false

function ajax_validate_email(emailStr) {
	var msg = "";
	
	/* The following variable tells the rest of the function whether or not
	to verify that the e-mail address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */

	var checkTLD=1;

	/* The following is the list of known TLDs that an e-mail address must end with. */

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */

	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the e-mail address.
	These characters include ( ) < > @ , ; : \ " . [ ] */

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a
	username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */
	
	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user
	
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied e-mail address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */
	
	var matchArray=emailStr.match(emailPat);
  
	if (matchArray != null) {
		if(matchArray[1])
			var user=matchArray[1];
		if(matchArray[2])
			var domain=matchArray[2];

		// Start by checking that only basic ASCII characters are in the strings (0-127).
		for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
				msg += "Ths username contains invalid characters.";
  		}
		}
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				msg += "Ths domain name contains invalid characters.";
   		}
		}

		// See if "user" is valid

		if (user.match(userPat)==null) {

			// user is not valid

			msg += "The username doesn't seem to be valid.";
		}

		/* if the e-mail address is at an IP address (as opposed to a symbolic
		host name) make sure the IP address is valid. */

		var IPArray=domain.match(ipDomainPat);
		
		if (IPArray!=null) {

			// this is an IP address

			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					msg += "Destination IP address is invalid!";
   			}
			}
		}

		// Domain is symbolic name.  Check if it's valid.

		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				msg += "The domain name does not seem to be valid.";
   		}
		}

		/* domain name seems valid, but now make sure that it ends in a
		known top-level domain (like com, edu, gov) or a two-letter word,
		representing country (uk, nl), and that there's a hostname preceding
		the domain or country. */

		if (checkTLD && domArr[domArr.length-1].length!=2 &&
			domArr[domArr.length-1].search(knownDomsPat)==-1) {
			msg += "The e-mail address "+ emailStr +" must end in a well-known domain or two letter " + "country.";
		}

		// Make sure there's a host name preceding the domain.
	
		if (len<2) {
			msg += "This e-mail address "+ emailStr +" is missing a hostname!";
		}
	}
	else
		msg += "E-mail address "+ emailStr +" seems incorrect check for @";

	if(msg != "")
		alert(msg);
	return msg;
}
 
function ajax_isblank(s) {
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

// This is the function that performs form verification. It will be invoked
// from the onSubmit() event handler. The handler should return whatever
// value this function returns.

/*
f and fn are the form objects f - verify and fn - ajax url
Any fields starting with "optional_" are optional
*/
function ajax_verify(f,fn,url,ajax,mydiv) {
    var msg;
    var str;
    var empty_fields = "";
    var empty_count = 0;
    var errors = "";

	var radio_rcnt 	= 0;
	var radio_fcnt 	= 0;
	var radio_rad 	= "";
	var radio_ltype = "";
	
	var chk_rcnt 	= 0;
	var chk_fcnt 	= 0;
	var chk_rad 	= "";
	var chk_ltype = "";
	var catch_err	= "";
   	
   	// Loop through the elements of the form, looking for all
    // text and textarea elements that don't have an "optional" property
    // defined. Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // then verify that they are numbers and that they are in the right range.
    // Put together error messages for fields that are wrong.
  
  	document.getElementById("hidden_field1").className = "hidden_field"; 
  	document.getElementById("hidden_field2").className = "hidden_field"; 
  	for(var i = 0; i < f.length; i++) {
    	var e = f.elements[i];
    	if(document.getElementById(e.name) != null)
    		document.getElementById(e.name).className = "left"; 
    	else if(e.type == "checkbox") {
    		var s3	= e.name.substr(0,e.name.length-2);
    		if(document.getElementById(s3) != null)
    			document.getElementById(s3).className = "left"; 
    	}
    }
    	
  	for(var i = 0; i < f.length; i++) {
    	var e = f.elements[i];
    	//  || (e.type == "hidden")
      	if (((e.type == "text") 
      		|| (e.type == "select-one") 
       		|| (e.type == "select-multiple") 
       		|| (e.type == "textarea") 
       		|| (e.type == "password") 
       		|| (e.type == "radio") 
       		|| (e.type == "file")  
       		|| (e.type == "checkbox"))) {
        	if(document.getElementById("optional_" + e.name + "_id") != null) {
        		var temp = e.name.split('_');
				for (k=0; k < temp.length; k++) {
					if((temp[k]=="email" || temp[k]=="email[]") && e.value != "") {
      					var err = ajax_validate_email(e.value);
      					if(err) {
      						if(document.getElementById("full_" + e.name + "_id") != null)
								document.getElementById(e.name).className = "red_all"; 
							else
								document.getElementById(e.name).className = "red"; 
      				 		errors += err;
      						errors += "\n";
      					}
      				}
				}
        		continue; // Skip optional fields
        	}
        	if(radio_rad != e.name && e.type == "radio") {
				if(radio_rcnt == radio_fcnt && radio_fcnt > 0 && radio_ltype=="radio") {
					empty_fields += "\n          " + radio_rad;
					empty_count++;
					radio_ltype="";
					try {	
						if(document.getElementById("full_" + e.name + "_id") != null)
							document.getElementById(radio_rad).className = "red_all"; 
						else
							document.getElementById(radio_rad).className = "red"; 
					}
					catch(err) {
						catch_err += e.name;
					}
				}
				radio_rad		=e.name;
				radio_ltype	="radio";
				radio_fcnt		=0;
				radio_rcnt		=0;
			}	
        	if(chk_rad != e.name && e.type == "checkbox") {
				if(chk_rcnt == chk_fcnt && chk_fcnt > 0 && chk_ltype=="checkbox") {
					empty_fields += "\n          " + chk_rad;
					empty_count++;
					chk_ltype="";
					try {	
						if(document.getElementById("full_" + e.name + "_id") != null)
							document.getElementById(chk_rad).className = "red_all"; 
						else
							document.getElementById(chk_rad).className = "red"; 
					}
					catch(err) {
						catch_err += e.name;
					}
				}
				chk_rad		=e.name;
				chk_ltype	="checkbox";
				chk_fcnt	=0;
				chk_rcnt	=0;
			}	
       	 	// Check for email field. Call validate_email to check for errors
        	var temp = e.name.split('_');
			for (k=0; k < temp.length; k++) {
				if(temp[k]=="email" || temp[k]=="email[]") {
      				var err = ajax_validate_email(e.value);
      				if(err != "") {
      					if(document.getElementById("full_" + e.name + "_id") != null)
							document.getElementById(e.name).className = "red_all"; 
						else
							document.getElementById(e.name).className = "red"; 
      				 	errors += err;
      					errors += "\n";
      				}
      			}
			}
				
			if (e.type == "select-one" || e.type == "select-multiple") {
				var n;
				var sel=0;
				for (n = 0; n < e.options.length; n++) {
					if (e.options[n].selected && e.value != null && e.value != "") {
						sel=1;
						break;
					}
				}
				if(sel==0) {
					empty_fields += "\n          " + e.name;
					empty_count++;
					try {
						//document.getElementById(e.name).className = "red"; 
						var temp = e.name.split('_');
						if(temp[0] == "full")
							document.getElementById(e.name).className = "red_all"; 
						else
							document.getElementById(e.name).className = "red"; 
					}
					catch(err) {
						catch_err += e.name;
					}
				}
				continue;
  			}
	
			if(e.type == "radio") {
				if(!e.checked)
					radio_rcnt++;
				radio_fcnt++;
			}
			if(e.type == "checkbox") {
				if(!e.checked)
					chk_rcnt++;
				chk_fcnt++;
			}
			if (e.value == null || e.value == "" || ajax_isblank(e.value)) {
       			empty_fields += "\n          " + e.name;
       	 		empty_count++;
       	 		var s1 = e.name.substr(e.name.length-1,1);
       	 		if((s1 == "2" || s1 == "3") && e.type != "textarea")
       	 			continue;
       	 		try {
					if(document.getElementById("full_" + e.name + "_id") != null)
						document.getElementById(e.name).className = "red_all"; 
					else
						document.getElementById(e.name).className = "red"; 
				}
				catch(err) {
					catch_err += e.name;
				}
         		continue;
       		}
        	
    		 // Now check for fields that are supposed to be numeric.
       	 	if (e.numeric || (e.min != null) || (e.max != null)) {
         		var v = parseFloat(e.value);
 	      		if (isNaN(v) || ((e.min != null) && (v < e.min)) || ((e.max != null) && (v > e.max))) {
       	    		errors += "- The field " + e.name + " must be a number";
          			if (e.min != null)
              			errors += " that is greater than or equal to " + e.min;
           	 		if (e.max != null && e.min != null)
           	  			errors += " and less than " + e.max;
            		else if (e.max != null)
              			errors += " that is less than or equal to " + e.max;
 	          		errors += ".\n";
   				}
     		}
   		}
 	}
 	if(radio_rcnt == radio_fcnt && radio_fcnt > 0 && radio_ltype=="radio") {
		empty_fields += "\n          " + radio_rad;
		empty_count++;
		try {
			if(document.getElementById("full_" + radio_rad + "_id") != null)
				document.getElementById(radio_rad).className = "red_all"; 
			else
				document.getElementById(radio_rad).className = "red"; 
		}
		catch(err) {
			catch_err += s3;
		}
	}
		
	if(chk_rcnt == chk_fcnt && chk_fcnt > 0 && chk_ltype=="checkbox") {
		empty_fields += "\n          " + chk_rad;
		empty_count++;
		var s3	= chk_rad.substr(0,chk_rad.length-2);
		try {
			if(document.getElementById("full_" + s3 + "_id") != null)
				document.getElementById(s3).className = "red_all"; 
			else
				document.getElementById(s3).className = "red"; 
		}
		catch(err) {
			catch_err += s3;
		}
	}			
				
    // Now, if there were any errors, display the messages, and
    // return false to prevent the form from being submitted.
    // Otherwise return true.

    if (!empty_fields && !errors) {
    	//alert("e1");
    	//alert("FN "+fn+" URL "+url+" DIV "+mydiv);
    	if(ajax == 1)
    		get_fld(fn,url,mydiv);
   	 	return true;
	}
    if (empty_fields != "" || errors != "") {
    	if(empty_fields != "") {
        	msg += "- The following required field(s) are empty:"
                + empty_fields + "\n";
        }
        if(errors != "") {
       	 msg += "- The following required field(s) are empty:"
                + errors + "\n";
        }
        //alert(msg);
        document.getElementById("hidden_field1").className = "hidden_red";
        document.getElementById("hidden_field2").className = "hidden_red";

    	return false;
    }
    else {
    	//alert("e2");
    	if(ajax == 1) {
    		get_fld(fn,url,mydiv);
    		
    	}
    	return true;
    }
    return false;
}


/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid) {
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	page_request.onreadystatechange=function() {
		loadpage(page_request, containerid)
	}
	if (bustcachevar) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
}

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	document.getElementById(containerid).innerHTML=page_request.responseText
}

*/





function fetch_unix_timestamp() {  
 	return parseInt(new Date().getTime().toString().substring(0, 10))  
 }  
   
 ////////////////////////////////  
 //  
 // Refreshing the DIV TIMEDIV  
 //  
 ////////////////////////////////  
   
 function refreshdiv_timediv(v,x,y,div1,div2,div3){  
   
    refreshdiv_2(x,div2);
  	refreshdiv_3(y,div3);
  
 	// Customise those settings  

 	var seconds = 5;  
 	//var divid = "timediv";  
 	var divid = div1;  
 	var url = "boo.php?v="+v;  
  
 	// The XMLHttpRequest object  
   
 	var xmlHttp;  
	 try{  
 		xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari  
 	}  
 	catch (e){  
 		try{  
 			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer  
 		}  
 		catch (e){  
 			try{  
 				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  
 			}  
 			catch (e){  
 				alert("Your browser does not support AJAX.");  
 				return false;  
 			}  
		}  
 	}  
   
 	var timestamp = fetch_unix_timestamp();  
 	//var nocacheurl = url+"?t="+timestamp;  
  	var nocacheurl = url;  
 	// The code...  
   
 	xmlHttp.onreadystatechange=function() {  
 		if(xmlHttp.readyState==4){  
 			var seconds = 5;  
 			document.getElementById(divid).innerHTML=xmlHttp.responseText;  
 			setTimeout('refreshdiv_timediv()',seconds*1000000);  
 		}  
 	}  
 	xmlHttp.open("GET",nocacheurl,true);  
 	xmlHttp.send(null);  
 }  
   
 // Start the refreshing process  
   
 window.onload = function startrefresh(){ 
 	var seconds = 5;  
 	setTimeout('refreshdiv_timediv()',seconds*1000000);  
 }  
   
 ////////////////////////////////  
 //  
 // Refreshing the DIV TIMEINWASHINGTON  
 //  
 ////////////////////////////////  
   
 function refreshdiv_2(y,thediv){  
   
 	// Customise those settings  
   
 	var seconds = 8;  
	 //var divid = "timeinwashington";  
	 var divid = thediv;
 	var url = "boo2.php?y="+y;  
   
	 // The XMLHttpRequest object  
   
 	var xmlHttp;  
 	try{  
 		xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari  
 	}  
	 catch (e){  
		 try{  
 			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer  
 		}  
 		catch (e){  
 			try{  
 				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  
 			}  
 			catch (e){  
 				alert("Your browser does not support AJAX.");  
 				return false;  
 			}  
 		}  
 	}  
   
 	var timestamp = fetch_unix_timestamp();  
 	//var nocacheurl = url+"?t="+timestamp;  
	var nocacheurl = url;  
   
 	// The code...  
   
 	xmlHttp.onreadystatechange=function(){  
 		if(xmlHttp.readyState==4){  
 			var seconds = 8; 
 			document.getElementById(divid).innerHTML=xmlHttp.responseText;  
 			setTimeout('refreshdiv_timeinwashington()',seconds*1000000);  
 		}  
 	}  
 	xmlHttp.open("GET",nocacheurl,true);  
 	xmlHttp.send(null);  
 }  
   
 // Start the refreshing process  
   
 window.onload = function startrefresh(){  
 	var seconds = 8; 
 	setTimeout('refreshdiv_timeinwashington()',seconds*1000000);  
 }  
   
 ////////////////////////////////  
 //  
 // Refreshing the DIV OTHERDIV  
 //  
 ////////////////////////////////  
   
 function refreshdiv_3(z,thediv){  
   
 	// Customise those settings  
   
 	var seconds = 10;  
 	//var divid = "otherdiv";  
 	var divid = thediv;  
 	var url = "boo3.php?z="+z;  
   
 	// The XMLHttpRequest object  
   
 	var xmlHttp;  
 	try{  
 		xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari  
 	}  
 	catch (e){  
 		try{  
 			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer  
 		}  
 		catch (e){  
 			try{  
 				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  
 			}  
 			catch (e){  
 				alert("Your browser does not support AJAX.");  
 				return false;  
 			}  
 		}  
 	}  
   
 	var timestamp = fetch_unix_timestamp();  
	//var nocacheurl = url+"?t="+timestamp;  
 	var nocacheurl = url;  
 	// The code...  
   
 	xmlHttp.onreadystatechange=function(){  
 		if(xmlHttp.readyState==4){  
 			var seconds = 10; 
 			document.getElementById(divid).innerHTML=xmlHttp.responseText;  
 			setTimeout('refreshdiv_otherdiv()',seconds*1000000);  
 		}  
 	}  
 	xmlHttp.open("GET",nocacheurl,true);  
 	xmlHttp.send(null);  
 }  
   
 // Start the refreshing process  
   
 window.onload = function startrefresh(){  
 	var seconds = 10;  
 	setTimeout('refreshdiv_otherdiv()',seconds*1000000);  
 }

