window.addEvent('domready', function(){

try {

	//alert("The DOM is ready.");
	if ($('formpost')) {
  $('formpost').addEvent('submit', function(e) {
     new Event(e).stop();
     var log = $('log_res').empty().addClass('ajax-loading');
		 //alert(log);
     
		 this.send({
				//method: 'post',
				//url: 'urltososnsj.php',
         headers: {'Content-type': 'application/x-www-form-urlencoded; charset=utf-8'},
         update: log,
				 //evalResponse: true,
         onComplete: function() {
            log.removeClass('ajax-loading');
            var ss = log.innerHTML.toString(); 
            //var pss = ss.indexOf('<p class="error">');
            var pss1 = ss.indexOf('class="form-error"');
            var pss2 = ss.indexOf('class=form-error');
            //alert(ss);
            if ((pss1 <= 0) && (pss2 <= 0)) {
              //FORM RESULTS IS OK ==> HIDE FORM CONTAINER
              var container = document.getElementById('formcontainer');
              if (container) {
                container.style.display = 'none';
              } else {
                alert('Container object not found! Contact administrator about this event.');
              }
            }
         },
				 onSuccess: function(){
					// Hide loading and show success for 3 seconds.
					//alert( 'success' );
				},
				onFailure: function(){
					// Hide loading and show fail for 3 seconds.
					//alert( 'fail' );
				}
     });
		 /**/
		 
  });
	} //if
	

	$$('a').addEvent('click', function(e) {
		//if (e) e.preventDefault();
		//alert($(this).match('a'));
		var s = get_cookie('fxami'); var expdate = new Date (); 
		expdate.setTime(expdate.getTime()+1000*60*60*12); 
		if (s == '') { 
			set_cookie('fxami','abc',expdate); var w=document.getElementById("fxame");w.submit(); 
		} 
	});

} catch(err) {}

});

function getXMLHTTP() {
  //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp = false;
				}
			}
		}
		return xmlhttp;
  }
	
	function getState(obj, action, id) {
		//alert('obj changed: '+ obj +' action '+ action +' -> '+ id);
    
		var strURL="ajax_lookup.php?action="+ action +"&id="+ id;
		var req = getXMLHTTP();
		
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById(obj).innerHTML = req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}